_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.26k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  640|  9.26k|  static const auto fptrs = populate_functions();
  641|  9.26k|  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.26k|  if (size < 4) {
  ------------------
  |  Branch (646:7): [True: 3, False: 9.26k]
  ------------------
  647|      3|    return 0;
  648|      3|  }
  649|       |
  650|  9.26k|  constexpr auto actionmask = std::bit_ceil(Ncases) - 1;
  651|  9.26k|  const auto action = data[0] & actionmask;
  652|  9.26k|  data += 4;
  653|  9.26k|  size -= 4;
  654|       |
  655|  9.26k|  if (action >= Ncases) {
  ------------------
  |  Branch (655:7): [True: 1, False: 9.26k]
  ------------------
  656|      1|    return 0;
  657|      1|  }
  658|       |
  659|  9.26k|  if constexpr (use_separate_allocation) {
  660|       |    // this is better at exercising null input and catch buffer underflows
  661|  9.26k|    const std::vector<char> separate{data, data + size};
  662|  9.26k|    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.26k|  return 0;
  669|  9.26k|}
conversion.cpp:_ZZ18populate_functionsvENK3$_0clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     87|    +[](std::span<const char> chardata) {                                      \
  555|     87|      const auto c =                                                           \
  556|     87|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     87|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     87|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     87|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     87|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     87|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     87|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     87|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     87|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     87|  constexpr auto _size = _name.size();                                \
  |  | 1183|     87|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     87|  return _nameof; }()
  ------------------
  561|     87|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     87|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     87|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     87|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     87|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     87|  constexpr auto _size = _name.size();                                \
  |  | 1183|     87|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     87|  return _nameof; }()
  ------------------
  562|     87|      c.fuzz(chardata);                                                        \
  563|     87|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    227|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    227|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    227|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    227|    static const bool do_print_testcase =
  181|    227|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    227|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 227]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    227|    do {
  189|       |      // step 0 - is the input valid?
  190|    227|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    227|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 227]
  |  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|    227|                    From == UtfEncodings::UTF8) {
  198|    227|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 227]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    227|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    227|      const auto [output_length, length_agree] =
  204|    227|          calculate_length(from, inputisvalid);
  205|    227|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 227]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    227|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 101, False: 126]
  |  Branch (208:28): [True: 16, False: 85]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     16|        return;
  211|     16|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    211|      const auto [written, outputs_agree] =
  215|    211|          do_conversion(from, output_length, inputisvalid);
  216|    211|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 211]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    211|      return;
  221|    211|    } 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|    227|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    227|  validation_result verify_valid_input(FromSpan src) const {
  231|    227|    validation_result ret{};
  232|       |
  233|    227|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    227|    const auto implementations = get_supported_implementations();
  235|    227|    std::vector<simdutf::result> results;
  236|    227|    results.reserve(implementations.size());
  237|       |
  238|    681|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 681, False: 227]
  ------------------
  239|    681|      results.push_back(
  240|    681|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    681|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    681|      const bool validation2 =
  245|    681|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    681|                      src.data(), src.size());
  247|    681|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 681]
  ------------------
  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|    681|    }
  258|       |
  259|    227|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    227|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 227]
  ------------------
  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|    227|    } else {
  273|    227|      ret.implementations_agree = true;
  274|    227|    }
  275|    227|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    227|      return r.error == simdutf::SUCCESS;
  277|    227|    });
  278|    227|    return ret;
  279|    227|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    454|    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|    479|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    479|      return r.error == simdutf::SUCCESS;
  277|    479|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    227|  bool count_the_input(FromSpan src) const {
  290|    227|    const auto implementations = get_supported_implementations();
  291|    227|    std::vector<std::size_t> results;
  292|    227|    results.reserve(implementations.size());
  293|       |
  294|    681|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 681, False: 227]
  ------------------
  295|    681|      std::size_t ret;
  296|    681|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    681|        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|    681|      results.push_back(ret);
  304|    681|    }
  305|    227|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    227|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 227]
  ------------------
  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|    227|    return true;
  321|    227|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    454|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    227|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    227|    length_result ret{};
  344|       |
  345|    227|    const auto implementations = get_supported_implementations();
  346|    227|    std::vector<std::size_t> results;
  347|    227|    results.reserve(implementations.size());
  348|       |
  349|    681|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 681, False: 227]
  ------------------
  350|    681|      const auto len = invoke_lengthcalc(impl, src);
  351|    681|      results.push_back(len);
  352|    681|      ret.length.push_back(len);
  353|    681|    }
  354|       |
  355|    227|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    227|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 227]
  ------------------
  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|    227|    } else {
  375|    227|      ret.implementations_agree = true;
  376|    227|    }
  377|    227|    return ret;
  378|    227|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    681|                                FromSpan src) const {
  331|    681|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    681|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    454|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    211|                                  const bool inputisvalid) const {
  383|    211|    conversion_result ret{};
  384|       |
  385|    211|    const auto implementations = get_supported_implementations();
  386|       |
  387|    211|    std::vector<result<ConversionResult>> results;
  388|    211|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    211|    std::vector<std::vector<ToType>> outputbuffers;
  393|    211|    outputbuffers.reserve(implementations.size());
  394|    844|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 633, False: 211]
  ------------------
  395|    633|      auto impl = implementations[i];
  396|    633|      const ToType canary1{42};
  397|    633|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    633|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    633|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    633|      const auto success = [](const ConversionResult& r) -> bool {
  402|    633|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    633|          return r != 0;
  404|    633|        } else {
  405|    633|          return r.error == simdutf::error_code::SUCCESS;
  406|    633|        }
  407|    633|      }(implret1);
  408|    633|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    633|      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|    633|        const ToType canary2{25};
  414|    633|        const auto outputbuffer_first_run = outputbuffer;
  415|    633|        std::ranges::fill(outputbuffer, canary2);
  416|    633|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    633|                                          src.size(), outputbuffer.data());
  418|       |
  419|    633|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 633]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    633|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 378, False: 255]
  |  Branch (423:29): [True: 366, False: 12]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    366|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    366|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 366]
  ------------------
  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|    366|        }
  440|    633|      }
  441|    633|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 366, False: 267]
  ------------------
  442|    633|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    211|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 85, False: 126]
  ------------------
  447|    255|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 255, False: 85]
  ------------------
  448|    255|        e.outputhash.clear();
  449|    255|      }
  450|     85|    }
  451|       |
  452|    211|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    211|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 211]
  ------------------
  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|    211|    } else {
  474|    211|      ret.implementations_agree = true;
  475|    211|    }
  476|    211|    return ret;
  477|    211|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    633|      const auto success = [](const ConversionResult& r) -> bool {
  402|    633|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    633|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    633|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    422|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_1clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    248|    +[](std::span<const char> chardata) {                                      \
  555|    248|      const auto c =                                                           \
  556|    248|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    248|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    248|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    248|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    248|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    248|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    248|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    248|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    248|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    248|  constexpr auto _size = _name.size();                                \
  |  | 1183|    248|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    248|  return _nameof; }()
  ------------------
  561|    248|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    248|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    248|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    248|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    248|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    248|  constexpr auto _size = _name.size();                                \
  |  | 1183|    248|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    248|  return _nameof; }()
  ------------------
  562|    248|      c.fuzz(chardata);                                                        \
  563|    248|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    421|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    421|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    421|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    421|    static const bool do_print_testcase =
  181|    421|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    421|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 421]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    421|    do {
  189|       |      // step 0 - is the input valid?
  190|    421|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    421|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 421]
  |  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|    421|                    From == UtfEncodings::UTF8) {
  198|    421|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 421]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    421|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    421|      const auto [output_length, length_agree] =
  204|    421|          calculate_length(from, inputisvalid);
  205|    421|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 421]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    421|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 102, False: 319]
  |  Branch (208:28): [True: 22, False: 80]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     22|        return;
  211|     22|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    399|      const auto [written, outputs_agree] =
  215|    399|          do_conversion(from, output_length, inputisvalid);
  216|    399|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 399]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    399|      return;
  221|    399|    } 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|    421|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    421|  validation_result verify_valid_input(FromSpan src) const {
  231|    421|    validation_result ret{};
  232|       |
  233|    421|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    421|    const auto implementations = get_supported_implementations();
  235|    421|    std::vector<simdutf::result> results;
  236|    421|    results.reserve(implementations.size());
  237|       |
  238|  1.26k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.26k, False: 421]
  ------------------
  239|  1.26k|      results.push_back(
  240|  1.26k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.26k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.26k|      const bool validation2 =
  245|  1.26k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.26k|                      src.data(), src.size());
  247|  1.26k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.26k]
  ------------------
  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.26k|    }
  258|       |
  259|    421|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    421|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 421]
  ------------------
  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|    421|    } else {
  273|    421|      ret.implementations_agree = true;
  274|    421|    }
  275|    421|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    421|      return r.error == simdutf::SUCCESS;
  277|    421|    });
  278|    421|    return ret;
  279|    421|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    842|    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.05k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.05k|      return r.error == simdutf::SUCCESS;
  277|  1.05k|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    421|  bool count_the_input(FromSpan src) const {
  290|    421|    const auto implementations = get_supported_implementations();
  291|    421|    std::vector<std::size_t> results;
  292|    421|    results.reserve(implementations.size());
  293|       |
  294|  1.26k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.26k, False: 421]
  ------------------
  295|  1.26k|      std::size_t ret;
  296|  1.26k|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|  1.26k|        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.26k|      results.push_back(ret);
  304|  1.26k|    }
  305|    421|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    421|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 421]
  ------------------
  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|    421|    return true;
  321|    421|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    842|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    421|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    421|    length_result ret{};
  344|       |
  345|    421|    const auto implementations = get_supported_implementations();
  346|    421|    std::vector<std::size_t> results;
  347|    421|    results.reserve(implementations.size());
  348|       |
  349|  1.26k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.26k, False: 421]
  ------------------
  350|  1.26k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.26k|      results.push_back(len);
  352|  1.26k|      ret.length.push_back(len);
  353|  1.26k|    }
  354|       |
  355|    421|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    421|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 421]
  ------------------
  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|    421|    } else {
  375|    421|      ret.implementations_agree = true;
  376|    421|    }
  377|    421|    return ret;
  378|    421|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.26k|                                FromSpan src) const {
  331|  1.26k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.26k|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    842|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    399|                                  const bool inputisvalid) const {
  383|    399|    conversion_result ret{};
  384|       |
  385|    399|    const auto implementations = get_supported_implementations();
  386|       |
  387|    399|    std::vector<result<ConversionResult>> results;
  388|    399|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    399|    std::vector<std::vector<ToType>> outputbuffers;
  393|    399|    outputbuffers.reserve(implementations.size());
  394|  1.59k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.19k, False: 399]
  ------------------
  395|  1.19k|      auto impl = implementations[i];
  396|  1.19k|      const ToType canary1{42};
  397|  1.19k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.19k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.19k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.19k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.19k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.19k|          return r != 0;
  404|  1.19k|        } else {
  405|  1.19k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.19k|        }
  407|  1.19k|      }(implret1);
  408|  1.19k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.19k|      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.19k|        const ToType canary2{25};
  414|  1.19k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.19k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.19k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.19k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.19k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.19k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.19k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 957, False: 240]
  |  Branch (423:29): [True: 948, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    948|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    948|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 948]
  ------------------
  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|    948|        }
  440|  1.19k|      }
  441|  1.19k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 948, False: 249]
  ------------------
  442|  1.19k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    399|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 80, False: 319]
  ------------------
  447|    240|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 240, False: 80]
  ------------------
  448|    240|        e.outputhash.clear();
  449|    240|      }
  450|     80|    }
  451|       |
  452|    399|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    399|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 399]
  ------------------
  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|    399|    } else {
  474|    399|      ret.implementations_agree = true;
  475|    399|    }
  476|    399|    return ret;
  477|    399|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.19k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.19k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.19k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.19k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    798|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_2clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     70|    +[](std::span<const char> chardata) {                                      \
  555|     70|      const auto c =                                                           \
  556|     70|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     70|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     70|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     70|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     70|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     70|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     70|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     70|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     70|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     70|  constexpr auto _size = _name.size();                                \
  |  | 1183|     70|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     70|  return _nameof; }()
  ------------------
  561|     70|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     70|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     70|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     70|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     70|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     70|  constexpr auto _size = _name.size();                                \
  |  | 1183|     70|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     70|  return _nameof; }()
  ------------------
  562|     70|      c.fuzz(chardata);                                                        \
  563|     70|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    233|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    233|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    233|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    233|    static const bool do_print_testcase =
  181|    233|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    233|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 233]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    233|    do {
  189|       |      // step 0 - is the input valid?
  190|    233|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    233|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 233]
  |  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|    233|                    From == UtfEncodings::UTF8) {
  198|    233|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 233]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    233|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    233|      const auto [output_length, length_agree] =
  204|    233|          calculate_length(from, inputisvalid);
  205|    233|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 233]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    233|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 106, False: 127]
  |  Branch (208:28): [True: 6, False: 100]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      6|        return;
  211|      6|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    227|      const auto [written, outputs_agree] =
  215|    227|          do_conversion(from, output_length, inputisvalid);
  216|    227|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 227]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    227|      return;
  221|    227|    } 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|    233|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    233|  validation_result verify_valid_input(FromSpan src) const {
  231|    233|    validation_result ret{};
  232|       |
  233|    233|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    233|    const auto implementations = get_supported_implementations();
  235|    233|    std::vector<simdutf::result> results;
  236|    233|    results.reserve(implementations.size());
  237|       |
  238|    699|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 699, False: 233]
  ------------------
  239|    699|      results.push_back(
  240|    699|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    699|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    699|      const bool validation2 =
  245|    699|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    699|                      src.data(), src.size());
  247|    699|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 699]
  ------------------
  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|    699|    }
  258|       |
  259|    233|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    233|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 233]
  ------------------
  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|    233|    } else {
  273|    233|      ret.implementations_agree = true;
  274|    233|    }
  275|    233|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    233|      return r.error == simdutf::SUCCESS;
  277|    233|    });
  278|    233|    return ret;
  279|    233|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    466|    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|    487|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    487|      return r.error == simdutf::SUCCESS;
  277|    487|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    233|  bool count_the_input(FromSpan src) const {
  290|    233|    const auto implementations = get_supported_implementations();
  291|    233|    std::vector<std::size_t> results;
  292|    233|    results.reserve(implementations.size());
  293|       |
  294|    699|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 699, False: 233]
  ------------------
  295|    699|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    699|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    699|        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|    699|      results.push_back(ret);
  304|    699|    }
  305|    233|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    233|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 233]
  ------------------
  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|    233|    return true;
  321|    233|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    466|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    233|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    233|    length_result ret{};
  344|       |
  345|    233|    const auto implementations = get_supported_implementations();
  346|    233|    std::vector<std::size_t> results;
  347|    233|    results.reserve(implementations.size());
  348|       |
  349|    699|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 699, False: 233]
  ------------------
  350|    699|      const auto len = invoke_lengthcalc(impl, src);
  351|    699|      results.push_back(len);
  352|    699|      ret.length.push_back(len);
  353|    699|    }
  354|       |
  355|    233|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    233|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 233]
  ------------------
  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|    233|    } else {
  375|    233|      ret.implementations_agree = true;
  376|    233|    }
  377|    233|    return ret;
  378|    233|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    699|                                FromSpan src) const {
  331|    699|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    699|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    466|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    227|                                  const bool inputisvalid) const {
  383|    227|    conversion_result ret{};
  384|       |
  385|    227|    const auto implementations = get_supported_implementations();
  386|       |
  387|    227|    std::vector<result<ConversionResult>> results;
  388|    227|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    227|    std::vector<std::vector<ToType>> outputbuffers;
  393|    227|    outputbuffers.reserve(implementations.size());
  394|    908|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 681, False: 227]
  ------------------
  395|    681|      auto impl = implementations[i];
  396|    681|      const ToType canary1{42};
  397|    681|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    681|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    681|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    681|      const auto success = [](const ConversionResult& r) -> bool {
  402|    681|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    681|          return r != 0;
  404|    681|        } else {
  405|    681|          return r.error == simdutf::error_code::SUCCESS;
  406|    681|        }
  407|    681|      }(implret1);
  408|    681|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    681|      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|    681|        const ToType canary2{25};
  414|    681|        const auto outputbuffer_first_run = outputbuffer;
  415|    681|        std::ranges::fill(outputbuffer, canary2);
  416|    681|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    681|                                          src.size(), outputbuffer.data());
  418|       |
  419|    681|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 681]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    681|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 381, False: 300]
  |  Branch (423:29): [True: 369, False: 12]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    369|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    369|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 369]
  ------------------
  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|    369|        }
  440|    681|      }
  441|    681|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 369, False: 312]
  ------------------
  442|    681|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    227|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 100, False: 127]
  ------------------
  447|    300|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 300, False: 100]
  ------------------
  448|    300|        e.outputhash.clear();
  449|    300|      }
  450|    100|    }
  451|       |
  452|    227|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    227|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 227]
  ------------------
  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|    227|    } else {
  474|    227|      ret.implementations_agree = true;
  475|    227|    }
  476|    227|    return ret;
  477|    227|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    681|      const auto success = [](const ConversionResult& r) -> bool {
  402|    681|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    681|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    681|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    454|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_3clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    215|    +[](std::span<const char> chardata) {                                      \
  555|    215|      const auto c =                                                           \
  556|    215|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    215|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    215|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    215|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    215|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    215|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    215|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    215|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    215|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    215|  constexpr auto _size = _name.size();                                \
  |  | 1183|    215|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    215|  return _nameof; }()
  ------------------
  561|    215|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    215|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    215|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    215|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    215|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    215|  constexpr auto _size = _name.size();                                \
  |  | 1183|    215|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    215|  return _nameof; }()
  ------------------
  562|    215|      c.fuzz(chardata);                                                        \
  563|    215|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    433|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    433|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    433|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    433|    static const bool do_print_testcase =
  181|    433|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    433|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 433]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    433|    do {
  189|       |      // step 0 - is the input valid?
  190|    433|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    433|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 433]
  |  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|    433|                    From == UtfEncodings::UTF8) {
  198|    433|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 433]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    433|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    433|      const auto [output_length, length_agree] =
  204|    433|          calculate_length(from, inputisvalid);
  205|    433|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 433]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    433|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 111, False: 322]
  |  Branch (208:28): [True: 12, False: 99]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     12|        return;
  211|     12|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    421|      const auto [written, outputs_agree] =
  215|    421|          do_conversion(from, output_length, inputisvalid);
  216|    421|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 421]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    421|      return;
  221|    421|    } 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|    433|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    433|  validation_result verify_valid_input(FromSpan src) const {
  231|    433|    validation_result ret{};
  232|       |
  233|    433|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    433|    const auto implementations = get_supported_implementations();
  235|    433|    std::vector<simdutf::result> results;
  236|    433|    results.reserve(implementations.size());
  237|       |
  238|  1.29k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.29k, False: 433]
  ------------------
  239|  1.29k|      results.push_back(
  240|  1.29k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.29k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.29k|      const bool validation2 =
  245|  1.29k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.29k|                      src.data(), src.size());
  247|  1.29k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.29k]
  ------------------
  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.29k|    }
  258|       |
  259|    433|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    433|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 433]
  ------------------
  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|    433|    } else {
  273|    433|      ret.implementations_agree = true;
  274|    433|    }
  275|    433|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    433|      return r.error == simdutf::SUCCESS;
  277|    433|    });
  278|    433|    return ret;
  279|    433|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    866|    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.07k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.07k|      return r.error == simdutf::SUCCESS;
  277|  1.07k|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    433|  bool count_the_input(FromSpan src) const {
  290|    433|    const auto implementations = get_supported_implementations();
  291|    433|    std::vector<std::size_t> results;
  292|    433|    results.reserve(implementations.size());
  293|       |
  294|  1.29k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.29k, False: 433]
  ------------------
  295|  1.29k|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|  1.29k|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|  1.29k|        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.29k|      results.push_back(ret);
  304|  1.29k|    }
  305|    433|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    433|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 433]
  ------------------
  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|    433|    return true;
  321|    433|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    866|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    433|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    433|    length_result ret{};
  344|       |
  345|    433|    const auto implementations = get_supported_implementations();
  346|    433|    std::vector<std::size_t> results;
  347|    433|    results.reserve(implementations.size());
  348|       |
  349|  1.29k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.29k, False: 433]
  ------------------
  350|  1.29k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.29k|      results.push_back(len);
  352|  1.29k|      ret.length.push_back(len);
  353|  1.29k|    }
  354|       |
  355|    433|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    433|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 433]
  ------------------
  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|    433|    } else {
  375|    433|      ret.implementations_agree = true;
  376|    433|    }
  377|    433|    return ret;
  378|    433|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.29k|                                FromSpan src) const {
  331|  1.29k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.29k|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    866|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    421|                                  const bool inputisvalid) const {
  383|    421|    conversion_result ret{};
  384|       |
  385|    421|    const auto implementations = get_supported_implementations();
  386|       |
  387|    421|    std::vector<result<ConversionResult>> results;
  388|    421|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    421|    std::vector<std::vector<ToType>> outputbuffers;
  393|    421|    outputbuffers.reserve(implementations.size());
  394|  1.68k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.26k, False: 421]
  ------------------
  395|  1.26k|      auto impl = implementations[i];
  396|  1.26k|      const ToType canary1{42};
  397|  1.26k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.26k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.26k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.26k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.26k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.26k|          return r != 0;
  404|  1.26k|        } else {
  405|  1.26k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.26k|        }
  407|  1.26k|      }(implret1);
  408|  1.26k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.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|  1.26k|        const ToType canary2{25};
  414|  1.26k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.26k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.26k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.26k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.26k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.26k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.26k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 966, False: 297]
  |  Branch (423:29): [True: 954, False: 12]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    954|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    954|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 954]
  ------------------
  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|    954|        }
  440|  1.26k|      }
  441|  1.26k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 954, False: 309]
  ------------------
  442|  1.26k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    421|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 99, False: 322]
  ------------------
  447|    297|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 297, False: 99]
  ------------------
  448|    297|        e.outputhash.clear();
  449|    297|      }
  450|     99|    }
  451|       |
  452|    421|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    421|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 421]
  ------------------
  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|    421|    } else {
  474|    421|      ret.implementations_agree = true;
  475|    421|    }
  476|    421|    return ret;
  477|    421|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.26k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.26k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.26k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.26k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    842|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_4clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     69|    +[](std::span<const char> chardata) {                                      \
  555|     69|      const auto c =                                                           \
  556|     69|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     69|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     69|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     69|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     69|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     69|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     69|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     69|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     69|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     69|  constexpr auto _size = _name.size();                                \
  |  | 1183|     69|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     69|  return _nameof; }()
  ------------------
  561|     69|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     69|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     69|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     69|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     69|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     69|  constexpr auto _size = _name.size();                                \
  |  | 1183|     69|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     69|  return _nameof; }()
  ------------------
  562|     69|      c.fuzz(chardata);                                                        \
  563|     69|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    339|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    339|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    339|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    339|    static const bool do_print_testcase =
  181|    339|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    339|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 339]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    339|    do {
  189|       |      // step 0 - is the input valid?
  190|    339|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    339|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 339]
  |  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|    339|      const auto [output_length, length_agree] =
  204|    339|          calculate_length(from, inputisvalid);
  205|    339|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 339]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    339|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 210, False: 129]
  |  Branch (208:28): [True: 2, False: 208]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      2|        return;
  211|      2|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    337|      const auto [written, outputs_agree] =
  215|    337|          do_conversion(from, output_length, inputisvalid);
  216|    337|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 337]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    337|      return;
  221|    337|    } 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|    339|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    339|  validation_result verify_valid_input(FromSpan src) const {
  231|    339|    validation_result ret{};
  232|       |
  233|    339|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    339|    const auto implementations = get_supported_implementations();
  235|    339|    std::vector<simdutf::result> results;
  236|    339|    results.reserve(implementations.size());
  237|       |
  238|  1.01k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.01k, False: 339]
  ------------------
  239|  1.01k|      results.push_back(
  240|  1.01k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.01k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.01k|      const bool validation2 =
  245|  1.01k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.01k|                      src.data(), src.size());
  247|  1.01k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.01k]
  ------------------
  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.01k|    }
  258|       |
  259|    339|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    339|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 339]
  ------------------
  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|    339|    } else {
  273|    339|      ret.implementations_agree = true;
  274|    339|    }
  275|    339|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    339|      return r.error == simdutf::SUCCESS;
  277|    339|    });
  278|    339|    return ret;
  279|    339|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    678|    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|    597|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    597|      return r.error == simdutf::SUCCESS;
  277|    597|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    339|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    339|    length_result ret{};
  344|       |
  345|    339|    const auto implementations = get_supported_implementations();
  346|    339|    std::vector<std::size_t> results;
  347|    339|    results.reserve(implementations.size());
  348|       |
  349|  1.01k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.01k, False: 339]
  ------------------
  350|  1.01k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.01k|      results.push_back(len);
  352|  1.01k|      ret.length.push_back(len);
  353|  1.01k|    }
  354|       |
  355|    339|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    339|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 339]
  ------------------
  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|    339|    } else {
  375|    339|      ret.implementations_agree = true;
  376|    339|    }
  377|    339|    return ret;
  378|    339|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.01k|                                FromSpan src) const {
  331|  1.01k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.01k|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    678|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    337|                                  const bool inputisvalid) const {
  383|    337|    conversion_result ret{};
  384|       |
  385|    337|    const auto implementations = get_supported_implementations();
  386|       |
  387|    337|    std::vector<result<ConversionResult>> results;
  388|    337|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    337|    std::vector<std::vector<ToType>> outputbuffers;
  393|    337|    outputbuffers.reserve(implementations.size());
  394|  1.34k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.01k, False: 337]
  ------------------
  395|  1.01k|      auto impl = implementations[i];
  396|  1.01k|      const ToType canary1{42};
  397|  1.01k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.01k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.01k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.01k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.01k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.01k|          return r != 0;
  404|  1.01k|        } else {
  405|  1.01k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.01k|        }
  407|  1.01k|      }(implret1);
  408|  1.01k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.01k|      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.01k|        const ToType canary2{25};
  414|  1.01k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.01k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.01k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.01k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.01k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.01k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.01k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 387, False: 624]
  |  Branch (423:29): [True: 378, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    378|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    378|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 378]
  ------------------
  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|    378|        }
  440|  1.01k|      }
  441|  1.01k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 378, False: 633]
  ------------------
  442|  1.01k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    337|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 208, False: 129]
  ------------------
  447|    624|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 624, False: 208]
  ------------------
  448|    624|        e.outputhash.clear();
  449|    624|      }
  450|    208|    }
  451|       |
  452|    337|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    337|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 337]
  ------------------
  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|    337|    } else {
  474|    337|      ret.implementations_agree = true;
  475|    337|    }
  476|    337|    return ret;
  477|    337|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.01k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.01k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.01k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.01k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    674|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_5clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    149|    +[](std::span<const char> chardata) {                                      \
  555|    149|      const auto c =                                                           \
  556|    149|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    149|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    149|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    149|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    149|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    149|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    149|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    149|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    149|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    149|  constexpr auto _size = _name.size();                                \
  |  | 1183|    149|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    149|  return _nameof; }()
  ------------------
  561|    149|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    149|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    149|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    149|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    149|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    149|  constexpr auto _size = _name.size();                                \
  |  | 1183|    149|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    149|  return _nameof; }()
  ------------------
  562|    149|      c.fuzz(chardata);                                                        \
  563|    149|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    420|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    420|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    420|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    420|    static const bool do_print_testcase =
  181|    420|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    420|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 420]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    420|    do {
  189|       |      // step 0 - is the input valid?
  190|    420|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    420|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 420]
  |  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|    420|      const auto [output_length, length_agree] =
  204|    420|          calculate_length(from, inputisvalid);
  205|    420|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 420]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    420|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 204, False: 216]
  |  Branch (208:28): [True: 9, False: 195]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      9|        return;
  211|      9|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    411|      const auto [written, outputs_agree] =
  215|    411|          do_conversion(from, output_length, inputisvalid);
  216|    411|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 411]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    411|      return;
  221|    411|    } 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|    420|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    420|  validation_result verify_valid_input(FromSpan src) const {
  231|    420|    validation_result ret{};
  232|       |
  233|    420|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    420|    const auto implementations = get_supported_implementations();
  235|    420|    std::vector<simdutf::result> results;
  236|    420|    results.reserve(implementations.size());
  237|       |
  238|  1.26k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.26k, False: 420]
  ------------------
  239|  1.26k|      results.push_back(
  240|  1.26k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.26k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.26k|      const bool validation2 =
  245|  1.26k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.26k|                      src.data(), src.size());
  247|  1.26k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.26k]
  ------------------
  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.26k|    }
  258|       |
  259|    420|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    420|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 420]
  ------------------
  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|    420|    } else {
  273|    420|      ret.implementations_agree = true;
  274|    420|    }
  275|    420|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    420|      return r.error == simdutf::SUCCESS;
  277|    420|    });
  278|    420|    return ret;
  279|    420|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    840|    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|    852|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    852|      return r.error == simdutf::SUCCESS;
  277|    852|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    420|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    420|    length_result ret{};
  344|       |
  345|    420|    const auto implementations = get_supported_implementations();
  346|    420|    std::vector<std::size_t> results;
  347|    420|    results.reserve(implementations.size());
  348|       |
  349|  1.26k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.26k, False: 420]
  ------------------
  350|  1.26k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.26k|      results.push_back(len);
  352|  1.26k|      ret.length.push_back(len);
  353|  1.26k|    }
  354|       |
  355|    420|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    420|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 420]
  ------------------
  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|    420|    } else {
  375|    420|      ret.implementations_agree = true;
  376|    420|    }
  377|    420|    return ret;
  378|    420|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.26k|                                FromSpan src) const {
  331|  1.26k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.26k|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    840|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    411|                                  const bool inputisvalid) const {
  383|    411|    conversion_result ret{};
  384|       |
  385|    411|    const auto implementations = get_supported_implementations();
  386|       |
  387|    411|    std::vector<result<ConversionResult>> results;
  388|    411|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    411|    std::vector<std::vector<ToType>> outputbuffers;
  393|    411|    outputbuffers.reserve(implementations.size());
  394|  1.64k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.23k, False: 411]
  ------------------
  395|  1.23k|      auto impl = implementations[i];
  396|  1.23k|      const ToType canary1{42};
  397|  1.23k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.23k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.23k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.23k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.23k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.23k|          return r != 0;
  404|  1.23k|        } else {
  405|  1.23k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.23k|        }
  407|  1.23k|      }(implret1);
  408|  1.23k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.23k|      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.23k|        const ToType canary2{25};
  414|  1.23k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.23k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.23k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.23k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.23k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.23k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.23k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 648, False: 585]
  |  Branch (423:29): [True: 636, False: 12]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    636|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    636|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 636]
  ------------------
  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|    636|        }
  440|  1.23k|      }
  441|  1.23k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 636, False: 597]
  ------------------
  442|  1.23k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    411|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 195, False: 216]
  ------------------
  447|    585|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 585, False: 195]
  ------------------
  448|    585|        e.outputhash.clear();
  449|    585|      }
  450|    195|    }
  451|       |
  452|    411|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    411|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 411]
  ------------------
  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|    411|    } else {
  474|    411|      ret.implementations_agree = true;
  475|    411|    }
  476|    411|    return ret;
  477|    411|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.23k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.23k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.23k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.23k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    822|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_6clENSt3__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_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    444|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    444|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    444|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    444|    static const bool do_print_testcase =
  181|    444|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    444|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 444]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    444|    do {
  189|       |      // step 0 - is the input valid?
  190|    444|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    444|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 444]
  |  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|    444|      const auto [output_length, length_agree] =
  204|    444|          calculate_length(from, inputisvalid);
  205|    444|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 444]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    444|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 286, False: 158]
  |  Branch (208:28): [True: 12, False: 274]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     12|        return;
  211|     12|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    432|      const auto [written, outputs_agree] =
  215|    432|          do_conversion(from, output_length, inputisvalid);
  216|    432|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 432]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    432|      return;
  221|    432|    } 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|    444|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    444|  validation_result verify_valid_input(FromSpan src) const {
  231|    444|    validation_result ret{};
  232|       |
  233|    444|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    444|    const auto implementations = get_supported_implementations();
  235|    444|    std::vector<simdutf::result> results;
  236|    444|    results.reserve(implementations.size());
  237|       |
  238|  1.33k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.33k, False: 444]
  ------------------
  239|  1.33k|      results.push_back(
  240|  1.33k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.33k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.33k|      const bool validation2 =
  245|  1.33k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.33k|                      src.data(), src.size());
  247|  1.33k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.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|  1.33k|    }
  258|       |
  259|    444|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    444|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 444]
  ------------------
  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|    444|    } else {
  273|    444|      ret.implementations_agree = true;
  274|    444|    }
  275|    444|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    444|      return r.error == simdutf::SUCCESS;
  277|    444|    });
  278|    444|    return ret;
  279|    444|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    888|    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|    760|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    760|      return r.error == simdutf::SUCCESS;
  277|    760|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    444|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    444|    length_result ret{};
  344|       |
  345|    444|    const auto implementations = get_supported_implementations();
  346|    444|    std::vector<std::size_t> results;
  347|    444|    results.reserve(implementations.size());
  348|       |
  349|  1.33k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.33k, False: 444]
  ------------------
  350|  1.33k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.33k|      results.push_back(len);
  352|  1.33k|      ret.length.push_back(len);
  353|  1.33k|    }
  354|       |
  355|    444|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    444|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 444]
  ------------------
  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|    444|    } else {
  375|    444|      ret.implementations_agree = true;
  376|    444|    }
  377|    444|    return ret;
  378|    444|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.33k|                                FromSpan src) const {
  331|  1.33k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.33k|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    888|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    432|                                  const bool inputisvalid) const {
  383|    432|    conversion_result ret{};
  384|       |
  385|    432|    const auto implementations = get_supported_implementations();
  386|       |
  387|    432|    std::vector<result<ConversionResult>> results;
  388|    432|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    432|    std::vector<std::vector<ToType>> outputbuffers;
  393|    432|    outputbuffers.reserve(implementations.size());
  394|  1.72k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.29k, False: 432]
  ------------------
  395|  1.29k|      auto impl = implementations[i];
  396|  1.29k|      const ToType canary1{42};
  397|  1.29k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.29k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.29k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.29k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.29k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.29k|          return r != 0;
  404|  1.29k|        } else {
  405|  1.29k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.29k|        }
  407|  1.29k|      }(implret1);
  408|  1.29k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.29k|      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.29k|        const ToType canary2{25};
  414|  1.29k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.29k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.29k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.29k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.29k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.29k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.29k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 474, False: 822]
  |  Branch (423:29): [True: 462, False: 12]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    462|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    462|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 462]
  ------------------
  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|    462|        }
  440|  1.29k|      }
  441|  1.29k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 462, False: 834]
  ------------------
  442|  1.29k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    432|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 274, False: 158]
  ------------------
  447|    822|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 822, False: 274]
  ------------------
  448|    822|        e.outputhash.clear();
  449|    822|      }
  450|    274|    }
  451|       |
  452|    432|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    432|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 432]
  ------------------
  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|    432|    } else {
  474|    432|      ret.implementations_agree = true;
  475|    432|    }
  476|    432|    return ret;
  477|    432|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.29k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.29k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.29k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.29k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    864|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_7clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    265|    +[](std::span<const char> chardata) {                                      \
  555|    265|      const auto c =                                                           \
  556|    265|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    265|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    265|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    265|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    265|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    265|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    265|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    265|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    265|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    265|  constexpr auto _size = _name.size();                                \
  |  | 1183|    265|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    265|  return _nameof; }()
  ------------------
  561|    265|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    265|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    265|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    265|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    265|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    265|  constexpr auto _size = _name.size();                                \
  |  | 1183|    265|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    265|  return _nameof; }()
  ------------------
  562|    265|      c.fuzz(chardata);                                                        \
  563|    265|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    662|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    662|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    662|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    662|    static const bool do_print_testcase =
  181|    662|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    662|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 662]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    662|    do {
  189|       |      // step 0 - is the input valid?
  190|    662|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    662|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 662]
  |  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|    662|                    From == UtfEncodings::UTF8) {
  198|    662|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 662]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    662|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    662|      const auto [output_length, length_agree] =
  204|    662|          calculate_length(from, inputisvalid);
  205|    662|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 662]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    662|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 289, False: 373]
  |  Branch (208:28): [True: 10, False: 279]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     10|        return;
  211|     10|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    652|      const auto [written, outputs_agree] =
  215|    652|          do_conversion(from, output_length, inputisvalid);
  216|    652|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 652]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    652|      return;
  221|    652|    } 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|    662|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    662|  validation_result verify_valid_input(FromSpan src) const {
  231|    662|    validation_result ret{};
  232|       |
  233|    662|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    662|    const auto implementations = get_supported_implementations();
  235|    662|    std::vector<simdutf::result> results;
  236|    662|    results.reserve(implementations.size());
  237|       |
  238|  1.98k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.98k, False: 662]
  ------------------
  239|  1.98k|      results.push_back(
  240|  1.98k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.98k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.98k|      const bool validation2 =
  245|  1.98k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.98k|                      src.data(), src.size());
  247|  1.98k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.98k]
  ------------------
  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.98k|    }
  258|       |
  259|    662|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    662|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 662]
  ------------------
  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|    662|    } else {
  273|    662|      ret.implementations_agree = true;
  274|    662|    }
  275|    662|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    662|      return r.error == simdutf::SUCCESS;
  277|    662|    });
  278|    662|    return ret;
  279|    662|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|  1.32k|    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.40k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.40k|      return r.error == simdutf::SUCCESS;
  277|  1.40k|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    662|  bool count_the_input(FromSpan src) const {
  290|    662|    const auto implementations = get_supported_implementations();
  291|    662|    std::vector<std::size_t> results;
  292|    662|    results.reserve(implementations.size());
  293|       |
  294|  1.98k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.98k, False: 662]
  ------------------
  295|  1.98k|      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.98k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.98k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.98k|      }
  303|  1.98k|      results.push_back(ret);
  304|  1.98k|    }
  305|    662|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    662|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 662]
  ------------------
  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|    662|    return true;
  321|    662|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|  1.32k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    662|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    662|    length_result ret{};
  344|       |
  345|    662|    const auto implementations = get_supported_implementations();
  346|    662|    std::vector<std::size_t> results;
  347|    662|    results.reserve(implementations.size());
  348|       |
  349|  1.98k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.98k, False: 662]
  ------------------
  350|  1.98k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.98k|      results.push_back(len);
  352|  1.98k|      ret.length.push_back(len);
  353|  1.98k|    }
  354|       |
  355|    662|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    662|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 662]
  ------------------
  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|    662|    } else {
  375|    662|      ret.implementations_agree = true;
  376|    662|    }
  377|    662|    return ret;
  378|    662|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.98k|                                FromSpan src) const {
  331|  1.98k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.98k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|  1.32k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    652|                                  const bool inputisvalid) const {
  383|    652|    conversion_result ret{};
  384|       |
  385|    652|    const auto implementations = get_supported_implementations();
  386|       |
  387|    652|    std::vector<result<ConversionResult>> results;
  388|    652|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    652|    std::vector<std::vector<ToType>> outputbuffers;
  393|    652|    outputbuffers.reserve(implementations.size());
  394|  2.60k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.95k, False: 652]
  ------------------
  395|  1.95k|      auto impl = implementations[i];
  396|  1.95k|      const ToType canary1{42};
  397|  1.95k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.95k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.95k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.95k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.95k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.95k|          return r != 0;
  404|  1.95k|        } else {
  405|  1.95k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.95k|        }
  407|  1.95k|      }(implret1);
  408|  1.95k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.95k|      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.95k|        const ToType canary2{25};
  414|  1.95k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.95k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.95k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.95k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.95k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.95k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.95k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 1.11k, False: 837]
  |  Branch (423:29): [True: 1.11k, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|  1.11k|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|  1.11k|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 1.11k]
  ------------------
  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.11k|        }
  440|  1.95k|      }
  441|  1.95k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 1.11k, False: 843]
  ------------------
  442|  1.95k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    652|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 279, False: 373]
  ------------------
  447|    837|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 837, False: 279]
  ------------------
  448|    837|        e.outputhash.clear();
  449|    837|      }
  450|    279|    }
  451|       |
  452|    652|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    652|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 652]
  ------------------
  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|    652|    } else {
  474|    652|      ret.implementations_agree = true;
  475|    652|    }
  476|    652|    return ret;
  477|    652|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.95k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.95k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.95k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.95k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|  1.30k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_8clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    236|    +[](std::span<const char> chardata) {                                      \
  555|    236|      const auto c =                                                           \
  556|    236|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    236|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    236|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    236|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    236|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    236|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    236|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    236|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    236|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    236|  constexpr auto _size = _name.size();                                \
  |  | 1183|    236|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    236|  return _nameof; }()
  ------------------
  561|    236|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    236|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    236|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    236|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    236|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    236|  constexpr auto _size = _name.size();                                \
  |  | 1183|    236|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    236|  return _nameof; }()
  ------------------
  562|    236|      c.fuzz(chardata);                                                        \
  563|    236|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    624|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    624|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    624|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    624|    static const bool do_print_testcase =
  181|    624|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    624|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 624]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    624|    do {
  189|       |      // step 0 - is the input valid?
  190|    624|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    624|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 624]
  |  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|    624|                    From == UtfEncodings::UTF8) {
  198|    624|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 624]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    624|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    624|      const auto [output_length, length_agree] =
  204|    624|          calculate_length(from, inputisvalid);
  205|    624|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 624]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    624|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 277, False: 347]
  |  Branch (208:28): [True: 11, False: 266]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     11|        return;
  211|     11|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    613|      const auto [written, outputs_agree] =
  215|    613|          do_conversion(from, output_length, inputisvalid);
  216|    613|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 613]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    613|      return;
  221|    613|    } 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|    624|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    624|  validation_result verify_valid_input(FromSpan src) const {
  231|    624|    validation_result ret{};
  232|       |
  233|    624|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    624|    const auto implementations = get_supported_implementations();
  235|    624|    std::vector<simdutf::result> results;
  236|    624|    results.reserve(implementations.size());
  237|       |
  238|  1.87k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.87k, False: 624]
  ------------------
  239|  1.87k|      results.push_back(
  240|  1.87k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.87k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.87k|      const bool validation2 =
  245|  1.87k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.87k|                      src.data(), src.size());
  247|  1.87k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.87k]
  ------------------
  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.87k|    }
  258|       |
  259|    624|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    624|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 624]
  ------------------
  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|    624|    } else {
  273|    624|      ret.implementations_agree = true;
  274|    624|    }
  275|    624|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    624|      return r.error == simdutf::SUCCESS;
  277|    624|    });
  278|    624|    return ret;
  279|    624|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|  1.24k|    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.31k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.31k|      return r.error == simdutf::SUCCESS;
  277|  1.31k|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    624|  bool count_the_input(FromSpan src) const {
  290|    624|    const auto implementations = get_supported_implementations();
  291|    624|    std::vector<std::size_t> results;
  292|    624|    results.reserve(implementations.size());
  293|       |
  294|  1.87k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.87k, False: 624]
  ------------------
  295|  1.87k|      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.87k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.87k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.87k|      }
  303|  1.87k|      results.push_back(ret);
  304|  1.87k|    }
  305|    624|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    624|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 624]
  ------------------
  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|    624|    return true;
  321|    624|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|  1.24k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    624|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    624|    length_result ret{};
  344|       |
  345|    624|    const auto implementations = get_supported_implementations();
  346|    624|    std::vector<std::size_t> results;
  347|    624|    results.reserve(implementations.size());
  348|       |
  349|  1.87k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.87k, False: 624]
  ------------------
  350|  1.87k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.87k|      results.push_back(len);
  352|  1.87k|      ret.length.push_back(len);
  353|  1.87k|    }
  354|       |
  355|    624|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    624|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 624]
  ------------------
  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|    624|    } else {
  375|    624|      ret.implementations_agree = true;
  376|    624|    }
  377|    624|    return ret;
  378|    624|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.87k|                                FromSpan src) const {
  331|  1.87k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.87k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|  1.24k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    613|                                  const bool inputisvalid) const {
  383|    613|    conversion_result ret{};
  384|       |
  385|    613|    const auto implementations = get_supported_implementations();
  386|       |
  387|    613|    std::vector<result<ConversionResult>> results;
  388|    613|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    613|    std::vector<std::vector<ToType>> outputbuffers;
  393|    613|    outputbuffers.reserve(implementations.size());
  394|  2.45k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.83k, False: 613]
  ------------------
  395|  1.83k|      auto impl = implementations[i];
  396|  1.83k|      const ToType canary1{42};
  397|  1.83k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.83k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.83k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.83k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.83k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.83k|          return r != 0;
  404|  1.83k|        } else {
  405|  1.83k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.83k|        }
  407|  1.83k|      }(implret1);
  408|  1.83k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.83k|      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.83k|        const ToType canary2{25};
  414|  1.83k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.83k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.83k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.83k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.83k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.83k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.83k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 1.04k, False: 798]
  |  Branch (423:29): [True: 1.03k, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|  1.03k|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|  1.03k|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 1.03k]
  ------------------
  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.03k|        }
  440|  1.83k|      }
  441|  1.83k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 1.03k, False: 804]
  ------------------
  442|  1.83k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    613|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 266, False: 347]
  ------------------
  447|    798|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 798, False: 266]
  ------------------
  448|    798|        e.outputhash.clear();
  449|    798|      }
  450|    266|    }
  451|       |
  452|    613|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    613|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 613]
  ------------------
  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|    613|    } else {
  474|    613|      ret.implementations_agree = true;
  475|    613|    }
  476|    613|    return ret;
  477|    613|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.83k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.83k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.83k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.83k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|  1.22k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_9clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    242|    +[](std::span<const char> chardata) {                                      \
  555|    242|      const auto c =                                                           \
  556|    242|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    242|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    242|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    242|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    242|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    242|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    242|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    242|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    242|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    242|  constexpr auto _size = _name.size();                                \
  |  | 1183|    242|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    242|  return _nameof; }()
  ------------------
  561|    242|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    242|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    242|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    242|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    242|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    242|  constexpr auto _size = _name.size();                                \
  |  | 1183|    242|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    242|  return _nameof; }()
  ------------------
  562|    242|      c.fuzz(chardata);                                                        \
  563|    242|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    621|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    621|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    621|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    621|    static const bool do_print_testcase =
  181|    621|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    621|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 621]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    621|    do {
  189|       |      // step 0 - is the input valid?
  190|    621|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    621|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 621]
  |  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|    621|                    From == UtfEncodings::UTF8) {
  198|    621|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 621]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    621|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    621|      const auto [output_length, length_agree] =
  204|    621|          calculate_length(from, inputisvalid);
  205|    621|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 621]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    621|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 257, False: 364]
  |  Branch (208:28): [True: 10, False: 247]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     10|        return;
  211|     10|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    611|      const auto [written, outputs_agree] =
  215|    611|          do_conversion(from, output_length, inputisvalid);
  216|    611|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 611]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    611|      return;
  221|    611|    } 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|    621|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    621|  validation_result verify_valid_input(FromSpan src) const {
  231|    621|    validation_result ret{};
  232|       |
  233|    621|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    621|    const auto implementations = get_supported_implementations();
  235|    621|    std::vector<simdutf::result> results;
  236|    621|    results.reserve(implementations.size());
  237|       |
  238|  1.86k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.86k, False: 621]
  ------------------
  239|  1.86k|      results.push_back(
  240|  1.86k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.86k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.86k|      const bool validation2 =
  245|  1.86k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.86k|                      src.data(), src.size());
  247|  1.86k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.86k]
  ------------------
  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.86k|    }
  258|       |
  259|    621|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    621|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 621]
  ------------------
  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|    621|    } else {
  273|    621|      ret.implementations_agree = true;
  274|    621|    }
  275|    621|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    621|      return r.error == simdutf::SUCCESS;
  277|    621|    });
  278|    621|    return ret;
  279|    621|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|  1.24k|    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.34k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.34k|      return r.error == simdutf::SUCCESS;
  277|  1.34k|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    621|  bool count_the_input(FromSpan src) const {
  290|    621|    const auto implementations = get_supported_implementations();
  291|    621|    std::vector<std::size_t> results;
  292|    621|    results.reserve(implementations.size());
  293|       |
  294|  1.86k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.86k, False: 621]
  ------------------
  295|  1.86k|      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.86k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.86k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.86k|      }
  303|  1.86k|      results.push_back(ret);
  304|  1.86k|    }
  305|    621|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    621|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 621]
  ------------------
  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|    621|    return true;
  321|    621|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|  1.24k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    621|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    621|    length_result ret{};
  344|       |
  345|    621|    const auto implementations = get_supported_implementations();
  346|    621|    std::vector<std::size_t> results;
  347|    621|    results.reserve(implementations.size());
  348|       |
  349|  1.86k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.86k, False: 621]
  ------------------
  350|  1.86k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.86k|      results.push_back(len);
  352|  1.86k|      ret.length.push_back(len);
  353|  1.86k|    }
  354|       |
  355|    621|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    621|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 621]
  ------------------
  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|    621|    } else {
  375|    621|      ret.implementations_agree = true;
  376|    621|    }
  377|    621|    return ret;
  378|    621|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.86k|                                FromSpan src) const {
  331|  1.86k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.86k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|  1.24k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    611|                                  const bool inputisvalid) const {
  383|    611|    conversion_result ret{};
  384|       |
  385|    611|    const auto implementations = get_supported_implementations();
  386|       |
  387|    611|    std::vector<result<ConversionResult>> results;
  388|    611|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    611|    std::vector<std::vector<ToType>> outputbuffers;
  393|    611|    outputbuffers.reserve(implementations.size());
  394|  2.44k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.83k, False: 611]
  ------------------
  395|  1.83k|      auto impl = implementations[i];
  396|  1.83k|      const ToType canary1{42};
  397|  1.83k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.83k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.83k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.83k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.83k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.83k|          return r != 0;
  404|  1.83k|        } else {
  405|  1.83k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.83k|        }
  407|  1.83k|      }(implret1);
  408|  1.83k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.83k|      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.83k|        const ToType canary2{25};
  414|  1.83k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.83k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.83k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.83k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.83k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.83k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.83k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 1.09k, False: 741]
  |  Branch (423:29): [True: 1.08k, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|  1.08k|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|  1.08k|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 1.08k]
  ------------------
  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.08k|        }
  440|  1.83k|      }
  441|  1.83k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 1.08k, False: 747]
  ------------------
  442|  1.83k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    611|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 247, False: 364]
  ------------------
  447|    741|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 741, False: 247]
  ------------------
  448|    741|        e.outputhash.clear();
  449|    741|      }
  450|    247|    }
  451|       |
  452|    611|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    611|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 611]
  ------------------
  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|    611|    } else {
  474|    611|      ret.implementations_agree = true;
  475|    611|    }
  476|    611|    return ret;
  477|    611|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.83k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.83k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.83k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.83k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|  1.22k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_10clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     57|    +[](std::span<const char> chardata) {                                      \
  555|     57|      const auto c =                                                           \
  556|     57|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     57|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     57|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     57|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     57|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     57|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     57|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     57|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     57|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     57|  constexpr auto _size = _name.size();                                \
  |  | 1183|     57|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     57|  return _nameof; }()
  ------------------
  561|     57|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     57|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     57|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     57|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     57|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     57|  constexpr auto _size = _name.size();                                \
  |  | 1183|     57|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     57|  return _nameof; }()
  ------------------
  562|     57|      c.fuzz(chardata);                                                        \
  563|     57|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|     57|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     57|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     57|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     57|    static const bool do_print_testcase =
  181|     57|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     57|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 57]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     57|    do {
  189|       |      // step 0 - is the input valid?
  190|     57|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     57|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 57]
  |  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|     57|                    From == UtfEncodings::UTF8) {
  198|     57|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 57]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|     57|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|     57|      const auto [output_length, length_agree] =
  204|     57|          calculate_length(from, inputisvalid);
  205|     57|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 57]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     57|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 11, False: 46]
  |  Branch (208:28): [True: 0, False: 11]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|     57|      const auto [written, outputs_agree] =
  215|     57|          do_conversion(from, output_length, inputisvalid);
  216|     57|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 57]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     57|      return;
  221|     57|    } 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|     57|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  230|     57|  validation_result verify_valid_input(FromSpan src) const {
  231|     57|    validation_result ret{};
  232|       |
  233|     57|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|     57|    const auto implementations = get_supported_implementations();
  235|     57|    std::vector<simdutf::result> results;
  236|     57|    results.reserve(implementations.size());
  237|       |
  238|    171|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 171, False: 57]
  ------------------
  239|    171|      results.push_back(
  240|    171|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    171|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    171|      const bool validation2 =
  245|    171|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    171|                      src.data(), src.size());
  247|    171|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 171]
  ------------------
  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|    171|    }
  258|       |
  259|     57|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|     57|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 57]
  ------------------
  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|     57|    } else {
  273|     57|      ret.implementations_agree = true;
  274|     57|    }
  275|     57|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|     57|      return r.error == simdutf::SUCCESS;
  277|     57|    });
  278|     57|    return ret;
  279|     57|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    114|    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|    149|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    149|      return r.error == simdutf::SUCCESS;
  277|    149|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE15count_the_inputENSt3__14spanIS5_Lm18446744073709551615EEE:
  289|     57|  bool count_the_input(FromSpan src) const {
  290|     57|    const auto implementations = get_supported_implementations();
  291|     57|    std::vector<std::size_t> results;
  292|     57|    results.reserve(implementations.size());
  293|       |
  294|    171|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 171, False: 57]
  ------------------
  295|    171|      std::size_t ret;
  296|    171|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    171|        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|    171|      results.push_back(ret);
  304|    171|    }
  305|     57|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|     57|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 57]
  ------------------
  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|     57|    return true;
  321|     57|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE15count_the_inputENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    114|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     57|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     57|    length_result ret{};
  344|       |
  345|     57|    const auto implementations = get_supported_implementations();
  346|     57|    std::vector<std::size_t> results;
  347|     57|    results.reserve(implementations.size());
  348|       |
  349|    171|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 171, False: 57]
  ------------------
  350|    171|      const auto len = invoke_lengthcalc(impl, src);
  351|    171|      results.push_back(len);
  352|    171|      ret.length.push_back(len);
  353|    171|    }
  354|       |
  355|     57|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     57|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 57]
  ------------------
  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|     57|    } else {
  375|     57|      ret.implementations_agree = true;
  376|     57|    }
  377|     57|    return ret;
  378|     57|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    171|                                FromSpan src) const {
  339|    171|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    171|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    114|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     57|                                  const bool inputisvalid) const {
  383|     57|    conversion_result ret{};
  384|       |
  385|     57|    const auto implementations = get_supported_implementations();
  386|       |
  387|     57|    std::vector<result<ConversionResult>> results;
  388|     57|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     57|    std::vector<std::vector<ToType>> outputbuffers;
  393|     57|    outputbuffers.reserve(implementations.size());
  394|    228|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 171, False: 57]
  ------------------
  395|    171|      auto impl = implementations[i];
  396|    171|      const ToType canary1{42};
  397|    171|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    171|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    171|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    171|      const auto success = [](const ConversionResult& r) -> bool {
  402|    171|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    171|          return r != 0;
  404|    171|        } else {
  405|    171|          return r.error == simdutf::error_code::SUCCESS;
  406|    171|        }
  407|    171|      }(implret1);
  408|    171|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    171|      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|    171|        const ToType canary2{25};
  414|    171|        const auto outputbuffer_first_run = outputbuffer;
  415|    171|        std::ranges::fill(outputbuffer, canary2);
  416|    171|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    171|                                          src.size(), outputbuffer.data());
  418|       |
  419|    171|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 171]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    171|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 138, False: 33]
  |  Branch (423:29): [True: 69, False: 69]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|     69|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|     69|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 69]
  ------------------
  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|     69|        }
  440|    171|      }
  441|    171|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 69, False: 102]
  ------------------
  442|    171|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     57|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 11, False: 46]
  ------------------
  447|     33|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 33, False: 11]
  ------------------
  448|     33|        e.outputhash.clear();
  449|     33|      }
  450|     11|    }
  451|       |
  452|     57|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     57|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 57]
  ------------------
  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|     57|    } else {
  474|     57|      ret.implementations_agree = true;
  475|     57|    }
  476|     57|    return ret;
  477|     57|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    171|      const auto success = [](const ConversionResult& r) -> bool {
  402|    171|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    171|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    171|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    114|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_11clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    140|    +[](std::span<const char> chardata) {                                      \
  555|    140|      const auto c =                                                           \
  556|    140|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    140|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    140|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    140|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    140|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    140|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    140|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    140|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    140|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    140|  constexpr auto _size = _name.size();                                \
  |  | 1183|    140|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    140|  return _nameof; }()
  ------------------
  561|    140|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    140|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    140|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    140|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    140|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    140|  constexpr auto _size = _name.size();                                \
  |  | 1183|    140|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    140|  return _nameof; }()
  ------------------
  562|    140|      c.fuzz(chardata);                                                        \
  563|    140|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_12clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    173|    +[](std::span<const char> chardata) {                                      \
  555|    173|      const auto c =                                                           \
  556|    173|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    173|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    173|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    173|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    173|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    173|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    173|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    173|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    173|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    173|  constexpr auto _size = _name.size();                                \
  |  | 1183|    173|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    173|  return _nameof; }()
  ------------------
  561|    173|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    173|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    173|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    173|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    173|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    173|  constexpr auto _size = _name.size();                                \
  |  | 1183|    173|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    173|  return _nameof; }()
  ------------------
  562|    173|      c.fuzz(chardata);                                                        \
  563|    173|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_13clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     62|    +[](std::span<const char> chardata) {                                      \
  555|     62|      const auto c =                                                           \
  556|     62|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     62|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     62|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     62|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     62|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     62|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     62|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     62|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     62|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     62|  constexpr auto _size = _name.size();                                \
  |  | 1183|     62|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     62|  return _nameof; }()
  ------------------
  561|     62|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     62|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     62|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     62|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     62|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     62|  constexpr auto _size = _name.size();                                \
  |  | 1183|     62|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     62|  return _nameof; }()
  ------------------
  562|     62|      c.fuzz(chardata);                                                        \
  563|     62|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|     62|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     62|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     62|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     62|    static const bool do_print_testcase =
  181|     62|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     62|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 62]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     62|    do {
  189|       |      // step 0 - is the input valid?
  190|     62|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     62|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 62]
  |  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|     62|                    From == UtfEncodings::UTF8) {
  198|     62|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 62]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|     62|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|     62|      const auto [output_length, length_agree] =
  204|     62|          calculate_length(from, inputisvalid);
  205|     62|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 62]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     62|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 16, False: 46]
  |  Branch (208:28): [True: 0, False: 16]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|     62|      const auto [written, outputs_agree] =
  215|     62|          do_conversion(from, output_length, inputisvalid);
  216|     62|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 62]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     62|      return;
  221|     62|    } 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|     62|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  230|     62|  validation_result verify_valid_input(FromSpan src) const {
  231|     62|    validation_result ret{};
  232|       |
  233|     62|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|     62|    const auto implementations = get_supported_implementations();
  235|     62|    std::vector<simdutf::result> results;
  236|     62|    results.reserve(implementations.size());
  237|       |
  238|    186|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 186, False: 62]
  ------------------
  239|    186|      results.push_back(
  240|    186|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    186|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    186|      const bool validation2 =
  245|    186|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    186|                      src.data(), src.size());
  247|    186|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 186]
  ------------------
  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|    186|    }
  258|       |
  259|     62|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|     62|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 62]
  ------------------
  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|     62|    } else {
  273|     62|      ret.implementations_agree = true;
  274|     62|    }
  275|     62|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|     62|      return r.error == simdutf::SUCCESS;
  277|     62|    });
  278|     62|    return ret;
  279|     62|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    124|    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|    154|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    154|      return r.error == simdutf::SUCCESS;
  277|    154|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE15count_the_inputENSt3__14spanIS5_Lm18446744073709551615EEE:
  289|     62|  bool count_the_input(FromSpan src) const {
  290|     62|    const auto implementations = get_supported_implementations();
  291|     62|    std::vector<std::size_t> results;
  292|     62|    results.reserve(implementations.size());
  293|       |
  294|    186|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 186, False: 62]
  ------------------
  295|    186|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    186|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    186|        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|    186|      results.push_back(ret);
  304|    186|    }
  305|     62|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|     62|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 62]
  ------------------
  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|     62|    return true;
  321|     62|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE15count_the_inputENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    124|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     62|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     62|    length_result ret{};
  344|       |
  345|     62|    const auto implementations = get_supported_implementations();
  346|     62|    std::vector<std::size_t> results;
  347|     62|    results.reserve(implementations.size());
  348|       |
  349|    186|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 186, False: 62]
  ------------------
  350|    186|      const auto len = invoke_lengthcalc(impl, src);
  351|    186|      results.push_back(len);
  352|    186|      ret.length.push_back(len);
  353|    186|    }
  354|       |
  355|     62|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     62|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 62]
  ------------------
  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|     62|    } else {
  375|     62|      ret.implementations_agree = true;
  376|     62|    }
  377|     62|    return ret;
  378|     62|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    186|                                FromSpan src) const {
  339|    186|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    186|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    124|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     62|                                  const bool inputisvalid) const {
  383|     62|    conversion_result ret{};
  384|       |
  385|     62|    const auto implementations = get_supported_implementations();
  386|       |
  387|     62|    std::vector<result<ConversionResult>> results;
  388|     62|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     62|    std::vector<std::vector<ToType>> outputbuffers;
  393|     62|    outputbuffers.reserve(implementations.size());
  394|    248|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 186, False: 62]
  ------------------
  395|    186|      auto impl = implementations[i];
  396|    186|      const ToType canary1{42};
  397|    186|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    186|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    186|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    186|      const auto success = [](const ConversionResult& r) -> bool {
  402|    186|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    186|          return r != 0;
  404|    186|        } else {
  405|    186|          return r.error == simdutf::error_code::SUCCESS;
  406|    186|        }
  407|    186|      }(implret1);
  408|    186|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    186|      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|    186|        const ToType canary2{25};
  414|    186|        const auto outputbuffer_first_run = outputbuffer;
  415|    186|        std::ranges::fill(outputbuffer, canary2);
  416|    186|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    186|                                          src.size(), outputbuffer.data());
  418|       |
  419|    186|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 186]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    186|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 138, False: 48]
  |  Branch (423:29): [True: 60, False: 78]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|     60|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|     60|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 60]
  ------------------
  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|     60|        }
  440|    186|      }
  441|    186|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 60, False: 126]
  ------------------
  442|    186|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     62|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 16, False: 46]
  ------------------
  447|     48|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 48, False: 16]
  ------------------
  448|     48|        e.outputhash.clear();
  449|     48|      }
  450|     16|    }
  451|       |
  452|     62|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     62|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 62]
  ------------------
  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|     62|    } else {
  474|     62|      ret.implementations_agree = true;
  475|     62|    }
  476|     62|    return ret;
  477|     62|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    186|      const auto success = [](const ConversionResult& r) -> bool {
  402|    186|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    186|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    186|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    124|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_14clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    163|    +[](std::span<const char> chardata) {                                      \
  555|    163|      const auto c =                                                           \
  556|    163|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    163|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    163|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    163|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    163|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    163|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    163|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    163|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    163|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    163|  constexpr auto _size = _name.size();                                \
  |  | 1183|    163|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    163|  return _nameof; }()
  ------------------
  561|    163|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    163|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    163|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    163|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    163|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    163|  constexpr auto _size = _name.size();                                \
  |  | 1183|    163|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    163|  return _nameof; }()
  ------------------
  562|    163|      c.fuzz(chardata);                                                        \
  563|    163|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_15clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    218|    +[](std::span<const char> chardata) {                                      \
  555|    218|      const auto c =                                                           \
  556|    218|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    218|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    218|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    218|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    218|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    218|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    218|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    218|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    218|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    218|  constexpr auto _size = _name.size();                                \
  |  | 1183|    218|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    218|  return _nameof; }()
  ------------------
  561|    218|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    218|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    218|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    218|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    218|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    218|  constexpr auto _size = _name.size();                                \
  |  | 1183|    218|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    218|  return _nameof; }()
  ------------------
  562|    218|      c.fuzz(chardata);                                                        \
  563|    218|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_16clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    114|    +[](std::span<const char> chardata) {                                      \
  555|    114|      const auto c =                                                           \
  556|    114|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    114|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    114|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    114|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    114|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    114|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    114|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    114|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    114|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    114|  constexpr auto _size = _name.size();                                \
  |  | 1183|    114|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    114|  return _nameof; }()
  ------------------
  561|    114|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    114|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    114|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    114|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    114|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    114|  constexpr auto _size = _name.size();                                \
  |  | 1183|    114|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    114|  return _nameof; }()
  ------------------
  562|    114|      c.fuzz(chardata);                                                        \
  563|    114|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    114|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    114|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    114|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    114|    static const bool do_print_testcase =
  181|    114|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    114|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 114]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    114|    do {
  189|       |      // step 0 - is the input valid?
  190|    114|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    114|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 114]
  |  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|    114|      const auto [output_length, length_agree] =
  204|    114|          calculate_length(from, inputisvalid);
  205|    114|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 114]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    114|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 81, False: 33]
  |  Branch (208:28): [True: 0, False: 81]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    114|      const auto [written, outputs_agree] =
  215|    114|          do_conversion(from, output_length, inputisvalid);
  216|    114|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 114]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    114|      return;
  221|    114|    } 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|    114|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  230|    114|  validation_result verify_valid_input(FromSpan src) const {
  231|    114|    validation_result ret{};
  232|       |
  233|    114|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    114|    const auto implementations = get_supported_implementations();
  235|    114|    std::vector<simdutf::result> results;
  236|    114|    results.reserve(implementations.size());
  237|       |
  238|    342|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 342, False: 114]
  ------------------
  239|    342|      results.push_back(
  240|    342|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    342|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    342|      const bool validation2 =
  245|    342|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    342|                      src.data(), src.size());
  247|    342|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 342]
  ------------------
  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|    342|    }
  258|       |
  259|    114|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    114|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 114]
  ------------------
  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|    114|    } else {
  273|    114|      ret.implementations_agree = true;
  274|    114|    }
  275|    114|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    114|      return r.error == simdutf::SUCCESS;
  277|    114|    });
  278|    114|    return ret;
  279|    114|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    228|    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|    180|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    180|      return r.error == simdutf::SUCCESS;
  277|    180|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|    114|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    114|    length_result ret{};
  344|       |
  345|    114|    const auto implementations = get_supported_implementations();
  346|    114|    std::vector<std::size_t> results;
  347|    114|    results.reserve(implementations.size());
  348|       |
  349|    342|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 342, False: 114]
  ------------------
  350|    342|      const auto len = invoke_lengthcalc(impl, src);
  351|    342|      results.push_back(len);
  352|    342|      ret.length.push_back(len);
  353|    342|    }
  354|       |
  355|    114|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    114|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 114]
  ------------------
  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|    114|    } else {
  375|    114|      ret.implementations_agree = true;
  376|    114|    }
  377|    114|    return ret;
  378|    114|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    342|                                FromSpan src) const {
  339|    342|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    342|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    228|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    114|                                  const bool inputisvalid) const {
  383|    114|    conversion_result ret{};
  384|       |
  385|    114|    const auto implementations = get_supported_implementations();
  386|       |
  387|    114|    std::vector<result<ConversionResult>> results;
  388|    114|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    114|    std::vector<std::vector<ToType>> outputbuffers;
  393|    114|    outputbuffers.reserve(implementations.size());
  394|    456|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 342, False: 114]
  ------------------
  395|    342|      auto impl = implementations[i];
  396|    342|      const ToType canary1{42};
  397|    342|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    342|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    342|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    342|      const auto success = [](const ConversionResult& r) -> bool {
  402|    342|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    342|          return r != 0;
  404|    342|        } else {
  405|    342|          return r.error == simdutf::error_code::SUCCESS;
  406|    342|        }
  407|    342|      }(implret1);
  408|    342|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    342|      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|    342|        const ToType canary2{25};
  414|    342|        const auto outputbuffer_first_run = outputbuffer;
  415|    342|        std::ranges::fill(outputbuffer, canary2);
  416|    342|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    342|                                          src.size(), outputbuffer.data());
  418|       |
  419|    342|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 342]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    342|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 99, False: 243]
  |  Branch (423:29): [True: 78, False: 21]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|     78|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|     78|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 78]
  ------------------
  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|     78|        }
  440|    342|      }
  441|    342|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 78, False: 264]
  ------------------
  442|    342|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    114|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 81, False: 33]
  ------------------
  447|    243|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 243, False: 81]
  ------------------
  448|    243|        e.outputhash.clear();
  449|    243|      }
  450|     81|    }
  451|       |
  452|    114|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    114|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 114]
  ------------------
  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|    114|    } else {
  474|    114|      ret.implementations_agree = true;
  475|    114|    }
  476|    114|    return ret;
  477|    114|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    342|      const auto success = [](const ConversionResult& r) -> bool {
  402|    342|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    342|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    342|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    228|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_17clENSt3__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|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_18clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    271|    +[](std::span<const char> chardata) {                                      \
  555|    271|      const auto c =                                                           \
  556|    271|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    271|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    271|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    271|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    271|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    271|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    271|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    271|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    271|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    271|  constexpr auto _size = _name.size();                                \
  |  | 1183|    271|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    271|  return _nameof; }()
  ------------------
  561|    271|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    271|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    271|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    271|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    271|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    271|  constexpr auto _size = _name.size();                                \
  |  | 1183|    271|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    271|  return _nameof; }()
  ------------------
  562|    271|      c.fuzz(chardata);                                                        \
  563|    271|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_19clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    324|    +[](std::span<const char> chardata) {                                      \
  555|    324|      const auto c =                                                           \
  556|    324|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    324|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    324|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    324|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    324|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    324|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    324|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    324|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    324|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    324|  constexpr auto _size = _name.size();                                \
  |  | 1183|    324|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    324|  return _nameof; }()
  ------------------
  561|    324|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    324|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    324|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    324|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    324|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    324|  constexpr auto _size = _name.size();                                \
  |  | 1183|    324|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    324|  return _nameof; }()
  ------------------
  562|    324|      c.fuzz(chardata);                                                        \
  563|    324|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_20clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    293|    +[](std::span<const char> chardata) {                                      \
  555|    293|      const auto c =                                                           \
  556|    293|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    293|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    293|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    293|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    293|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    293|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    293|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    293|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    293|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    293|  constexpr auto _size = _name.size();                                \
  |  | 1183|    293|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    293|  return _nameof; }()
  ------------------
  561|    293|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    293|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    293|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    293|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    293|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    293|  constexpr auto _size = _name.size();                                \
  |  | 1183|    293|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    293|  return _nameof; }()
  ------------------
  562|    293|      c.fuzz(chardata);                                                        \
  563|    293|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    293|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    293|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    293|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    293|    static const bool do_print_testcase =
  181|    293|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    293|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 293]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    293|    do {
  189|       |      // step 0 - is the input valid?
  190|    293|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    293|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 293]
  |  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|    293|                    From == UtfEncodings::UTF8) {
  198|    293|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 293]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    293|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    293|      const auto [output_length, length_agree] =
  204|    293|          calculate_length(from, inputisvalid);
  205|    293|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 293]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    293|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 199, False: 94]
  |  Branch (208:28): [True: 0, False: 199]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    293|      const auto [written, outputs_agree] =
  215|    293|          do_conversion(from, output_length, inputisvalid);
  216|    293|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 293]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    293|      return;
  221|    293|    } 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|    293|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    293|  validation_result verify_valid_input(FromSpan src) const {
  231|    293|    validation_result ret{};
  232|       |
  233|    293|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    293|    const auto implementations = get_supported_implementations();
  235|    293|    std::vector<simdutf::result> results;
  236|    293|    results.reserve(implementations.size());
  237|       |
  238|    879|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 879, False: 293]
  ------------------
  239|    879|      results.push_back(
  240|    879|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    879|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    879|      const bool validation2 =
  245|    879|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    879|                      src.data(), src.size());
  247|    879|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 879]
  ------------------
  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|    879|    }
  258|       |
  259|    293|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    293|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 293]
  ------------------
  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|    293|    } else {
  273|    293|      ret.implementations_agree = true;
  274|    293|    }
  275|    293|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    293|      return r.error == simdutf::SUCCESS;
  277|    293|    });
  278|    293|    return ret;
  279|    293|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    586|    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|    481|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    481|      return r.error == simdutf::SUCCESS;
  277|    481|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    293|  bool count_the_input(FromSpan src) const {
  290|    293|    const auto implementations = get_supported_implementations();
  291|    293|    std::vector<std::size_t> results;
  292|    293|    results.reserve(implementations.size());
  293|       |
  294|    879|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 879, False: 293]
  ------------------
  295|    879|      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|    879|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|    879|        ret = impl->count_utf8(src.data(), src.size());
  302|    879|      }
  303|    879|      results.push_back(ret);
  304|    879|    }
  305|    293|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    293|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 293]
  ------------------
  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|    293|    return true;
  321|    293|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    586|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    293|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    293|    length_result ret{};
  344|       |
  345|    293|    const auto implementations = get_supported_implementations();
  346|    293|    std::vector<std::size_t> results;
  347|    293|    results.reserve(implementations.size());
  348|       |
  349|    879|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 879, False: 293]
  ------------------
  350|    879|      const auto len = invoke_lengthcalc(impl, src);
  351|    879|      results.push_back(len);
  352|    879|      ret.length.push_back(len);
  353|    879|    }
  354|       |
  355|    293|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    293|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 293]
  ------------------
  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|    293|    } else {
  375|    293|      ret.implementations_agree = true;
  376|    293|    }
  377|    293|    return ret;
  378|    293|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    879|                                FromSpan src) const {
  331|    879|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    879|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    586|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    293|                                  const bool inputisvalid) const {
  383|    293|    conversion_result ret{};
  384|       |
  385|    293|    const auto implementations = get_supported_implementations();
  386|       |
  387|    293|    std::vector<result<ConversionResult>> results;
  388|    293|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    293|    std::vector<std::vector<ToType>> outputbuffers;
  393|    293|    outputbuffers.reserve(implementations.size());
  394|  1.17k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 879, False: 293]
  ------------------
  395|    879|      auto impl = implementations[i];
  396|    879|      const ToType canary1{42};
  397|    879|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    879|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    879|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    879|      const auto success = [](const ConversionResult& r) -> bool {
  402|    879|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    879|          return r != 0;
  404|    879|        } else {
  405|    879|          return r.error == simdutf::error_code::SUCCESS;
  406|    879|        }
  407|    879|      }(implret1);
  408|    879|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    879|      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|    879|        const ToType canary2{25};
  414|    879|        const auto outputbuffer_first_run = outputbuffer;
  415|    879|        std::ranges::fill(outputbuffer, canary2);
  416|    879|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    879|                                          src.size(), outputbuffer.data());
  418|       |
  419|    879|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 879]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    879|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 282, False: 597]
  |  Branch (423:29): [True: 252, False: 30]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    252|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    252|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 252]
  ------------------
  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|    252|        }
  440|    879|      }
  441|    879|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 252, False: 627]
  ------------------
  442|    879|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    293|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 199, False: 94]
  ------------------
  447|    597|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 597, False: 199]
  ------------------
  448|    597|        e.outputhash.clear();
  449|    597|      }
  450|    199|    }
  451|       |
  452|    293|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    293|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 293]
  ------------------
  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|    293|    } else {
  474|    293|      ret.implementations_agree = true;
  475|    293|    }
  476|    293|    return ret;
  477|    293|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    879|      const auto success = [](const ConversionResult& r) -> bool {
  402|    879|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    879|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    879|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    586|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_21clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    397|    +[](std::span<const char> chardata) {                                      \
  555|    397|      const auto c =                                                           \
  556|    397|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    397|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    397|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    397|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    397|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    397|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    397|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    397|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    397|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    397|  constexpr auto _size = _name.size();                                \
  |  | 1183|    397|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    397|  return _nameof; }()
  ------------------
  561|    397|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    397|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    397|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    397|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    397|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    397|  constexpr auto _size = _name.size();                                \
  |  | 1183|    397|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    397|  return _nameof; }()
  ------------------
  562|    397|      c.fuzz(chardata);                                                        \
  563|    397|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_22clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    388|    +[](std::span<const char> chardata) {                                      \
  555|    388|      const auto c =                                                           \
  556|    388|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    388|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    388|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    388|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    388|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    388|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    388|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    388|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    388|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    388|  constexpr auto _size = _name.size();                                \
  |  | 1183|    388|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    388|  return _nameof; }()
  ------------------
  561|    388|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    388|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    388|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    388|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    388|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    388|  constexpr auto _size = _name.size();                                \
  |  | 1183|    388|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    388|  return _nameof; }()
  ------------------
  562|    388|      c.fuzz(chardata);                                                        \
  563|    388|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_23clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    379|    +[](std::span<const char> chardata) {                                      \
  555|    379|      const auto c =                                                           \
  556|    379|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    379|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    379|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    379|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    379|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    379|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    379|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    379|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    379|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    379|  constexpr auto _size = _name.size();                                \
  |  | 1183|    379|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    379|  return _nameof; }()
  ------------------
  561|    379|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    379|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    379|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    379|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    379|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    379|  constexpr auto _size = _name.size();                                \
  |  | 1183|    379|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    379|  return _nameof; }()
  ------------------
  562|    379|      c.fuzz(chardata);                                                        \
  563|    379|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_24clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    133|    +[](std::span<const char> chardata) {                                      \
  555|    133|      const auto c =                                                           \
  556|    133|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    133|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    133|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    133|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    133|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    133|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    133|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    133|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    133|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    133|  constexpr auto _size = _name.size();                                \
  |  | 1183|    133|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    133|  return _nameof; }()
  ------------------
  561|    133|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    133|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    133|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    133|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    133|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    133|  constexpr auto _size = _name.size();                                \
  |  | 1183|    133|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    133|  return _nameof; }()
  ------------------
  562|    133|      c.fuzz(chardata);                                                        \
  563|    133|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    133|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    133|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    133|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    133|    static const bool do_print_testcase =
  181|    133|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    133|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 133]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    133|    do {
  189|       |      // step 0 - is the input valid?
  190|    133|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    133|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 133]
  |  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|    133|                    From == UtfEncodings::UTF8) {
  198|    133|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 133]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    133|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    133|      const auto [output_length, length_agree] =
  204|    133|          calculate_length(from, inputisvalid);
  205|    133|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 133]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    133|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 31, False: 102]
  |  Branch (208:28): [True: 0, False: 31]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    133|      const auto [written, outputs_agree] =
  215|    133|          do_conversion(from, output_length, inputisvalid);
  216|    133|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 133]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    133|      return;
  221|    133|    } 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|    133|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEE:
  230|    133|  validation_result verify_valid_input(FromSpan src) const {
  231|    133|    validation_result ret{};
  232|       |
  233|    133|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    133|    const auto implementations = get_supported_implementations();
  235|    133|    std::vector<simdutf::result> results;
  236|    133|    results.reserve(implementations.size());
  237|       |
  238|    399|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 399, False: 133]
  ------------------
  239|    399|      results.push_back(
  240|    399|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    399|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    399|      const bool validation2 =
  245|    399|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    399|                      src.data(), src.size());
  247|    399|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 399]
  ------------------
  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|    399|    }
  258|       |
  259|    133|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    133|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 133]
  ------------------
  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|    133|    } else {
  273|    133|      ret.implementations_agree = true;
  274|    133|    }
  275|    133|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    133|      return r.error == simdutf::SUCCESS;
  277|    133|    });
  278|    133|    return ret;
  279|    133|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS5_S5_EEDaSJ_SM_:
  259|    266|    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|    337|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    337|      return r.error == simdutf::SUCCESS;
  277|    337|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE15count_the_inputENSt3__14spanIS6_Lm18446744073709551615EEE:
  289|    133|  bool count_the_input(FromSpan src) const {
  290|    133|    const auto implementations = get_supported_implementations();
  291|    133|    std::vector<std::size_t> results;
  292|    133|    results.reserve(implementations.size());
  293|       |
  294|    399|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 399, False: 133]
  ------------------
  295|    399|      std::size_t ret;
  296|    399|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    399|        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|    399|      results.push_back(ret);
  304|    399|    }
  305|    133|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    133|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 133]
  ------------------
  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|    133|    return true;
  321|    133|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE15count_the_inputENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    266|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEb:
  342|    133|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    133|    length_result ret{};
  344|       |
  345|    133|    const auto implementations = get_supported_implementations();
  346|    133|    std::vector<std::size_t> results;
  347|    133|    results.reserve(implementations.size());
  348|       |
  349|    399|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 399, False: 133]
  ------------------
  350|    399|      const auto len = invoke_lengthcalc(impl, src);
  351|    399|      results.push_back(len);
  352|    399|      ret.length.push_back(len);
  353|    399|    }
  354|       |
  355|    133|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    133|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 133]
  ------------------
  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|    133|    } else {
  375|    133|      ret.implementations_agree = true;
  376|    133|    }
  377|    133|    return ret;
  378|    133|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSF_NSt3__14spanIS6_Lm18446744073709551615EEE:
  338|    399|                                FromSpan src) const {
  339|    399|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    399|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    266|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    133|                                  const bool inputisvalid) const {
  383|    133|    conversion_result ret{};
  384|       |
  385|    133|    const auto implementations = get_supported_implementations();
  386|       |
  387|    133|    std::vector<result<ConversionResult>> results;
  388|    133|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    133|    std::vector<std::vector<ToType>> outputbuffers;
  393|    133|    outputbuffers.reserve(implementations.size());
  394|    532|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 399, False: 133]
  ------------------
  395|    399|      auto impl = implementations[i];
  396|    399|      const ToType canary1{42};
  397|    399|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    399|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    399|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    399|      const auto success = [](const ConversionResult& r) -> bool {
  402|    399|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    399|          return r != 0;
  404|    399|        } else {
  405|    399|          return r.error == simdutf::error_code::SUCCESS;
  406|    399|        }
  407|    399|      }(implret1);
  408|    399|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    399|      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|    399|        const ToType canary2{25};
  414|    399|        const auto outputbuffer_first_run = outputbuffer;
  415|    399|        std::ranges::fill(outputbuffer, canary2);
  416|    399|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    399|                                          src.size(), outputbuffer.data());
  418|       |
  419|    399|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 399]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    399|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 306, False: 93]
  |  Branch (423:29): [True: 138, False: 168]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    138|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    138|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 138]
  ------------------
  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|    138|        }
  440|    399|      }
  441|    399|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 138, False: 261]
  ------------------
  442|    399|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    133|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 31, False: 102]
  ------------------
  447|     93|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 93, False: 31]
  ------------------
  448|     93|        e.outputhash.clear();
  449|     93|      }
  450|     31|    }
  451|       |
  452|    133|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    133|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 133]
  ------------------
  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|    133|    } else {
  474|    133|      ret.implementations_agree = true;
  475|    133|    }
  476|    133|    return ret;
  477|    133|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS5_E_clESM_:
  401|    399|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    399|        } else {
  405|    399|          return r.error == simdutf::error_code::SUCCESS;
  406|    399|        }
  407|    399|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS5_ESU_EEDaSN_SQ_:
  452|    266|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_25clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    173|    +[](std::span<const char> chardata) {                                      \
  555|    173|      const auto c =                                                           \
  556|    173|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    173|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    173|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    173|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    173|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    173|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    173|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    173|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    173|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    173|  constexpr auto _size = _name.size();                                \
  |  | 1183|    173|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    173|  return _nameof; }()
  ------------------
  561|    173|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    173|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    173|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    173|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    173|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    173|  constexpr auto _size = _name.size();                                \
  |  | 1183|    173|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    173|  return _nameof; }()
  ------------------
  562|    173|      c.fuzz(chardata);                                                        \
  563|    173|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    173|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    173|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    173|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    173|    static const bool do_print_testcase =
  181|    173|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    173|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 173]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    173|    do {
  189|       |      // step 0 - is the input valid?
  190|    173|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    173|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 173]
  |  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|    173|                    From == UtfEncodings::UTF8) {
  198|    173|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 173]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    173|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    173|      const auto [output_length, length_agree] =
  204|    173|          calculate_length(from, inputisvalid);
  205|    173|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 173]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    173|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 92, False: 81]
  |  Branch (208:28): [True: 0, False: 92]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    173|      const auto [written, outputs_agree] =
  215|    173|          do_conversion(from, output_length, inputisvalid);
  216|    173|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 173]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    173|      return;
  221|    173|    } 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|    173|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    173|  validation_result verify_valid_input(FromSpan src) const {
  231|    173|    validation_result ret{};
  232|       |
  233|    173|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    173|    const auto implementations = get_supported_implementations();
  235|    173|    std::vector<simdutf::result> results;
  236|    173|    results.reserve(implementations.size());
  237|       |
  238|    519|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 519, False: 173]
  ------------------
  239|    519|      results.push_back(
  240|    519|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    519|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    519|      const bool validation2 =
  245|    519|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    519|                      src.data(), src.size());
  247|    519|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 519]
  ------------------
  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|    519|    }
  258|       |
  259|    173|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    173|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 173]
  ------------------
  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|    173|    } else {
  273|    173|      ret.implementations_agree = true;
  274|    173|    }
  275|    173|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    173|      return r.error == simdutf::SUCCESS;
  277|    173|    });
  278|    173|    return ret;
  279|    173|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    346|    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|    335|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    335|      return r.error == simdutf::SUCCESS;
  277|    335|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    173|  bool count_the_input(FromSpan src) const {
  290|    173|    const auto implementations = get_supported_implementations();
  291|    173|    std::vector<std::size_t> results;
  292|    173|    results.reserve(implementations.size());
  293|       |
  294|    519|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 519, False: 173]
  ------------------
  295|    519|      std::size_t ret;
  296|    519|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    519|        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|    519|      results.push_back(ret);
  304|    519|    }
  305|    173|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    173|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 173]
  ------------------
  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|    173|    return true;
  321|    173|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    346|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    173|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    173|    length_result ret{};
  344|       |
  345|    173|    const auto implementations = get_supported_implementations();
  346|    173|    std::vector<std::size_t> results;
  347|    173|    results.reserve(implementations.size());
  348|       |
  349|    519|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 519, False: 173]
  ------------------
  350|    519|      const auto len = invoke_lengthcalc(impl, src);
  351|    519|      results.push_back(len);
  352|    519|      ret.length.push_back(len);
  353|    519|    }
  354|       |
  355|    173|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    173|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 173]
  ------------------
  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|    173|    } else {
  375|    173|      ret.implementations_agree = true;
  376|    173|    }
  377|    173|    return ret;
  378|    173|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    519|                                FromSpan src) const {
  331|    519|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    519|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    346|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    173|                                  const bool inputisvalid) const {
  383|    173|    conversion_result ret{};
  384|       |
  385|    173|    const auto implementations = get_supported_implementations();
  386|       |
  387|    173|    std::vector<result<ConversionResult>> results;
  388|    173|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    173|    std::vector<std::vector<ToType>> outputbuffers;
  393|    173|    outputbuffers.reserve(implementations.size());
  394|    692|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 519, False: 173]
  ------------------
  395|    519|      auto impl = implementations[i];
  396|    519|      const ToType canary1{42};
  397|    519|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    519|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    519|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    519|      const auto success = [](const ConversionResult& r) -> bool {
  402|    519|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    519|          return r != 0;
  404|    519|        } else {
  405|    519|          return r.error == simdutf::error_code::SUCCESS;
  406|    519|        }
  407|    519|      }(implret1);
  408|    519|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    519|      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|    519|        const ToType canary2{25};
  414|    519|        const auto outputbuffer_first_run = outputbuffer;
  415|    519|        std::ranges::fill(outputbuffer, canary2);
  416|    519|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    519|                                          src.size(), outputbuffer.data());
  418|       |
  419|    519|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 519]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    519|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 243, False: 276]
  |  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|    519|      }
  441|    519|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 243, False: 276]
  ------------------
  442|    519|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    173|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 92, False: 81]
  ------------------
  447|    276|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 276, False: 92]
  ------------------
  448|    276|        e.outputhash.clear();
  449|    276|      }
  450|     92|    }
  451|       |
  452|    173|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    173|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 173]
  ------------------
  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|    173|    } else {
  474|    173|      ret.implementations_agree = true;
  475|    173|    }
  476|    173|    return ret;
  477|    173|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    519|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    519|        } else {
  405|    519|          return r.error == simdutf::error_code::SUCCESS;
  406|    519|        }
  407|    519|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    346|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_26clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    327|    +[](std::span<const char> chardata) {                                      \
  555|    327|      const auto c =                                                           \
  556|    327|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    327|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    327|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    327|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    327|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    327|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    327|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    327|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    327|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    327|  constexpr auto _size = _name.size();                                \
  |  | 1183|    327|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    327|  return _nameof; }()
  ------------------
  561|    327|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    327|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    327|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    327|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    327|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    327|  constexpr auto _size = _name.size();                                \
  |  | 1183|    327|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    327|  return _nameof; }()
  ------------------
  562|    327|      c.fuzz(chardata);                                                        \
  563|    327|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    327|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    327|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    327|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    327|    static const bool do_print_testcase =
  181|    327|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    327|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 327]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    327|    do {
  189|       |      // step 0 - is the input valid?
  190|    327|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    327|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 327]
  |  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|    327|                    From == UtfEncodings::UTF8) {
  198|    327|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 327]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    327|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    327|      const auto [output_length, length_agree] =
  204|    327|          calculate_length(from, inputisvalid);
  205|    327|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 327]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    327|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 136, False: 191]
  |  Branch (208:28): [True: 0, False: 136]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    327|      const auto [written, outputs_agree] =
  215|    327|          do_conversion(from, output_length, inputisvalid);
  216|    327|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 327]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    327|      return;
  221|    327|    } 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|    327|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    327|  validation_result verify_valid_input(FromSpan src) const {
  231|    327|    validation_result ret{};
  232|       |
  233|    327|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    327|    const auto implementations = get_supported_implementations();
  235|    327|    std::vector<simdutf::result> results;
  236|    327|    results.reserve(implementations.size());
  237|       |
  238|    981|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 981, False: 327]
  ------------------
  239|    981|      results.push_back(
  240|    981|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    981|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    981|      const bool validation2 =
  245|    981|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    981|                      src.data(), src.size());
  247|    981|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 981]
  ------------------
  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|    981|    }
  258|       |
  259|    327|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    327|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 327]
  ------------------
  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|    327|    } else {
  273|    327|      ret.implementations_agree = true;
  274|    327|    }
  275|    327|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    327|      return r.error == simdutf::SUCCESS;
  277|    327|    });
  278|    327|    return ret;
  279|    327|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    654|    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|    709|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    709|      return r.error == simdutf::SUCCESS;
  277|    709|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    327|  bool count_the_input(FromSpan src) const {
  290|    327|    const auto implementations = get_supported_implementations();
  291|    327|    std::vector<std::size_t> results;
  292|    327|    results.reserve(implementations.size());
  293|       |
  294|    981|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 981, False: 327]
  ------------------
  295|    981|      std::size_t ret;
  296|    981|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    981|        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|    981|      results.push_back(ret);
  304|    981|    }
  305|    327|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    327|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 327]
  ------------------
  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|    327|    return true;
  321|    327|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    654|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    327|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    327|    length_result ret{};
  344|       |
  345|    327|    const auto implementations = get_supported_implementations();
  346|    327|    std::vector<std::size_t> results;
  347|    327|    results.reserve(implementations.size());
  348|       |
  349|    981|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 981, False: 327]
  ------------------
  350|    981|      const auto len = invoke_lengthcalc(impl, src);
  351|    981|      results.push_back(len);
  352|    981|      ret.length.push_back(len);
  353|    981|    }
  354|       |
  355|    327|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    327|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 327]
  ------------------
  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|    327|    } else {
  375|    327|      ret.implementations_agree = true;
  376|    327|    }
  377|    327|    return ret;
  378|    327|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    981|                                FromSpan src) const {
  331|    981|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    981|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    654|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    327|                                  const bool inputisvalid) const {
  383|    327|    conversion_result ret{};
  384|       |
  385|    327|    const auto implementations = get_supported_implementations();
  386|       |
  387|    327|    std::vector<result<ConversionResult>> results;
  388|    327|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    327|    std::vector<std::vector<ToType>> outputbuffers;
  393|    327|    outputbuffers.reserve(implementations.size());
  394|  1.30k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 981, False: 327]
  ------------------
  395|    981|      auto impl = implementations[i];
  396|    981|      const ToType canary1{42};
  397|    981|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    981|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    981|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    981|      const auto success = [](const ConversionResult& r) -> bool {
  402|    981|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    981|          return r != 0;
  404|    981|        } else {
  405|    981|          return r.error == simdutf::error_code::SUCCESS;
  406|    981|        }
  407|    981|      }(implret1);
  408|    981|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    981|      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|    981|        const ToType canary2{25};
  414|    981|        const auto outputbuffer_first_run = outputbuffer;
  415|    981|        std::ranges::fill(outputbuffer, canary2);
  416|    981|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    981|                                          src.size(), outputbuffer.data());
  418|       |
  419|    981|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 981]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    981|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 573, False: 408]
  |  Branch (423:29): [True: 573, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    573|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    573|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 573]
  ------------------
  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|    573|        }
  440|    981|      }
  441|    981|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 573, False: 408]
  ------------------
  442|    981|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    327|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 136, False: 191]
  ------------------
  447|    408|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 408, False: 136]
  ------------------
  448|    408|        e.outputhash.clear();
  449|    408|      }
  450|    136|    }
  451|       |
  452|    327|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    327|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 327]
  ------------------
  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|    327|    } else {
  474|    327|      ret.implementations_agree = true;
  475|    327|    }
  476|    327|    return ret;
  477|    327|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    981|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    981|        } else {
  405|    981|          return r.error == simdutf::error_code::SUCCESS;
  406|    981|        }
  407|    981|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    654|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_27clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    139|    +[](std::span<const char> chardata) {                                      \
  555|    139|      const auto c =                                                           \
  556|    139|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    139|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    139|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    139|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    139|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    139|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    139|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    139|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    139|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    139|  constexpr auto _size = _name.size();                                \
  |  | 1183|    139|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    139|  return _nameof; }()
  ------------------
  561|    139|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    139|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    139|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    139|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    139|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    139|  constexpr auto _size = _name.size();                                \
  |  | 1183|    139|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    139|  return _nameof; }()
  ------------------
  562|    139|      c.fuzz(chardata);                                                        \
  563|    139|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    139|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    139|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    139|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    139|    static const bool do_print_testcase =
  181|    139|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    139|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 139]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    139|    do {
  189|       |      // step 0 - is the input valid?
  190|    139|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    139|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 139]
  |  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|    139|                    From == UtfEncodings::UTF8) {
  198|    139|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 139]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    139|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    139|      const auto [output_length, length_agree] =
  204|    139|          calculate_length(from, inputisvalid);
  205|    139|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 139]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    139|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 24, False: 115]
  |  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|    139|      const auto [written, outputs_agree] =
  215|    139|          do_conversion(from, output_length, inputisvalid);
  216|    139|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 139]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    139|      return;
  221|    139|    } 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|    139|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEE:
  230|    139|  validation_result verify_valid_input(FromSpan src) const {
  231|    139|    validation_result ret{};
  232|       |
  233|    139|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    139|    const auto implementations = get_supported_implementations();
  235|    139|    std::vector<simdutf::result> results;
  236|    139|    results.reserve(implementations.size());
  237|       |
  238|    417|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 417, False: 139]
  ------------------
  239|    417|      results.push_back(
  240|    417|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    417|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    417|      const bool validation2 =
  245|    417|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    417|                      src.data(), src.size());
  247|    417|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 417]
  ------------------
  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|    417|    }
  258|       |
  259|    139|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    139|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 139]
  ------------------
  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|    139|    } else {
  273|    139|      ret.implementations_agree = true;
  274|    139|    }
  275|    139|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    139|      return r.error == simdutf::SUCCESS;
  277|    139|    });
  278|    139|    return ret;
  279|    139|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS5_S5_EEDaSJ_SM_:
  259|    278|    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|    369|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    369|      return r.error == simdutf::SUCCESS;
  277|    369|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE15count_the_inputENSt3__14spanIS6_Lm18446744073709551615EEE:
  289|    139|  bool count_the_input(FromSpan src) const {
  290|    139|    const auto implementations = get_supported_implementations();
  291|    139|    std::vector<std::size_t> results;
  292|    139|    results.reserve(implementations.size());
  293|       |
  294|    417|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 417, False: 139]
  ------------------
  295|    417|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    417|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    417|        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|    417|      results.push_back(ret);
  304|    417|    }
  305|    139|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    139|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 139]
  ------------------
  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|    139|    return true;
  321|    139|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE15count_the_inputENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    278|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEb:
  342|    139|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    139|    length_result ret{};
  344|       |
  345|    139|    const auto implementations = get_supported_implementations();
  346|    139|    std::vector<std::size_t> results;
  347|    139|    results.reserve(implementations.size());
  348|       |
  349|    417|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 417, False: 139]
  ------------------
  350|    417|      const auto len = invoke_lengthcalc(impl, src);
  351|    417|      results.push_back(len);
  352|    417|      ret.length.push_back(len);
  353|    417|    }
  354|       |
  355|    139|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    139|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 139]
  ------------------
  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|    139|    } else {
  375|    139|      ret.implementations_agree = true;
  376|    139|    }
  377|    139|    return ret;
  378|    139|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSF_NSt3__14spanIS6_Lm18446744073709551615EEE:
  338|    417|                                FromSpan src) const {
  339|    417|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    417|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    278|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    139|                                  const bool inputisvalid) const {
  383|    139|    conversion_result ret{};
  384|       |
  385|    139|    const auto implementations = get_supported_implementations();
  386|       |
  387|    139|    std::vector<result<ConversionResult>> results;
  388|    139|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    139|    std::vector<std::vector<ToType>> outputbuffers;
  393|    139|    outputbuffers.reserve(implementations.size());
  394|    556|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 417, False: 139]
  ------------------
  395|    417|      auto impl = implementations[i];
  396|    417|      const ToType canary1{42};
  397|    417|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    417|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    417|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    417|      const auto success = [](const ConversionResult& r) -> bool {
  402|    417|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    417|          return r != 0;
  404|    417|        } else {
  405|    417|          return r.error == simdutf::error_code::SUCCESS;
  406|    417|        }
  407|    417|      }(implret1);
  408|    417|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    417|      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|    417|        const ToType canary2{25};
  414|    417|        const auto outputbuffer_first_run = outputbuffer;
  415|    417|        std::ranges::fill(outputbuffer, canary2);
  416|    417|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    417|                                          src.size(), outputbuffer.data());
  418|       |
  419|    417|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 417]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    417|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 345, False: 72]
  |  Branch (423:29): [True: 141, False: 204]
  ------------------
  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|    417|      }
  441|    417|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 141, False: 276]
  ------------------
  442|    417|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    139|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 24, False: 115]
  ------------------
  447|     72|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 72, False: 24]
  ------------------
  448|     72|        e.outputhash.clear();
  449|     72|      }
  450|     24|    }
  451|       |
  452|    139|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    139|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 139]
  ------------------
  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|    139|    } else {
  474|    139|      ret.implementations_agree = true;
  475|    139|    }
  476|    139|    return ret;
  477|    139|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS5_E_clESM_:
  401|    417|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    417|        } else {
  405|    417|          return r.error == simdutf::error_code::SUCCESS;
  406|    417|        }
  407|    417|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS5_ESU_EEDaSN_SQ_:
  452|    278|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_28clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    167|    +[](std::span<const char> chardata) {                                      \
  555|    167|      const auto c =                                                           \
  556|    167|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    167|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    167|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    167|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    167|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    167|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    167|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    167|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    167|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    167|  constexpr auto _size = _name.size();                                \
  |  | 1183|    167|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    167|  return _nameof; }()
  ------------------
  561|    167|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    167|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    167|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    167|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    167|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    167|  constexpr auto _size = _name.size();                                \
  |  | 1183|    167|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    167|  return _nameof; }()
  ------------------
  562|    167|      c.fuzz(chardata);                                                        \
  563|    167|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    167|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    167|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    167|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    167|    static const bool do_print_testcase =
  181|    167|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    167|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 167]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    167|    do {
  189|       |      // step 0 - is the input valid?
  190|    167|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    167|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 167]
  |  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|    167|                    From == UtfEncodings::UTF8) {
  198|    167|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 167]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    167|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    167|      const auto [output_length, length_agree] =
  204|    167|          calculate_length(from, inputisvalid);
  205|    167|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 167]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    167|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 90, False: 77]
  |  Branch (208:28): [True: 0, False: 90]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    167|      const auto [written, outputs_agree] =
  215|    167|          do_conversion(from, output_length, inputisvalid);
  216|    167|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 167]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    167|      return;
  221|    167|    } 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|    167|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    167|  validation_result verify_valid_input(FromSpan src) const {
  231|    167|    validation_result ret{};
  232|       |
  233|    167|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    167|    const auto implementations = get_supported_implementations();
  235|    167|    std::vector<simdutf::result> results;
  236|    167|    results.reserve(implementations.size());
  237|       |
  238|    501|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 501, False: 167]
  ------------------
  239|    501|      results.push_back(
  240|    501|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    501|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    501|      const bool validation2 =
  245|    501|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    501|                      src.data(), src.size());
  247|    501|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 501]
  ------------------
  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|    501|    }
  258|       |
  259|    167|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    167|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 167]
  ------------------
  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|    167|    } else {
  273|    167|      ret.implementations_agree = true;
  274|    167|    }
  275|    167|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    167|      return r.error == simdutf::SUCCESS;
  277|    167|    });
  278|    167|    return ret;
  279|    167|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    334|    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|    321|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    321|      return r.error == simdutf::SUCCESS;
  277|    321|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    167|  bool count_the_input(FromSpan src) const {
  290|    167|    const auto implementations = get_supported_implementations();
  291|    167|    std::vector<std::size_t> results;
  292|    167|    results.reserve(implementations.size());
  293|       |
  294|    501|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 501, False: 167]
  ------------------
  295|    501|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    501|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    501|        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|    501|      results.push_back(ret);
  304|    501|    }
  305|    167|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    167|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 167]
  ------------------
  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|    167|    return true;
  321|    167|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    334|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    167|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    167|    length_result ret{};
  344|       |
  345|    167|    const auto implementations = get_supported_implementations();
  346|    167|    std::vector<std::size_t> results;
  347|    167|    results.reserve(implementations.size());
  348|       |
  349|    501|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 501, False: 167]
  ------------------
  350|    501|      const auto len = invoke_lengthcalc(impl, src);
  351|    501|      results.push_back(len);
  352|    501|      ret.length.push_back(len);
  353|    501|    }
  354|       |
  355|    167|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    167|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 167]
  ------------------
  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|    167|    } else {
  375|    167|      ret.implementations_agree = true;
  376|    167|    }
  377|    167|    return ret;
  378|    167|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    501|                                FromSpan src) const {
  331|    501|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    501|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    334|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    167|                                  const bool inputisvalid) const {
  383|    167|    conversion_result ret{};
  384|       |
  385|    167|    const auto implementations = get_supported_implementations();
  386|       |
  387|    167|    std::vector<result<ConversionResult>> results;
  388|    167|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    167|    std::vector<std::vector<ToType>> outputbuffers;
  393|    167|    outputbuffers.reserve(implementations.size());
  394|    668|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 501, False: 167]
  ------------------
  395|    501|      auto impl = implementations[i];
  396|    501|      const ToType canary1{42};
  397|    501|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    501|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    501|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    501|      const auto success = [](const ConversionResult& r) -> bool {
  402|    501|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    501|          return r != 0;
  404|    501|        } else {
  405|    501|          return r.error == simdutf::error_code::SUCCESS;
  406|    501|        }
  407|    501|      }(implret1);
  408|    501|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    501|      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|    501|        const ToType canary2{25};
  414|    501|        const auto outputbuffer_first_run = outputbuffer;
  415|    501|        std::ranges::fill(outputbuffer, canary2);
  416|    501|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    501|                                          src.size(), outputbuffer.data());
  418|       |
  419|    501|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 501]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    501|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 231, False: 270]
  |  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|    501|      }
  441|    501|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 231, False: 270]
  ------------------
  442|    501|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    167|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 90, False: 77]
  ------------------
  447|    270|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 270, False: 90]
  ------------------
  448|    270|        e.outputhash.clear();
  449|    270|      }
  450|     90|    }
  451|       |
  452|    167|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    167|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 167]
  ------------------
  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|    167|    } else {
  474|    167|      ret.implementations_agree = true;
  475|    167|    }
  476|    167|    return ret;
  477|    167|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    501|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    501|        } else {
  405|    501|          return r.error == simdutf::error_code::SUCCESS;
  406|    501|        }
  407|    501|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    334|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_29clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    321|    +[](std::span<const char> chardata) {                                      \
  555|    321|      const auto c =                                                           \
  556|    321|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    321|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    321|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    321|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    321|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    321|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    321|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    321|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    321|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    321|  constexpr auto _size = _name.size();                                \
  |  | 1183|    321|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    321|  return _nameof; }()
  ------------------
  561|    321|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    321|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    321|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    321|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    321|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    321|  constexpr auto _size = _name.size();                                \
  |  | 1183|    321|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    321|  return _nameof; }()
  ------------------
  562|    321|      c.fuzz(chardata);                                                        \
  563|    321|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    321|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    321|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    321|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    321|    static const bool do_print_testcase =
  181|    321|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    321|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 321]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    321|    do {
  189|       |      // step 0 - is the input valid?
  190|    321|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    321|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 321]
  |  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|    321|                    From == UtfEncodings::UTF8) {
  198|    321|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 321]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    321|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    321|      const auto [output_length, length_agree] =
  204|    321|          calculate_length(from, inputisvalid);
  205|    321|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 321]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    321|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 120, False: 201]
  |  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|    321|      const auto [written, outputs_agree] =
  215|    321|          do_conversion(from, output_length, inputisvalid);
  216|    321|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 321]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    321|      return;
  221|    321|    } 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|    321|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    321|  validation_result verify_valid_input(FromSpan src) const {
  231|    321|    validation_result ret{};
  232|       |
  233|    321|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    321|    const auto implementations = get_supported_implementations();
  235|    321|    std::vector<simdutf::result> results;
  236|    321|    results.reserve(implementations.size());
  237|       |
  238|    963|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 963, False: 321]
  ------------------
  239|    963|      results.push_back(
  240|    963|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    963|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    963|      const bool validation2 =
  245|    963|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    963|                      src.data(), src.size());
  247|    963|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 963]
  ------------------
  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|    963|    }
  258|       |
  259|    321|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    321|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 321]
  ------------------
  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|    321|    } else {
  273|    321|      ret.implementations_agree = true;
  274|    321|    }
  275|    321|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    321|      return r.error == simdutf::SUCCESS;
  277|    321|    });
  278|    321|    return ret;
  279|    321|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    642|    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|    723|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    723|      return r.error == simdutf::SUCCESS;
  277|    723|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    321|  bool count_the_input(FromSpan src) const {
  290|    321|    const auto implementations = get_supported_implementations();
  291|    321|    std::vector<std::size_t> results;
  292|    321|    results.reserve(implementations.size());
  293|       |
  294|    963|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 963, False: 321]
  ------------------
  295|    963|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    963|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    963|        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|    963|      results.push_back(ret);
  304|    963|    }
  305|    321|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    321|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 321]
  ------------------
  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|    321|    return true;
  321|    321|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    642|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    321|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    321|    length_result ret{};
  344|       |
  345|    321|    const auto implementations = get_supported_implementations();
  346|    321|    std::vector<std::size_t> results;
  347|    321|    results.reserve(implementations.size());
  348|       |
  349|    963|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 963, False: 321]
  ------------------
  350|    963|      const auto len = invoke_lengthcalc(impl, src);
  351|    963|      results.push_back(len);
  352|    963|      ret.length.push_back(len);
  353|    963|    }
  354|       |
  355|    321|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    321|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 321]
  ------------------
  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|    321|    } else {
  375|    321|      ret.implementations_agree = true;
  376|    321|    }
  377|    321|    return ret;
  378|    321|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    963|                                FromSpan src) const {
  331|    963|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    963|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    642|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    321|                                  const bool inputisvalid) const {
  383|    321|    conversion_result ret{};
  384|       |
  385|    321|    const auto implementations = get_supported_implementations();
  386|       |
  387|    321|    std::vector<result<ConversionResult>> results;
  388|    321|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    321|    std::vector<std::vector<ToType>> outputbuffers;
  393|    321|    outputbuffers.reserve(implementations.size());
  394|  1.28k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 963, False: 321]
  ------------------
  395|    963|      auto impl = implementations[i];
  396|    963|      const ToType canary1{42};
  397|    963|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    963|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    963|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    963|      const auto success = [](const ConversionResult& r) -> bool {
  402|    963|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    963|          return r != 0;
  404|    963|        } else {
  405|    963|          return r.error == simdutf::error_code::SUCCESS;
  406|    963|        }
  407|    963|      }(implret1);
  408|    963|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    963|      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|    963|        const ToType canary2{25};
  414|    963|        const auto outputbuffer_first_run = outputbuffer;
  415|    963|        std::ranges::fill(outputbuffer, canary2);
  416|    963|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    963|                                          src.size(), outputbuffer.data());
  418|       |
  419|    963|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 963]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    963|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 603, False: 360]
  |  Branch (423:29): [True: 603, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    603|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    603|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 603]
  ------------------
  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|    603|        }
  440|    963|      }
  441|    963|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 603, False: 360]
  ------------------
  442|    963|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    321|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 120, False: 201]
  ------------------
  447|    360|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 360, False: 120]
  ------------------
  448|    360|        e.outputhash.clear();
  449|    360|      }
  450|    120|    }
  451|       |
  452|    321|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    321|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 321]
  ------------------
  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|    321|    } else {
  474|    321|      ret.implementations_agree = true;
  475|    321|    }
  476|    321|    return ret;
  477|    321|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    963|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    963|        } else {
  405|    963|          return r.error == simdutf::error_code::SUCCESS;
  406|    963|        }
  407|    963|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    642|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_30clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    218|    +[](std::span<const char> chardata) {                                      \
  555|    218|      const auto c =                                                           \
  556|    218|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    218|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    218|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    218|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    218|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    218|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    218|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    218|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    218|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    218|  constexpr auto _size = _name.size();                                \
  |  | 1183|    218|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    218|  return _nameof; }()
  ------------------
  561|    218|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    218|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    218|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    218|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    218|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    218|  constexpr auto _size = _name.size();                                \
  |  | 1183|    218|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    218|  return _nameof; }()
  ------------------
  562|    218|      c.fuzz(chardata);                                                        \
  563|    218|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    218|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    218|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    218|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    218|    static const bool do_print_testcase =
  181|    218|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    218|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 218]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    218|    do {
  189|       |      // step 0 - is the input valid?
  190|    218|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    218|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 218]
  |  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|    218|      const auto [output_length, length_agree] =
  204|    218|          calculate_length(from, inputisvalid);
  205|    218|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 218]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    218|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 189, False: 29]
  |  Branch (208:28): [True: 0, False: 189]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    218|      const auto [written, outputs_agree] =
  215|    218|          do_conversion(from, output_length, inputisvalid);
  216|    218|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 218]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    218|      return;
  221|    218|    } 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|    218|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEE:
  230|    218|  validation_result verify_valid_input(FromSpan src) const {
  231|    218|    validation_result ret{};
  232|       |
  233|    218|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    218|    const auto implementations = get_supported_implementations();
  235|    218|    std::vector<simdutf::result> results;
  236|    218|    results.reserve(implementations.size());
  237|       |
  238|    654|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 654, False: 218]
  ------------------
  239|    654|      results.push_back(
  240|    654|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    654|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    654|      const bool validation2 =
  245|    654|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    654|                      src.data(), src.size());
  247|    654|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 654]
  ------------------
  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|    654|    }
  258|       |
  259|    218|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    218|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 218]
  ------------------
  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|    218|    } else {
  273|    218|      ret.implementations_agree = true;
  274|    218|    }
  275|    218|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    218|      return r.error == simdutf::SUCCESS;
  277|    218|    });
  278|    218|    return ret;
  279|    218|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS5_S5_EEDaSJ_SM_:
  259|    436|    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|    276|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    276|      return r.error == simdutf::SUCCESS;
  277|    276|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEb:
  342|    218|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    218|    length_result ret{};
  344|       |
  345|    218|    const auto implementations = get_supported_implementations();
  346|    218|    std::vector<std::size_t> results;
  347|    218|    results.reserve(implementations.size());
  348|       |
  349|    654|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 654, False: 218]
  ------------------
  350|    654|      const auto len = invoke_lengthcalc(impl, src);
  351|    654|      results.push_back(len);
  352|    654|      ret.length.push_back(len);
  353|    654|    }
  354|       |
  355|    218|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    218|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 218]
  ------------------
  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|    218|    } else {
  375|    218|      ret.implementations_agree = true;
  376|    218|    }
  377|    218|    return ret;
  378|    218|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSF_NSt3__14spanIS6_Lm18446744073709551615EEE:
  338|    654|                                FromSpan src) const {
  339|    654|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    654|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    436|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    218|                                  const bool inputisvalid) const {
  383|    218|    conversion_result ret{};
  384|       |
  385|    218|    const auto implementations = get_supported_implementations();
  386|       |
  387|    218|    std::vector<result<ConversionResult>> results;
  388|    218|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    218|    std::vector<std::vector<ToType>> outputbuffers;
  393|    218|    outputbuffers.reserve(implementations.size());
  394|    872|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 654, False: 218]
  ------------------
  395|    654|      auto impl = implementations[i];
  396|    654|      const ToType canary1{42};
  397|    654|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    654|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    654|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    654|      const auto success = [](const ConversionResult& r) -> bool {
  402|    654|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    654|          return r != 0;
  404|    654|        } else {
  405|    654|          return r.error == simdutf::error_code::SUCCESS;
  406|    654|        }
  407|    654|      }(implret1);
  408|    654|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    654|      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|    654|        const ToType canary2{25};
  414|    654|        const auto outputbuffer_first_run = outputbuffer;
  415|    654|        std::ranges::fill(outputbuffer, canary2);
  416|    654|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    654|                                          src.size(), outputbuffer.data());
  418|       |
  419|    654|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 654]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    654|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 87, False: 567]
  |  Branch (423:29): [True: 63, False: 24]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|     63|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|     63|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 63]
  ------------------
  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|     63|        }
  440|    654|      }
  441|    654|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 63, False: 591]
  ------------------
  442|    654|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    218|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 189, False: 29]
  ------------------
  447|    567|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 567, False: 189]
  ------------------
  448|    567|        e.outputhash.clear();
  449|    567|      }
  450|    189|    }
  451|       |
  452|    218|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    218|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 218]
  ------------------
  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|    218|    } else {
  474|    218|      ret.implementations_agree = true;
  475|    218|    }
  476|    218|    return ret;
  477|    218|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS5_E_clESM_:
  401|    654|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    654|        } else {
  405|    654|          return r.error == simdutf::error_code::SUCCESS;
  406|    654|        }
  407|    654|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS5_ESU_EEDaSN_SQ_:
  452|    436|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_31clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    347|    +[](std::span<const char> chardata) {                                      \
  555|    347|      const auto c =                                                           \
  556|    347|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    347|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    347|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    347|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    347|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    347|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    347|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    347|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    347|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    347|  constexpr auto _size = _name.size();                                \
  |  | 1183|    347|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    347|  return _nameof; }()
  ------------------
  561|    347|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    347|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    347|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    347|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    347|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    347|  constexpr auto _size = _name.size();                                \
  |  | 1183|    347|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    347|  return _nameof; }()
  ------------------
  562|    347|      c.fuzz(chardata);                                                        \
  563|    347|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    347|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    347|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    347|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    347|    static const bool do_print_testcase =
  181|    347|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    347|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 347]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    347|    do {
  189|       |      // step 0 - is the input valid?
  190|    347|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    347|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 347]
  |  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|    347|      const auto [output_length, length_agree] =
  204|    347|          calculate_length(from, inputisvalid);
  205|    347|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 347]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    347|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 256, False: 91]
  |  Branch (208:28): [True: 0, False: 256]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    347|      const auto [written, outputs_agree] =
  215|    347|          do_conversion(from, output_length, inputisvalid);
  216|    347|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 347]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    347|      return;
  221|    347|    } 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|    347|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    347|  validation_result verify_valid_input(FromSpan src) const {
  231|    347|    validation_result ret{};
  232|       |
  233|    347|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    347|    const auto implementations = get_supported_implementations();
  235|    347|    std::vector<simdutf::result> results;
  236|    347|    results.reserve(implementations.size());
  237|       |
  238|  1.04k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.04k, False: 347]
  ------------------
  239|  1.04k|      results.push_back(
  240|  1.04k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.04k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.04k|      const bool validation2 =
  245|  1.04k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.04k|                      src.data(), src.size());
  247|  1.04k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.04k]
  ------------------
  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.04k|    }
  258|       |
  259|    347|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    347|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 347]
  ------------------
  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|    347|    } else {
  273|    347|      ret.implementations_agree = true;
  274|    347|    }
  275|    347|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    347|      return r.error == simdutf::SUCCESS;
  277|    347|    });
  278|    347|    return ret;
  279|    347|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    694|    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|    529|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    529|      return r.error == simdutf::SUCCESS;
  277|    529|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    347|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    347|    length_result ret{};
  344|       |
  345|    347|    const auto implementations = get_supported_implementations();
  346|    347|    std::vector<std::size_t> results;
  347|    347|    results.reserve(implementations.size());
  348|       |
  349|  1.04k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.04k, False: 347]
  ------------------
  350|  1.04k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.04k|      results.push_back(len);
  352|  1.04k|      ret.length.push_back(len);
  353|  1.04k|    }
  354|       |
  355|    347|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    347|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 347]
  ------------------
  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|    347|    } else {
  375|    347|      ret.implementations_agree = true;
  376|    347|    }
  377|    347|    return ret;
  378|    347|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.04k|                                FromSpan src) const {
  331|  1.04k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.04k|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    694|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    347|                                  const bool inputisvalid) const {
  383|    347|    conversion_result ret{};
  384|       |
  385|    347|    const auto implementations = get_supported_implementations();
  386|       |
  387|    347|    std::vector<result<ConversionResult>> results;
  388|    347|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    347|    std::vector<std::vector<ToType>> outputbuffers;
  393|    347|    outputbuffers.reserve(implementations.size());
  394|  1.38k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.04k, False: 347]
  ------------------
  395|  1.04k|      auto impl = implementations[i];
  396|  1.04k|      const ToType canary1{42};
  397|  1.04k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.04k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.04k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.04k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.04k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.04k|          return r != 0;
  404|  1.04k|        } else {
  405|  1.04k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.04k|        }
  407|  1.04k|      }(implret1);
  408|  1.04k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.04k|      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.04k|        const ToType canary2{25};
  414|  1.04k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.04k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.04k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.04k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.04k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.04k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.04k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 273, False: 768]
  |  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|  1.04k|      }
  441|  1.04k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 273, False: 768]
  ------------------
  442|  1.04k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    347|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 256, False: 91]
  ------------------
  447|    768|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 768, False: 256]
  ------------------
  448|    768|        e.outputhash.clear();
  449|    768|      }
  450|    256|    }
  451|       |
  452|    347|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    347|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 347]
  ------------------
  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|    347|    } else {
  474|    347|      ret.implementations_agree = true;
  475|    347|    }
  476|    347|    return ret;
  477|    347|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|  1.04k|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|  1.04k|        } else {
  405|  1.04k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.04k|        }
  407|  1.04k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    694|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_32clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    337|    +[](std::span<const char> chardata) {                                      \
  555|    337|      const auto c =                                                           \
  556|    337|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    337|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    337|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    337|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    337|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    337|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    337|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    337|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    337|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    337|  constexpr auto _size = _name.size();                                \
  |  | 1183|    337|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    337|  return _nameof; }()
  ------------------
  561|    337|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    337|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    337|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    337|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    337|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    337|  constexpr auto _size = _name.size();                                \
  |  | 1183|    337|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    337|  return _nameof; }()
  ------------------
  562|    337|      c.fuzz(chardata);                                                        \
  563|    337|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    337|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    337|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    337|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    337|    static const bool do_print_testcase =
  181|    337|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    337|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 337]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    337|    do {
  189|       |      // step 0 - is the input valid?
  190|    337|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    337|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 337]
  |  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|    337|      const auto [output_length, length_agree] =
  204|    337|          calculate_length(from, inputisvalid);
  205|    337|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 337]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    337|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 252, False: 85]
  |  Branch (208:28): [True: 0, False: 252]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    337|      const auto [written, outputs_agree] =
  215|    337|          do_conversion(from, output_length, inputisvalid);
  216|    337|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 337]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    337|      return;
  221|    337|    } 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|    337|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    337|  validation_result verify_valid_input(FromSpan src) const {
  231|    337|    validation_result ret{};
  232|       |
  233|    337|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    337|    const auto implementations = get_supported_implementations();
  235|    337|    std::vector<simdutf::result> results;
  236|    337|    results.reserve(implementations.size());
  237|       |
  238|  1.01k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.01k, False: 337]
  ------------------
  239|  1.01k|      results.push_back(
  240|  1.01k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.01k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.01k|      const bool validation2 =
  245|  1.01k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.01k|                      src.data(), src.size());
  247|  1.01k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.01k]
  ------------------
  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.01k|    }
  258|       |
  259|    337|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    337|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 337]
  ------------------
  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|    337|    } else {
  273|    337|      ret.implementations_agree = true;
  274|    337|    }
  275|    337|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    337|      return r.error == simdutf::SUCCESS;
  277|    337|    });
  278|    337|    return ret;
  279|    337|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    674|    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|    507|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    507|      return r.error == simdutf::SUCCESS;
  277|    507|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    337|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    337|    length_result ret{};
  344|       |
  345|    337|    const auto implementations = get_supported_implementations();
  346|    337|    std::vector<std::size_t> results;
  347|    337|    results.reserve(implementations.size());
  348|       |
  349|  1.01k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.01k, False: 337]
  ------------------
  350|  1.01k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.01k|      results.push_back(len);
  352|  1.01k|      ret.length.push_back(len);
  353|  1.01k|    }
  354|       |
  355|    337|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    337|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 337]
  ------------------
  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|    337|    } else {
  375|    337|      ret.implementations_agree = true;
  376|    337|    }
  377|    337|    return ret;
  378|    337|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.01k|                                FromSpan src) const {
  331|  1.01k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.01k|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    674|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    337|                                  const bool inputisvalid) const {
  383|    337|    conversion_result ret{};
  384|       |
  385|    337|    const auto implementations = get_supported_implementations();
  386|       |
  387|    337|    std::vector<result<ConversionResult>> results;
  388|    337|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    337|    std::vector<std::vector<ToType>> outputbuffers;
  393|    337|    outputbuffers.reserve(implementations.size());
  394|  1.34k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.01k, False: 337]
  ------------------
  395|  1.01k|      auto impl = implementations[i];
  396|  1.01k|      const ToType canary1{42};
  397|  1.01k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.01k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.01k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.01k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.01k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.01k|          return r != 0;
  404|  1.01k|        } else {
  405|  1.01k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.01k|        }
  407|  1.01k|      }(implret1);
  408|  1.01k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.01k|      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.01k|        const ToType canary2{25};
  414|  1.01k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.01k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.01k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.01k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.01k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.01k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.01k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 255, False: 756]
  |  Branch (423:29): [True: 255, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    255|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    255|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 255]
  ------------------
  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|    255|        }
  440|  1.01k|      }
  441|  1.01k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 255, False: 756]
  ------------------
  442|  1.01k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    337|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 252, False: 85]
  ------------------
  447|    756|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 756, False: 252]
  ------------------
  448|    756|        e.outputhash.clear();
  449|    756|      }
  450|    252|    }
  451|       |
  452|    337|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    337|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 337]
  ------------------
  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|    337|    } else {
  474|    337|      ret.implementations_agree = true;
  475|    337|    }
  476|    337|    return ret;
  477|    337|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|  1.01k|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|  1.01k|        } else {
  405|  1.01k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.01k|        }
  407|  1.01k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    674|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_33clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    416|    +[](std::span<const char> chardata) {                                      \
  555|    416|      const auto c =                                                           \
  556|    416|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    416|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    416|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    416|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    416|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    416|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    416|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    416|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    416|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    416|  constexpr auto _size = _name.size();                                \
  |  | 1183|    416|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    416|  return _nameof; }()
  ------------------
  561|    416|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    416|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    416|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    416|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    416|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    416|  constexpr auto _size = _name.size();                                \
  |  | 1183|    416|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    416|  return _nameof; }()
  ------------------
  562|    416|      c.fuzz(chardata);                                                        \
  563|    416|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    416|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    416|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    416|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    416|    static const bool do_print_testcase =
  181|    416|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    416|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 416]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    416|    do {
  189|       |      // step 0 - is the input valid?
  190|    416|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    416|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 416]
  |  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|    416|      const auto [output_length, length_agree] =
  204|    416|          calculate_length(from, inputisvalid);
  205|    416|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 416]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    416|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 309, False: 107]
  |  Branch (208:28): [True: 0, False: 309]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    416|      const auto [written, outputs_agree] =
  215|    416|          do_conversion(from, output_length, inputisvalid);
  216|    416|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 416]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    416|      return;
  221|    416|    } 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|    416|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    416|  validation_result verify_valid_input(FromSpan src) const {
  231|    416|    validation_result ret{};
  232|       |
  233|    416|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    416|    const auto implementations = get_supported_implementations();
  235|    416|    std::vector<simdutf::result> results;
  236|    416|    results.reserve(implementations.size());
  237|       |
  238|  1.24k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.24k, False: 416]
  ------------------
  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|    416|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    416|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 416]
  ------------------
  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|    416|    } else {
  273|    416|      ret.implementations_agree = true;
  274|    416|    }
  275|    416|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    416|      return r.error == simdutf::SUCCESS;
  277|    416|    });
  278|    416|    return ret;
  279|    416|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    832|    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|    630|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    630|      return r.error == simdutf::SUCCESS;
  277|    630|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    416|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    416|    length_result ret{};
  344|       |
  345|    416|    const auto implementations = get_supported_implementations();
  346|    416|    std::vector<std::size_t> results;
  347|    416|    results.reserve(implementations.size());
  348|       |
  349|  1.24k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.24k, False: 416]
  ------------------
  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|    416|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    416|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 416]
  ------------------
  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|    416|    } else {
  375|    416|      ret.implementations_agree = true;
  376|    416|    }
  377|    416|    return ret;
  378|    416|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.24k|                                FromSpan src) const {
  331|  1.24k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.24k|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    832|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    416|                                  const bool inputisvalid) const {
  383|    416|    conversion_result ret{};
  384|       |
  385|    416|    const auto implementations = get_supported_implementations();
  386|       |
  387|    416|    std::vector<result<ConversionResult>> results;
  388|    416|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    416|    std::vector<std::vector<ToType>> outputbuffers;
  393|    416|    outputbuffers.reserve(implementations.size());
  394|  1.66k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.24k, False: 416]
  ------------------
  395|  1.24k|      auto impl = implementations[i];
  396|  1.24k|      const ToType canary1{42};
  397|  1.24k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.24k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.24k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.24k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.24k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.24k|          return r != 0;
  404|  1.24k|        } else {
  405|  1.24k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.24k|        }
  407|  1.24k|      }(implret1);
  408|  1.24k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.24k|      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.24k|        const ToType canary2{25};
  414|  1.24k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.24k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.24k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.24k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.24k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.24k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.24k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 321, False: 927]
  |  Branch (423:29): [True: 321, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    321|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    321|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 321]
  ------------------
  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|    321|        }
  440|  1.24k|      }
  441|  1.24k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 321, False: 927]
  ------------------
  442|  1.24k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    416|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 309, False: 107]
  ------------------
  447|    927|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 927, False: 309]
  ------------------
  448|    927|        e.outputhash.clear();
  449|    927|      }
  450|    309|    }
  451|       |
  452|    416|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    416|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 416]
  ------------------
  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|    416|    } else {
  474|    416|      ret.implementations_agree = true;
  475|    416|    }
  476|    416|    return ret;
  477|    416|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|  1.24k|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|  1.24k|        } else {
  405|  1.24k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.24k|        }
  407|  1.24k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    832|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_34clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    256|    +[](std::span<const char> chardata) {                                      \
  555|    256|      const auto c =                                                           \
  556|    256|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    256|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    256|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    256|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    256|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    256|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    256|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    256|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    256|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    256|  constexpr auto _size = _name.size();                                \
  |  | 1183|    256|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    256|  return _nameof; }()
  ------------------
  561|    256|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    256|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    256|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    256|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    256|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    256|  constexpr auto _size = _name.size();                                \
  |  | 1183|    256|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    256|  return _nameof; }()
  ------------------
  562|    256|      c.fuzz(chardata);                                                        \
  563|    256|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    256|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    256|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    256|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    256|    static const bool do_print_testcase =
  181|    256|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    256|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 256]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    256|    do {
  189|       |      // step 0 - is the input valid?
  190|    256|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    256|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 256]
  |  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|    256|                    From == UtfEncodings::UTF8) {
  198|    256|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 256]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    256|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    256|      const auto [output_length, length_agree] =
  204|    256|          calculate_length(from, inputisvalid);
  205|    256|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 256]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    256|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 139, False: 117]
  |  Branch (208:28): [True: 0, False: 139]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    256|      const auto [written, outputs_agree] =
  215|    256|          do_conversion(from, output_length, inputisvalid);
  216|    256|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 256]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    256|      return;
  221|    256|    } 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|    256|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    256|  validation_result verify_valid_input(FromSpan src) const {
  231|    256|    validation_result ret{};
  232|       |
  233|    256|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    256|    const auto implementations = get_supported_implementations();
  235|    256|    std::vector<simdutf::result> results;
  236|    256|    results.reserve(implementations.size());
  237|       |
  238|    768|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 768, False: 256]
  ------------------
  239|    768|      results.push_back(
  240|    768|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    768|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    768|      const bool validation2 =
  245|    768|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    768|                      src.data(), src.size());
  247|    768|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 768]
  ------------------
  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|    768|    }
  258|       |
  259|    256|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    256|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 256]
  ------------------
  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|    256|    } else {
  273|    256|      ret.implementations_agree = true;
  274|    256|    }
  275|    256|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    256|      return r.error == simdutf::SUCCESS;
  277|    256|    });
  278|    256|    return ret;
  279|    256|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    512|    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|    490|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    490|      return r.error == simdutf::SUCCESS;
  277|    490|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    256|  bool count_the_input(FromSpan src) const {
  290|    256|    const auto implementations = get_supported_implementations();
  291|    256|    std::vector<std::size_t> results;
  292|    256|    results.reserve(implementations.size());
  293|       |
  294|    768|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 768, False: 256]
  ------------------
  295|    768|      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|    768|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|    768|        ret = impl->count_utf8(src.data(), src.size());
  302|    768|      }
  303|    768|      results.push_back(ret);
  304|    768|    }
  305|    256|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    256|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 256]
  ------------------
  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|    256|    return true;
  321|    256|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    512|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    256|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    256|    length_result ret{};
  344|       |
  345|    256|    const auto implementations = get_supported_implementations();
  346|    256|    std::vector<std::size_t> results;
  347|    256|    results.reserve(implementations.size());
  348|       |
  349|    768|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 768, False: 256]
  ------------------
  350|    768|      const auto len = invoke_lengthcalc(impl, src);
  351|    768|      results.push_back(len);
  352|    768|      ret.length.push_back(len);
  353|    768|    }
  354|       |
  355|    256|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    256|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 256]
  ------------------
  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|    256|    } else {
  375|    256|      ret.implementations_agree = true;
  376|    256|    }
  377|    256|    return ret;
  378|    256|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    768|                                FromSpan src) const {
  331|    768|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    768|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    512|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    256|                                  const bool inputisvalid) const {
  383|    256|    conversion_result ret{};
  384|       |
  385|    256|    const auto implementations = get_supported_implementations();
  386|       |
  387|    256|    std::vector<result<ConversionResult>> results;
  388|    256|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    256|    std::vector<std::vector<ToType>> outputbuffers;
  393|    256|    outputbuffers.reserve(implementations.size());
  394|  1.02k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 768, False: 256]
  ------------------
  395|    768|      auto impl = implementations[i];
  396|    768|      const ToType canary1{42};
  397|    768|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    768|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    768|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    768|      const auto success = [](const ConversionResult& r) -> bool {
  402|    768|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    768|          return r != 0;
  404|    768|        } else {
  405|    768|          return r.error == simdutf::error_code::SUCCESS;
  406|    768|        }
  407|    768|      }(implret1);
  408|    768|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    768|      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|    768|        const ToType canary2{25};
  414|    768|        const auto outputbuffer_first_run = outputbuffer;
  415|    768|        std::ranges::fill(outputbuffer, canary2);
  416|    768|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    768|                                          src.size(), outputbuffer.data());
  418|       |
  419|    768|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 768]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    768|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 351, False: 417]
  |  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|    768|      }
  441|    768|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 339, False: 429]
  ------------------
  442|    768|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    256|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 139, False: 117]
  ------------------
  447|    417|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 417, False: 139]
  ------------------
  448|    417|        e.outputhash.clear();
  449|    417|      }
  450|    139|    }
  451|       |
  452|    256|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    256|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 256]
  ------------------
  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|    256|    } else {
  474|    256|      ret.implementations_agree = true;
  475|    256|    }
  476|    256|    return ret;
  477|    256|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    768|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    768|        } else {
  405|    768|          return r.error == simdutf::error_code::SUCCESS;
  406|    768|        }
  407|    768|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    512|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_35clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    353|    +[](std::span<const char> chardata) {                                      \
  555|    353|      const auto c =                                                           \
  556|    353|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    353|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    353|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    353|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    353|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    353|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    353|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    353|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    353|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    353|  constexpr auto _size = _name.size();                                \
  |  | 1183|    353|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    353|  return _nameof; }()
  ------------------
  561|    353|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    353|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    353|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    353|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    353|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    353|  constexpr auto _size = _name.size();                                \
  |  | 1183|    353|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    353|  return _nameof; }()
  ------------------
  562|    353|      c.fuzz(chardata);                                                        \
  563|    353|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    353|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    353|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    353|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    353|    static const bool do_print_testcase =
  181|    353|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    353|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 353]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    353|    do {
  189|       |      // step 0 - is the input valid?
  190|    353|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    353|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 353]
  |  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|    353|                    From == UtfEncodings::UTF8) {
  198|    353|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 353]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    353|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    353|      const auto [output_length, length_agree] =
  204|    353|          calculate_length(from, inputisvalid);
  205|    353|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 353]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    353|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 197, False: 156]
  |  Branch (208:28): [True: 0, False: 197]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    353|      const auto [written, outputs_agree] =
  215|    353|          do_conversion(from, output_length, inputisvalid);
  216|    353|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 353]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    353|      return;
  221|    353|    } 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|    353|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    353|  validation_result verify_valid_input(FromSpan src) const {
  231|    353|    validation_result ret{};
  232|       |
  233|    353|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    353|    const auto implementations = get_supported_implementations();
  235|    353|    std::vector<simdutf::result> results;
  236|    353|    results.reserve(implementations.size());
  237|       |
  238|  1.05k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.05k, False: 353]
  ------------------
  239|  1.05k|      results.push_back(
  240|  1.05k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.05k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.05k|      const bool validation2 =
  245|  1.05k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.05k|                      src.data(), src.size());
  247|  1.05k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.05k]
  ------------------
  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.05k|    }
  258|       |
  259|    353|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    353|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 353]
  ------------------
  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|    353|    } else {
  273|    353|      ret.implementations_agree = true;
  274|    353|    }
  275|    353|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    353|      return r.error == simdutf::SUCCESS;
  277|    353|    });
  278|    353|    return ret;
  279|    353|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    706|    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|    665|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    665|      return r.error == simdutf::SUCCESS;
  277|    665|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    353|  bool count_the_input(FromSpan src) const {
  290|    353|    const auto implementations = get_supported_implementations();
  291|    353|    std::vector<std::size_t> results;
  292|    353|    results.reserve(implementations.size());
  293|       |
  294|  1.05k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.05k, False: 353]
  ------------------
  295|  1.05k|      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.05k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.05k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.05k|      }
  303|  1.05k|      results.push_back(ret);
  304|  1.05k|    }
  305|    353|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    353|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 353]
  ------------------
  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|    353|    return true;
  321|    353|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    706|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    353|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    353|    length_result ret{};
  344|       |
  345|    353|    const auto implementations = get_supported_implementations();
  346|    353|    std::vector<std::size_t> results;
  347|    353|    results.reserve(implementations.size());
  348|       |
  349|  1.05k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.05k, False: 353]
  ------------------
  350|  1.05k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.05k|      results.push_back(len);
  352|  1.05k|      ret.length.push_back(len);
  353|  1.05k|    }
  354|       |
  355|    353|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    353|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 353]
  ------------------
  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|    353|    } else {
  375|    353|      ret.implementations_agree = true;
  376|    353|    }
  377|    353|    return ret;
  378|    353|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.05k|                                FromSpan src) const {
  331|  1.05k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.05k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    706|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    353|                                  const bool inputisvalid) const {
  383|    353|    conversion_result ret{};
  384|       |
  385|    353|    const auto implementations = get_supported_implementations();
  386|       |
  387|    353|    std::vector<result<ConversionResult>> results;
  388|    353|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    353|    std::vector<std::vector<ToType>> outputbuffers;
  393|    353|    outputbuffers.reserve(implementations.size());
  394|  1.41k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.05k, False: 353]
  ------------------
  395|  1.05k|      auto impl = implementations[i];
  396|  1.05k|      const ToType canary1{42};
  397|  1.05k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.05k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.05k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.05k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.05k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.05k|          return r != 0;
  404|  1.05k|        } else {
  405|  1.05k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.05k|        }
  407|  1.05k|      }(implret1);
  408|  1.05k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.05k|      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.05k|        const ToType canary2{25};
  414|  1.05k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.05k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.05k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.05k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.05k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.05k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.05k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 468, False: 591]
  |  Branch (423:29): [True: 468, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    468|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    468|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 468]
  ------------------
  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|    468|        }
  440|  1.05k|      }
  441|  1.05k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 468, False: 591]
  ------------------
  442|  1.05k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    353|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 197, False: 156]
  ------------------
  447|    591|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 591, False: 197]
  ------------------
  448|    591|        e.outputhash.clear();
  449|    591|      }
  450|    197|    }
  451|       |
  452|    353|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    353|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 353]
  ------------------
  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|    353|    } else {
  474|    353|      ret.implementations_agree = true;
  475|    353|    }
  476|    353|    return ret;
  477|    353|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|  1.05k|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|  1.05k|        } else {
  405|  1.05k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.05k|        }
  407|  1.05k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    706|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_36clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    305|    +[](std::span<const char> chardata) {                                      \
  555|    305|      const auto c =                                                           \
  556|    305|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    305|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    305|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    305|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    305|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    305|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    305|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    305|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    305|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    305|  constexpr auto _size = _name.size();                                \
  |  | 1183|    305|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    305|  return _nameof; }()
  ------------------
  561|    305|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    305|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    305|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    305|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    305|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    305|  constexpr auto _size = _name.size();                                \
  |  | 1183|    305|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    305|  return _nameof; }()
  ------------------
  562|    305|      c.fuzz(chardata);                                                        \
  563|    305|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    305|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    305|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    305|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    305|    static const bool do_print_testcase =
  181|    305|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    305|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 305]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    305|    do {
  189|       |      // step 0 - is the input valid?
  190|    305|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    305|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 305]
  |  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|    305|                    From == UtfEncodings::UTF8) {
  198|    305|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 305]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    305|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    305|      const auto [output_length, length_agree] =
  204|    305|          calculate_length(from, inputisvalid);
  205|    305|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 305]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    305|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 184, False: 121]
  |  Branch (208:28): [True: 0, False: 184]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    305|      const auto [written, outputs_agree] =
  215|    305|          do_conversion(from, output_length, inputisvalid);
  216|    305|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 305]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    305|      return;
  221|    305|    } 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|    305|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    305|  validation_result verify_valid_input(FromSpan src) const {
  231|    305|    validation_result ret{};
  232|       |
  233|    305|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    305|    const auto implementations = get_supported_implementations();
  235|    305|    std::vector<simdutf::result> results;
  236|    305|    results.reserve(implementations.size());
  237|       |
  238|    915|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 915, False: 305]
  ------------------
  239|    915|      results.push_back(
  240|    915|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    915|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    915|      const bool validation2 =
  245|    915|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    915|                      src.data(), src.size());
  247|    915|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 915]
  ------------------
  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|    915|    }
  258|       |
  259|    305|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    305|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 305]
  ------------------
  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|    305|    } else {
  273|    305|      ret.implementations_agree = true;
  274|    305|    }
  275|    305|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    305|      return r.error == simdutf::SUCCESS;
  277|    305|    });
  278|    305|    return ret;
  279|    305|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    610|    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|    547|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    547|      return r.error == simdutf::SUCCESS;
  277|    547|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    305|  bool count_the_input(FromSpan src) const {
  290|    305|    const auto implementations = get_supported_implementations();
  291|    305|    std::vector<std::size_t> results;
  292|    305|    results.reserve(implementations.size());
  293|       |
  294|    915|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 915, False: 305]
  ------------------
  295|    915|      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|    915|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|    915|        ret = impl->count_utf8(src.data(), src.size());
  302|    915|      }
  303|    915|      results.push_back(ret);
  304|    915|    }
  305|    305|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    305|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 305]
  ------------------
  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|    305|    return true;
  321|    305|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    610|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    305|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    305|    length_result ret{};
  344|       |
  345|    305|    const auto implementations = get_supported_implementations();
  346|    305|    std::vector<std::size_t> results;
  347|    305|    results.reserve(implementations.size());
  348|       |
  349|    915|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 915, False: 305]
  ------------------
  350|    915|      const auto len = invoke_lengthcalc(impl, src);
  351|    915|      results.push_back(len);
  352|    915|      ret.length.push_back(len);
  353|    915|    }
  354|       |
  355|    305|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    305|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 305]
  ------------------
  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|    305|    } else {
  375|    305|      ret.implementations_agree = true;
  376|    305|    }
  377|    305|    return ret;
  378|    305|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    915|                                FromSpan src) const {
  331|    915|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    915|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    610|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    305|                                  const bool inputisvalid) const {
  383|    305|    conversion_result ret{};
  384|       |
  385|    305|    const auto implementations = get_supported_implementations();
  386|       |
  387|    305|    std::vector<result<ConversionResult>> results;
  388|    305|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    305|    std::vector<std::vector<ToType>> outputbuffers;
  393|    305|    outputbuffers.reserve(implementations.size());
  394|  1.22k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 915, False: 305]
  ------------------
  395|    915|      auto impl = implementations[i];
  396|    915|      const ToType canary1{42};
  397|    915|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    915|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    915|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    915|      const auto success = [](const ConversionResult& r) -> bool {
  402|    915|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    915|          return r != 0;
  404|    915|        } else {
  405|    915|          return r.error == simdutf::error_code::SUCCESS;
  406|    915|        }
  407|    915|      }(implret1);
  408|    915|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    915|      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|    915|        const ToType canary2{25};
  414|    915|        const auto outputbuffer_first_run = outputbuffer;
  415|    915|        std::ranges::fill(outputbuffer, canary2);
  416|    915|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    915|                                          src.size(), outputbuffer.data());
  418|       |
  419|    915|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 915]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    915|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 363, False: 552]
  |  Branch (423:29): [True: 363, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    363|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    363|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 363]
  ------------------
  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|    363|        }
  440|    915|      }
  441|    915|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 363, False: 552]
  ------------------
  442|    915|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    305|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 184, False: 121]
  ------------------
  447|    552|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 552, False: 184]
  ------------------
  448|    552|        e.outputhash.clear();
  449|    552|      }
  450|    184|    }
  451|       |
  452|    305|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    305|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 305]
  ------------------
  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|    305|    } else {
  474|    305|      ret.implementations_agree = true;
  475|    305|    }
  476|    305|    return ret;
  477|    305|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    915|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    915|        } else {
  405|    915|          return r.error == simdutf::error_code::SUCCESS;
  406|    915|        }
  407|    915|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    610|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_37clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    373|    +[](std::span<const char> chardata) {                                      \
  555|    373|      const auto c =                                                           \
  556|    373|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    373|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    373|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    373|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    373|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    373|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    373|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    373|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    373|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    373|  constexpr auto _size = _name.size();                                \
  |  | 1183|    373|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    373|  return _nameof; }()
  ------------------
  561|    373|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    373|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    373|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    373|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    373|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    373|  constexpr auto _size = _name.size();                                \
  |  | 1183|    373|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    373|  return _nameof; }()
  ------------------
  562|    373|      c.fuzz(chardata);                                                        \
  563|    373|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    373|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    373|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    373|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    373|    static const bool do_print_testcase =
  181|    373|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    373|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 373]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    373|    do {
  189|       |      // step 0 - is the input valid?
  190|    373|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    373|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 373]
  |  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|    373|                    From == UtfEncodings::UTF8) {
  198|    373|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 373]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    373|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    373|      const auto [output_length, length_agree] =
  204|    373|          calculate_length(from, inputisvalid);
  205|    373|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 373]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    373|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 217, False: 156]
  |  Branch (208:28): [True: 0, False: 217]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    373|      const auto [written, outputs_agree] =
  215|    373|          do_conversion(from, output_length, inputisvalid);
  216|    373|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 373]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    373|      return;
  221|    373|    } 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|    373|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    373|  validation_result verify_valid_input(FromSpan src) const {
  231|    373|    validation_result ret{};
  232|       |
  233|    373|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    373|    const auto implementations = get_supported_implementations();
  235|    373|    std::vector<simdutf::result> results;
  236|    373|    results.reserve(implementations.size());
  237|       |
  238|  1.11k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.11k, False: 373]
  ------------------
  239|  1.11k|      results.push_back(
  240|  1.11k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.11k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.11k|      const bool validation2 =
  245|  1.11k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.11k|                      src.data(), src.size());
  247|  1.11k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.11k]
  ------------------
  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.11k|    }
  258|       |
  259|    373|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    373|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 373]
  ------------------
  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|    373|    } else {
  273|    373|      ret.implementations_agree = true;
  274|    373|    }
  275|    373|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    373|      return r.error == simdutf::SUCCESS;
  277|    373|    });
  278|    373|    return ret;
  279|    373|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    746|    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|    685|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    685|      return r.error == simdutf::SUCCESS;
  277|    685|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    373|  bool count_the_input(FromSpan src) const {
  290|    373|    const auto implementations = get_supported_implementations();
  291|    373|    std::vector<std::size_t> results;
  292|    373|    results.reserve(implementations.size());
  293|       |
  294|  1.11k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.11k, False: 373]
  ------------------
  295|  1.11k|      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.11k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.11k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.11k|      }
  303|  1.11k|      results.push_back(ret);
  304|  1.11k|    }
  305|    373|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    373|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 373]
  ------------------
  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|    373|    return true;
  321|    373|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    746|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    373|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    373|    length_result ret{};
  344|       |
  345|    373|    const auto implementations = get_supported_implementations();
  346|    373|    std::vector<std::size_t> results;
  347|    373|    results.reserve(implementations.size());
  348|       |
  349|  1.11k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.11k, False: 373]
  ------------------
  350|  1.11k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.11k|      results.push_back(len);
  352|  1.11k|      ret.length.push_back(len);
  353|  1.11k|    }
  354|       |
  355|    373|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    373|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 373]
  ------------------
  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|    373|    } else {
  375|    373|      ret.implementations_agree = true;
  376|    373|    }
  377|    373|    return ret;
  378|    373|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.11k|                                FromSpan src) const {
  331|  1.11k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.11k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    746|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    373|                                  const bool inputisvalid) const {
  383|    373|    conversion_result ret{};
  384|       |
  385|    373|    const auto implementations = get_supported_implementations();
  386|       |
  387|    373|    std::vector<result<ConversionResult>> results;
  388|    373|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    373|    std::vector<std::vector<ToType>> outputbuffers;
  393|    373|    outputbuffers.reserve(implementations.size());
  394|  1.49k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.11k, False: 373]
  ------------------
  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: 468, False: 651]
  |  Branch (423:29): [True: 468, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    468|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    468|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 468]
  ------------------
  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|    468|        }
  440|  1.11k|      }
  441|  1.11k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 468, False: 651]
  ------------------
  442|  1.11k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    373|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 217, False: 156]
  ------------------
  447|    651|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 651, False: 217]
  ------------------
  448|    651|        e.outputhash.clear();
  449|    651|      }
  450|    217|    }
  451|       |
  452|    373|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    373|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 373]
  ------------------
  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|    373|    } else {
  474|    373|      ret.implementations_agree = true;
  475|    373|    }
  476|    373|    return ret;
  477|    373|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|  1.11k|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|  1.11k|        } else {
  405|  1.11k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.11k|        }
  407|  1.11k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    746|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_38clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     62|    +[](std::span<const char> chardata) {                                      \
  555|     62|      const auto c =                                                           \
  556|     62|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     62|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     62|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     62|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     62|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     62|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     62|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     62|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     62|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     62|  constexpr auto _size = _name.size();                                \
  |  | 1183|     62|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     62|  return _nameof; }()
  ------------------
  561|     62|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     62|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     62|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     62|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     62|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     62|  constexpr auto _size = _name.size();                                \
  |  | 1183|     62|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     62|  return _nameof; }()
  ------------------
  562|     62|      c.fuzz(chardata);                                                        \
  563|     62|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE4fuzzENSt3__14spanIS5_Lm18446744073709551615EEE:
  175|     62|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     62|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     62|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     62|    static const bool do_print_testcase =
  181|     62|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     62|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 62]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     62|    do {
  189|       |      // step 0 - is the input valid?
  190|     62|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     62|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 62]
  |  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|     62|      const auto [output_length, length_agree] =
  204|     62|          calculate_length(from, inputisvalid);
  205|     62|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 62]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     62|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 0, False: 62]
  |  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|     62|      const auto [written, outputs_agree] =
  215|     62|          do_conversion(from, output_length, inputisvalid);
  216|     62|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 62]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     62|      return;
  221|     62|    } 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|     62|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE18verify_valid_inputIvQeqT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  283|     62|  validation_result verify_valid_input(FromSpan) const {
  284|       |    // all latin1 input is valid. there is no simdutf validation function for
  285|       |    // it.
  286|     62|    return validation_result{.valid = true, .implementations_agree = true};
  287|     62|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     62|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     62|    length_result ret{};
  344|       |
  345|     62|    const auto implementations = get_supported_implementations();
  346|     62|    std::vector<std::size_t> results;
  347|     62|    results.reserve(implementations.size());
  348|       |
  349|    186|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 186, False: 62]
  ------------------
  350|    186|      const auto len = invoke_lengthcalc(impl, src);
  351|    186|      results.push_back(len);
  352|    186|      ret.length.push_back(len);
  353|    186|    }
  354|       |
  355|     62|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     62|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 62]
  ------------------
  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|     62|    } else {
  375|     62|      ret.implementations_agree = true;
  376|     62|    }
  377|     62|    return ret;
  378|     62|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    186|                                FromSpan src) const {
  339|    186|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    186|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    124|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     62|                                  const bool inputisvalid) const {
  383|     62|    conversion_result ret{};
  384|       |
  385|     62|    const auto implementations = get_supported_implementations();
  386|       |
  387|     62|    std::vector<result<ConversionResult>> results;
  388|     62|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     62|    std::vector<std::vector<ToType>> outputbuffers;
  393|     62|    outputbuffers.reserve(implementations.size());
  394|    248|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 186, False: 62]
  ------------------
  395|    186|      auto impl = implementations[i];
  396|    186|      const ToType canary1{42};
  397|    186|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    186|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    186|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    186|      const auto success = [](const ConversionResult& r) -> bool {
  402|    186|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    186|          return r != 0;
  404|    186|        } else {
  405|    186|          return r.error == simdutf::error_code::SUCCESS;
  406|    186|        }
  407|    186|      }(implret1);
  408|    186|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    186|      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|    186|        const ToType canary2{25};
  414|    186|        const auto outputbuffer_first_run = outputbuffer;
  415|    186|        std::ranges::fill(outputbuffer, canary2);
  416|    186|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    186|                                          src.size(), outputbuffer.data());
  418|       |
  419|    186|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 186]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    186|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 186, False: 0]
  |  Branch (423:29): [True: 180, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    180|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    180|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 180]
  ------------------
  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|    180|        }
  440|    186|      }
  441|    186|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 180, False: 6]
  ------------------
  442|    186|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     62|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 0, False: 62]
  ------------------
  447|      0|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 0, False: 0]
  ------------------
  448|      0|        e.outputhash.clear();
  449|      0|      }
  450|      0|    }
  451|       |
  452|     62|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     62|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 62]
  ------------------
  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|     62|    } else {
  474|     62|      ret.implementations_agree = true;
  475|     62|    }
  476|     62|    return ret;
  477|     62|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    186|      const auto success = [](const ConversionResult& r) -> bool {
  402|    186|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    186|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    186|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    124|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_39clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     48|    +[](std::span<const char> chardata) {                                      \
  555|     48|      const auto c =                                                           \
  556|     48|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     48|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     48|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     48|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     48|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     48|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     48|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     48|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     48|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     48|  constexpr auto _size = _name.size();                                \
  |  | 1183|     48|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     48|  return _nameof; }()
  ------------------
  561|     48|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     48|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     48|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     48|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     48|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     48|  constexpr auto _size = _name.size();                                \
  |  | 1183|     48|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     48|  return _nameof; }()
  ------------------
  562|     48|      c.fuzz(chardata);                                                        \
  563|     48|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE4fuzzENSt3__14spanIS5_Lm18446744073709551615EEE:
  175|     48|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     48|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     48|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     48|    static const bool do_print_testcase =
  181|     48|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     48|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 48]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     48|    do {
  189|       |      // step 0 - is the input valid?
  190|     48|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     48|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 48]
  |  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|     48|      const auto [output_length, length_agree] =
  204|     48|          calculate_length(from, inputisvalid);
  205|     48|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 48]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     48|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 0, False: 48]
  |  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|     48|      const auto [written, outputs_agree] =
  215|     48|          do_conversion(from, output_length, inputisvalid);
  216|     48|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 48]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     48|      return;
  221|     48|    } 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|     48|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE18verify_valid_inputIvQeqT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  283|     48|  validation_result verify_valid_input(FromSpan) const {
  284|       |    // all latin1 input is valid. there is no simdutf validation function for
  285|       |    // it.
  286|     48|    return validation_result{.valid = true, .implementations_agree = true};
  287|     48|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     48|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     48|    length_result ret{};
  344|       |
  345|     48|    const auto implementations = get_supported_implementations();
  346|     48|    std::vector<std::size_t> results;
  347|     48|    results.reserve(implementations.size());
  348|       |
  349|    144|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 144, False: 48]
  ------------------
  350|    144|      const auto len = invoke_lengthcalc(impl, src);
  351|    144|      results.push_back(len);
  352|    144|      ret.length.push_back(len);
  353|    144|    }
  354|       |
  355|     48|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     48|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 48]
  ------------------
  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|     48|    } else {
  375|     48|      ret.implementations_agree = true;
  376|     48|    }
  377|     48|    return ret;
  378|     48|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    144|                                FromSpan src) const {
  339|    144|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    144|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|     96|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     48|                                  const bool inputisvalid) const {
  383|     48|    conversion_result ret{};
  384|       |
  385|     48|    const auto implementations = get_supported_implementations();
  386|       |
  387|     48|    std::vector<result<ConversionResult>> results;
  388|     48|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     48|    std::vector<std::vector<ToType>> outputbuffers;
  393|     48|    outputbuffers.reserve(implementations.size());
  394|    192|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 144, False: 48]
  ------------------
  395|    144|      auto impl = implementations[i];
  396|    144|      const ToType canary1{42};
  397|    144|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    144|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    144|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    144|      const auto success = [](const ConversionResult& r) -> bool {
  402|    144|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    144|          return r != 0;
  404|    144|        } else {
  405|    144|          return r.error == simdutf::error_code::SUCCESS;
  406|    144|        }
  407|    144|      }(implret1);
  408|    144|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    144|      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|    144|        const ToType canary2{25};
  414|    144|        const auto outputbuffer_first_run = outputbuffer;
  415|    144|        std::ranges::fill(outputbuffer, canary2);
  416|    144|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    144|                                          src.size(), outputbuffer.data());
  418|       |
  419|    144|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 144]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    144|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 144, False: 0]
  |  Branch (423:29): [True: 138, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    138|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    138|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 138]
  ------------------
  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|    138|        }
  440|    144|      }
  441|    144|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 138, False: 6]
  ------------------
  442|    144|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     48|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 0, False: 48]
  ------------------
  447|      0|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 0, False: 0]
  ------------------
  448|      0|        e.outputhash.clear();
  449|      0|      }
  450|      0|    }
  451|       |
  452|     48|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     48|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 48]
  ------------------
  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|     48|    } else {
  474|     48|      ret.implementations_agree = true;
  475|     48|    }
  476|     48|    return ret;
  477|     48|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    144|      const auto success = [](const ConversionResult& r) -> bool {
  402|    144|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    144|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    144|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|     96|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_40clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     38|    +[](std::span<const char> chardata) {                                      \
  555|     38|      const auto c =                                                           \
  556|     38|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     38|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     38|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     38|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     38|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     38|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     38|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     38|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     38|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     38|  constexpr auto _size = _name.size();                                \
  |  | 1183|     38|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     38|  return _nameof; }()
  ------------------
  561|     38|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     38|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     38|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     38|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     38|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     38|  constexpr auto _size = _name.size();                                \
  |  | 1183|     38|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     38|  return _nameof; }()
  ------------------
  562|     38|      c.fuzz(chardata);                                                        \
  563|     38|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE4fuzzENSt3__14spanIS5_Lm18446744073709551615EEE:
  175|     38|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     38|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     38|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     38|    static const bool do_print_testcase =
  181|     38|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     38|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 38]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     38|    do {
  189|       |      // step 0 - is the input valid?
  190|     38|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     38|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 38]
  |  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|     38|      const auto [output_length, length_agree] =
  204|     38|          calculate_length(from, inputisvalid);
  205|     38|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 38]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     38|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 0, False: 38]
  |  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|     38|      const auto [written, outputs_agree] =
  215|     38|          do_conversion(from, output_length, inputisvalid);
  216|     38|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 38]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     38|      return;
  221|     38|    } 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|     38|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE18verify_valid_inputIvQeqT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  283|     38|  validation_result verify_valid_input(FromSpan) const {
  284|       |    // all latin1 input is valid. there is no simdutf validation function for
  285|       |    // it.
  286|     38|    return validation_result{.valid = true, .implementations_agree = true};
  287|     38|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     38|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     38|    length_result ret{};
  344|       |
  345|     38|    const auto implementations = get_supported_implementations();
  346|     38|    std::vector<std::size_t> results;
  347|     38|    results.reserve(implementations.size());
  348|       |
  349|    114|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 114, False: 38]
  ------------------
  350|    114|      const auto len = invoke_lengthcalc(impl, src);
  351|    114|      results.push_back(len);
  352|    114|      ret.length.push_back(len);
  353|    114|    }
  354|       |
  355|     38|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     38|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 38]
  ------------------
  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|     38|    } else {
  375|     38|      ret.implementations_agree = true;
  376|     38|    }
  377|     38|    return ret;
  378|     38|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    114|                                FromSpan src) const {
  339|    114|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    114|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|     76|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     38|                                  const bool inputisvalid) const {
  383|     38|    conversion_result ret{};
  384|       |
  385|     38|    const auto implementations = get_supported_implementations();
  386|       |
  387|     38|    std::vector<result<ConversionResult>> results;
  388|     38|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     38|    std::vector<std::vector<ToType>> outputbuffers;
  393|     38|    outputbuffers.reserve(implementations.size());
  394|    152|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 114, False: 38]
  ------------------
  395|    114|      auto impl = implementations[i];
  396|    114|      const ToType canary1{42};
  397|    114|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    114|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    114|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    114|      const auto success = [](const ConversionResult& r) -> bool {
  402|    114|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    114|          return r != 0;
  404|    114|        } else {
  405|    114|          return r.error == simdutf::error_code::SUCCESS;
  406|    114|        }
  407|    114|      }(implret1);
  408|    114|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    114|      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|    114|        const ToType canary2{25};
  414|    114|        const auto outputbuffer_first_run = outputbuffer;
  415|    114|        std::ranges::fill(outputbuffer, canary2);
  416|    114|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    114|                                          src.size(), outputbuffer.data());
  418|       |
  419|    114|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 114]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    114|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 114, False: 0]
  |  Branch (423:29): [True: 108, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    108|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    108|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 108]
  ------------------
  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|    108|        }
  440|    114|      }
  441|    114|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 108, False: 6]
  ------------------
  442|    114|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     38|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 0, False: 38]
  ------------------
  447|      0|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 0, False: 0]
  ------------------
  448|      0|        e.outputhash.clear();
  449|      0|      }
  450|      0|    }
  451|       |
  452|     38|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     38|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 38]
  ------------------
  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|     38|    } else {
  474|     38|      ret.implementations_agree = true;
  475|     38|    }
  476|     38|    return ret;
  477|     38|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    114|      const auto success = [](const ConversionResult& r) -> bool {
  402|    114|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    114|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    114|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|     76|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_41clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    302|    +[](std::span<const char> chardata) {                                      \
  555|    302|      const auto c =                                                           \
  556|    302|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    302|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    302|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    302|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    302|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    302|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    302|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    302|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    302|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    302|  constexpr auto _size = _name.size();                                \
  |  | 1183|    302|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    302|  return _nameof; }()
  ------------------
  561|    302|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    302|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    302|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    302|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    302|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    302|  constexpr auto _size = _name.size();                                \
  |  | 1183|    302|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    302|  return _nameof; }()
  ------------------
  562|    302|      c.fuzz(chardata);                                                        \
  563|    302|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    302|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    302|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    302|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    302|    static const bool do_print_testcase =
  181|    302|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    302|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 302]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    302|    do {
  189|       |      // step 0 - is the input valid?
  190|    302|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    302|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 302]
  |  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|    302|      const auto [output_length, length_agree] =
  204|    302|          calculate_length(from, inputisvalid);
  205|    302|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 302]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    302|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 0, False: 302]
  |  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|    302|      const auto [written, outputs_agree] =
  215|    302|          do_conversion(from, output_length, inputisvalid);
  216|    302|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 302]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    302|      return;
  221|    302|    } 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|    302|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQeqT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  283|    302|  validation_result verify_valid_input(FromSpan) const {
  284|       |    // all latin1 input is valid. there is no simdutf validation function for
  285|       |    // it.
  286|    302|    return validation_result{.valid = true, .implementations_agree = true};
  287|    302|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    302|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    302|    length_result ret{};
  344|       |
  345|    302|    const auto implementations = get_supported_implementations();
  346|    302|    std::vector<std::size_t> results;
  347|    302|    results.reserve(implementations.size());
  348|       |
  349|    906|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 906, False: 302]
  ------------------
  350|    906|      const auto len = invoke_lengthcalc(impl, src);
  351|    906|      results.push_back(len);
  352|    906|      ret.length.push_back(len);
  353|    906|    }
  354|       |
  355|    302|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    302|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 302]
  ------------------
  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|    302|    } else {
  375|    302|      ret.implementations_agree = true;
  376|    302|    }
  377|    302|    return ret;
  378|    302|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    906|                                FromSpan src) const {
  331|    906|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    906|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    604|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    302|                                  const bool inputisvalid) const {
  383|    302|    conversion_result ret{};
  384|       |
  385|    302|    const auto implementations = get_supported_implementations();
  386|       |
  387|    302|    std::vector<result<ConversionResult>> results;
  388|    302|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    302|    std::vector<std::vector<ToType>> outputbuffers;
  393|    302|    outputbuffers.reserve(implementations.size());
  394|  1.20k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 906, False: 302]
  ------------------
  395|    906|      auto impl = implementations[i];
  396|    906|      const ToType canary1{42};
  397|    906|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    906|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    906|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    906|      const auto success = [](const ConversionResult& r) -> bool {
  402|    906|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    906|          return r != 0;
  404|    906|        } else {
  405|    906|          return r.error == simdutf::error_code::SUCCESS;
  406|    906|        }
  407|    906|      }(implret1);
  408|    906|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    906|      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|    906|        const ToType canary2{25};
  414|    906|        const auto outputbuffer_first_run = outputbuffer;
  415|    906|        std::ranges::fill(outputbuffer, canary2);
  416|    906|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    906|                                          src.size(), outputbuffer.data());
  418|       |
  419|    906|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 906]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    906|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 906, False: 0]
  |  Branch (423:29): [True: 900, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    900|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    900|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 900]
  ------------------
  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|    900|        }
  440|    906|      }
  441|    906|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 900, False: 6]
  ------------------
  442|    906|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    302|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 0, False: 302]
  ------------------
  447|      0|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 0, False: 0]
  ------------------
  448|      0|        e.outputhash.clear();
  449|      0|      }
  450|      0|    }
  451|       |
  452|    302|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    302|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 302]
  ------------------
  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|    302|    } else {
  474|    302|      ret.implementations_agree = true;
  475|    302|    }
  476|    302|    return ret;
  477|    302|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    906|      const auto success = [](const ConversionResult& r) -> bool {
  402|    906|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    906|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    906|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    604|    auto neq = [](const auto& a, const auto& b) { return a != b; };

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

_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.00k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt25EE4dataEv:
  233|  1.00k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt25EE4sizeEv:
  235|  1.00k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_0clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     87|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     87|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     87|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     87|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     87|  constexpr auto _size = _name.size();                                \
 1183|     87|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     87|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_0clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     87|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     87|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     87|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     87|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     87|  constexpr auto _size = _name.size();                                \
 1183|     87|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     87|  return _nameof; }()
_ZNK6nameof7cstringILt30EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    375|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt30EE4dataEv:
  233|    375|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt30EE4sizeEv:
  235|    375|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_1clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    248|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    248|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    248|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    248|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    248|  constexpr auto _size = _name.size();                                \
 1183|    248|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    248|  return _nameof; }()
_ZNK6nameof7cstringILt24EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  3.21k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt24EE4dataEv:
  233|  3.21k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt24EE4sizeEv:
  235|  3.21k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_1clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    248|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    248|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    248|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    248|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    248|  constexpr auto _size = _name.size();                                \
 1183|    248|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    248|  return _nameof; }()
_ZNK6nameof7cstringILt29EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    964|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt29EE4dataEv:
  233|    964|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt29EE4sizeEv:
  235|    964|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_2clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     70|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     70|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     70|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     70|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     70|  constexpr auto _size = _name.size();                                \
 1183|     70|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     70|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_2clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     70|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     70|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     70|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     70|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     70|  constexpr auto _size = _name.size();                                \
 1183|     70|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     70|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_3clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    215|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    215|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    215|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    215|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    215|  constexpr auto _size = _name.size();                                \
 1183|    215|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    215|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_3clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    215|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    215|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    215|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    215|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    215|  constexpr auto _size = _name.size();                                \
 1183|    215|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    215|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_4clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     69|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     69|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     69|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     69|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     69|  constexpr auto _size = _name.size();                                \
 1183|     69|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     69|  return _nameof; }()
_ZNK6nameof7cstringILt23EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  3.64k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt23EE4dataEv:
  233|  3.64k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt23EE4sizeEv:
  235|  3.64k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_4clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     69|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     69|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     69|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     69|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     69|  constexpr auto _size = _name.size();                                \
 1183|     69|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     69|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_5clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    149|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    149|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    149|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    149|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    149|  constexpr auto _size = _name.size();                                \
 1183|    149|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    149|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_5clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    149|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    149|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    149|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    149|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    149|  constexpr auto _size = _name.size();                                \
 1183|    149|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    149|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_6clENSt3__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; }()
_ZNK6nameof7cstringILt22EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  4.39k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt22EE4dataEv:
  233|  4.39k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt22EE4sizeEv:
  235|  4.39k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_6clENSt3__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; }()
_ZNK6nameof7cstringILt27EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    362|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt27EE4dataEv:
  233|    362|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt27EE4sizeEv:
  235|    362|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_7clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    265|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    265|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    265|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    265|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    265|  constexpr auto _size = _name.size();                                \
 1183|    265|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    265|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_7clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    265|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    265|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    265|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    265|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    265|  constexpr auto _size = _name.size();                                \
 1183|    265|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    265|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_8clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    236|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    236|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    236|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    236|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    236|  constexpr auto _size = _name.size();                                \
 1183|    236|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    236|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_8clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    236|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    236|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    236|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    236|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    236|  constexpr auto _size = _name.size();                                \
 1183|    236|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    236|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_9clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    242|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    242|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    242|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    242|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    242|  constexpr auto _size = _name.size();                                \
 1183|    242|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    242|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_9clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    242|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    242|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    242|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    242|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    242|  constexpr auto _size = _name.size();                                \
 1183|    242|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    242|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_10clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     57|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     57|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     57|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     57|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     57|  constexpr auto _size = _name.size();                                \
 1183|     57|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     57|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_10clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     57|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     57|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     57|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     57|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     57|  constexpr auto _size = _name.size();                                \
 1183|     57|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     57|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_11clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    140|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    140|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    140|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    140|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    140|  constexpr auto _size = _name.size();                                \
 1183|    140|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    140|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_11clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    140|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    140|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    140|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    140|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    140|  constexpr auto _size = _name.size();                                \
 1183|    140|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    140|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_12clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    173|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    173|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    173|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    173|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    173|  constexpr auto _size = _name.size();                                \
 1183|    173|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    173|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_12clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    173|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    173|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    173|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    173|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    173|  constexpr auto _size = _name.size();                                \
 1183|    173|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    173|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_13clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     62|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     62|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     62|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     62|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     62|  constexpr auto _size = _name.size();                                \
 1183|     62|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     62|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_13clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     62|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     62|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     62|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     62|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     62|  constexpr auto _size = _name.size();                                \
 1183|     62|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     62|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_14clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    163|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    163|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    163|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    163|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    163|  constexpr auto _size = _name.size();                                \
 1183|    163|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    163|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_14clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    163|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    163|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    163|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    163|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    163|  constexpr auto _size = _name.size();                                \
 1183|    163|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    163|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_15clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    218|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    218|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    218|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    218|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    218|  constexpr auto _size = _name.size();                                \
 1183|    218|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    218|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_15clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    218|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    218|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    218|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    218|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    218|  constexpr auto _size = _name.size();                                \
 1183|    218|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    218|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_16clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    114|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    114|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    114|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    114|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    114|  constexpr auto _size = _name.size();                                \
 1183|    114|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    114|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_16clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    114|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    114|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    114|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    114|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    114|  constexpr auto _size = _name.size();                                \
 1183|    114|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    114|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_17clENSt3__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$_17clENSt3__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; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_18clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    271|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    271|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    271|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    271|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    271|  constexpr auto _size = _name.size();                                \
 1183|    271|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    271|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_18clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    271|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    271|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    271|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    271|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    271|  constexpr auto _size = _name.size();                                \
 1183|    271|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    271|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_19clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    324|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    324|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    324|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    324|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    324|  constexpr auto _size = _name.size();                                \
 1183|    324|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    324|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_19clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    324|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    324|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    324|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    324|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    324|  constexpr auto _size = _name.size();                                \
 1183|    324|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    324|  return _nameof; }()
_ZNK6nameof7cstringILt21EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    703|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt21EE4dataEv:
  233|    703|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt21EE4sizeEv:
  235|    703|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_20clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    293|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    293|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    293|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    293|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    293|  constexpr auto _size = _name.size();                                \
 1183|    293|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    293|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_20clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    293|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    293|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    293|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    293|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    293|  constexpr auto _size = _name.size();                                \
 1183|    293|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    293|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_21clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    397|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    397|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    397|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    397|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    397|  constexpr auto _size = _name.size();                                \
 1183|    397|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    397|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_21clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    397|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    397|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    397|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    397|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    397|  constexpr auto _size = _name.size();                                \
 1183|    397|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    397|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_22clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    388|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    388|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    388|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    388|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    388|  constexpr auto _size = _name.size();                                \
 1183|    388|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    388|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_22clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    388|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    388|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    388|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    388|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    388|  constexpr auto _size = _name.size();                                \
 1183|    388|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    388|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_23clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    379|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    379|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    379|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    379|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    379|  constexpr auto _size = _name.size();                                \
 1183|    379|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    379|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_23clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    379|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    379|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    379|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    379|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    379|  constexpr auto _size = _name.size();                                \
 1183|    379|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    379|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_24clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    133|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    133|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    133|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    133|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    133|  constexpr auto _size = _name.size();                                \
 1183|    133|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    133|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_24clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    133|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    133|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    133|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    133|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    133|  constexpr auto _size = _name.size();                                \
 1183|    133|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    133|  return _nameof; }()
_ZNK6nameof7cstringILt37EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    272|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt37EE4dataEv:
  233|    272|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt37EE4sizeEv:
  235|    272|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_25clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    173|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    173|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    173|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    173|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    173|  constexpr auto _size = _name.size();                                \
 1183|    173|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    173|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_25clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    173|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    173|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    173|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    173|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    173|  constexpr auto _size = _name.size();                                \
 1183|    173|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    173|  return _nameof; }()
_ZNK6nameof7cstringILt36EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  1.02k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt36EE4dataEv:
  233|  1.02k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt36EE4sizeEv:
  235|  1.02k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_26clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    327|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    327|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    327|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    327|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    327|  constexpr auto _size = _name.size();                                \
 1183|    327|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    327|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_26clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    327|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    327|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    327|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    327|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    327|  constexpr auto _size = _name.size();                                \
 1183|    327|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    327|  return _nameof; }()
_ZNK6nameof7cstringILt35EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  1.52k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt35EE4dataEv:
  233|  1.52k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt35EE4sizeEv:
  235|  1.52k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_27clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    139|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    139|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    139|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    139|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    139|  constexpr auto _size = _name.size();                                \
 1183|    139|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    139|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_27clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    139|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    139|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    139|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    139|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    139|  constexpr auto _size = _name.size();                                \
 1183|    139|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    139|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_28clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    167|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    167|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    167|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    167|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    167|  constexpr auto _size = _name.size();                                \
 1183|    167|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    167|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_28clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    167|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    167|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    167|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    167|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    167|  constexpr auto _size = _name.size();                                \
 1183|    167|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    167|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_29clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    321|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    321|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    321|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    321|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    321|  constexpr auto _size = _name.size();                                \
 1183|    321|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    321|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_29clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    321|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    321|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    321|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    321|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    321|  constexpr auto _size = _name.size();                                \
 1183|    321|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    321|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_30clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    218|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    218|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    218|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    218|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    218|  constexpr auto _size = _name.size();                                \
 1183|    218|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    218|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_30clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    218|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    218|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    218|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    218|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    218|  constexpr auto _size = _name.size();                                \
 1183|    218|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    218|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_31clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    347|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    347|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    347|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    347|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    347|  constexpr auto _size = _name.size();                                \
 1183|    347|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    347|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_31clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    347|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    347|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    347|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    347|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    347|  constexpr auto _size = _name.size();                                \
 1183|    347|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    347|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_32clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    337|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    337|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    337|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    337|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    337|  constexpr auto _size = _name.size();                                \
 1183|    337|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    337|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_32clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    337|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    337|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    337|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    337|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    337|  constexpr auto _size = _name.size();                                \
 1183|    337|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    337|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_33clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    416|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    416|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    416|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    416|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    416|  constexpr auto _size = _name.size();                                \
 1183|    416|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    416|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_33clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    416|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    416|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    416|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    416|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    416|  constexpr auto _size = _name.size();                                \
 1183|    416|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    416|  return _nameof; }()
_ZNK6nameof7cstringILt33EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    789|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt33EE4dataEv:
  233|    789|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt33EE4sizeEv:
  235|    789|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_34clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    256|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    256|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    256|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    256|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    256|  constexpr auto _size = _name.size();                                \
 1183|    256|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    256|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_34clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    256|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    256|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    256|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    256|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    256|  constexpr auto _size = _name.size();                                \
 1183|    256|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    256|  return _nameof; }()
_ZNK6nameof7cstringILt34EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    256|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt34EE4dataEv:
  233|    256|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt34EE4sizeEv:
  235|    256|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_35clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    353|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    353|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    353|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    353|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    353|  constexpr auto _size = _name.size();                                \
 1183|    353|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    353|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_35clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    353|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    353|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    353|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    353|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    353|  constexpr auto _size = _name.size();                                \
 1183|    353|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    353|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_36clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    305|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    305|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    305|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    305|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    305|  constexpr auto _size = _name.size();                                \
 1183|    305|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    305|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_36clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    305|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    305|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    305|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    305|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    305|  constexpr auto _size = _name.size();                                \
 1183|    305|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    305|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_37clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    373|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    373|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    373|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    373|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    373|  constexpr auto _size = _name.size();                                \
 1183|    373|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    373|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_37clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    373|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    373|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    373|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    373|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    373|  constexpr auto _size = _name.size();                                \
 1183|    373|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    373|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_38clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     62|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     62|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     62|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     62|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     62|  constexpr auto _size = _name.size();                                \
 1183|     62|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     62|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_38clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     62|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     62|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     62|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     62|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     62|  constexpr auto _size = _name.size();                                \
 1183|     62|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     62|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_39clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     48|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     48|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     48|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     48|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     48|  constexpr auto _size = _name.size();                                \
 1183|     48|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     48|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_39clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     48|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     48|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     48|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     48|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     48|  constexpr auto _size = _name.size();                                \
 1183|     48|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     48|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_40clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     38|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     38|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     38|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     38|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     38|  constexpr auto _size = _name.size();                                \
 1183|     38|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     38|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_40clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     38|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     38|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     38|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     38|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     38|  constexpr auto _size = _name.size();                                \
 1183|     38|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     38|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_41clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    302|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    302|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    302|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    302|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    302|  constexpr auto _size = _name.size();                                \
 1183|    302|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    302|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_41clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    302|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    302|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    302|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    302|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    302|  constexpr auto _size = _name.size();                                \
 1183|    302|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    302|  return _nameof; }()

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

_ZNK7simdutf14implementation4nameEv:
 5106|      4|  virtual std::string_view name() const noexcept { return _name; }
_ZNK7simdutf14implementation25required_instruction_setsEv:
 5157|      8|  virtual uint32_t required_instruction_sets() const {
 5158|      8|    return _required_instruction_sets;
 5159|      8|  }
_ZNK7simdutf14implementation24utf16_length_from_latin1Em:
 6347|    258|  utf16_length_from_latin1(size_t length) const noexcept {
 6348|    258|    return length;
 6349|    258|  }
_ZNK7simdutf14implementation24latin1_length_from_utf32Em:
 6535|    996|  latin1_length_from_utf32(size_t length) const noexcept {
 6536|    996|    return length;
 6537|    996|  }
_ZNK7simdutf14implementation24latin1_length_from_utf16Em:
 6572|  1.17k|  latin1_length_from_utf16(size_t length) const noexcept {
 6573|  1.17k|    return length;
 6574|  1.17k|  }
_ZNK7simdutf14implementation24utf32_length_from_latin1Em:
 6605|    186|  utf32_length_from_latin1(size_t length) const noexcept {
 6606|    186|    return length;
 6607|    186|  }
_ZN7simdutf14implementationC2EPKcS2_j:
 7043|      4|      : _name(name), _description(description),
 7044|      4|        _required_instruction_sets(required_instruction_sets) {}
_ZN7simdutf8internal29available_implementation_listC2Ev:
 7075|      1|  simdutf_really_inline available_implementation_list() {}

simdutf.cpp:_ZN7simdutf8internalL30detect_supported_architecturesEv:
  236|      8|static inline uint32_t detect_supported_architectures() {
  237|      8|  uint32_t eax;
  238|      8|  uint32_t ebx = 0;
  239|      8|  uint32_t ecx = 0;
  240|      8|  uint32_t edx = 0;
  241|      8|  uint32_t host_isa = 0x0;
  242|       |
  243|       |  // EBX for EAX=0x1
  244|      8|  eax = 0x1;
  245|      8|  cpuid(&eax, &ebx, &ecx, &edx);
  246|       |
  247|      8|  if (ecx & cpuid_bit::sse42) {
  ------------------
  |  Branch (247:7): [True: 8, False: 0]
  ------------------
  248|      8|    host_isa |= instruction_set::SSE42;
  249|      8|  }
  250|       |
  251|      8|  if (ecx & cpuid_bit::pclmulqdq) {
  ------------------
  |  Branch (251:7): [True: 8, False: 0]
  ------------------
  252|      8|    host_isa |= instruction_set::PCLMULQDQ;
  253|      8|  }
  254|       |
  255|      8|  if ((ecx & cpuid_bit::osxsave) != cpuid_bit::osxsave) {
  ------------------
  |  Branch (255:7): [True: 0, False: 8]
  ------------------
  256|      0|    return host_isa;
  257|      0|  }
  258|       |
  259|       |  // xgetbv for checking if the OS saves registers
  260|      8|  uint64_t xcr0 = xgetbv();
  261|       |
  262|      8|  if ((xcr0 & cpuid_bit::xcr0_bit::avx256_saved) == 0) {
  ------------------
  |  Branch (262:7): [True: 0, False: 8]
  ------------------
  263|      0|    return host_isa;
  264|      0|  }
  265|       |  // ECX for EAX=0x7
  266|      8|  eax = 0x7;
  267|      8|  ecx = 0x0; // Sub-leaf = 0
  268|      8|  cpuid(&eax, &ebx, &ecx, &edx);
  269|      8|  if (ebx & cpuid_bit::ebx::avx2) {
  ------------------
  |  Branch (269:7): [True: 8, False: 0]
  ------------------
  270|      8|    host_isa |= instruction_set::AVX2;
  271|      8|  }
  272|      8|  if (ebx & cpuid_bit::ebx::bmi1) {
  ------------------
  |  Branch (272:7): [True: 8, False: 0]
  ------------------
  273|      8|    host_isa |= instruction_set::BMI1;
  274|      8|  }
  275|      8|  if (ebx & cpuid_bit::ebx::bmi2) {
  ------------------
  |  Branch (275:7): [True: 8, False: 0]
  ------------------
  276|      8|    host_isa |= instruction_set::BMI2;
  277|      8|  }
  278|      8|  if (!((xcr0 & cpuid_bit::xcr0_bit::avx512_saved) ==
  ------------------
  |  Branch (278:7): [True: 8, False: 0]
  ------------------
  279|      8|        cpuid_bit::xcr0_bit::avx512_saved)) {
  280|      8|    return host_isa;
  281|      8|  }
  282|      0|  if (ebx & cpuid_bit::ebx::avx512f) {
  ------------------
  |  Branch (282:7): [True: 0, False: 0]
  ------------------
  283|      0|    host_isa |= instruction_set::AVX512F;
  284|      0|  }
  285|      0|  if (ebx & cpuid_bit::ebx::avx512bw) {
  ------------------
  |  Branch (285:7): [True: 0, False: 0]
  ------------------
  286|      0|    host_isa |= instruction_set::AVX512BW;
  287|      0|  }
  288|      0|  if (ebx & cpuid_bit::ebx::avx512cd) {
  ------------------
  |  Branch (288:7): [True: 0, False: 0]
  ------------------
  289|      0|    host_isa |= instruction_set::AVX512CD;
  290|      0|  }
  291|      0|  if (ebx & cpuid_bit::ebx::avx512dq) {
  ------------------
  |  Branch (291:7): [True: 0, False: 0]
  ------------------
  292|      0|    host_isa |= instruction_set::AVX512DQ;
  293|      0|  }
  294|      0|  if (ebx & cpuid_bit::ebx::avx512vl) {
  ------------------
  |  Branch (294:7): [True: 0, False: 0]
  ------------------
  295|      0|    host_isa |= instruction_set::AVX512VL;
  296|      0|  }
  297|      0|  if (ecx & cpuid_bit::ecx::avx512vbmi2) {
  ------------------
  |  Branch (297:7): [True: 0, False: 0]
  ------------------
  298|      0|    host_isa |= instruction_set::AVX512VBMI2;
  299|      0|  }
  300|      0|  if (ecx & cpuid_bit::ecx::avx512vpopcnt) {
  ------------------
  |  Branch (300:7): [True: 0, False: 0]
  ------------------
  301|      0|    host_isa |= instruction_set::AVX512VPOPCNTDQ;
  302|      0|  }
  303|      0|  return host_isa;
  304|      8|}
simdutf.cpp:_ZN7simdutf8internalL5cpuidEPjS1_S1_S1_:
  202|     16|                         uint32_t *edx) {
  203|       |  #if defined(_MSC_VER)
  204|       |  int cpu_info[4];
  205|       |  __cpuidex(cpu_info, *eax, *ecx);
  206|       |  *eax = cpu_info[0];
  207|       |  *ebx = cpu_info[1];
  208|       |  *ecx = cpu_info[2];
  209|       |  *edx = cpu_info[3];
  210|       |  #elif (defined(HAVE_GCC_GET_CPUID) && defined(USE_GCC_GET_CPUID)) ||         \
  211|       |      defined(__FILC__)
  212|       |  uint32_t level = *eax;
  213|       |  __get_cpuid(level, eax, ebx, ecx, edx);
  214|       |  #else
  215|     16|  uint32_t a = *eax, b, c = *ecx, d;
  216|     16|  asm volatile("cpuid\n\t" : "+a"(a), "=b"(b), "+c"(c), "=d"(d));
  217|     16|  *eax = a;
  218|     16|  *ebx = b;
  219|     16|  *ecx = c;
  220|     16|  *edx = d;
  221|     16|  #endif
  222|     16|}
simdutf.cpp:_ZN7simdutf8internalL6xgetbvEv:
  224|      8|static inline uint64_t xgetbv() {
  225|       |  #if defined(_MSC_VER)
  226|       |  return _xgetbv(0);
  227|       |  #elif defined(__FILC__)
  228|       |  return zxgetbv();
  229|       |  #else
  230|      8|  uint32_t xcr0_lo, xcr0_hi;
  231|      8|  asm volatile("xgetbv\n\t" : "=a"(xcr0_lo), "=d"(xcr0_hi) : "c"(0));
  232|      8|  return xcr0_lo | ((uint64_t)xcr0_hi << 32);
  233|      8|  #endif
  234|      8|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_16latin123utf8_length_from_latin1EPKcm:
   10|    604|                                                     size_t len) {
   11|    604|  const uint8_t *c = reinterpret_cast<const uint8_t *>(buf);
   12|    604|  size_t answer = 0;
   13|  4.71k|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (13:22): [True: 4.11k, False: 604]
  ------------------
   14|  4.11k|    if ((c[i] >> 7)) {
  ------------------
  |  Branch (14:9): [True: 1.16k, False: 2.94k]
  ------------------
   15|  1.16k|      answer++;
   16|  1.16k|    }
   17|  4.11k|  }
   18|    604|  return answer + len;
   19|    604|}

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

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

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114latin1_to_utf87convertEPKcmPc:
   66|  1.71k|                                     char *utf8_output) {
   67|  1.71k|  return convert(reinterpret_cast<const unsigned char *>(buf), len,
   68|  1.71k|                 utf8_output);
   69|  1.71k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114latin1_to_utf87convertIPKhPcQaasr7simdutf6detailE22indexes_into_byte_likeIT_Esr7simdutf6detailE26index_assignable_from_charIT0_EEEmS7_mS8_:
   17|  1.71k|                                   OutputPtr utf8_output) {
   18|       |  // const unsigned char *data = reinterpret_cast<const unsigned char *>(buf);
   19|  1.71k|  size_t pos = 0;
   20|  1.71k|  size_t utf8_pos = 0;
   21|       |
   22|  8.58M|  while (pos < len) {
  ------------------
  |  Branch (22:10): [True: 8.57M, False: 1.71k]
  ------------------
   23|       |#if SIMDUTF_CPLUSPLUS23
   24|       |    if !consteval
   25|       |#endif
   26|  8.57M|    {
   27|       |      // try to convert the next block of 16 ASCII bytes
   28|  8.57M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (28:11): [True: 8.56M, False: 15.3k]
  ------------------
   29|       |                             // they are ascii
   30|  8.56M|        uint64_t v1;
   31|  8.56M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   32|  8.56M|        uint64_t v2;
   33|  8.56M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   34|  8.56M|        uint64_t v{v1 |
   35|  8.56M|                   v2}; // We are only interested in these bits: 1000 1000 1000
   36|       |                        // 1000, so it makes sense to concatenate everything
   37|  8.56M|        if ((v & 0x8080808080808080) ==
  ------------------
  |  Branch (37:13): [True: 3.00M, False: 5.55M]
  ------------------
   38|  8.56M|            0) { // if NONE of these are set, e.g. all of them are zero, then
   39|       |                 // everything is ASCII
   40|  3.00M|          size_t final_pos = pos + 16;
   41|  51.1M|          while (pos < final_pos) {
  ------------------
  |  Branch (41:18): [True: 48.1M, False: 3.00M]
  ------------------
   42|  48.1M|            utf8_output[utf8_pos++] = char(data[pos]);
   43|  48.1M|            pos++;
   44|  48.1M|          }
   45|  3.00M|          continue;
   46|  3.00M|        }
   47|  8.56M|      } // if (pos + 16 <= len)
   48|  8.57M|    } // !consteval scope
   49|       |
   50|  5.57M|    unsigned char byte = data[pos];
   51|  5.57M|    if ((byte & 0x80) == 0) { // if ASCII
  ------------------
  |  Branch (51:9): [True: 2.42M, False: 3.14M]
  ------------------
   52|       |      // will generate one UTF-8 bytes
   53|  2.42M|      utf8_output[utf8_pos++] = char(byte);
   54|  2.42M|      pos++;
   55|  3.14M|    } else {
   56|       |      // will generate two UTF-8 bytes
   57|  3.14M|      utf8_output[utf8_pos++] = char((byte >> 6) | 0b11000000);
   58|  3.14M|      utf8_output[utf8_pos++] = char((byte & 0b111111) | 0b10000000);
   59|  3.14M|      pos++;
   60|  3.14M|    }
   61|  5.57M|  } // while
   62|  1.71k|  return utf8_pos;
   63|  1.71k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114latin1_to_utf823utf8_length_from_latin1IPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEEmS6_m:
  152|    302|utf8_length_from_latin1(InputPtr input, size_t length) noexcept {
  153|    302|  size_t answer = length;
  154|    302|  size_t i = 0;
  155|       |
  156|       |#if SIMDUTF_CPLUSPLUS23
  157|       |  if !consteval
  158|       |#endif
  159|    302|  {
  160|    302|    auto pop = [](uint64_t v) {
  161|    302|      return (size_t)(((v >> 7) & UINT64_C(0x0101010101010101)) *
  162|    302|                          UINT64_C(0x0101010101010101) >>
  163|    302|                      56);
  164|    302|    };
  165|   839k|    for (; i + 32 <= length; i += 32) {
  ------------------
  |  Branch (165:12): [True: 838k, False: 302]
  ------------------
  166|   838k|      uint64_t v;
  167|   838k|      memcpy(&v, input + i, 8);
  168|   838k|      answer += pop(v);
  169|   838k|      memcpy(&v, input + i + 8, sizeof(v));
  170|   838k|      answer += pop(v);
  171|   838k|      memcpy(&v, input + i + 16, sizeof(v));
  172|   838k|      answer += pop(v);
  173|   838k|      memcpy(&v, input + i + 24, sizeof(v));
  174|   838k|      answer += pop(v);
  175|   838k|    }
  176|    592|    for (; i + 8 <= length; i += 8) {
  ------------------
  |  Branch (176:12): [True: 290, False: 302]
  ------------------
  177|    290|      uint64_t v;
  178|    290|      memcpy(&v, input + i, sizeof(v));
  179|    290|      answer += pop(v);
  180|    290|    }
  181|    302|  } // !consteval scope
  182|    814|  for (; i + 1 <= length; i += 1) {
  ------------------
  |  Branch (182:10): [True: 512, False: 302]
  ------------------
  183|    512|    answer += static_cast<uint8_t>(input[i]) >> 7;
  184|    512|  }
  185|    302|  return answer;
  186|    302|}
simdutf.cpp:_ZZN7simdutf6scalar12_GLOBAL__N_114latin1_to_utf823utf8_length_from_latin1IPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEEmS6_mENKUlmE_clEm:
  160|  3.35M|    auto pop = [](uint64_t v) {
  161|  3.35M|      return (size_t)(((v >> 7) & UINT64_C(0x0101010101010101)) *
  162|       |                          UINT64_C(0x0101010101010101) >>
  163|  3.35M|                      56);
  164|  3.35M|    };

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

_ZN7simdutf6scalar5utf168validateILNS_10endiannessE0EEEbPKDsm:
   22|  3.80k|validate(const char16_t *data, size_t len) noexcept {
   23|  3.80k|  uint64_t pos = 0;
   24|  20.3M|  while (pos < len) {
  ------------------
  |  Branch (24:10): [True: 20.3M, False: 2.63k]
  ------------------
   25|  20.3M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   26|  20.3M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (26:9): [True: 16.6k, False: 20.3M]
  ------------------
   27|  16.6k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 204, False: 16.4k]
  ------------------
   28|    204|        return false;
   29|    204|      }
   30|  16.4k|      char16_t diff = char16_t(word - 0xD800);
   31|  16.4k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (31:11): [True: 356, False: 16.0k]
  ------------------
   32|    356|        return false;
   33|    356|      }
   34|  16.0k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (34:28): [Folded, False: 16.0k]
  ------------------
   35|  16.0k|                               ? u16_swap_bytes(data[pos + 1])
   36|  16.0k|                               : data[pos + 1];
   37|  16.0k|      char16_t diff2 = char16_t(next_word - 0xDC00);
   38|  16.0k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (38:11): [True: 614, False: 15.4k]
  ------------------
   39|    614|        return false;
   40|    614|      }
   41|  15.4k|      pos += 2;
   42|  20.3M|    } else {
   43|  20.3M|      pos++;
   44|  20.3M|    }
   45|  20.3M|  }
   46|  2.63k|  return true;
   47|  3.80k|}
_ZN7simdutf6scalar5utf168validateILNS_10endiannessE1EEEbPKDsm:
   22|  3.72k|validate(const char16_t *data, size_t len) noexcept {
   23|  3.72k|  uint64_t pos = 0;
   24|  20.9M|  while (pos < len) {
  ------------------
  |  Branch (24:10): [True: 20.9M, False: 2.56k]
  ------------------
   25|  20.9M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   26|  20.9M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (26:9): [True: 16.2k, False: 20.9M]
  ------------------
   27|  16.2k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 195, False: 16.0k]
  ------------------
   28|    195|        return false;
   29|    195|      }
   30|  16.0k|      char16_t diff = char16_t(word - 0xD800);
   31|  16.0k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (31:11): [True: 417, False: 15.6k]
  ------------------
   32|    417|        return false;
   33|    417|      }
   34|  15.6k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (34:28): [True: 15.6k, Folded]
  ------------------
   35|  15.6k|                               ? u16_swap_bytes(data[pos + 1])
   36|  15.6k|                               : data[pos + 1];
   37|  15.6k|      char16_t diff2 = char16_t(next_word - 0xDC00);
   38|  15.6k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (38:11): [True: 550, False: 15.1k]
  ------------------
   39|    550|        return false;
   40|    550|      }
   41|  15.1k|      pos += 2;
   42|  20.9M|    } else {
   43|  20.9M|      pos++;
   44|  20.9M|    }
   45|  20.9M|  }
   46|  2.56k|  return true;
   47|  3.72k|}
_ZN7simdutf6scalar5utf1620validate_with_errorsILNS_10endiannessE0EEENS_6resultEPKDsm:
   51|  4.03k|validate_with_errors(const char16_t *data, size_t len) noexcept {
   52|  4.03k|  size_t pos = 0;
   53|  20.3M|  while (pos < len) {
  ------------------
  |  Branch (53:10): [True: 20.3M, False: 2.63k]
  ------------------
   54|  20.3M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   55|  20.3M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (55:9): [True: 16.9k, False: 20.3M]
  ------------------
   56|  16.9k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (56:11): [True: 204, False: 16.7k]
  ------------------
   57|    204|        return result(error_code::SURROGATE, pos);
   58|    204|      }
   59|  16.7k|      char16_t diff = char16_t(word - 0xD800);
   60|  16.7k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (60:11): [True: 474, False: 16.2k]
  ------------------
   61|    474|        return result(error_code::SURROGATE, pos);
   62|    474|      }
   63|  16.2k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (63:28): [Folded, False: 16.2k]
  ------------------
   64|  16.2k|                               ? u16_swap_bytes(data[pos + 1])
   65|  16.2k|                               : data[pos + 1];
   66|  16.2k|      char16_t diff2 = uint16_t(next_word - 0xDC00);
   67|  16.2k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (67:11): [True: 723, False: 15.5k]
  ------------------
   68|    723|        return result(error_code::SURROGATE, pos);
   69|    723|      }
   70|  15.5k|      pos += 2;
   71|  20.3M|    } else {
   72|  20.3M|      pos++;
   73|  20.3M|    }
   74|  20.3M|  }
   75|  2.63k|  return result(error_code::SUCCESS, pos);
   76|  4.03k|}
_ZN7simdutf6scalar5utf1620validate_with_errorsILNS_10endiannessE1EEENS_6resultEPKDsm:
   51|  3.98k|validate_with_errors(const char16_t *data, size_t len) noexcept {
   52|  3.98k|  size_t pos = 0;
   53|  20.9M|  while (pos < len) {
  ------------------
  |  Branch (53:10): [True: 20.9M, False: 2.56k]
  ------------------
   54|  20.9M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   55|  20.9M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (55:9): [True: 16.5k, False: 20.9M]
  ------------------
   56|  16.5k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (56:11): [True: 195, False: 16.3k]
  ------------------
   57|    195|        return result(error_code::SURROGATE, pos);
   58|    195|      }
   59|  16.3k|      char16_t diff = char16_t(word - 0xD800);
   60|  16.3k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (60:11): [True: 540, False: 15.8k]
  ------------------
   61|    540|        return result(error_code::SURROGATE, pos);
   62|    540|      }
   63|  15.8k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (63:28): [True: 15.8k, Folded]
  ------------------
   64|  15.8k|                               ? u16_swap_bytes(data[pos + 1])
   65|  15.8k|                               : data[pos + 1];
   66|  15.8k|      char16_t diff2 = uint16_t(next_word - 0xDC00);
   67|  15.8k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (67:11): [True: 684, False: 15.1k]
  ------------------
   68|    684|        return result(error_code::SURROGATE, pos);
   69|    684|      }
   70|  15.1k|      pos += 2;
   71|  20.9M|    } else {
   72|  20.9M|      pos++;
   73|  20.9M|    }
   74|  20.9M|  }
   75|  2.56k|  return result(error_code::SUCCESS, pos);
   76|  3.98k|}
_ZN7simdutf6scalar5utf1617count_code_pointsILNS_10endiannessE0EEEmPKDsm:
   79|  4.86k|simdutf_constexpr23 size_t count_code_points(const char16_t *p, size_t len) {
   80|       |  // We are not BOM aware.
   81|  4.86k|  size_t counter{0};
   82|  29.5M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (82:22): [True: 29.5M, False: 4.86k]
  ------------------
   83|  29.5M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
   84|  29.5M|    counter += ((word & 0xFC00) != 0xDC00);
   85|  29.5M|  }
   86|  4.86k|  return counter;
   87|  4.86k|}
_ZN7simdutf6scalar5utf1617count_code_pointsILNS_10endiannessE1EEEmPKDsm:
   79|  4.81k|simdutf_constexpr23 size_t count_code_points(const char16_t *p, size_t len) {
   80|       |  // We are not BOM aware.
   81|  4.81k|  size_t counter{0};
   82|  27.5M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (82:22): [True: 27.5M, False: 4.81k]
  ------------------
   83|  27.5M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
   84|  27.5M|    counter += ((word & 0xFC00) != 0xDC00);
   85|  27.5M|  }
   86|  4.81k|  return counter;
   87|  4.81k|}
_ZN7simdutf6scalar5utf1622utf8_length_from_utf16ILNS_10endiannessE0EEEmPKDsm:
   91|  2.26k|                                                  size_t len) {
   92|       |  // We are not BOM aware.
   93|  2.26k|  size_t counter{0};
   94|  16.9M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (94:22): [True: 16.9M, False: 2.26k]
  ------------------
   95|  16.9M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
   96|  16.9M|    counter++; // ASCII
   97|  16.9M|    counter += static_cast<size_t>(
   98|  16.9M|        word >
   99|  16.9M|        0x7F); // non-ASCII is at least 2 bytes, surrogates are 2*2 == 4 bytes
  100|  16.9M|    counter += static_cast<size_t>((word > 0x7FF && word <= 0xD7FF) ||
  ------------------
  |  Branch (100:37): [True: 3.63M, False: 13.2M]
  |  Branch (100:53): [True: 3.35M, False: 283k]
  ------------------
  101|  13.5M|                                   (word >= 0xE000)); // three-byte
  ------------------
  |  Branch (101:36): [True: 224k, False: 13.3M]
  ------------------
  102|  16.9M|  }
  103|  2.26k|  return counter;
  104|  2.26k|}
_ZN7simdutf6scalar5utf1622utf8_length_from_utf16ILNS_10endiannessE1EEEmPKDsm:
   91|  2.24k|                                                  size_t len) {
   92|       |  // We are not BOM aware.
   93|  2.24k|  size_t counter{0};
   94|  15.1M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (94:22): [True: 15.1M, False: 2.24k]
  ------------------
   95|  15.1M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
   96|  15.1M|    counter++; // ASCII
   97|  15.1M|    counter += static_cast<size_t>(
   98|  15.1M|        word >
   99|  15.1M|        0x7F); // non-ASCII is at least 2 bytes, surrogates are 2*2 == 4 bytes
  100|  15.1M|    counter += static_cast<size_t>((word > 0x7FF && word <= 0xD7FF) ||
  ------------------
  |  Branch (100:37): [True: 3.49M, False: 11.7M]
  |  Branch (100:53): [True: 3.34M, False: 150k]
  ------------------
  101|  11.8M|                                   (word >= 0xE000)); // three-byte
  ------------------
  |  Branch (101:36): [True: 127k, False: 11.7M]
  ------------------
  102|  15.1M|  }
  103|  2.24k|  return counter;
  104|  2.24k|}
_ZN7simdutf6scalar5utf1623utf32_length_from_utf16ILNS_10endiannessE0EEEmPKDsm:
  108|    400|                                                   size_t len) {
  109|       |  // We are not BOM aware.
  110|    400|  size_t counter{0};
  111|  7.40M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (111:22): [True: 7.40M, False: 400]
  ------------------
  112|  7.40M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
  113|  7.40M|    counter += ((word & 0xFC00) != 0xDC00);
  114|  7.40M|  }
  115|    400|  return counter;
  116|    400|}
_ZN7simdutf6scalar5utf1623utf32_length_from_utf16ILNS_10endiannessE1EEEmPKDsm:
  108|    400|                                                   size_t len) {
  109|       |  // We are not BOM aware.
  110|    400|  size_t counter{0};
  111|  5.82M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (111:22): [True: 5.82M, False: 400]
  ------------------
  112|  5.82M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
  113|  5.82M|    counter += ((word & 0xFC00) != 0xDC00);
  114|  5.82M|  }
  115|    400|  return counter;
  116|    400|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf16_to_latin17convertILNS_10endiannessE0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEEmS8_mS9_:
   17|    272|                                   OutputPtr latin_output) {
   18|    272|  if (len == 0) {
  ------------------
  |  Branch (18:7): [True: 6, False: 266]
  ------------------
   19|      6|    return 0;
   20|      6|  }
   21|    266|  size_t pos = 0;
   22|    266|  const auto latin_output_start = latin_output;
   23|    266|  uint16_t word = 0;
   24|    266|  uint16_t too_large = 0;
   25|       |
   26|   567k|  while (pos < len) {
  ------------------
  |  Branch (26:10): [True: 567k, False: 266]
  ------------------
   27|   567k|    word = !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (27:12): [Folded, False: 567k]
  ------------------
   28|   567k|    too_large |= word;
   29|   567k|    *latin_output++ = char(word & 0xFF);
   30|   567k|    pos++;
   31|   567k|  }
   32|    266|  if ((too_large & 0xFF00) != 0) {
  ------------------
  |  Branch (32:7): [True: 174, False: 92]
  ------------------
   33|    174|    return 0;
   34|    174|  }
   35|       |
   36|     92|  return latin_output - latin_output_start;
   37|    266|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf16_to_latin17convertILNS_10endiannessE1EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEEmS8_mS9_:
   17|    244|                                   OutputPtr latin_output) {
   18|    244|  if (len == 0) {
  ------------------
  |  Branch (18:7): [True: 6, False: 238]
  ------------------
   19|      6|    return 0;
   20|      6|  }
   21|    238|  size_t pos = 0;
   22|    238|  const auto latin_output_start = latin_output;
   23|    238|  uint16_t word = 0;
   24|    238|  uint16_t too_large = 0;
   25|       |
   26|  1.73M|  while (pos < len) {
  ------------------
  |  Branch (26:10): [True: 1.73M, False: 238]
  ------------------
   27|  1.73M|    word = !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (27:12): [True: 1.73M, Folded]
  ------------------
   28|  1.73M|    too_large |= word;
   29|  1.73M|    *latin_output++ = char(word & 0xFF);
   30|  1.73M|    pos++;
   31|  1.73M|  }
   32|    238|  if ((too_large & 0xFF00) != 0) {
  ------------------
  |  Branch (32:7): [True: 124, False: 114]
  ------------------
   33|    124|    return 0;
   34|    124|  }
   35|       |
   36|    114|  return latin_output - latin_output_start;
   37|    238|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf16_to_latin119convert_with_errorsILNS_10endiannessE0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEENS_6resultES8_mS9_:
   45|    466|                                               OutputPtr latin_output) {
   46|    466|  if (len == 0) {
  ------------------
  |  Branch (46:7): [True: 4, False: 462]
  ------------------
   47|      4|    return result(error_code::SUCCESS, 0);
   48|      4|  }
   49|    462|  size_t pos = 0;
   50|    462|  auto start = latin_output;
   51|    462|  uint16_t word;
   52|       |
   53|   412k|  while (pos < len) {
  ------------------
  |  Branch (53:10): [True: 412k, False: 184]
  ------------------
   54|       |#if SIMDUTF_CPLUSPLUS23
   55|       |    if !consteval
   56|       |#endif
   57|   412k|    {
   58|   412k|      if (pos + 16 <= len) { // if it is safe to read 32 more bytes, check that
  ------------------
  |  Branch (58:11): [True: 410k, False: 1.67k]
  ------------------
   59|       |                             // they are Latin1
   60|   410k|        uint64_t v1, v2, v3, v4;
   61|   410k|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   62|   410k|        ::memcpy(&v2, data + pos + 4, sizeof(uint64_t));
   63|   410k|        ::memcpy(&v3, data + pos + 8, sizeof(uint64_t));
   64|   410k|        ::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|   410k|        if (((v1 | v2 | v3 | v4) & 0xFF00FF00FF00FF00) == 0) {
  ------------------
  |  Branch (79:13): [True: 410k, False: 260]
  ------------------
   80|   410k|          size_t final_pos = pos + 16;
   81|  6.97M|          while (pos < final_pos) {
  ------------------
  |  Branch (81:18): [True: 6.56M, False: 410k]
  ------------------
   82|  6.56M|            *latin_output++ = !match_system(big_endian)
  ------------------
  |  Branch (82:31): [Folded, False: 6.56M]
  ------------------
   83|  6.56M|                                  ? char(u16_swap_bytes(data[pos]))
   84|  6.56M|                                  : char(data[pos]);
   85|  6.56M|            pos++;
   86|  6.56M|          }
   87|   410k|          continue;
   88|   410k|        }
   89|   410k|      }
   90|   412k|    }
   91|       |
   92|  1.93k|    word = !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (92:12): [Folded, False: 1.93k]
  ------------------
   93|  1.93k|    if ((word & 0xFF00) == 0) {
  ------------------
  |  Branch (93:9): [True: 1.65k, False: 278]
  ------------------
   94|  1.65k|      *latin_output++ = char(word & 0xFF);
   95|  1.65k|      pos++;
   96|  1.65k|    } else {
   97|    278|      return result(error_code::TOO_LARGE, pos);
   98|    278|    }
   99|  1.93k|  }
  100|    184|  return result(error_code::SUCCESS, latin_output - start);
  101|    462|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf16_to_latin119convert_with_errorsILNS_10endiannessE1EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEENS_6resultES8_mS9_:
   45|    464|                                               OutputPtr latin_output) {
   46|    464|  if (len == 0) {
  ------------------
  |  Branch (46:7): [True: 4, False: 460]
  ------------------
   47|      4|    return result(error_code::SUCCESS, 0);
   48|      4|  }
   49|    460|  size_t pos = 0;
   50|    460|  auto start = latin_output;
   51|    460|  uint16_t word;
   52|       |
   53|   524k|  while (pos < len) {
  ------------------
  |  Branch (53:10): [True: 523k, False: 194]
  ------------------
   54|       |#if SIMDUTF_CPLUSPLUS23
   55|       |    if !consteval
   56|       |#endif
   57|   523k|    {
   58|   523k|      if (pos + 16 <= len) { // if it is safe to read 32 more bytes, check that
  ------------------
  |  Branch (58:11): [True: 522k, False: 1.55k]
  ------------------
   59|       |                             // they are Latin1
   60|   522k|        uint64_t v1, v2, v3, v4;
   61|   522k|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   62|   522k|        ::memcpy(&v2, data + pos + 4, sizeof(uint64_t));
   63|   522k|        ::memcpy(&v3, data + pos + 8, sizeof(uint64_t));
   64|   522k|        ::memcpy(&v4, data + pos + 12, sizeof(uint64_t));
   65|       |
   66|   522k|        if constexpr (!match_system(big_endian)) {
   67|   522k|          v1 = (v1 >> 8) | (v1 << (64 - 8));
   68|   522k|        }
   69|   522k|        if constexpr (!match_system(big_endian)) {
   70|   522k|          v2 = (v2 >> 8) | (v2 << (64 - 8));
   71|   522k|        }
   72|   522k|        if constexpr (!match_system(big_endian)) {
   73|   522k|          v3 = (v3 >> 8) | (v3 << (64 - 8));
   74|   522k|        }
   75|   522k|        if constexpr (!match_system(big_endian)) {
   76|   522k|          v4 = (v4 >> 8) | (v4 << (64 - 8));
   77|   522k|        }
   78|       |
   79|   522k|        if (((v1 | v2 | v3 | v4) & 0xFF00FF00FF00FF00) == 0) {
  ------------------
  |  Branch (79:13): [True: 522k, False: 326]
  ------------------
   80|   522k|          size_t final_pos = pos + 16;
   81|  8.87M|          while (pos < final_pos) {
  ------------------
  |  Branch (81:18): [True: 8.35M, False: 522k]
  ------------------
   82|  8.35M|            *latin_output++ = !match_system(big_endian)
  ------------------
  |  Branch (82:31): [True: 8.35M, Folded]
  ------------------
   83|  8.35M|                                  ? char(u16_swap_bytes(data[pos]))
   84|  8.35M|                                  : char(data[pos]);
   85|  8.35M|            pos++;
   86|  8.35M|          }
   87|   522k|          continue;
   88|   522k|        }
   89|   522k|      }
   90|   523k|    }
   91|       |
   92|  1.87k|    word = !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (92:12): [True: 1.87k, Folded]
  ------------------
   93|  1.87k|    if ((word & 0xFF00) == 0) {
  ------------------
  |  Branch (93:9): [True: 1.61k, False: 266]
  ------------------
   94|  1.61k|      *latin_output++ = char(word & 0xFF);
   95|  1.61k|      pos++;
   96|  1.61k|    } else {
   97|    266|      return result(error_code::TOO_LARGE, pos);
   98|    266|    }
   99|  1.87k|  }
  100|    194|  return result(error_code::SUCCESS, latin_output - start);
  101|    460|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf327convertILNS_10endiannessE0EEEmPKDsmPDi:
   11|    840|                                   char32_t *utf32_output) {
   12|    840|  size_t pos = 0;
   13|    840|  char32_t *start{utf32_output};
   14|  2.51M|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 2.51M, False: 494]
  ------------------
   15|  2.51M|    uint16_t word =
   16|  2.51M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (16:9): [Folded, False: 2.51M]
  ------------------
   17|  2.51M|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (17:9): [True: 2.51M, False: 3.66k]
  ------------------
   18|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   19|  2.51M|      *utf32_output++ = char32_t(word);
   20|  2.51M|      pos++;
   21|  2.51M|    } else {
   22|       |      // must be a surrogate pair
   23|  3.66k|      uint16_t diff = uint16_t(word - 0xD800);
   24|  3.66k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (24:11): [True: 126, False: 3.54k]
  ------------------
   25|    126|        return 0;
   26|    126|      }
   27|  3.54k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 72, False: 3.47k]
  ------------------
   28|     72|        return 0;
   29|     72|      } // minimal bound checking
   30|  3.47k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (30:28): [Folded, False: 3.47k]
  ------------------
   31|  3.47k|                               ? u16_swap_bytes(data[pos + 1])
   32|  3.47k|                               : data[pos + 1];
   33|  3.47k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   34|  3.47k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (34:11): [True: 148, False: 3.32k]
  ------------------
   35|    148|        return 0;
   36|    148|      }
   37|  3.32k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   38|  3.32k|      *utf32_output++ = char32_t(value);
   39|  3.32k|      pos += 2;
   40|  3.32k|    }
   41|  2.51M|  }
   42|    494|  return utf32_output - start;
   43|    840|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf327convertILNS_10endiannessE1EEEmPKDsmPDi:
   11|    820|                                   char32_t *utf32_output) {
   12|    820|  size_t pos = 0;
   13|    820|  char32_t *start{utf32_output};
   14|  1.59M|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 1.59M, False: 500]
  ------------------
   15|  1.59M|    uint16_t word =
   16|  1.59M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (16:9): [True: 1.59M, Folded]
  ------------------
   17|  1.59M|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (17:9): [True: 1.59M, False: 1.82k]
  ------------------
   18|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   19|  1.59M|      *utf32_output++ = char32_t(word);
   20|  1.59M|      pos++;
   21|  1.59M|    } else {
   22|       |      // must be a surrogate pair
   23|  1.82k|      uint16_t diff = uint16_t(word - 0xD800);
   24|  1.82k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (24:11): [True: 86, False: 1.74k]
  ------------------
   25|     86|        return 0;
   26|     86|      }
   27|  1.74k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 114, False: 1.62k]
  ------------------
   28|    114|        return 0;
   29|    114|      } // minimal bound checking
   30|  1.62k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (30:28): [True: 1.62k, Folded]
  ------------------
   31|  1.62k|                               ? u16_swap_bytes(data[pos + 1])
   32|  1.62k|                               : data[pos + 1];
   33|  1.62k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   34|  1.62k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (34:11): [True: 120, False: 1.50k]
  ------------------
   35|    120|        return 0;
   36|    120|      }
   37|  1.50k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   38|  1.50k|      *utf32_output++ = char32_t(value);
   39|  1.50k|      pos += 2;
   40|  1.50k|    }
   41|  1.59M|  }
   42|    500|  return utf32_output - start;
   43|    820|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf3219convert_with_errorsILNS_10endiannessE0EEENS_6resultEPKDsmPDi:
   47|    690|                                               char32_t *utf32_output) {
   48|    690|  size_t pos = 0;
   49|    690|  char32_t *start{utf32_output};
   50|  2.54M|  while (pos < len) {
  ------------------
  |  Branch (50:10): [True: 2.54M, False: 378]
  ------------------
   51|  2.54M|    uint16_t word =
   52|  2.54M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (52:9): [Folded, False: 2.54M]
  ------------------
   53|  2.54M|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (53:9): [True: 2.53M, False: 9.83k]
  ------------------
   54|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   55|  2.53M|      *utf32_output++ = char32_t(word);
   56|  2.53M|      pos++;
   57|  2.53M|    } else {
   58|       |      // must be a surrogate pair
   59|  9.83k|      uint16_t diff = uint16_t(word - 0xD800);
   60|  9.83k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (60:11): [True: 78, False: 9.75k]
  ------------------
   61|     78|        return result(error_code::SURROGATE, pos);
   62|     78|      }
   63|  9.75k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (63:11): [True: 84, False: 9.66k]
  ------------------
   64|     84|        return result(error_code::SURROGATE, pos);
   65|     84|      } // minimal bound checking
   66|  9.66k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (66:28): [Folded, False: 9.66k]
  ------------------
   67|  9.66k|                               ? u16_swap_bytes(data[pos + 1])
   68|  9.66k|                               : data[pos + 1];
   69|  9.66k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   70|  9.66k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (70:11): [True: 150, False: 9.51k]
  ------------------
   71|    150|        return result(error_code::SURROGATE, pos);
   72|    150|      }
   73|  9.51k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   74|  9.51k|      *utf32_output++ = char32_t(value);
   75|  9.51k|      pos += 2;
   76|  9.51k|    }
   77|  2.54M|  }
   78|    378|  return result(error_code::SUCCESS, utf32_output - start);
   79|    690|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf3219convert_with_errorsILNS_10endiannessE1EEENS_6resultEPKDsmPDi:
   47|    758|                                               char32_t *utf32_output) {
   48|    758|  size_t pos = 0;
   49|    758|  char32_t *start{utf32_output};
   50|  2.40M|  while (pos < len) {
  ------------------
  |  Branch (50:10): [True: 2.40M, False: 414]
  ------------------
   51|  2.40M|    uint16_t word =
   52|  2.40M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (52:9): [True: 2.40M, Folded]
  ------------------
   53|  2.40M|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (53:9): [True: 2.39M, False: 10.3k]
  ------------------
   54|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   55|  2.39M|      *utf32_output++ = char32_t(word);
   56|  2.39M|      pos++;
   57|  2.39M|    } else {
   58|       |      // must be a surrogate pair
   59|  10.3k|      uint16_t diff = uint16_t(word - 0xD800);
   60|  10.3k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (60:11): [True: 116, False: 10.2k]
  ------------------
   61|    116|        return result(error_code::SURROGATE, pos);
   62|    116|      }
   63|  10.2k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (63:11): [True: 78, False: 10.1k]
  ------------------
   64|     78|        return result(error_code::SURROGATE, pos);
   65|     78|      } // minimal bound checking
   66|  10.1k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (66:28): [True: 10.1k, Folded]
  ------------------
   67|  10.1k|                               ? u16_swap_bytes(data[pos + 1])
   68|  10.1k|                               : data[pos + 1];
   69|  10.1k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   70|  10.1k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (70:11): [True: 150, False: 9.99k]
  ------------------
   71|    150|        return result(error_code::SURROGATE, pos);
   72|    150|      }
   73|  9.99k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   74|  9.99k|      *utf32_output++ = char32_t(value);
   75|  9.99k|      pos += 2;
   76|  9.99k|    }
   77|  2.40M|  }
   78|    414|  return result(error_code::SUCCESS, utf32_output - start);
   79|    758|}

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

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf87convertILNS_10endiannessE0EPKDsPcQsr7simdutf6detailE18indexes_into_utf16IT0_EEEmS8_mT1_:
   17|  1.88k|                                   OutputPtr utf8_output) {
   18|  1.88k|  size_t pos = 0;
   19|  1.88k|  const auto start = utf8_output;
   20|  3.43M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 3.43M, False: 1.51k]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  3.43M|    {
   25|       |      // try to convert the next block of 8 bytes
   26|  3.43M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (26:11): [True: 3.43M, False: 3.43k]
  ------------------
   27|       |                            // they are ascii
   28|  3.43M|        uint64_t v;
   29|  3.43M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   30|       |        if constexpr (!match_system(big_endian)) {
   31|       |          v = (v >> 8) | (v << (64 - 8));
   32|       |        }
   33|  3.43M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (33:13): [True: 1.54M, False: 1.88M]
  ------------------
   34|  1.54M|          size_t final_pos = pos + 4;
   35|  7.74M|          while (pos < final_pos) {
  ------------------
  |  Branch (35:18): [True: 6.19M, False: 1.54M]
  ------------------
   36|  6.19M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (36:30): [Folded, False: 6.19M]
  ------------------
   37|  6.19M|                                 ? char(u16_swap_bytes(data[pos]))
   38|  6.19M|                                 : char(data[pos]);
   39|  6.19M|            pos++;
   40|  6.19M|          }
   41|  1.54M|          continue;
   42|  1.54M|        }
   43|  3.43M|      }
   44|  3.43M|    }
   45|  1.88M|    uint16_t word =
   46|  1.88M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (46:9): [Folded, False: 1.88M]
  ------------------
   47|  1.88M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (47:9): [True: 162k, False: 1.72M]
  ------------------
   48|       |      // will generate one UTF-8 bytes
   49|   162k|      *utf8_output++ = char(word);
   50|   162k|      pos++;
   51|  1.72M|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (51:16): [True: 1.41M, False: 308k]
  ------------------
   52|       |      // will generate two UTF-8 bytes
   53|       |      // we have 0b110XXXXX 0b10XXXXXX
   54|  1.41M|      *utf8_output++ = char((word >> 6) | 0b11000000);
   55|  1.41M|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   56|  1.41M|      pos++;
   57|  1.41M|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (57:16): [True: 302k, False: 6.16k]
  ------------------
   58|       |      // will generate three UTF-8 bytes
   59|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   60|   302k|      *utf8_output++ = char((word >> 12) | 0b11100000);
   61|   302k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   62|   302k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   63|   302k|      pos++;
   64|   302k|    } else {
   65|       |      // must be a surrogate pair
   66|  6.16k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (66:11): [True: 66, False: 6.10k]
  ------------------
   67|     66|        return 0;
   68|     66|      }
   69|  6.10k|      uint16_t diff = uint16_t(word - 0xD800);
   70|  6.10k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (70:11): [True: 104, False: 5.99k]
  ------------------
   71|    104|        return 0;
   72|    104|      }
   73|  5.99k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (73:28): [Folded, False: 5.99k]
  ------------------
   74|  5.99k|                               ? u16_swap_bytes(data[pos + 1])
   75|  5.99k|                               : data[pos + 1];
   76|  5.99k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   77|  5.99k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (77:11): [True: 200, False: 5.79k]
  ------------------
   78|    200|        return 0;
   79|    200|      }
   80|  5.79k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   81|       |      // will generate four UTF-8 bytes
   82|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   83|  5.79k|      *utf8_output++ = char((value >> 18) | 0b11110000);
   84|  5.79k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
   85|  5.79k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
   86|  5.79k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
   87|  5.79k|      pos += 2;
   88|  5.79k|    }
   89|  1.88M|  }
   90|  1.51k|  return utf8_output - start;
   91|  1.88k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf87convertILNS_10endiannessE1EPKDsPcQsr7simdutf6detailE18indexes_into_utf16IT0_EEEmS8_mT1_:
   17|  1.73k|                                   OutputPtr utf8_output) {
   18|  1.73k|  size_t pos = 0;
   19|  1.73k|  const auto start = utf8_output;
   20|  3.01M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 3.01M, False: 1.45k]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  3.01M|    {
   25|       |      // try to convert the next block of 8 bytes
   26|  3.01M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (26:11): [True: 3.00M, False: 3.20k]
  ------------------
   27|       |                            // they are ascii
   28|  3.00M|        uint64_t v;
   29|  3.00M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   30|  3.00M|        if constexpr (!match_system(big_endian)) {
   31|  3.00M|          v = (v >> 8) | (v << (64 - 8));
   32|  3.00M|        }
   33|  3.00M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (33:13): [True: 1.10M, False: 1.90M]
  ------------------
   34|  1.10M|          size_t final_pos = pos + 4;
   35|  5.50M|          while (pos < final_pos) {
  ------------------
  |  Branch (35:18): [True: 4.40M, False: 1.10M]
  ------------------
   36|  4.40M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (36:30): [True: 4.40M, Folded]
  ------------------
   37|  4.40M|                                 ? char(u16_swap_bytes(data[pos]))
   38|  4.40M|                                 : char(data[pos]);
   39|  4.40M|            pos++;
   40|  4.40M|          }
   41|  1.10M|          continue;
   42|  1.10M|        }
   43|  3.00M|      }
   44|  3.01M|    }
   45|  1.91M|    uint16_t word =
   46|  1.91M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (46:9): [True: 1.91M, Folded]
  ------------------
   47|  1.91M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (47:9): [True: 80.0k, False: 1.83M]
  ------------------
   48|       |      // will generate one UTF-8 bytes
   49|  80.0k|      *utf8_output++ = char(word);
   50|  80.0k|      pos++;
   51|  1.83M|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (51:16): [True: 28.8k, False: 1.80M]
  ------------------
   52|       |      // will generate two UTF-8 bytes
   53|       |      // we have 0b110XXXXX 0b10XXXXXX
   54|  28.8k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   55|  28.8k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   56|  28.8k|      pos++;
   57|  1.80M|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (57:16): [True: 1.79M, False: 3.05k]
  ------------------
   58|       |      // will generate three UTF-8 bytes
   59|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   60|  1.79M|      *utf8_output++ = char((word >> 12) | 0b11100000);
   61|  1.79M|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   62|  1.79M|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   63|  1.79M|      pos++;
   64|  1.79M|    } else {
   65|       |      // must be a surrogate pair
   66|  3.05k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (66:11): [True: 30, False: 3.02k]
  ------------------
   67|     30|        return 0;
   68|     30|      }
   69|  3.02k|      uint16_t diff = uint16_t(word - 0xD800);
   70|  3.02k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (70:11): [True: 126, False: 2.89k]
  ------------------
   71|    126|        return 0;
   72|    126|      }
   73|  2.89k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (73:28): [True: 2.89k, Folded]
  ------------------
   74|  2.89k|                               ? u16_swap_bytes(data[pos + 1])
   75|  2.89k|                               : data[pos + 1];
   76|  2.89k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   77|  2.89k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (77:11): [True: 128, False: 2.77k]
  ------------------
   78|    128|        return 0;
   79|    128|      }
   80|  2.77k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   81|       |      // will generate four UTF-8 bytes
   82|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   83|  2.77k|      *utf8_output++ = char((value >> 18) | 0b11110000);
   84|  2.77k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
   85|  2.77k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
   86|  2.77k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
   87|  2.77k|      pos += 2;
   88|  2.77k|    }
   89|  1.91M|  }
   90|  1.45k|  return utf8_output - start;
   91|  1.73k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf819convert_with_errorsILNS_10endiannessE0ELb0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT1_Esr7simdutf6detailE26index_assignable_from_charIT2_EEENS_11full_resultES8_mS9_m:
  101|  1.61k|                                                    size_t utf8_len = 0) {
  102|  1.61k|  if (check_output && utf8_len == 0) {
  ------------------
  |  Branch (102:7): [Folded, False: 1.61k]
  |  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.61k|  size_t pos = 0;
  107|  1.61k|  auto start = utf8_output;
  108|  1.61k|  auto end = utf8_output + utf8_len;
  109|       |
  110|  6.34M|  while (pos < len) {
  ------------------
  |  Branch (110:10): [True: 6.34M, False: 1.19k]
  ------------------
  111|       |#if SIMDUTF_CPLUSPLUS23
  112|       |    if !consteval
  113|       |#endif
  114|  6.34M|    {
  115|       |      // try to convert the next block of 8 bytes
  116|  6.34M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (116:11): [True: 6.34M, False: 2.70k]
  ------------------
  117|       |                            // they are ascii
  118|  6.34M|        uint64_t v;
  119|  6.34M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
  120|       |        if constexpr (!match_system(big_endian))
  121|       |          v = (v >> 8) | (v << (64 - 8));
  122|  6.34M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (122:13): [True: 1.33M, False: 5.00M]
  ------------------
  123|  1.33M|          size_t final_pos = pos + 4;
  124|  6.67M|          while (pos < final_pos) {
  ------------------
  |  Branch (124:18): [True: 5.34M, False: 1.33M]
  ------------------
  125|  5.34M|            if (check_output && size_t(end - utf8_output) < 1) {
  ------------------
  |  Branch (125:17): [Folded, False: 5.34M]
  |  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|  5.34M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (129:30): [Folded, False: 5.34M]
  ------------------
  130|  5.34M|                                 ? char(u16_swap_bytes(data[pos]))
  131|  5.34M|                                 : char(data[pos]);
  132|  5.34M|            pos++;
  133|  5.34M|          }
  134|  1.33M|          continue;
  135|  1.33M|        }
  136|  6.34M|      }
  137|  6.34M|    }
  138|       |
  139|  5.00M|    uint16_t word =
  140|  5.00M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (140:9): [Folded, False: 5.00M]
  ------------------
  141|  5.00M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (141:9): [True: 208k, False: 4.80M]
  ------------------
  142|       |      // will generate one UTF-8 bytes
  143|   208k|      if (check_output && size_t(end - utf8_output) < 1) {
  ------------------
  |  Branch (143:11): [Folded, False: 208k]
  |  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|   208k|      *utf8_output++ = char(word);
  148|   208k|      pos++;
  149|  4.80M|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (149:16): [True: 967k, False: 3.83M]
  ------------------
  150|       |      // will generate two UTF-8 bytes
  151|       |      // we have 0b110XXXXX 0b10XXXXXX
  152|   967k|      if (check_output && size_t(end - utf8_output) < 2) {
  ------------------
  |  Branch (152:11): [Folded, False: 967k]
  |  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|   967k|      *utf8_output++ = char((word >> 6) | 0b11000000);
  157|   967k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  158|   967k|      pos++;
  159|       |
  160|  3.83M|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (160:16): [True: 3.83M, False: 3.71k]
  ------------------
  161|       |      // will generate three UTF-8 bytes
  162|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
  163|  3.83M|      if (check_output && size_t(end - utf8_output) < 3) {
  ------------------
  |  Branch (163:11): [Folded, False: 3.83M]
  |  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.83M|      *utf8_output++ = char((word >> 12) | 0b11100000);
  168|  3.83M|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  169|  3.83M|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  170|  3.83M|      pos++;
  171|  3.83M|    } else {
  172|       |
  173|  3.71k|      if (check_output && size_t(end - utf8_output) < 4) {
  ------------------
  |  Branch (173:11): [Folded, False: 3.71k]
  |  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.71k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (178:11): [True: 36, False: 3.67k]
  ------------------
  179|     36|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  180|     36|      }
  181|  3.67k|      uint16_t diff = uint16_t(word - 0xD800);
  182|  3.67k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (182:11): [True: 126, False: 3.55k]
  ------------------
  183|    126|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  184|    126|      }
  185|  3.55k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (185:28): [Folded, False: 3.55k]
  ------------------
  186|  3.55k|                               ? u16_swap_bytes(data[pos + 1])
  187|  3.55k|                               : data[pos + 1];
  188|  3.55k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
  189|  3.55k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (189:11): [True: 254, False: 3.29k]
  ------------------
  190|    254|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  191|    254|      }
  192|  3.29k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
  193|       |      // will generate four UTF-8 bytes
  194|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
  195|  3.29k|      *utf8_output++ = char((value >> 18) | 0b11110000);
  196|  3.29k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  197|  3.29k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  198|  3.29k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
  199|  3.29k|      pos += 2;
  200|  3.29k|    }
  201|  5.00M|  }
  202|  1.19k|  return full_result(error_code::SUCCESS, pos, utf8_output - start);
  203|  1.61k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf819convert_with_errorsILNS_10endiannessE1ELb0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT1_Esr7simdutf6detailE26index_assignable_from_charIT2_EEENS_11full_resultES8_mS9_m:
  101|  1.61k|                                                    size_t utf8_len = 0) {
  102|  1.61k|  if (check_output && utf8_len == 0) {
  ------------------
  |  Branch (102:7): [Folded, False: 1.61k]
  |  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.61k|  size_t pos = 0;
  107|  1.61k|  auto start = utf8_output;
  108|  1.61k|  auto end = utf8_output + utf8_len;
  109|       |
  110|  2.77M|  while (pos < len) {
  ------------------
  |  Branch (110:10): [True: 2.77M, False: 1.13k]
  ------------------
  111|       |#if SIMDUTF_CPLUSPLUS23
  112|       |    if !consteval
  113|       |#endif
  114|  2.77M|    {
  115|       |      // try to convert the next block of 8 bytes
  116|  2.77M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (116:11): [True: 2.77M, False: 2.46k]
  ------------------
  117|       |                            // they are ascii
  118|  2.77M|        uint64_t v;
  119|  2.77M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
  120|       |        if constexpr (!match_system(big_endian))
  121|  2.77M|          v = (v >> 8) | (v << (64 - 8));
  122|  2.77M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (122:13): [True: 1.66M, False: 1.10M]
  ------------------
  123|  1.66M|          size_t final_pos = pos + 4;
  124|  8.34M|          while (pos < final_pos) {
  ------------------
  |  Branch (124:18): [True: 6.67M, False: 1.66M]
  ------------------
  125|  6.67M|            if (check_output && size_t(end - utf8_output) < 1) {
  ------------------
  |  Branch (125:17): [Folded, False: 6.67M]
  |  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|  6.67M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (129:30): [True: 6.67M, Folded]
  ------------------
  130|  6.67M|                                 ? char(u16_swap_bytes(data[pos]))
  131|  6.67M|                                 : char(data[pos]);
  132|  6.67M|            pos++;
  133|  6.67M|          }
  134|  1.66M|          continue;
  135|  1.66M|        }
  136|  2.77M|      }
  137|  2.77M|    }
  138|       |
  139|  1.10M|    uint16_t word =
  140|  1.10M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (140:9): [True: 1.10M, Folded]
  ------------------
  141|  1.10M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (141:9): [True: 289k, False: 816k]
  ------------------
  142|       |      // will generate one UTF-8 bytes
  143|   289k|      if (check_output && size_t(end - utf8_output) < 1) {
  ------------------
  |  Branch (143:11): [Folded, False: 289k]
  |  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|   289k|      *utf8_output++ = char(word);
  148|   289k|      pos++;
  149|   816k|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (149:16): [True: 127k, False: 689k]
  ------------------
  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|   689k|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (160:16): [True: 679k, False: 9.39k]
  ------------------
  161|       |      // will generate three UTF-8 bytes
  162|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
  163|   679k|      if (check_output && size_t(end - utf8_output) < 3) {
  ------------------
  |  Branch (163:11): [Folded, False: 679k]
  |  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|   679k|      *utf8_output++ = char((word >> 12) | 0b11100000);
  168|   679k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  169|   679k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  170|   679k|      pos++;
  171|   679k|    } else {
  172|       |
  173|  9.39k|      if (check_output && size_t(end - utf8_output) < 4) {
  ------------------
  |  Branch (173:11): [Folded, False: 9.39k]
  |  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|  9.39k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (178:11): [True: 48, False: 9.34k]
  ------------------
  179|     48|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  180|     48|      }
  181|  9.34k|      uint16_t diff = uint16_t(word - 0xD800);
  182|  9.34k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (182:11): [True: 176, False: 9.16k]
  ------------------
  183|    176|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  184|    176|      }
  185|  9.16k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (185:28): [True: 9.16k, Folded]
  ------------------
  186|  9.16k|                               ? u16_swap_bytes(data[pos + 1])
  187|  9.16k|                               : data[pos + 1];
  188|  9.16k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
  189|  9.16k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (189:11): [True: 254, False: 8.91k]
  ------------------
  190|    254|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  191|    254|      }
  192|  8.91k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
  193|       |      // will generate four UTF-8 bytes
  194|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
  195|  8.91k|      *utf8_output++ = char((value >> 18) | 0b11110000);
  196|  8.91k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  197|  8.91k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  198|  8.91k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
  199|  8.91k|      pos += 2;
  200|  8.91k|    }
  201|  1.10M|  }
  202|  1.13k|  return full_result(error_code::SUCCESS, pos, utf8_output - start);
  203|  1.61k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf813convert_validILNS_10endiannessE0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEEmS8_mS9_:
   17|    406|                                         OutputPtr utf8_output) {
   18|    406|  size_t pos = 0;
   19|    406|  auto start = utf8_output;
   20|  2.03M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 2.03M, False: 406]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  2.03M|    {
   25|       |      // try to convert the next block of 4 ASCII characters
   26|  2.03M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (26:11): [True: 2.03M, False: 842]
  ------------------
   27|       |                            // they are ascii
   28|  2.03M|        uint64_t v;
   29|  2.03M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   30|       |        if constexpr (!match_system(big_endian)) {
   31|       |          v = (v >> 8) | (v << (64 - 8));
   32|       |        }
   33|  2.03M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (33:13): [True: 1.54M, False: 489k]
  ------------------
   34|  1.54M|          size_t final_pos = pos + 4;
   35|  7.74M|          while (pos < final_pos) {
  ------------------
  |  Branch (35:18): [True: 6.19M, False: 1.54M]
  ------------------
   36|  6.19M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (36:30): [Folded, False: 6.19M]
  ------------------
   37|  6.19M|                                 ? char(u16_swap_bytes(data[pos]))
   38|  6.19M|                                 : char(data[pos]);
   39|  6.19M|            pos++;
   40|  6.19M|          }
   41|  1.54M|          continue;
   42|  1.54M|        }
   43|  2.03M|      }
   44|  2.03M|    }
   45|       |
   46|   490k|    uint16_t word =
   47|   490k|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (47:9): [Folded, False: 490k]
  ------------------
   48|   490k|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (48:9): [True: 261k, False: 228k]
  ------------------
   49|       |      // will generate one UTF-8 bytes
   50|   261k|      *utf8_output++ = char(word);
   51|   261k|      pos++;
   52|   261k|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (52:16): [True: 77.4k, False: 151k]
  ------------------
   53|       |      // will generate two UTF-8 bytes
   54|       |      // we have 0b110XXXXX 0b10XXXXXX
   55|  77.4k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   56|  77.4k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   57|  77.4k|      pos++;
   58|   151k|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (58:16): [True: 148k, False: 2.60k]
  ------------------
   59|       |      // will generate three UTF-8 bytes
   60|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   61|   148k|      *utf8_output++ = char((word >> 12) | 0b11100000);
   62|   148k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   63|   148k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   64|   148k|      pos++;
   65|   148k|    } else {
   66|       |      // must be a surrogate pair
   67|  2.60k|      uint16_t diff = uint16_t(word - 0xD800);
   68|  2.60k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (68:11): [True: 0, False: 2.60k]
  ------------------
   69|      0|        return 0;
   70|      0|      } // minimal bound checking
   71|  2.60k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (71:28): [Folded, False: 2.60k]
  ------------------
   72|  2.60k|                               ? u16_swap_bytes(data[pos + 1])
   73|  2.60k|                               : data[pos + 1];
   74|  2.60k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   75|  2.60k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   76|       |      // will generate four UTF-8 bytes
   77|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   78|  2.60k|      *utf8_output++ = char((value >> 18) | 0b11110000);
   79|  2.60k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
   80|  2.60k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
   81|  2.60k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
   82|  2.60k|      pos += 2;
   83|  2.60k|    }
   84|   490k|  }
   85|    406|  return utf8_output - start;
   86|    406|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf813convert_validILNS_10endiannessE1EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEEmS8_mS9_:
   17|    452|                                         OutputPtr utf8_output) {
   18|    452|  size_t pos = 0;
   19|    452|  auto start = utf8_output;
   20|  3.13M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 3.13M, False: 452]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  3.13M|    {
   25|       |      // try to convert the next block of 4 ASCII characters
   26|  3.13M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (26:11): [True: 3.13M, False: 940]
  ------------------
   27|       |                            // they are ascii
   28|  3.13M|        uint64_t v;
   29|  3.13M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   30|  3.13M|        if constexpr (!match_system(big_endian)) {
   31|  3.13M|          v = (v >> 8) | (v << (64 - 8));
   32|  3.13M|        }
   33|  3.13M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (33:13): [True: 1.95M, False: 1.17M]
  ------------------
   34|  1.95M|          size_t final_pos = pos + 4;
   35|  9.77M|          while (pos < final_pos) {
  ------------------
  |  Branch (35:18): [True: 7.82M, False: 1.95M]
  ------------------
   36|  7.82M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (36:30): [True: 7.82M, Folded]
  ------------------
   37|  7.82M|                                 ? char(u16_swap_bytes(data[pos]))
   38|  7.82M|                                 : char(data[pos]);
   39|  7.82M|            pos++;
   40|  7.82M|          }
   41|  1.95M|          continue;
   42|  1.95M|        }
   43|  3.13M|      }
   44|  3.13M|    }
   45|       |
   46|  1.17M|    uint16_t word =
   47|  1.17M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (47:9): [True: 1.17M, Folded]
  ------------------
   48|  1.17M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (48:9): [True: 319k, False: 860k]
  ------------------
   49|       |      // will generate one UTF-8 bytes
   50|   319k|      *utf8_output++ = char(word);
   51|   319k|      pos++;
   52|   860k|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (52:16): [True: 98.9k, False: 761k]
  ------------------
   53|       |      // will generate two UTF-8 bytes
   54|       |      // we have 0b110XXXXX 0b10XXXXXX
   55|  98.9k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   56|  98.9k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   57|  98.9k|      pos++;
   58|   761k|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (58:16): [True: 759k, False: 2.80k]
  ------------------
   59|       |      // will generate three UTF-8 bytes
   60|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   61|   759k|      *utf8_output++ = char((word >> 12) | 0b11100000);
   62|   759k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   63|   759k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   64|   759k|      pos++;
   65|   759k|    } else {
   66|       |      // must be a surrogate pair
   67|  2.80k|      uint16_t diff = uint16_t(word - 0xD800);
   68|  2.80k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (68:11): [True: 0, False: 2.80k]
  ------------------
   69|      0|        return 0;
   70|      0|      } // minimal bound checking
   71|  2.80k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (71:28): [True: 2.80k, Folded]
  ------------------
   72|  2.80k|                               ? u16_swap_bytes(data[pos + 1])
   73|  2.80k|                               : data[pos + 1];
   74|  2.80k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   75|  2.80k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   76|       |      // will generate four UTF-8 bytes
   77|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   78|  2.80k|      *utf8_output++ = char((value >> 18) | 0b11110000);
   79|  2.80k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
   80|  2.80k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
   81|  2.80k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
   82|  2.80k|      pos += 2;
   83|  2.80k|    }
   84|  1.17M|  }
   85|    452|  return utf8_output - start;
   86|    452|}

_ZN7simdutf6scalar5utf328validateEPKDim:
   25|  5.67k|                                                        size_t len) noexcept {
   26|  5.67k|  return validate(reinterpret_cast<const uint32_t *>(buf), len);
   27|  5.67k|}
_ZN7simdutf6scalar5utf3220validate_with_errorsEPKDim:
   49|  7.86k|validate_with_errors(const char32_t *buf, size_t len) noexcept {
   50|  7.86k|  return validate_with_errors(reinterpret_cast<const uint32_t *>(buf), len);
   51|  7.86k|}
_ZN7simdutf6scalar5utf3222utf8_length_from_utf32EPKDim:
   54|  2.58k|                                                         size_t len) {
   55|       |  // We are not BOM aware.
   56|  2.58k|  size_t counter{0};
   57|  2.79M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (57:22): [True: 2.79M, False: 2.58k]
  ------------------
   58|       |    // credit: @ttsugriy  for the vectorizable approach
   59|  2.79M|    counter++;                                     // ASCII
   60|  2.79M|    counter += static_cast<size_t>(p[i] > 0x7F);   // two-byte
   61|  2.79M|    counter += static_cast<size_t>(p[i] > 0x7FF);  // three-byte
   62|  2.79M|    counter += static_cast<size_t>(p[i] > 0xFFFF); // four-bytes
   63|  2.79M|  }
   64|  2.58k|  return counter;
   65|  2.58k|}
_ZN7simdutf6scalar5utf3223utf16_length_from_utf32EPKDim:
   68|  4.32k|utf16_length_from_utf32(const char32_t *p, size_t len) {
   69|       |  // We are not BOM aware.
   70|  4.32k|  size_t counter{0};
   71|  4.66M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (71:22): [True: 4.65M, False: 4.32k]
  ------------------
   72|  4.65M|    counter++;                                     // non-surrogate word
   73|  4.65M|    counter += static_cast<size_t>(p[i] > 0xFFFF); // surrogate pair
   74|  4.65M|  }
   75|  4.32k|  return counter;
   76|  4.32k|}
_ZN7simdutf6scalar5utf328validateIPKjQsr7simdutf6detailE19indexes_into_uint32IT_EEEbS5_m:
   13|  5.67k|                                                      size_t len) noexcept {
   14|  5.67k|  uint64_t pos = 0;
   15|  1.99M|  for (; pos < len; pos++) {
  ------------------
  |  Branch (15:10): [True: 1.99M, False: 2.50k]
  ------------------
   16|  1.99M|    uint32_t word = data[pos];
   17|  1.99M|    if (word > 0x10FFFF || (word >= 0xD800 && word <= 0xDFFF)) {
  ------------------
  |  Branch (17:9): [True: 2.74k, False: 1.99M]
  |  Branch (17:29): [True: 40.8k, False: 1.95M]
  |  Branch (17:47): [True: 435, False: 40.4k]
  ------------------
   18|  3.17k|      return false;
   19|  3.17k|    }
   20|  1.99M|  }
   21|  2.50k|  return true;
   22|  5.67k|}
_ZN7simdutf6scalar5utf3220validate_with_errorsIPKjQsr7simdutf6detailE19indexes_into_uint32IT_EEENS_6resultES5_m:
   34|  7.86k|validate_with_errors(InputPtr data, size_t len) noexcept {
   35|  7.86k|  size_t pos = 0;
   36|  2.00M|  for (; pos < len; pos++) {
  ------------------
  |  Branch (36:10): [True: 2.00M, False: 2.50k]
  ------------------
   37|  2.00M|    uint32_t word = data[pos];
   38|  2.00M|    if (word > 0x10FFFF) {
  ------------------
  |  Branch (38:9): [True: 4.52k, False: 1.99M]
  ------------------
   39|  4.52k|      return result(error_code::TOO_LARGE, pos);
   40|  4.52k|    }
   41|  1.99M|    if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (41:9): [True: 42.2k, False: 1.95M]
  |  Branch (41:27): [True: 834, False: 41.4k]
  ------------------
   42|    834|      return result(error_code::SURROGATE, pos);
   43|    834|    }
   44|  1.99M|  }
   45|  2.50k|  return result(error_code::SUCCESS, pos);
   46|  7.86k|}

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

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf167convertILNS_10endiannessE0EEEmPKDimPDs:
   11|  1.91k|                                   char16_t *utf16_output) {
   12|  1.91k|  size_t pos = 0;
   13|  1.91k|  char16_t *start{utf16_output};
   14|   670k|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 669k, False: 1.00k]
  ------------------
   15|   669k|    uint32_t word = data[pos];
   16|   669k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (16:9): [True: 665k, False: 3.73k]
  ------------------
   17|   665k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (17:11): [True: 1.80k, False: 663k]
  |  Branch (17:29): [True: 218, False: 1.58k]
  ------------------
   18|    218|        return 0;
   19|    218|      }
   20|       |      // will not generate a surrogate pair
   21|   665k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (21:25): [Folded, False: 665k]
  ------------------
   22|   665k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   23|   665k|                            : char16_t(word);
   24|   665k|    } else {
   25|       |      // will generate a surrogate pair
   26|  3.73k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (26:11): [True: 694, False: 3.03k]
  ------------------
   27|    694|        return 0;
   28|    694|      }
   29|  3.03k|      word -= 0x10000;
   30|  3.03k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   31|  3.03k|      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|  3.03k|      *utf16_output++ = char16_t(high_surrogate);
   37|  3.03k|      *utf16_output++ = char16_t(low_surrogate);
   38|  3.03k|    }
   39|   668k|    pos++;
   40|   668k|  }
   41|  1.00k|  return utf16_output - start;
   42|  1.91k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf167convertILNS_10endiannessE1EEEmPKDimPDs:
   11|  1.56k|                                   char16_t *utf16_output) {
   12|  1.56k|  size_t pos = 0;
   13|  1.56k|  char16_t *start{utf16_output};
   14|   110k|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 109k, False: 628]
  ------------------
   15|   109k|    uint32_t word = data[pos];
   16|   109k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (16:9): [True: 106k, False: 2.88k]
  ------------------
   17|   106k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (17:11): [True: 1.10k, False: 105k]
  |  Branch (17:29): [True: 166, False: 940]
  ------------------
   18|    166|        return 0;
   19|    166|      }
   20|       |      // will not generate a surrogate pair
   21|   106k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (21:25): [True: 106k, Folded]
  ------------------
   22|   106k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   23|   106k|                            : char16_t(word);
   24|   106k|    } else {
   25|       |      // will generate a surrogate pair
   26|  2.88k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (26:11): [True: 772, False: 2.10k]
  ------------------
   27|    772|        return 0;
   28|    772|      }
   29|  2.10k|      word -= 0x10000;
   30|  2.10k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   31|  2.10k|      uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   32|  2.10k|      if constexpr (!match_system(big_endian)) {
   33|  2.10k|        high_surrogate = u16_swap_bytes(high_surrogate);
   34|  2.10k|        low_surrogate = u16_swap_bytes(low_surrogate);
   35|  2.10k|      }
   36|  2.10k|      *utf16_output++ = char16_t(high_surrogate);
   37|  2.10k|      *utf16_output++ = char16_t(low_surrogate);
   38|  2.10k|    }
   39|   108k|    pos++;
   40|   108k|  }
   41|    628|  return utf16_output - start;
   42|  1.56k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf1619convert_with_errorsILNS_10endiannessE0EEENS_6resultEPKDimPDs:
   46|  1.99k|                                               char16_t *utf16_output) {
   47|  1.99k|  size_t pos = 0;
   48|  1.99k|  char16_t *start{utf16_output};
   49|   547k|  while (pos < len) {
  ------------------
  |  Branch (49:10): [True: 546k, False: 484]
  ------------------
   50|   546k|    uint32_t word = data[pos];
   51|   546k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (51:9): [True: 539k, False: 7.21k]
  ------------------
   52|   539k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (52:11): [True: 1.52k, False: 538k]
  |  Branch (52:29): [True: 240, False: 1.28k]
  ------------------
   53|    240|        return result(error_code::SURROGATE, pos);
   54|    240|      }
   55|       |      // will not generate a surrogate pair
   56|   539k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (56:25): [Folded, False: 539k]
  ------------------
   57|   539k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   58|   539k|                            : char16_t(word);
   59|   539k|    } else {
   60|       |      // will generate a surrogate pair
   61|  7.21k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (61:11): [True: 1.27k, False: 5.94k]
  ------------------
   62|  1.27k|        return result(error_code::TOO_LARGE, pos);
   63|  1.27k|      }
   64|  5.94k|      word -= 0x10000;
   65|  5.94k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   66|  5.94k|      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|  5.94k|      *utf16_output++ = char16_t(high_surrogate);
   72|  5.94k|      *utf16_output++ = char16_t(low_surrogate);
   73|  5.94k|    }
   74|   545k|    pos++;
   75|   545k|  }
   76|    484|  return result(error_code::SUCCESS, utf16_output - start);
   77|  1.99k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf1619convert_with_errorsILNS_10endiannessE1EEENS_6resultEPKDimPDs:
   46|  2.05k|                                               char16_t *utf16_output) {
   47|  2.05k|  size_t pos = 0;
   48|  2.05k|  char16_t *start{utf16_output};
   49|  37.3k|  while (pos < len) {
  ------------------
  |  Branch (49:10): [True: 36.8k, False: 518]
  ------------------
   50|  36.8k|    uint32_t word = data[pos];
   51|  36.8k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (51:9): [True: 31.9k, False: 4.92k]
  ------------------
   52|  31.9k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (52:11): [True: 1.83k, False: 30.0k]
  |  Branch (52:29): [True: 240, False: 1.59k]
  ------------------
   53|    240|        return result(error_code::SURROGATE, pos);
   54|    240|      }
   55|       |      // will not generate a surrogate pair
   56|  31.6k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (56:25): [True: 31.6k, Folded]
  ------------------
   57|  31.6k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   58|  31.6k|                            : char16_t(word);
   59|  31.6k|    } else {
   60|       |      // will generate a surrogate pair
   61|  4.92k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (61:11): [True: 1.29k, False: 3.63k]
  ------------------
   62|  1.29k|        return result(error_code::TOO_LARGE, pos);
   63|  1.29k|      }
   64|  3.63k|      word -= 0x10000;
   65|  3.63k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   66|  3.63k|      uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   67|  3.63k|      if constexpr (!match_system(big_endian)) {
   68|  3.63k|        high_surrogate = u16_swap_bytes(high_surrogate);
   69|  3.63k|        low_surrogate = u16_swap_bytes(low_surrogate);
   70|  3.63k|      }
   71|  3.63k|      *utf16_output++ = char16_t(high_surrogate);
   72|  3.63k|      *utf16_output++ = char16_t(low_surrogate);
   73|  3.63k|    }
   74|  35.3k|    pos++;
   75|  35.3k|  }
   76|    518|  return result(error_code::SUCCESS, utf16_output - start);
   77|  2.05k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf1613convert_validILNS_10endiannessE0EEEmPKDimPDs:
   11|    280|                                         char16_t *utf16_output) {
   12|    280|  size_t pos = 0;
   13|    280|  char16_t *start{utf16_output};
   14|   547k|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 546k, False: 280]
  ------------------
   15|   546k|    uint32_t word = data[pos];
   16|   546k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (16:9): [True: 526k, False: 20.2k]
  ------------------
   17|       |      // will not generate a surrogate pair
   18|   526k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (18:25): [Folded, False: 526k]
  ------------------
   19|   526k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   20|   526k|                            : char16_t(word);
   21|   526k|      pos++;
   22|   526k|    } else {
   23|       |      // will generate a surrogate pair
   24|  20.2k|      word -= 0x10000;
   25|  20.2k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   26|  20.2k|      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|  20.2k|      *utf16_output++ = char16_t(high_surrogate);
   32|  20.2k|      *utf16_output++ = char16_t(low_surrogate);
   33|  20.2k|      pos++;
   34|  20.2k|    }
   35|   546k|  }
   36|    280|  return utf16_output - start;
   37|    280|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf1613convert_validILNS_10endiannessE1EEEmPKDimPDs:
   11|    134|                                         char16_t *utf16_output) {
   12|    134|  size_t pos = 0;
   13|    134|  char16_t *start{utf16_output};
   14|  32.5k|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 32.3k, False: 134]
  ------------------
   15|  32.3k|    uint32_t word = data[pos];
   16|  32.3k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (16:9): [True: 11.6k, False: 20.7k]
  ------------------
   17|       |      // will not generate a surrogate pair
   18|  11.6k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (18:25): [True: 11.6k, Folded]
  ------------------
   19|  11.6k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   20|  11.6k|                            : char16_t(word);
   21|  11.6k|      pos++;
   22|  20.7k|    } else {
   23|       |      // will generate a surrogate pair
   24|  20.7k|      word -= 0x10000;
   25|  20.7k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   26|  20.7k|      uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   27|  20.7k|      if constexpr (!match_system(big_endian)) {
   28|  20.7k|        high_surrogate = u16_swap_bytes(high_surrogate);
   29|  20.7k|        low_surrogate = u16_swap_bytes(low_surrogate);
   30|  20.7k|      }
   31|  20.7k|      *utf16_output++ = char16_t(high_surrogate);
   32|  20.7k|      *utf16_output++ = char16_t(low_surrogate);
   33|  20.7k|      pos++;
   34|  20.7k|    }
   35|  32.3k|  }
   36|    134|  return utf16_output - start;
   37|    134|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf32_to_utf87convertIPKDiPcQaasr7simdutf6detailE18indexes_into_utf32IT_Esr7simdutf6detailE26index_assignable_from_charIT0_EEEmS7_mS8_:
   17|  1.81k|                                   OutputPtr utf8_output) {
   18|  1.81k|  size_t pos = 0;
   19|  1.81k|  auto start = utf8_output;
   20|   263k|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 263k, False: 716]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|   263k|    { // try to convert the next block of 2 ASCII characters
   25|   263k|      if (pos + 2 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 262k, False: 952]
  ------------------
   26|       |                            // they are ascii
   27|   262k|        uint64_t v;
   28|   262k|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   29|   262k|        if ((v & 0xFFFFFF80FFFFFF80) == 0) {
  ------------------
  |  Branch (29:13): [True: 242k, False: 19.7k]
  ------------------
   30|   242k|          *utf8_output++ = char(data[pos]);
   31|   242k|          *utf8_output++ = char(data[pos + 1]);
   32|   242k|          pos += 2;
   33|   242k|          continue;
   34|   242k|        }
   35|   262k|      }
   36|   263k|    }
   37|       |
   38|  20.6k|    uint32_t word = data[pos];
   39|  20.6k|    if ((word & 0xFFFFFF80) == 0) {
  ------------------
  |  Branch (39:9): [True: 3.31k, False: 17.3k]
  ------------------
   40|       |      // will generate one UTF-8 bytes
   41|  3.31k|      *utf8_output++ = char(word);
   42|  3.31k|      pos++;
   43|  17.3k|    } else if ((word & 0xFFFFF800) == 0) {
  ------------------
  |  Branch (43:16): [True: 3.64k, False: 13.6k]
  ------------------
   44|       |      // will generate two UTF-8 bytes
   45|       |      // we have 0b110XXXXX 0b10XXXXXX
   46|  3.64k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   47|  3.64k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   48|  3.64k|      pos++;
   49|  13.6k|    } else if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (49:16): [True: 8.71k, False: 4.98k]
  ------------------
   50|       |      // will generate three UTF-8 bytes
   51|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   52|  8.71k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (52:11): [True: 6.29k, False: 2.42k]
  |  Branch (52:29): [True: 150, False: 6.14k]
  ------------------
   53|    150|        return 0;
   54|    150|      }
   55|  8.56k|      *utf8_output++ = char((word >> 12) | 0b11100000);
   56|  8.56k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   57|  8.56k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   58|  8.56k|      pos++;
   59|  8.56k|    } else {
   60|       |      // will generate four UTF-8 bytes
   61|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   62|  4.98k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (62:11): [True: 946, False: 4.04k]
  ------------------
   63|    946|        return 0;
   64|    946|      }
   65|  4.04k|      *utf8_output++ = char((word >> 18) | 0b11110000);
   66|  4.04k|      *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000);
   67|  4.04k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   68|  4.04k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   69|  4.04k|      pos++;
   70|  4.04k|    }
   71|  20.6k|  }
   72|    716|  return utf8_output - start;
   73|  1.81k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf32_to_utf819convert_with_errorsIPKDiPcQaasr7simdutf6detailE18indexes_into_utf32IT_Esr7simdutf6detailE26index_assignable_from_charIT0_EEENS_6resultES7_mS8_:
   81|  2.48k|                                               OutputPtr utf8_output) {
   82|  2.48k|  size_t pos = 0;
   83|  2.48k|  auto start = utf8_output;
   84|   211k|  while (pos < len) {
  ------------------
  |  Branch (84:10): [True: 210k, False: 634]
  ------------------
   85|       |#if SIMDUTF_CPLUSPLUS23
   86|       |    if !consteval
   87|       |#endif
   88|   210k|    { // try to convert the next block of 2 ASCII characters
   89|   210k|      if (pos + 2 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (89:11): [True: 209k, False: 1.01k]
  ------------------
   90|       |                            // they are ascii
   91|   209k|        uint64_t v;
   92|   209k|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   93|   209k|        if ((v & 0xFFFFFF80FFFFFF80) == 0) {
  ------------------
  |  Branch (93:13): [True: 172k, False: 37.0k]
  ------------------
   94|   172k|          *utf8_output++ = char(data[pos]);
   95|   172k|          *utf8_output++ = char(data[pos + 1]);
   96|   172k|          pos += 2;
   97|   172k|          continue;
   98|   172k|        }
   99|   209k|      }
  100|   210k|    }
  101|       |
  102|  38.0k|    uint32_t word = data[pos];
  103|  38.0k|    if ((word & 0xFFFFFF80) == 0) {
  ------------------
  |  Branch (103:9): [True: 4.44k, False: 33.5k]
  ------------------
  104|       |      // will generate one UTF-8 bytes
  105|  4.44k|      *utf8_output++ = char(word);
  106|  4.44k|      pos++;
  107|  33.5k|    } else if ((word & 0xFFFFF800) == 0) {
  ------------------
  |  Branch (107:16): [True: 16.7k, False: 16.8k]
  ------------------
  108|       |      // will generate two UTF-8 bytes
  109|       |      // we have 0b110XXXXX 0b10XXXXXX
  110|  16.7k|      *utf8_output++ = char((word >> 6) | 0b11000000);
  111|  16.7k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  112|  16.7k|      pos++;
  113|  16.8k|    } else if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (113:16): [True: 10.9k, False: 5.89k]
  ------------------
  114|       |      // will generate three UTF-8 bytes
  115|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
  116|  10.9k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (116:11): [True: 7.67k, False: 3.28k]
  |  Branch (116:29): [True: 318, False: 7.36k]
  ------------------
  117|    318|        return result(error_code::SURROGATE, pos);
  118|    318|      }
  119|  10.6k|      *utf8_output++ = char((word >> 12) | 0b11100000);
  120|  10.6k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  121|  10.6k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  122|  10.6k|      pos++;
  123|  10.6k|    } else {
  124|       |      // will generate four UTF-8 bytes
  125|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
  126|  5.89k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (126:11): [True: 1.53k, False: 4.35k]
  ------------------
  127|  1.53k|        return result(error_code::TOO_LARGE, pos);
  128|  1.53k|      }
  129|  4.35k|      *utf8_output++ = char((word >> 18) | 0b11110000);
  130|  4.35k|      *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000);
  131|  4.35k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  132|  4.35k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  133|  4.35k|      pos++;
  134|  4.35k|    }
  135|  38.0k|  }
  136|    634|  return result(error_code::SUCCESS, utf8_output - start);
  137|  2.48k|}

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

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf88validateEPKcm:
  113|  3.48k|                                                        size_t len) noexcept {
  114|  3.48k|  return validate(reinterpret_cast<const uint8_t *>(buf), len);
  115|  3.48k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf88validateIPKhEEbT_m:
   14|  3.48k|                                                      size_t len) noexcept {
   15|  3.48k|  static_assert(
   16|  3.48k|      std::is_same<typename std::decay<decltype(*data)>::type, uint8_t>::value,
   17|  3.48k|      "dereferencing the data pointer must result in a uint8_t");
   18|  3.48k|  uint64_t pos = 0;
   19|  3.48k|  uint32_t code_point = 0;
   20|  8.88M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 8.88M, False: 619]
  ------------------
   21|  8.88M|    uint64_t next_pos;
   22|       |#if SIMDUTF_CPLUSPLUS23
   23|       |    if !consteval
   24|       |#endif
   25|  8.88M|    { // check if the next 16 bytes are ascii.
   26|  8.88M|      next_pos = pos + 16;
   27|  8.88M|      if (next_pos <= len) { // if it is safe to read 16 more bytes, check
  ------------------
  |  Branch (27:11): [True: 8.88M, False: 3.40k]
  ------------------
   28|       |                             // that they are ascii
   29|  8.88M|        uint64_t v1{};
   30|  8.88M|        std::memcpy(&v1, data + pos, sizeof(uint64_t));
   31|  8.88M|        uint64_t v2{};
   32|  8.88M|        std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   33|  8.88M|        uint64_t v{v1 | v2};
   34|  8.88M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (34:13): [True: 7.67M, False: 1.20M]
  ------------------
   35|  7.67M|          pos = next_pos;
   36|  7.67M|          continue;
   37|  7.67M|        }
   38|  8.88M|      }
   39|  8.88M|    }
   40|       |
   41|  1.21M|    unsigned char byte = data[pos];
   42|       |
   43|  6.16M|    while (byte < 0b10000000) {
  ------------------
  |  Branch (43:12): [True: 4.95M, False: 1.21M]
  ------------------
   44|  4.95M|      if (++pos == len) {
  ------------------
  |  Branch (44:11): [True: 1.10k, False: 4.95M]
  ------------------
   45|  1.10k|        return true;
   46|  1.10k|      }
   47|  4.95M|      byte = data[pos];
   48|  4.95M|    }
   49|       |
   50|  1.21M|    if ((byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (50:9): [True: 804k, False: 405k]
  ------------------
   51|   804k|      next_pos = pos + 2;
   52|   804k|      if (next_pos > len) {
  ------------------
  |  Branch (52:11): [True: 65, False: 804k]
  ------------------
   53|     65|        return false;
   54|     65|      }
   55|   804k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (55:11): [True: 239, False: 803k]
  ------------------
   56|    239|        return false;
   57|    239|      }
   58|       |      // range check
   59|   803k|      code_point = (byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
   60|   803k|      if (code_point < 0x80) {
  ------------------
  |  Branch (60:11): [True: 35, False: 803k]
  ------------------
   61|     35|        return false;
   62|     35|      }
   63|   803k|    } else if ((byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (63:16): [True: 336k, False: 69.5k]
  ------------------
   64|   336k|      next_pos = pos + 3;
   65|   336k|      if (next_pos > len) {
  ------------------
  |  Branch (65:11): [True: 57, False: 336k]
  ------------------
   66|     57|        return false;
   67|     57|      }
   68|   336k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (68:11): [True: 133, False: 336k]
  ------------------
   69|    133|        return false;
   70|    133|      }
   71|   336k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (71:11): [True: 42, False: 336k]
  ------------------
   72|     42|        return false;
   73|     42|      }
   74|       |      // range check
   75|   336k|      code_point = (byte & 0b00001111) << 12 |
   76|   336k|                   (data[pos + 1] & 0b00111111) << 6 |
   77|   336k|                   (data[pos + 2] & 0b00111111);
   78|   336k|      if ((code_point < 0x800) ||
  ------------------
  |  Branch (78:11): [True: 40, False: 335k]
  ------------------
   79|   335k|          (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (79:12): [True: 7.39k, False: 328k]
  |  Branch (79:35): [True: 23, False: 7.37k]
  ------------------
   80|     63|        return false;
   81|     63|      }
   82|   336k|    } else if ((byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (82:16): [True: 68.7k, False: 836]
  ------------------
   83|  68.7k|      next_pos = pos + 4;
   84|  68.7k|      if (next_pos > len) {
  ------------------
  |  Branch (84:11): [True: 43, False: 68.6k]
  ------------------
   85|     43|        return false;
   86|     43|      }
   87|  68.6k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (87:11): [True: 83, False: 68.5k]
  ------------------
   88|     83|        return false;
   89|     83|      }
   90|  68.5k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (90:11): [True: 42, False: 68.5k]
  ------------------
   91|     42|        return false;
   92|     42|      }
   93|  68.5k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (93:11): [True: 43, False: 68.5k]
  ------------------
   94|     43|        return false;
   95|     43|      }
   96|       |      // range check
   97|  68.5k|      code_point =
   98|  68.5k|          (byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 |
   99|  68.5k|          (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111);
  100|  68.5k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (100:11): [True: 42, False: 68.4k]
  |  Branch (100:35): [True: 36, False: 68.4k]
  ------------------
  101|     78|        return false;
  102|     78|      }
  103|  68.5k|    } else {
  104|       |      // we may have a continuation
  105|    836|      return false;
  106|    836|    }
  107|  1.20M|    pos = next_pos;
  108|  1.20M|  }
  109|    619|  return true;
  110|  3.48k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf820validate_with_errorsEPKcm:
  221|  6.73k|validate_with_errors(const char *buf, size_t len) noexcept {
  222|  6.73k|  return validate_with_errors(reinterpret_cast<const uint8_t *>(buf), len);
  223|  6.73k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf820validate_with_errorsIPKhEENS_6resultET_m:
  119|  6.73k|validate_with_errors(BytePtr data, size_t len) noexcept {
  120|  6.73k|  static_assert(
  121|  6.73k|      std::is_same<typename std::decay<decltype(*data)>::type, uint8_t>::value,
  122|  6.73k|      "dereferencing the data pointer must result in a uint8_t");
  123|  6.73k|  size_t pos = 0;
  124|  6.73k|  uint32_t code_point = 0;
  125|  8.89M|  while (pos < len) {
  ------------------
  |  Branch (125:10): [True: 8.89M, False: 619]
  ------------------
  126|       |    // check of the next 16 bytes are ascii.
  127|  8.89M|    size_t next_pos = pos + 16;
  128|  8.89M|    if (next_pos <=
  ------------------
  |  Branch (128:9): [True: 8.88M, False: 5.22k]
  ------------------
  129|  8.89M|        len) { // if it is safe to read 16 more bytes, check that they are ascii
  130|  8.88M|      uint64_t v1;
  131|  8.88M|      std::memcpy(&v1, data + pos, sizeof(uint64_t));
  132|  8.88M|      uint64_t v2;
  133|  8.88M|      std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  134|  8.88M|      uint64_t v{v1 | v2};
  135|  8.88M|      if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (135:11): [True: 7.67M, False: 1.21M]
  ------------------
  136|  7.67M|        pos = next_pos;
  137|  7.67M|        continue;
  138|  7.67M|      }
  139|  8.88M|    }
  140|  1.21M|    unsigned char byte = data[pos];
  141|       |
  142|  6.19M|    while (byte < 0b10000000) {
  ------------------
  |  Branch (142:12): [True: 4.97M, False: 1.21M]
  ------------------
  143|  4.97M|      if (++pos == len) {
  ------------------
  |  Branch (143:11): [True: 1.10k, False: 4.97M]
  ------------------
  144|  1.10k|        return result(error_code::SUCCESS, len);
  145|  1.10k|      }
  146|  4.97M|      byte = data[pos];
  147|  4.97M|    }
  148|       |
  149|  1.21M|    if ((byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (149:9): [True: 806k, False: 409k]
  ------------------
  150|   806k|      next_pos = pos + 2;
  151|   806k|      if (next_pos > len) {
  ------------------
  |  Branch (151:11): [True: 195, False: 806k]
  ------------------
  152|    195|        return result(error_code::TOO_SHORT, pos);
  153|    195|      }
  154|   806k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (154:11): [True: 717, False: 805k]
  ------------------
  155|    717|        return result(error_code::TOO_SHORT, pos);
  156|    717|      }
  157|       |      // range check
  158|   805k|      code_point = (byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
  159|   805k|      if (code_point < 0x80) {
  ------------------
  |  Branch (159:11): [True: 105, False: 805k]
  ------------------
  160|    105|        return result(error_code::OVERLONG, pos);
  161|    105|      }
  162|   805k|    } else if ((byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (162:16): [True: 337k, False: 71.9k]
  ------------------
  163|   337k|      next_pos = pos + 3;
  164|   337k|      if (next_pos > len) {
  ------------------
  |  Branch (164:11): [True: 171, False: 337k]
  ------------------
  165|    171|        return result(error_code::TOO_SHORT, pos);
  166|    171|      }
  167|   337k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (167:11): [True: 399, False: 337k]
  ------------------
  168|    399|        return result(error_code::TOO_SHORT, pos);
  169|    399|      }
  170|   337k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (170:11): [True: 126, False: 337k]
  ------------------
  171|    126|        return result(error_code::TOO_SHORT, pos);
  172|    126|      }
  173|       |      // range check
  174|   337k|      code_point = (byte & 0b00001111) << 12 |
  175|   337k|                   (data[pos + 1] & 0b00111111) << 6 |
  176|   337k|                   (data[pos + 2] & 0b00111111);
  177|   337k|      if (code_point < 0x800) {
  ------------------
  |  Branch (177:11): [True: 120, False: 337k]
  ------------------
  178|    120|        return result(error_code::OVERLONG, pos);
  179|    120|      }
  180|   337k|      if (0xd7ff < code_point && code_point < 0xe000) {
  ------------------
  |  Branch (180:11): [True: 8.01k, False: 329k]
  |  Branch (180:34): [True: 69, False: 7.94k]
  ------------------
  181|     69|        return result(error_code::SURROGATE, pos);
  182|     69|      }
  183|   337k|    } else if ((byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (183:16): [True: 69.7k, False: 2.23k]
  ------------------
  184|  69.7k|      next_pos = pos + 4;
  185|  69.7k|      if (next_pos > len) {
  ------------------
  |  Branch (185:11): [True: 129, False: 69.6k]
  ------------------
  186|    129|        return result(error_code::TOO_SHORT, pos);
  187|    129|      }
  188|  69.6k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (188:11): [True: 249, False: 69.3k]
  ------------------
  189|    249|        return result(error_code::TOO_SHORT, pos);
  190|    249|      }
  191|  69.3k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (191:11): [True: 126, False: 69.2k]
  ------------------
  192|    126|        return result(error_code::TOO_SHORT, pos);
  193|    126|      }
  194|  69.2k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (194:11): [True: 129, False: 69.1k]
  ------------------
  195|    129|        return result(error_code::TOO_SHORT, pos);
  196|    129|      }
  197|       |      // range check
  198|  69.1k|      code_point =
  199|  69.1k|          (byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 |
  200|  69.1k|          (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111);
  201|  69.1k|      if (code_point <= 0xffff) {
  ------------------
  |  Branch (201:11): [True: 126, False: 68.9k]
  ------------------
  202|    126|        return result(error_code::OVERLONG, pos);
  203|    126|      }
  204|  68.9k|      if (0x10ffff < code_point) {
  ------------------
  |  Branch (204:11): [True: 108, False: 68.8k]
  ------------------
  205|    108|        return result(error_code::TOO_LARGE, pos);
  206|    108|      }
  207|  68.9k|    } else {
  208|       |      // we either have too many continuation bytes or an invalid leading byte
  209|  2.23k|      if ((byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (209:11): [True: 1.17k, False: 1.06k]
  ------------------
  210|  1.17k|        return result(error_code::TOO_LONG, pos);
  211|  1.17k|      } else {
  212|  1.06k|        return result(error_code::HEADER_BITS, pos);
  213|  1.06k|      }
  214|  2.23k|    }
  215|  1.21M|    pos = next_pos;
  216|  1.21M|  }
  217|    619|  return result(error_code::SUCCESS, len);
  218|  6.73k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf831rewind_and_validate_with_errorsEPKcS4_m:
  232|  3.51k|    const char *start, const char *buf, size_t len) noexcept {
  233|       |  // First check that we start with a leading byte
  234|  3.51k|  if ((*start & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (234:7): [True: 270, False: 3.24k]
  ------------------
  235|    270|    return result(error_code::TOO_LONG, 0);
  236|    270|  }
  237|  3.24k|  size_t extra_len{0};
  238|       |  // A leading byte cannot be further than 4 bytes away
  239|  3.44k|  for (int i = 0; i < 5; i++) {
  ------------------
  |  Branch (239:19): [True: 3.44k, False: 0]
  ------------------
  240|  3.44k|    unsigned char byte = *buf;
  241|  3.44k|    if ((byte & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (241:9): [True: 3.24k, False: 192]
  ------------------
  242|  3.24k|      break;
  243|  3.24k|    } else {
  244|    192|      buf--;
  245|    192|      extra_len++;
  246|    192|    }
  247|  3.44k|  }
  248|       |
  249|  3.24k|  result res = validate_with_errors(buf, len + extra_len);
  250|  3.24k|  res.count -= extra_len; // Might underflow
  251|  3.24k|  return res;
  252|  3.51k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf817count_code_pointsIPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEEmS6_m:
  258|  15.0k|simdutf_constexpr23 size_t count_code_points(InputPtr data, size_t len) {
  259|  15.0k|  size_t counter{0};
  260|   264M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (260:22): [True: 264M, False: 15.0k]
  ------------------
  261|       |    // -65 is 0b10111111, anything larger in two-complement's should start a new
  262|       |    // code point.
  263|   264M|    if (int8_t(data[i]) > -65) {
  ------------------
  |  Branch (263:9): [True: 261M, False: 3.13M]
  ------------------
  264|   261M|      counter++;
  265|   261M|    }
  266|   264M|  }
  267|  15.0k|  return counter;
  268|  15.0k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf822utf16_length_from_utf8IPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEEmS6_m:
  274|  5.83k|simdutf_constexpr23 size_t utf16_length_from_utf8(InputPtr data, size_t len) {
  275|  5.83k|  size_t counter{0};
  276|  97.4M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (276:22): [True: 97.4M, False: 5.83k]
  ------------------
  277|  97.4M|    if (int8_t(data[i]) > -65) {
  ------------------
  |  Branch (277:9): [True: 95.7M, False: 1.65M]
  ------------------
  278|  95.7M|      counter++;
  279|  95.7M|    }
  280|  97.4M|    if (uint8_t(data[i]) >= 240) {
  ------------------
  |  Branch (280:9): [True: 137k, False: 97.3M]
  ------------------
  281|   137k|      counter++;
  282|   137k|    }
  283|  97.4M|  }
  284|  5.83k|  return counter;
  285|  5.83k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf8_to_latin130rewind_and_convert_with_errorsEmPKcmPc:
  176|  1.01k|                                             char *latin1_output) {
  177|  1.01k|  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.01k|  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.01k|  bool found_leading_bytes{false};
  185|       |  // important: it is i <= how_far_back and not 'i < how_far_back'.
  186|  1.10k|  for (size_t i = 0; i <= how_far_back; i++) {
  ------------------
  |  Branch (186:22): [True: 1.02k, False: 88]
  ------------------
  187|  1.02k|    unsigned char byte = buf[-static_cast<std::ptrdiff_t>(i)];
  188|  1.02k|    found_leading_bytes = ((byte & 0b11000000) != 0b10000000);
  189|  1.02k|    if (found_leading_bytes) {
  ------------------
  |  Branch (189:9): [True: 928, False: 92]
  ------------------
  190|    928|      if (i > 0 && byte < 128) {
  ------------------
  |  Branch (190:11): [True: 4, False: 924]
  |  Branch (190:20): [True: 4, False: 0]
  ------------------
  191|       |        // If we had to go back and the leading byte is ascii
  192|       |        // then we can stop right away.
  193|      4|        return result(error_code::TOO_LONG, 0 - i + 1);
  194|      4|      }
  195|    924|      buf -= i;
  196|    924|      extra_len = i;
  197|    924|      break;
  198|    928|    }
  199|  1.02k|  }
  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|  1.01k|  if (!found_leading_bytes) {
  ------------------
  |  Branch (208:7): [True: 88, False: 924]
  ------------------
  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|     88|    return result(error_code::TOO_LONG, 0 - how_far_back);
  214|     88|  }
  215|    924|  result res = convert_with_errors(buf, len + extra_len, latin1_output);
  216|    924|  if (res.error) {
  ------------------
  |  Branch (216:7): [True: 480, False: 444]
  ------------------
  217|    480|    res.count -= extra_len;
  218|    480|  }
  219|    924|  return res;
  220|  1.01k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf8_to_latin119convert_with_errorsIPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEENS_6resultES6_mPc:
   92|  1.43k|                                               char *latin_output) {
   93|  1.43k|  size_t pos = 0;
   94|  1.43k|  char *start{latin_output};
   95|       |
   96|  1.44M|  while (pos < len) {
  ------------------
  |  Branch (96:10): [True: 1.44M, False: 670]
  ------------------
   97|       |#if SIMDUTF_CPLUSPLUS23
   98|       |    if !consteval
   99|       |#endif
  100|  1.44M|    {
  101|       |      // try to convert the next block of 16 ASCII bytes
  102|  1.44M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (102:11): [True: 1.44M, False: 6.37k]
  ------------------
  103|       |                             // they are ascii
  104|  1.44M|        uint64_t v1;
  105|  1.44M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
  106|  1.44M|        uint64_t v2;
  107|  1.44M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  108|  1.44M|        uint64_t v{v1 | v2}; // We are only interested in these bits: 1000 1000
  109|       |                             // 1000 1000...etc
  110|  1.44M|        if ((v & 0x8080808080808080) ==
  ------------------
  |  Branch (110:13): [True: 1.22M, False: 210k]
  ------------------
  111|  1.44M|            0) { // if NONE of these are set, e.g. all of them are zero, then
  112|       |                 // everything is ASCII
  113|  1.22M|          size_t final_pos = pos + 16;
  114|  20.8M|          while (pos < final_pos) {
  ------------------
  |  Branch (114:18): [True: 19.6M, False: 1.22M]
  ------------------
  115|  19.6M|            *latin_output++ = char(data[pos]);
  116|  19.6M|            pos++;
  117|  19.6M|          }
  118|  1.22M|          continue;
  119|  1.22M|        }
  120|  1.44M|      }
  121|  1.44M|    }
  122|       |    // suppose it is not an all ASCII byte sequence
  123|   217k|    uint8_t leading_byte = data[pos]; // leading byte
  124|   217k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (124:9): [True: 189k, False: 27.8k]
  ------------------
  125|       |      // converting one ASCII byte !!!
  126|   189k|      *latin_output++ = char(leading_byte);
  127|   189k|      pos++;
  128|   189k|    } else if ((leading_byte & 0b11100000) ==
  ------------------
  |  Branch (128:16): [True: 27.3k, False: 496]
  ------------------
  129|  27.8k|               0b11000000) { // the first three bits indicate:
  130|       |      // We have a two-byte UTF-8
  131|  27.3k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (131:11): [True: 30, False: 27.3k]
  ------------------
  132|     30|        return result(error_code::TOO_SHORT, pos);
  133|     30|      } // minimal bound checking
  134|  27.3k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (134:11): [True: 180, False: 27.1k]
  ------------------
  135|    180|        return result(error_code::TOO_SHORT, pos);
  136|    180|      } // 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|  27.1k|      uint32_t code_point =
  140|  27.1k|          (leading_byte & 0b00011111) << 6 |
  141|  27.1k|          (data[pos + 1] &
  142|  27.1k|           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|  27.1k|      if (code_point < 0x80) {
  ------------------
  |  Branch (147:11): [True: 12, False: 27.1k]
  ------------------
  148|     12|        return result(error_code::OVERLONG, pos);
  149|     12|      }
  150|  27.1k|      if (0xFF < code_point) {
  ------------------
  |  Branch (150:11): [True: 48, False: 27.0k]
  ------------------
  151|     48|        return result(error_code::TOO_LARGE, pos);
  152|     48|      } // We only care about the range 129-255 which is Non-ASCII latin1
  153|       |        // characters
  154|  27.0k|      *latin_output++ = char(code_point);
  155|  27.0k|      pos += 2;
  156|  27.0k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (156:16): [True: 60, False: 436]
  ------------------
  157|       |      // We have a three-byte UTF-8
  158|     60|      return result(error_code::TOO_LARGE, pos);
  159|    436|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (159:16): [True: 54, False: 382]
  ------------------
  160|       |      // we have a 4-byte UTF-8 word.
  161|     54|      return result(error_code::TOO_LARGE, pos);
  162|    382|    } else {
  163|       |      // we either have too many continuation bytes or an invalid leading byte
  164|    382|      if ((leading_byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (164:11): [True: 196, False: 186]
  ------------------
  165|    196|        return result(error_code::TOO_LONG, pos);
  166|    196|      }
  167|       |
  168|    186|      return result(error_code::HEADER_BITS, pos);
  169|    382|    }
  170|   217k|  }
  171|    670|  return result(error_code::SUCCESS, latin_output - start);
  172|  1.43k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf8_to_latin17convertIPKcPcQaasr7simdutf6detailE22indexes_into_byte_likeIT_Esr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mS8_:
   17|  1.22k|                                   OutputPtr latin_output) {
   18|  1.22k|  size_t pos = 0;
   19|  1.22k|  auto start = latin_output;
   20|       |
   21|  1.49M|  while (pos < len) {
  ------------------
  |  Branch (21:10): [True: 1.49M, False: 508]
  ------------------
   22|       |#if SIMDUTF_CPLUSPLUS23
   23|       |    if !consteval
   24|       |#endif
   25|  1.49M|    {
   26|       |      // try to convert the next block of 16 ASCII bytes
   27|  1.49M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (27:11): [True: 1.49M, False: 3.89k]
  ------------------
   28|       |                             // they are ascii
   29|  1.49M|        uint64_t v1;
   30|  1.49M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   31|  1.49M|        uint64_t v2;
   32|  1.49M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   33|  1.49M|        uint64_t v{v1 | v2}; // We are only interested in these bits: 1000 1000
   34|       |                             // 1000 1000 .... etc
   35|  1.49M|        if ((v & 0x8080808080808080) ==
  ------------------
  |  Branch (35:13): [True: 1.35M, False: 134k]
  ------------------
   36|  1.49M|            0) { // if NONE of these are set, e.g. all of them are zero, then
   37|       |                 // everything is ASCII
   38|  1.35M|          size_t final_pos = pos + 16;
   39|  23.1M|          while (pos < final_pos) {
  ------------------
  |  Branch (39:18): [True: 21.7M, False: 1.35M]
  ------------------
   40|  21.7M|            *latin_output++ = char(data[pos]);
   41|  21.7M|            pos++;
   42|  21.7M|          }
   43|  1.35M|          continue;
   44|  1.35M|        }
   45|  1.49M|      }
   46|  1.49M|    }
   47|       |
   48|       |    // suppose it is not an all ASCII byte sequence
   49|   138k|    uint8_t leading_byte = data[pos]; // leading byte
   50|   138k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (50:9): [True: 121k, False: 16.6k]
  ------------------
   51|       |      // converting one ASCII byte !!!
   52|   121k|      *latin_output++ = char(leading_byte);
   53|   121k|      pos++;
   54|   121k|    } else if ((leading_byte & 0b11100000) ==
  ------------------
  |  Branch (54:16): [True: 16.1k, False: 504]
  ------------------
   55|  16.6k|               0b11000000) { // the first three bits indicate:
   56|       |      // We have a two-byte UTF-8
   57|  16.1k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (57:11): [True: 36, False: 16.0k]
  ------------------
   58|     36|        return 0;
   59|     36|      } // minimal bound checking
   60|  16.0k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (60:11): [True: 96, False: 15.9k]
  ------------------
   61|     96|        return 0;
   62|     96|      } // 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|  15.9k|      uint32_t code_point =
   66|  15.9k|          (leading_byte & 0b00011111) << 6 |
   67|  15.9k|          (data[pos + 1] &
   68|  15.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|  15.9k|      if (code_point < 0x80 || 0xFF < code_point) {
  ------------------
  |  Branch (73:11): [True: 16, False: 15.9k]
  |  Branch (73:32): [True: 66, False: 15.8k]
  ------------------
   74|     82|        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|     82|      }
   78|  15.8k|      *latin_output++ = char(code_point);
   79|  15.8k|      pos += 2;
   80|  15.8k|    } else {
   81|    504|      return 0;
   82|    504|    }
   83|   138k|  }
   84|    508|  return latin_output - start;
   85|  1.22k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf167convertILNS_10endiannessE0EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mPDs:
   16|  1.66k|                                   char16_t *utf16_output) {
   17|  1.66k|  size_t pos = 0;
   18|  1.66k|  char16_t *start{utf16_output};
   19|  1.47M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 1.47M, False: 728]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|       |    // try to convert the next block of 16 ASCII bytes
   24|  1.47M|    {
   25|  1.47M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 1.47M, False: 4.96k]
  ------------------
   26|       |                             // they are ascii
   27|  1.47M|        uint64_t v1;
   28|  1.47M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   29|  1.47M|        uint64_t v2;
   30|  1.47M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   31|  1.47M|        uint64_t v{v1 | v2};
   32|  1.47M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (32:13): [True: 917k, False: 556k]
  ------------------
   33|   917k|          size_t final_pos = pos + 16;
   34|  15.5M|          while (pos < final_pos) {
  ------------------
  |  Branch (34:18): [True: 14.6M, False: 917k]
  ------------------
   35|  14.6M|            *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (35:31): [Folded, False: 14.6M]
  ------------------
   36|  14.6M|                                  ? char16_t(u16_swap_bytes(data[pos]))
   37|  14.6M|                                  : char16_t(data[pos]);
   38|  14.6M|            pos++;
   39|  14.6M|          }
   40|   917k|          continue;
   41|   917k|        }
   42|  1.47M|      }
   43|  1.47M|    }
   44|       |
   45|   561k|    uint8_t leading_byte = data[pos]; // leading byte
   46|   561k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (46:9): [True: 444k, False: 116k]
  ------------------
   47|       |      // converting one ASCII byte !!!
   48|   444k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (48:25): [Folded, False: 444k]
  ------------------
   49|   444k|                            ? char16_t(u16_swap_bytes(leading_byte))
   50|   444k|                            : char16_t(leading_byte);
   51|   444k|      pos++;
   52|   444k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (52:16): [True: 76.0k, False: 40.7k]
  ------------------
   53|       |      // We have a two-byte UTF-8, it should become
   54|       |      // a single UTF-16 word.
   55|  76.0k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (55:11): [True: 18, False: 76.0k]
  ------------------
   56|     18|        return 0;
   57|     18|      } // minimal bound checking
   58|  76.0k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (58:11): [True: 98, False: 75.9k]
  ------------------
   59|     98|        return 0;
   60|     98|      }
   61|       |      // range check
   62|  75.9k|      uint32_t code_point =
   63|  75.9k|          (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
   64|  75.9k|      if (code_point < 0x80) {
  ------------------
  |  Branch (64:11): [True: 20, False: 75.9k]
  ------------------
   65|     20|        return 0;
   66|     20|      }
   67|       |      if constexpr (!match_system(big_endian)) {
   68|       |        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
   69|       |      }
   70|  75.9k|      *utf16_output++ = char16_t(code_point);
   71|  75.9k|      pos += 2;
   72|  75.9k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (72:16): [True: 33.8k, False: 6.92k]
  ------------------
   73|       |      // We have a three-byte UTF-8, it should become
   74|       |      // a single UTF-16 word.
   75|  33.8k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (75:11): [True: 60, False: 33.7k]
  ------------------
   76|     60|        return 0;
   77|     60|      } // minimal bound checking
   78|       |
   79|  33.7k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (79:11): [True: 54, False: 33.7k]
  ------------------
   80|     54|        return 0;
   81|     54|      }
   82|  33.7k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (82:11): [True: 40, False: 33.6k]
  ------------------
   83|     40|        return 0;
   84|     40|      }
   85|       |      // range check
   86|  33.6k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
   87|  33.6k|                            (data[pos + 1] & 0b00111111) << 6 |
   88|  33.6k|                            (data[pos + 2] & 0b00111111);
   89|  33.6k|      if (code_point < 0x800 || (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (89:11): [True: 46, False: 33.6k]
  |  Branch (89:34): [True: 772, False: 32.8k]
  |  Branch (89:57): [True: 18, False: 754]
  ------------------
   90|     64|        return 0;
   91|     64|      }
   92|       |      if constexpr (!match_system(big_endian)) {
   93|       |        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
   94|       |      }
   95|  33.6k|      *utf16_output++ = char16_t(code_point);
   96|  33.6k|      pos += 3;
   97|  33.6k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (97:16): [True: 6.51k, False: 408]
  ------------------
   98|       |      // we have a 4-byte UTF-8 word.
   99|  6.51k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (99:11): [True: 24, False: 6.49k]
  ------------------
  100|     24|        return 0;
  101|     24|      } // minimal bound checking
  102|  6.49k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (102:11): [True: 34, False: 6.45k]
  ------------------
  103|     34|        return 0;
  104|     34|      }
  105|  6.45k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (105:11): [True: 10, False: 6.44k]
  ------------------
  106|     10|        return 0;
  107|     10|      }
  108|  6.44k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (108:11): [True: 40, False: 6.40k]
  ------------------
  109|     40|        return 0;
  110|     40|      }
  111|       |
  112|       |      // range check
  113|  6.40k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  114|  6.40k|                            (data[pos + 1] & 0b00111111) << 12 |
  115|  6.40k|                            (data[pos + 2] & 0b00111111) << 6 |
  116|  6.40k|                            (data[pos + 3] & 0b00111111);
  117|  6.40k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (117:11): [True: 36, False: 6.37k]
  |  Branch (117:35): [True: 34, False: 6.33k]
  ------------------
  118|     70|        return 0;
  119|     70|      }
  120|  6.33k|      code_point -= 0x10000;
  121|  6.33k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
  122|  6.33k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
  123|       |      if constexpr (!match_system(big_endian)) {
  124|       |        high_surrogate = u16_swap_bytes(high_surrogate);
  125|       |        low_surrogate = u16_swap_bytes(low_surrogate);
  126|       |      }
  127|  6.33k|      *utf16_output++ = char16_t(high_surrogate);
  128|  6.33k|      *utf16_output++ = char16_t(low_surrogate);
  129|  6.33k|      pos += 4;
  130|  6.33k|    } else {
  131|    408|      return 0;
  132|    408|    }
  133|   561k|  }
  134|    728|  return utf16_output - start;
  135|  1.66k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf167convertILNS_10endiannessE1EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mPDs:
   16|  1.67k|                                   char16_t *utf16_output) {
   17|  1.67k|  size_t pos = 0;
   18|  1.67k|  char16_t *start{utf16_output};
   19|  2.30M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 2.30M, False: 704]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|       |    // try to convert the next block of 16 ASCII bytes
   24|  2.30M|    {
   25|  2.30M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 2.29M, False: 5.03k]
  ------------------
   26|       |                             // they are ascii
   27|  2.29M|        uint64_t v1;
   28|  2.29M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   29|  2.29M|        uint64_t v2;
   30|  2.29M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   31|  2.29M|        uint64_t v{v1 | v2};
   32|  2.29M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (32:13): [True: 1.37M, False: 917k]
  ------------------
   33|  1.37M|          size_t final_pos = pos + 16;
   34|  23.4M|          while (pos < final_pos) {
  ------------------
  |  Branch (34:18): [True: 22.0M, False: 1.37M]
  ------------------
   35|  22.0M|            *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (35:31): [True: 22.0M, Folded]
  ------------------
   36|  22.0M|                                  ? char16_t(u16_swap_bytes(data[pos]))
   37|  22.0M|                                  : char16_t(data[pos]);
   38|  22.0M|            pos++;
   39|  22.0M|          }
   40|  1.37M|          continue;
   41|  1.37M|        }
   42|  2.29M|      }
   43|  2.30M|    }
   44|       |
   45|   922k|    uint8_t leading_byte = data[pos]; // leading byte
   46|   922k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (46:9): [True: 751k, False: 171k]
  ------------------
   47|       |      // converting one ASCII byte !!!
   48|   751k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (48:25): [True: 751k, Folded]
  ------------------
   49|   751k|                            ? char16_t(u16_swap_bytes(leading_byte))
   50|   751k|                            : char16_t(leading_byte);
   51|   751k|      pos++;
   52|   751k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (52:16): [True: 107k, False: 63.4k]
  ------------------
   53|       |      // We have a two-byte UTF-8, it should become
   54|       |      // a single UTF-16 word.
   55|   107k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (55:11): [True: 78, False: 107k]
  ------------------
   56|     78|        return 0;
   57|     78|      } // minimal bound checking
   58|   107k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (58:11): [True: 80, False: 107k]
  ------------------
   59|     80|        return 0;
   60|     80|      }
   61|       |      // range check
   62|   107k|      uint32_t code_point =
   63|   107k|          (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
   64|   107k|      if (code_point < 0x80) {
  ------------------
  |  Branch (64:11): [True: 24, False: 107k]
  ------------------
   65|     24|        return 0;
   66|     24|      }
   67|   107k|      if constexpr (!match_system(big_endian)) {
   68|   107k|        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
   69|   107k|      }
   70|   107k|      *utf16_output++ = char16_t(code_point);
   71|   107k|      pos += 2;
   72|   107k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (72:16): [True: 52.2k, False: 11.2k]
  ------------------
   73|       |      // We have a three-byte UTF-8, it should become
   74|       |      // a single UTF-16 word.
   75|  52.2k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (75:11): [True: 24, False: 52.1k]
  ------------------
   76|     24|        return 0;
   77|     24|      } // minimal bound checking
   78|       |
   79|  52.1k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (79:11): [True: 64, False: 52.1k]
  ------------------
   80|     64|        return 0;
   81|     64|      }
   82|  52.1k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (82:11): [True: 32, False: 52.0k]
  ------------------
   83|     32|        return 0;
   84|     32|      }
   85|       |      // range check
   86|  52.0k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
   87|  52.0k|                            (data[pos + 1] & 0b00111111) << 6 |
   88|  52.0k|                            (data[pos + 2] & 0b00111111);
   89|  52.0k|      if (code_point < 0x800 || (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (89:11): [True: 32, False: 52.0k]
  |  Branch (89:34): [True: 706, False: 51.3k]
  |  Branch (89:57): [True: 14, False: 692]
  ------------------
   90|     46|        return 0;
   91|     46|      }
   92|  52.0k|      if constexpr (!match_system(big_endian)) {
   93|  52.0k|        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
   94|  52.0k|      }
   95|  52.0k|      *utf16_output++ = char16_t(code_point);
   96|  52.0k|      pos += 3;
   97|  52.0k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (97:16): [True: 10.8k, False: 394]
  ------------------
   98|       |      // we have a 4-byte UTF-8 word.
   99|  10.8k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (99:11): [True: 48, False: 10.8k]
  ------------------
  100|     48|        return 0;
  101|     48|      } // minimal bound checking
  102|  10.8k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (102:11): [True: 42, False: 10.7k]
  ------------------
  103|     42|        return 0;
  104|     42|      }
  105|  10.7k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (105:11): [True: 36, False: 10.7k]
  ------------------
  106|     36|        return 0;
  107|     36|      }
  108|  10.7k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (108:11): [True: 32, False: 10.7k]
  ------------------
  109|     32|        return 0;
  110|     32|      }
  111|       |
  112|       |      // range check
  113|  10.7k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  114|  10.7k|                            (data[pos + 1] & 0b00111111) << 12 |
  115|  10.7k|                            (data[pos + 2] & 0b00111111) << 6 |
  116|  10.7k|                            (data[pos + 3] & 0b00111111);
  117|  10.7k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (117:11): [True: 46, False: 10.6k]
  |  Branch (117:35): [True: 24, False: 10.6k]
  ------------------
  118|     70|        return 0;
  119|     70|      }
  120|  10.6k|      code_point -= 0x10000;
  121|  10.6k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
  122|  10.6k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
  123|  10.6k|      if constexpr (!match_system(big_endian)) {
  124|  10.6k|        high_surrogate = u16_swap_bytes(high_surrogate);
  125|  10.6k|        low_surrogate = u16_swap_bytes(low_surrogate);
  126|  10.6k|      }
  127|  10.6k|      *utf16_output++ = char16_t(high_surrogate);
  128|  10.6k|      *utf16_output++ = char16_t(low_surrogate);
  129|  10.6k|      pos += 4;
  130|  10.6k|    } else {
  131|    394|      return 0;
  132|    394|    }
  133|   922k|  }
  134|    704|  return utf16_output - start;
  135|  1.67k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1619convert_with_errorsILNS_10endiannessE0EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEENS_6resultES7_mPDs:
  142|  1.73k|                                               char16_t *utf16_output) {
  143|  1.73k|  size_t pos = 0;
  144|  1.73k|  char16_t *start{utf16_output};
  145|  2.88M|  while (pos < len) {
  ------------------
  |  Branch (145:10): [True: 2.88M, False: 718]
  ------------------
  146|       |#if SIMDUTF_CPLUSPLUS23
  147|       |    if !consteval
  148|       |#endif
  149|  2.88M|    {
  150|       |      // try to convert the next block of 16 ASCII bytes
  151|  2.88M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (151:11): [True: 2.87M, False: 5.79k]
  ------------------
  152|       |                             // they are ascii
  153|  2.87M|        uint64_t v1;
  154|  2.87M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
  155|  2.87M|        uint64_t v2;
  156|  2.87M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  157|  2.87M|        uint64_t v{v1 | v2};
  158|  2.87M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (158:13): [True: 1.36M, False: 1.50M]
  ------------------
  159|  1.36M|          size_t final_pos = pos + 16;
  160|  23.2M|          while (pos < final_pos) {
  ------------------
  |  Branch (160:18): [True: 21.9M, False: 1.36M]
  ------------------
  161|  21.9M|            const char16_t byte = uint8_t(data[pos]);
  162|  21.9M|            *utf16_output++ =
  163|  21.9M|                !match_system(big_endian) ? u16_swap_bytes(byte) : byte;
  ------------------
  |  Branch (163:17): [Folded, False: 21.9M]
  ------------------
  164|  21.9M|            pos++;
  165|  21.9M|          }
  166|  1.36M|          continue;
  167|  1.36M|        }
  168|  2.87M|      }
  169|  2.88M|    }
  170|       |
  171|  1.51M|    auto leading_byte = uint8_t(data[pos]); // leading byte
  172|  1.51M|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (172:9): [True: 1.24M, False: 273k]
  ------------------
  173|       |      // converting one ASCII byte !!!
  174|  1.24M|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (174:25): [Folded, False: 1.24M]
  ------------------
  175|  1.24M|                            ? char16_t(u16_swap_bytes(leading_byte))
  176|  1.24M|                            : char16_t(leading_byte);
  177|  1.24M|      pos++;
  178|  1.24M|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (178:16): [True: 179k, False: 94.4k]
  ------------------
  179|       |      // We have a two-byte UTF-8, it should become
  180|       |      // a single UTF-16 word.
  181|   179k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (181:11): [True: 54, False: 179k]
  ------------------
  182|     54|        return result(error_code::TOO_SHORT, pos);
  183|     54|      } // minimal bound checking
  184|   179k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (184:11): [True: 144, False: 179k]
  ------------------
  185|    144|        return result(error_code::TOO_SHORT, pos);
  186|    144|      }
  187|       |      // range check
  188|   179k|      uint32_t code_point = (leading_byte & 0b00011111) << 6 |
  189|   179k|                            (uint8_t(data[pos + 1]) & 0b00111111);
  190|   179k|      if (code_point < 0x80) {
  ------------------
  |  Branch (190:11): [True: 24, False: 179k]
  ------------------
  191|     24|        return result(error_code::OVERLONG, pos);
  192|     24|      }
  193|       |      if constexpr (!match_system(big_endian)) {
  194|       |        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
  195|       |      }
  196|   179k|      *utf16_output++ = char16_t(code_point);
  197|   179k|      pos += 2;
  198|   179k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (198:16): [True: 68.4k, False: 25.9k]
  ------------------
  199|       |      // We have a three-byte UTF-8, it should become
  200|       |      // a single UTF-16 word.
  201|  68.4k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (201:11): [True: 30, False: 68.4k]
  ------------------
  202|     30|        return result(error_code::TOO_SHORT, pos);
  203|     30|      } // minimal bound checking
  204|       |
  205|  68.4k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (205:11): [True: 108, False: 68.2k]
  ------------------
  206|    108|        return result(error_code::TOO_SHORT, pos);
  207|    108|      }
  208|  68.2k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (208:11): [True: 12, False: 68.2k]
  ------------------
  209|     12|        return result(error_code::TOO_SHORT, pos);
  210|     12|      }
  211|       |      // range check
  212|  68.2k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
  213|  68.2k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 6 |
  214|  68.2k|                            (uint8_t(data[pos + 2]) & 0b00111111);
  215|  68.2k|      if (code_point < 0x800) {
  ------------------
  |  Branch (215:11): [True: 42, False: 68.2k]
  ------------------
  216|     42|        return result(error_code::OVERLONG, pos);
  217|     42|      }
  218|  68.2k|      if (0xd7ff < code_point && code_point < 0xe000) {
  ------------------
  |  Branch (218:11): [True: 1.00k, False: 67.2k]
  |  Branch (218:34): [True: 18, False: 986]
  ------------------
  219|     18|        return result(error_code::SURROGATE, pos);
  220|     18|      }
  221|       |      if constexpr (!match_system(big_endian)) {
  222|       |        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
  223|       |      }
  224|  68.2k|      *utf16_output++ = char16_t(code_point);
  225|  68.2k|      pos += 3;
  226|  68.2k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (226:16): [True: 25.6k, False: 384]
  ------------------
  227|       |      // we have a 4-byte UTF-8 word.
  228|  25.6k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (228:11): [True: 48, False: 25.5k]
  ------------------
  229|     48|        return result(error_code::TOO_SHORT, pos);
  230|     48|      } // minimal bound checking
  231|  25.5k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (231:11): [True: 42, False: 25.5k]
  ------------------
  232|     42|        return result(error_code::TOO_SHORT, pos);
  233|     42|      }
  234|  25.5k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (234:11): [True: 42, False: 25.4k]
  ------------------
  235|     42|        return result(error_code::TOO_SHORT, pos);
  236|     42|      }
  237|  25.4k|      if ((uint8_t(data[pos + 3]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (237:11): [True: 12, False: 25.4k]
  ------------------
  238|     12|        return result(error_code::TOO_SHORT, pos);
  239|     12|      }
  240|       |
  241|       |      // range check
  242|  25.4k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  243|  25.4k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 12 |
  244|  25.4k|                            (uint8_t(data[pos + 2]) & 0b00111111) << 6 |
  245|  25.4k|                            (uint8_t(data[pos + 3]) & 0b00111111);
  246|  25.4k|      if (code_point <= 0xffff) {
  ------------------
  |  Branch (246:11): [True: 36, False: 25.4k]
  ------------------
  247|     36|        return result(error_code::OVERLONG, pos);
  248|     36|      }
  249|  25.4k|      if (0x10ffff < code_point) {
  ------------------
  |  Branch (249:11): [True: 24, False: 25.4k]
  ------------------
  250|     24|        return result(error_code::TOO_LARGE, pos);
  251|     24|      }
  252|  25.4k|      code_point -= 0x10000;
  253|  25.4k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
  254|  25.4k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
  255|       |      if constexpr (!match_system(big_endian)) {
  256|       |        high_surrogate = u16_swap_bytes(high_surrogate);
  257|       |        low_surrogate = u16_swap_bytes(low_surrogate);
  258|       |      }
  259|  25.4k|      *utf16_output++ = char16_t(high_surrogate);
  260|  25.4k|      *utf16_output++ = char16_t(low_surrogate);
  261|  25.4k|      pos += 4;
  262|  25.4k|    } else {
  263|       |      // we either have too many continuation bytes or an invalid leading byte
  264|    384|      if ((leading_byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (264:11): [True: 192, False: 192]
  ------------------
  265|    192|        return result(error_code::TOO_LONG, pos);
  266|    192|      } else {
  267|    192|        return result(error_code::HEADER_BITS, pos);
  268|    192|      }
  269|    384|    }
  270|  1.51M|  }
  271|    718|  return result(error_code::SUCCESS, utf16_output - start);
  272|  1.73k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1619convert_with_errorsILNS_10endiannessE1EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEENS_6resultES7_mPDs:
  142|  2.04k|                                               char16_t *utf16_output) {
  143|  2.04k|  size_t pos = 0;
  144|  2.04k|  char16_t *start{utf16_output};
  145|  2.49M|  while (pos < len) {
  ------------------
  |  Branch (145:10): [True: 2.49M, False: 928]
  ------------------
  146|       |#if SIMDUTF_CPLUSPLUS23
  147|       |    if !consteval
  148|       |#endif
  149|  2.49M|    {
  150|       |      // try to convert the next block of 16 ASCII bytes
  151|  2.49M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (151:11): [True: 2.48M, False: 8.98k]
  ------------------
  152|       |                             // they are ascii
  153|  2.48M|        uint64_t v1;
  154|  2.48M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
  155|  2.48M|        uint64_t v2;
  156|  2.48M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  157|  2.48M|        uint64_t v{v1 | v2};
  158|  2.48M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (158:13): [True: 1.32M, False: 1.15M]
  ------------------
  159|  1.32M|          size_t final_pos = pos + 16;
  160|  22.5M|          while (pos < final_pos) {
  ------------------
  |  Branch (160:18): [True: 21.2M, False: 1.32M]
  ------------------
  161|  21.2M|            const char16_t byte = uint8_t(data[pos]);
  162|  21.2M|            *utf16_output++ =
  163|  21.2M|                !match_system(big_endian) ? u16_swap_bytes(byte) : byte;
  ------------------
  |  Branch (163:17): [True: 21.2M, Folded]
  ------------------
  164|  21.2M|            pos++;
  165|  21.2M|          }
  166|  1.32M|          continue;
  167|  1.32M|        }
  168|  2.48M|      }
  169|  2.49M|    }
  170|       |
  171|  1.16M|    auto leading_byte = uint8_t(data[pos]); // leading byte
  172|  1.16M|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (172:9): [True: 950k, False: 213k]
  ------------------
  173|       |      // converting one ASCII byte !!!
  174|   950k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (174:25): [True: 950k, Folded]
  ------------------
  175|   950k|                            ? char16_t(u16_swap_bytes(leading_byte))
  176|   950k|                            : char16_t(leading_byte);
  177|   950k|      pos++;
  178|   950k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (178:16): [True: 139k, False: 74.2k]
  ------------------
  179|       |      // We have a two-byte UTF-8, it should become
  180|       |      // a single UTF-16 word.
  181|   139k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (181:11): [True: 30, False: 139k]
  ------------------
  182|     30|        return result(error_code::TOO_SHORT, pos);
  183|     30|      } // minimal bound checking
  184|   139k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (184:11): [True: 156, False: 138k]
  ------------------
  185|    156|        return result(error_code::TOO_SHORT, pos);
  186|    156|      }
  187|       |      // range check
  188|   138k|      uint32_t code_point = (leading_byte & 0b00011111) << 6 |
  189|   138k|                            (uint8_t(data[pos + 1]) & 0b00111111);
  190|   138k|      if (code_point < 0x80) {
  ------------------
  |  Branch (190:11): [True: 12, False: 138k]
  ------------------
  191|     12|        return result(error_code::OVERLONG, pos);
  192|     12|      }
  193|   138k|      if constexpr (!match_system(big_endian)) {
  194|   138k|        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
  195|   138k|      }
  196|   138k|      *utf16_output++ = char16_t(code_point);
  197|   138k|      pos += 2;
  198|   138k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (198:16): [True: 64.5k, False: 9.67k]
  ------------------
  199|       |      // We have a three-byte UTF-8, it should become
  200|       |      // a single UTF-16 word.
  201|  64.5k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (201:11): [True: 42, False: 64.5k]
  ------------------
  202|     42|        return result(error_code::TOO_SHORT, pos);
  203|     42|      } // minimal bound checking
  204|       |
  205|  64.5k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (205:11): [True: 102, False: 64.4k]
  ------------------
  206|    102|        return result(error_code::TOO_SHORT, pos);
  207|    102|      }
  208|  64.4k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (208:11): [True: 30, False: 64.4k]
  ------------------
  209|     30|        return result(error_code::TOO_SHORT, pos);
  210|     30|      }
  211|       |      // range check
  212|  64.4k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
  213|  64.4k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 6 |
  214|  64.4k|                            (uint8_t(data[pos + 2]) & 0b00111111);
  215|  64.4k|      if (code_point < 0x800) {
  ------------------
  |  Branch (215:11): [True: 36, False: 64.3k]
  ------------------
  216|     36|        return result(error_code::OVERLONG, pos);
  217|     36|      }
  218|  64.3k|      if (0xd7ff < code_point && code_point < 0xe000) {
  ------------------
  |  Branch (218:11): [True: 2.55k, False: 61.8k]
  |  Branch (218:34): [True: 18, False: 2.53k]
  ------------------
  219|     18|        return result(error_code::SURROGATE, pos);
  220|     18|      }
  221|  64.3k|      if constexpr (!match_system(big_endian)) {
  222|  64.3k|        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
  223|  64.3k|      }
  224|  64.3k|      *utf16_output++ = char16_t(code_point);
  225|  64.3k|      pos += 3;
  226|  64.3k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (226:16): [True: 9.19k, False: 478]
  ------------------
  227|       |      // we have a 4-byte UTF-8 word.
  228|  9.19k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (228:11): [True: 60, False: 9.13k]
  ------------------
  229|     60|        return result(error_code::TOO_SHORT, pos);
  230|     60|      } // minimal bound checking
  231|  9.13k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (231:11): [True: 36, False: 9.09k]
  ------------------
  232|     36|        return result(error_code::TOO_SHORT, pos);
  233|     36|      }
  234|  9.09k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (234:11): [True: 36, False: 9.06k]
  ------------------
  235|     36|        return result(error_code::TOO_SHORT, pos);
  236|     36|      }
  237|  9.06k|      if ((uint8_t(data[pos + 3]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (237:11): [True: 36, False: 9.02k]
  ------------------
  238|     36|        return result(error_code::TOO_SHORT, pos);
  239|     36|      }
  240|       |
  241|       |      // range check
  242|  9.02k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  243|  9.02k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 12 |
  244|  9.02k|                            (uint8_t(data[pos + 2]) & 0b00111111) << 6 |
  245|  9.02k|                            (uint8_t(data[pos + 3]) & 0b00111111);
  246|  9.02k|      if (code_point <= 0xffff) {
  ------------------
  |  Branch (246:11): [True: 12, False: 9.01k]
  ------------------
  247|     12|        return result(error_code::OVERLONG, pos);
  248|     12|      }
  249|  9.01k|      if (0x10ffff < code_point) {
  ------------------
  |  Branch (249:11): [True: 30, False: 8.98k]
  ------------------
  250|     30|        return result(error_code::TOO_LARGE, pos);
  251|     30|      }
  252|  8.98k|      code_point -= 0x10000;
  253|  8.98k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
  254|  8.98k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
  255|  8.98k|      if constexpr (!match_system(big_endian)) {
  256|  8.98k|        high_surrogate = u16_swap_bytes(high_surrogate);
  257|  8.98k|        low_surrogate = u16_swap_bytes(low_surrogate);
  258|  8.98k|      }
  259|  8.98k|      *utf16_output++ = char16_t(high_surrogate);
  260|  8.98k|      *utf16_output++ = char16_t(low_surrogate);
  261|  8.98k|      pos += 4;
  262|  8.98k|    } else {
  263|       |      // we either have too many continuation bytes or an invalid leading byte
  264|    478|      if ((leading_byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (264:11): [True: 232, False: 246]
  ------------------
  265|    232|        return result(error_code::TOO_LONG, pos);
  266|    246|      } else {
  267|    246|        return result(error_code::HEADER_BITS, pos);
  268|    246|      }
  269|    478|    }
  270|  1.16M|  }
  271|    928|  return result(error_code::SUCCESS, utf16_output - start);
  272|  2.04k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1630rewind_and_convert_with_errorsILNS_10endiannessE0EEENS_6resultEmPKcmPDs:
  292|  1.21k|                                             char16_t *utf16_output) {
  293|  1.21k|  size_t extra_len{0};
  294|       |  // We potentially need to go back in time and find a leading byte.
  295|       |  // In theory '3' would be sufficient, but sometimes the error can go back
  296|       |  // quite far.
  297|  1.21k|  size_t how_far_back = prior_bytes;
  298|       |  // size_t how_far_back = 3; // 3 bytes in the past + current position
  299|       |  // if(how_far_back >= prior_bytes) { how_far_back = prior_bytes; }
  300|  1.21k|  bool found_leading_bytes{false};
  301|       |  // important: it is i <= how_far_back and not 'i < how_far_back'.
  302|  1.29k|  for (size_t i = 0; i <= how_far_back; i++) {
  ------------------
  |  Branch (302:22): [True: 1.21k, False: 80]
  ------------------
  303|  1.21k|    unsigned char byte = buf[-static_cast<std::ptrdiff_t>(i)];
  304|  1.21k|    found_leading_bytes = ((byte & 0b11000000) != 0b10000000);
  305|  1.21k|    if (found_leading_bytes) {
  ------------------
  |  Branch (305:9): [True: 1.13k, False: 84]
  ------------------
  306|  1.13k|      if (i > 0 && byte < 128) {
  ------------------
  |  Branch (306:11): [True: 4, False: 1.12k]
  |  Branch (306:20): [True: 4, False: 0]
  ------------------
  307|       |        // If we had to go back and the leading byte is ascii
  308|       |        // then we can stop right away.
  309|      4|        return result(error_code::TOO_LONG, 0 - i + 1);
  310|      4|      }
  311|  1.12k|      buf -= i;
  312|  1.12k|      extra_len = i;
  313|  1.12k|      break;
  314|  1.13k|    }
  315|  1.21k|  }
  316|       |  //
  317|       |  // It is possible for this function to return a negative count in its result.
  318|       |  // C++ Standard Section 18.1 defines size_t is in <cstddef> which is described
  319|       |  // in C Standard as <stddef.h>. C Standard Section 4.1.5 defines size_t as an
  320|       |  // unsigned integral type of the result of the sizeof operator
  321|       |  //
  322|       |  // An unsigned type will simply wrap round arithmetically (well defined).
  323|       |  //
  324|  1.20k|  if (!found_leading_bytes) {
  ------------------
  |  Branch (324:7): [True: 80, False: 1.12k]
  ------------------
  325|       |    // If how_far_back == 3, we may have four consecutive continuation bytes!!!
  326|       |    // [....] [continuation] [continuation] [continuation] | [buf is
  327|       |    // continuation] Or we possibly have a stream that does not start with a
  328|       |    // leading byte.
  329|     80|    return result(error_code::TOO_LONG, 0 - how_far_back);
  330|     80|  }
  331|  1.12k|  result res = convert_with_errors<endian>(buf, len + extra_len, utf16_output);
  332|  1.12k|  if (res.error) {
  ------------------
  |  Branch (332:7): [True: 652, False: 476]
  ------------------
  333|    652|    res.count -= extra_len;
  334|    652|  }
  335|  1.12k|  return res;
  336|  1.20k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1630rewind_and_convert_with_errorsILNS_10endiannessE1EEENS_6resultEmPKcmPDs:
  292|  1.40k|                                             char16_t *utf16_output) {
  293|  1.40k|  size_t extra_len{0};
  294|       |  // We potentially need to go back in time and find a leading byte.
  295|       |  // In theory '3' would be sufficient, but sometimes the error can go back
  296|       |  // quite far.
  297|  1.40k|  size_t how_far_back = prior_bytes;
  298|       |  // size_t how_far_back = 3; // 3 bytes in the past + current position
  299|       |  // if(how_far_back >= prior_bytes) { how_far_back = prior_bytes; }
  300|  1.40k|  bool found_leading_bytes{false};
  301|       |  // important: it is i <= how_far_back and not 'i < how_far_back'.
  302|  1.47k|  for (size_t i = 0; i <= how_far_back; i++) {
  ------------------
  |  Branch (302:22): [True: 1.40k, False: 64]
  ------------------
  303|  1.40k|    unsigned char byte = buf[-static_cast<std::ptrdiff_t>(i)];
  304|  1.40k|    found_leading_bytes = ((byte & 0b11000000) != 0b10000000);
  305|  1.40k|    if (found_leading_bytes) {
  ------------------
  |  Branch (305:9): [True: 1.34k, False: 68]
  ------------------
  306|  1.34k|      if (i > 0 && byte < 128) {
  ------------------
  |  Branch (306:11): [True: 4, False: 1.33k]
  |  Branch (306:20): [True: 4, False: 0]
  ------------------
  307|       |        // If we had to go back and the leading byte is ascii
  308|       |        // then we can stop right away.
  309|      4|        return result(error_code::TOO_LONG, 0 - i + 1);
  310|      4|      }
  311|  1.33k|      buf -= i;
  312|  1.33k|      extra_len = i;
  313|  1.33k|      break;
  314|  1.34k|    }
  315|  1.40k|  }
  316|       |  //
  317|       |  // It is possible for this function to return a negative count in its result.
  318|       |  // C++ Standard Section 18.1 defines size_t is in <cstddef> which is described
  319|       |  // in C Standard as <stddef.h>. C Standard Section 4.1.5 defines size_t as an
  320|       |  // unsigned integral type of the result of the sizeof operator
  321|       |  //
  322|       |  // An unsigned type will simply wrap round arithmetically (well defined).
  323|       |  //
  324|  1.40k|  if (!found_leading_bytes) {
  ------------------
  |  Branch (324:7): [True: 64, False: 1.33k]
  ------------------
  325|       |    // If how_far_back == 3, we may have four consecutive continuation bytes!!!
  326|       |    // [....] [continuation] [continuation] [continuation] | [buf is
  327|       |    // continuation] Or we possibly have a stream that does not start with a
  328|       |    // leading byte.
  329|     64|    return result(error_code::TOO_LONG, 0 - how_far_back);
  330|     64|  }
  331|  1.33k|  result res = convert_with_errors<endian>(buf, len + extra_len, utf16_output);
  332|  1.33k|  if (res.error) {
  ------------------
  |  Branch (332:7): [True: 720, False: 616]
  ------------------
  333|    720|    res.count -= extra_len;
  334|    720|  }
  335|  1.33k|  return res;
  336|  1.40k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1613convert_validILNS_10endiannessE0EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mPDs:
   16|  1.35k|                                         char16_t *utf16_output) {
   17|  1.35k|  size_t pos = 0;
   18|  1.35k|  char16_t *start{utf16_output};
   19|  5.05M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 5.05M, False: 1.35k]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|  5.05M|    {                       // try to convert the next block of 8 ASCII bytes
   24|  5.05M|      if (pos + 8 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (24:11): [True: 5.04M, False: 4.40k]
  ------------------
   25|       |                            // they are ascii
   26|  5.04M|        uint64_t v;
   27|  5.04M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   28|  5.04M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (28:13): [True: 3.20M, False: 1.84M]
  ------------------
   29|  3.20M|          size_t final_pos = pos + 8;
   30|  28.8M|          while (pos < final_pos) {
  ------------------
  |  Branch (30:18): [True: 25.6M, False: 3.20M]
  ------------------
   31|  25.6M|            const char16_t byte = uint8_t(data[pos]);
   32|  25.6M|            *utf16_output++ =
   33|  25.6M|                !match_system(big_endian) ? u16_swap_bytes(byte) : byte;
  ------------------
  |  Branch (33:17): [Folded, False: 25.6M]
  ------------------
   34|  25.6M|            pos++;
   35|  25.6M|          }
   36|  3.20M|          continue;
   37|  3.20M|        }
   38|  5.04M|      }
   39|  5.05M|    }
   40|       |
   41|  1.84M|    auto leading_byte = uint8_t(data[pos]); // leading byte
   42|  1.84M|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (42:9): [True: 1.23M, False: 612k]
  ------------------
   43|       |      // converting one ASCII byte !!!
   44|  1.23M|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (44:25): [Folded, False: 1.23M]
  ------------------
   45|  1.23M|                            ? char16_t(u16_swap_bytes(leading_byte))
   46|  1.23M|                            : char16_t(leading_byte);
   47|  1.23M|      pos++;
   48|  1.23M|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (48:16): [True: 362k, False: 249k]
  ------------------
   49|       |      // We have a two-byte UTF-8, it should become
   50|       |      // a single UTF-16 word.
   51|   362k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (51:11): [True: 0, False: 362k]
  ------------------
   52|      0|        break;
   53|      0|      } // minimal bound checking
   54|   362k|      uint16_t code_point = uint16_t(((leading_byte & 0b00011111) << 6) |
   55|   362k|                                     (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|   362k|      *utf16_output++ = char16_t(code_point);
   60|   362k|      pos += 2;
   61|   362k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (61:16): [True: 229k, False: 19.7k]
  ------------------
   62|       |      // We have a three-byte UTF-8, it should become
   63|       |      // a single UTF-16 word.
   64|   229k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (64:11): [True: 0, False: 229k]
  ------------------
   65|      0|        break;
   66|      0|      } // minimal bound checking
   67|   229k|      uint16_t code_point =
   68|   229k|          uint16_t(((leading_byte & 0b00001111) << 12) |
   69|   229k|                   ((uint8_t(data[pos + 1]) & 0b00111111) << 6) |
   70|   229k|                   (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|   229k|      *utf16_output++ = char16_t(code_point);
   75|   229k|      pos += 3;
   76|   229k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (76:16): [True: 19.7k, False: 0]
  ------------------
   77|       |      // we have a 4-byte UTF-8 word.
   78|  19.7k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (78:11): [True: 0, False: 19.7k]
  ------------------
   79|      0|        break;
   80|      0|      } // minimal bound checking
   81|  19.7k|      uint32_t code_point = ((leading_byte & 0b00000111) << 18) |
   82|  19.7k|                            ((uint8_t(data[pos + 1]) & 0b00111111) << 12) |
   83|  19.7k|                            ((uint8_t(data[pos + 2]) & 0b00111111) << 6) |
   84|  19.7k|                            (uint8_t(data[pos + 3]) & 0b00111111);
   85|  19.7k|      code_point -= 0x10000;
   86|  19.7k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
   87|  19.7k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
   88|       |      if constexpr (!match_system(big_endian)) {
   89|       |        high_surrogate = u16_swap_bytes(high_surrogate);
   90|       |        low_surrogate = u16_swap_bytes(low_surrogate);
   91|       |      }
   92|  19.7k|      *utf16_output++ = char16_t(high_surrogate);
   93|  19.7k|      *utf16_output++ = char16_t(low_surrogate);
   94|  19.7k|      pos += 4;
   95|  19.7k|    } else {
   96|       |      // we may have a continuation but we do not do error checking
   97|      0|      return 0;
   98|      0|    }
   99|  1.84M|  }
  100|  1.35k|  return utf16_output - start;
  101|  1.35k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1613convert_validILNS_10endiannessE1EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mPDs:
   16|  1.53k|                                         char16_t *utf16_output) {
   17|  1.53k|  size_t pos = 0;
   18|  1.53k|  char16_t *start{utf16_output};
   19|  4.11M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 4.11M, False: 1.53k]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|  4.11M|    {                       // try to convert the next block of 8 ASCII bytes
   24|  4.11M|      if (pos + 8 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (24:11): [True: 4.10M, False: 4.72k]
  ------------------
   25|       |                            // they are ascii
   26|  4.10M|        uint64_t v;
   27|  4.10M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   28|  4.10M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (28:13): [True: 3.21M, False: 895k]
  ------------------
   29|  3.21M|          size_t final_pos = pos + 8;
   30|  28.9M|          while (pos < final_pos) {
  ------------------
  |  Branch (30:18): [True: 25.7M, False: 3.21M]
  ------------------
   31|  25.7M|            const char16_t byte = uint8_t(data[pos]);
   32|  25.7M|            *utf16_output++ =
   33|  25.7M|                !match_system(big_endian) ? u16_swap_bytes(byte) : byte;
  ------------------
  |  Branch (33:17): [True: 25.7M, Folded]
  ------------------
   34|  25.7M|            pos++;
   35|  25.7M|          }
   36|  3.21M|          continue;
   37|  3.21M|        }
   38|  4.10M|      }
   39|  4.11M|    }
   40|       |
   41|   899k|    auto leading_byte = uint8_t(data[pos]); // leading byte
   42|   899k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (42:9): [True: 521k, False: 378k]
  ------------------
   43|       |      // converting one ASCII byte !!!
   44|   521k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (44:25): [True: 521k, Folded]
  ------------------
   45|   521k|                            ? char16_t(u16_swap_bytes(leading_byte))
   46|   521k|                            : char16_t(leading_byte);
   47|   521k|      pos++;
   48|   521k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (48:16): [True: 292k, False: 85.9k]
  ------------------
   49|       |      // We have a two-byte UTF-8, it should become
   50|       |      // a single UTF-16 word.
   51|   292k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (51:11): [True: 0, False: 292k]
  ------------------
   52|      0|        break;
   53|      0|      } // minimal bound checking
   54|   292k|      uint16_t code_point = uint16_t(((leading_byte & 0b00011111) << 6) |
   55|   292k|                                     (uint8_t(data[pos + 1]) & 0b00111111));
   56|   292k|      if constexpr (!match_system(big_endian)) {
   57|   292k|        code_point = u16_swap_bytes(uint16_t(code_point));
   58|   292k|      }
   59|   292k|      *utf16_output++ = char16_t(code_point);
   60|   292k|      pos += 2;
   61|   292k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (61:16): [True: 56.1k, False: 29.8k]
  ------------------
   62|       |      // We have a three-byte UTF-8, it should become
   63|       |      // a single UTF-16 word.
   64|  56.1k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (64:11): [True: 0, False: 56.1k]
  ------------------
   65|      0|        break;
   66|      0|      } // minimal bound checking
   67|  56.1k|      uint16_t code_point =
   68|  56.1k|          uint16_t(((leading_byte & 0b00001111) << 12) |
   69|  56.1k|                   ((uint8_t(data[pos + 1]) & 0b00111111) << 6) |
   70|  56.1k|                   (uint8_t(data[pos + 2]) & 0b00111111));
   71|  56.1k|      if constexpr (!match_system(big_endian)) {
   72|  56.1k|        code_point = u16_swap_bytes(uint16_t(code_point));
   73|  56.1k|      }
   74|  56.1k|      *utf16_output++ = char16_t(code_point);
   75|  56.1k|      pos += 3;
   76|  56.1k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (76:16): [True: 29.8k, False: 0]
  ------------------
   77|       |      // we have a 4-byte UTF-8 word.
   78|  29.8k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (78:11): [True: 0, False: 29.8k]
  ------------------
   79|      0|        break;
   80|      0|      } // minimal bound checking
   81|  29.8k|      uint32_t code_point = ((leading_byte & 0b00000111) << 18) |
   82|  29.8k|                            ((uint8_t(data[pos + 1]) & 0b00111111) << 12) |
   83|  29.8k|                            ((uint8_t(data[pos + 2]) & 0b00111111) << 6) |
   84|  29.8k|                            (uint8_t(data[pos + 3]) & 0b00111111);
   85|  29.8k|      code_point -= 0x10000;
   86|  29.8k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
   87|  29.8k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
   88|  29.8k|      if constexpr (!match_system(big_endian)) {
   89|  29.8k|        high_surrogate = u16_swap_bytes(high_surrogate);
   90|  29.8k|        low_surrogate = u16_swap_bytes(low_surrogate);
   91|  29.8k|      }
   92|  29.8k|      *utf16_output++ = char16_t(high_surrogate);
   93|  29.8k|      *utf16_output++ = char16_t(low_surrogate);
   94|  29.8k|      pos += 4;
   95|  29.8k|    } else {
   96|       |      // we may have a continuation but we do not do error checking
   97|      0|      return 0;
   98|      0|    }
   99|   899k|  }
  100|  1.53k|  return utf16_output - start;
  101|  1.53k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf3230rewind_and_convert_with_errorsEmPKcmPDi:
  249|  1.48k|                                             char32_t *utf32_output) {
  250|  1.48k|  size_t extra_len{0};
  251|       |  // We potentially need to go back in time and find a leading byte.
  252|  1.48k|  size_t how_far_back = 3; // 3 bytes in the past + current position
  253|  1.48k|  if (how_far_back > prior_bytes) {
  ------------------
  |  Branch (253:7): [True: 800, False: 684]
  ------------------
  254|    800|    how_far_back = prior_bytes;
  255|    800|  }
  256|  1.48k|  bool found_leading_bytes{false};
  257|       |  // important: it is i <= how_far_back and not 'i < how_far_back'.
  258|  1.57k|  for (size_t i = 0; i <= how_far_back; i++) {
  ------------------
  |  Branch (258:22): [True: 1.48k, False: 88]
  ------------------
  259|  1.48k|    unsigned char byte = buf[-static_cast<std::ptrdiff_t>(i)];
  260|  1.48k|    found_leading_bytes = ((byte & 0b11000000) != 0b10000000);
  261|  1.48k|    if (found_leading_bytes) {
  ------------------
  |  Branch (261:9): [True: 1.39k, False: 92]
  ------------------
  262|  1.39k|      if (i > 0 && byte < 128) {
  ------------------
  |  Branch (262:11): [True: 4, False: 1.39k]
  |  Branch (262:20): [True: 4, False: 0]
  ------------------
  263|       |        // If we had to go back and the leading byte is ascii
  264|       |        // then we can stop right away.
  265|      4|        return result(error_code::TOO_LONG, 0 - i + 1);
  266|      4|      }
  267|  1.39k|      buf -= i;
  268|  1.39k|      extra_len = i;
  269|  1.39k|      break;
  270|  1.39k|    }
  271|  1.48k|  }
  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.48k|  if (!found_leading_bytes) {
  ------------------
  |  Branch (280:7): [True: 88, False: 1.39k]
  ------------------
  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|     88|    return result(error_code::TOO_LONG, 0 - how_far_back);
  286|     88|  }
  287|       |
  288|  1.39k|  result res = convert_with_errors(buf, len + extra_len, utf32_output);
  289|  1.39k|  if (res.error) {
  ------------------
  |  Branch (289:7): [True: 776, False: 616]
  ------------------
  290|    776|    res.count -= extra_len;
  291|    776|  }
  292|  1.39k|  return res;
  293|  1.48k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf3219convert_with_errorsIPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEENS_6resultES6_mPDi:
  121|  2.13k|                                               char32_t *utf32_output) {
  122|  2.13k|  size_t pos = 0;
  123|  2.13k|  char32_t *start{utf32_output};
  124|  2.79M|  while (pos < len) {
  ------------------
  |  Branch (124:10): [True: 2.79M, False: 928]
  ------------------
  125|       |#if SIMDUTF_CPLUSPLUS23
  126|       |    if !consteval
  127|       |#endif
  128|  2.79M|    {
  129|       |      // try to convert the next block of 16 ASCII bytes
  130|  2.79M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (130:11): [True: 2.78M, False: 8.18k]
  ------------------
  131|       |                             // they are ascii
  132|  2.78M|        uint64_t v1;
  133|  2.78M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
  134|  2.78M|        uint64_t v2;
  135|  2.78M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  136|  2.78M|        uint64_t v{v1 | v2};
  137|  2.78M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (137:13): [True: 1.61M, False: 1.16M]
  ------------------
  138|  1.61M|          size_t final_pos = pos + 16;
  139|  27.5M|          while (pos < final_pos) {
  ------------------
  |  Branch (139:18): [True: 25.8M, False: 1.61M]
  ------------------
  140|  25.8M|            *utf32_output++ = uint8_t(data[pos]);
  141|  25.8M|            pos++;
  142|  25.8M|          }
  143|  1.61M|          continue;
  144|  1.61M|        }
  145|  2.78M|      }
  146|  2.79M|    }
  147|  1.17M|    auto leading_byte = uint8_t(data[pos]); // leading byte
  148|  1.17M|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (148:9): [True: 946k, False: 229k]
  ------------------
  149|       |      // converting one ASCII byte !!!
  150|   946k|      *utf32_output++ = char32_t(leading_byte);
  151|   946k|      pos++;
  152|   946k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (152:16): [True: 143k, False: 85.3k]
  ------------------
  153|       |      // We have a two-byte UTF-8
  154|   143k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (154:11): [True: 60, False: 143k]
  ------------------
  155|     60|        return result(error_code::TOO_SHORT, pos);
  156|     60|      } // minimal bound checking
  157|   143k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (157:11): [True: 150, False: 143k]
  ------------------
  158|    150|        return result(error_code::TOO_SHORT, pos);
  159|    150|      }
  160|       |      // range check
  161|   143k|      uint32_t code_point = (leading_byte & 0b00011111) << 6 |
  162|   143k|                            (uint8_t(data[pos + 1]) & 0b00111111);
  163|   143k|      if (code_point < 0x80) {
  ------------------
  |  Branch (163:11): [True: 36, False: 143k]
  ------------------
  164|     36|        return result(error_code::OVERLONG, pos);
  165|     36|      }
  166|   143k|      *utf32_output++ = char32_t(code_point);
  167|   143k|      pos += 2;
  168|   143k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (168:16): [True: 77.0k, False: 8.31k]
  ------------------
  169|       |      // We have a three-byte UTF-8
  170|  77.0k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (170:11): [True: 78, False: 76.9k]
  ------------------
  171|     78|        return result(error_code::TOO_SHORT, pos);
  172|     78|      } // minimal bound checking
  173|       |
  174|  76.9k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (174:11): [True: 132, False: 76.8k]
  ------------------
  175|    132|        return result(error_code::TOO_SHORT, pos);
  176|    132|      }
  177|  76.8k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (177:11): [True: 18, False: 76.8k]
  ------------------
  178|     18|        return result(error_code::TOO_SHORT, pos);
  179|     18|      }
  180|       |      // range check
  181|  76.8k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
  182|  76.8k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 6 |
  183|  76.8k|                            (uint8_t(data[pos + 2]) & 0b00111111);
  184|  76.8k|      if (code_point < 0x800) {
  ------------------
  |  Branch (184:11): [True: 36, False: 76.7k]
  ------------------
  185|     36|        return result(error_code::OVERLONG, pos);
  186|     36|      }
  187|  76.7k|      if (0xd7ff < code_point && code_point < 0xe000) {
  ------------------
  |  Branch (187:11): [True: 3.78k, False: 73.0k]
  |  Branch (187:34): [True: 18, False: 3.76k]
  ------------------
  188|     18|        return result(error_code::SURROGATE, pos);
  189|     18|      }
  190|  76.7k|      *utf32_output++ = char32_t(code_point);
  191|  76.7k|      pos += 3;
  192|  76.7k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (192:16): [True: 7.89k, False: 424]
  ------------------
  193|       |      // we have a 4-byte UTF-8 word.
  194|  7.89k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (194:11): [True: 36, False: 7.85k]
  ------------------
  195|     36|        return result(error_code::TOO_SHORT, pos);
  196|     36|      } // minimal bound checking
  197|  7.85k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (197:11): [True: 90, False: 7.76k]
  ------------------
  198|     90|        return result(error_code::TOO_SHORT, pos);
  199|     90|      }
  200|  7.76k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (200:11): [True: 36, False: 7.73k]
  ------------------
  201|     36|        return result(error_code::TOO_SHORT, pos);
  202|     36|      }
  203|  7.73k|      if ((uint8_t(data[pos + 3]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (203:11): [True: 36, False: 7.69k]
  ------------------
  204|     36|        return result(error_code::TOO_SHORT, pos);
  205|     36|      }
  206|       |
  207|       |      // range check
  208|  7.69k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  209|  7.69k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 12 |
  210|  7.69k|                            (uint8_t(data[pos + 2]) & 0b00111111) << 6 |
  211|  7.69k|                            (uint8_t(data[pos + 3]) & 0b00111111);
  212|  7.69k|      if (code_point <= 0xffff) {
  ------------------
  |  Branch (212:11): [True: 30, False: 7.66k]
  ------------------
  213|     30|        return result(error_code::OVERLONG, pos);
  214|     30|      }
  215|  7.66k|      if (0x10ffff < code_point) {
  ------------------
  |  Branch (215:11): [True: 30, False: 7.63k]
  ------------------
  216|     30|        return result(error_code::TOO_LARGE, pos);
  217|     30|      }
  218|  7.63k|      *utf32_output++ = char32_t(code_point);
  219|  7.63k|      pos += 4;
  220|  7.63k|    } else {
  221|       |      // we either have too many continuation bytes or an invalid leading byte
  222|    424|      if ((leading_byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (222:11): [True: 202, False: 222]
  ------------------
  223|    202|        return result(error_code::TOO_LONG, pos);
  224|    222|      } else {
  225|    222|        return result(error_code::HEADER_BITS, pos);
  226|    222|      }
  227|    424|    }
  228|  1.17M|  }
  229|    928|  return result(error_code::SUCCESS, utf32_output - start);
  230|  2.13k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf327convertIPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEEmS6_mPDi:
   16|  1.72k|                                   char32_t *utf32_output) {
   17|  1.72k|  size_t pos = 0;
   18|  1.72k|  char32_t *start{utf32_output};
   19|  2.05M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 2.05M, False: 788]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|  2.05M|    {
   24|       |      // try to convert the next block of 16 ASCII bytes
   25|  2.05M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 2.04M, False: 6.13k]
  ------------------
   26|       |                             // they are ascii
   27|  2.04M|        uint64_t v1;
   28|  2.04M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   29|  2.04M|        uint64_t v2;
   30|  2.04M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   31|  2.04M|        uint64_t v{v1 | v2};
   32|  2.04M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (32:13): [True: 1.31M, False: 732k]
  ------------------
   33|  1.31M|          size_t final_pos = pos + 16;
   34|  22.3M|          while (pos < final_pos) {
  ------------------
  |  Branch (34:18): [True: 21.0M, False: 1.31M]
  ------------------
   35|  21.0M|            *utf32_output++ = uint8_t(data[pos]);
   36|  21.0M|            pos++;
   37|  21.0M|          }
   38|  1.31M|          continue;
   39|  1.31M|        }
   40|  2.04M|      }
   41|  2.05M|    }
   42|   738k|    auto leading_byte = uint8_t(data[pos]); // leading byte
   43|   738k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (43:9): [True: 610k, False: 128k]
  ------------------
   44|       |      // converting one ASCII byte !!!
   45|   610k|      *utf32_output++ = char32_t(leading_byte);
   46|   610k|      pos++;
   47|   610k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (47:16): [True: 74.2k, False: 53.8k]
  ------------------
   48|       |      // We have a two-byte UTF-8
   49|  74.2k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (49:11): [True: 54, False: 74.2k]
  ------------------
   50|     54|        return 0;
   51|     54|      } // minimal bound checking
   52|  74.2k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (52:11): [True: 116, False: 74.1k]
  ------------------
   53|    116|        return 0;
   54|    116|      }
   55|       |      // range check
   56|  74.1k|      uint32_t code_point = (leading_byte & 0b00011111) << 6 |
   57|  74.1k|                            (uint8_t(data[pos + 1]) & 0b00111111);
   58|  74.1k|      if (code_point < 0x80) {
  ------------------
  |  Branch (58:11): [True: 22, False: 74.0k]
  ------------------
   59|     22|        return 0;
   60|     22|      }
   61|  74.0k|      *utf32_output++ = char32_t(code_point);
   62|  74.0k|      pos += 2;
   63|  74.0k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (63:16): [True: 48.9k, False: 4.86k]
  ------------------
   64|       |      // We have a three-byte UTF-8
   65|  48.9k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (65:11): [True: 42, False: 48.9k]
  ------------------
   66|     42|        return 0;
   67|     42|      } // minimal bound checking
   68|       |
   69|  48.9k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (69:11): [True: 80, False: 48.8k]
  ------------------
   70|     80|        return 0;
   71|     80|      }
   72|  48.8k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (72:11): [True: 40, False: 48.8k]
  ------------------
   73|     40|        return 0;
   74|     40|      }
   75|       |      // range check
   76|  48.8k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
   77|  48.8k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 6 |
   78|  48.8k|                            (uint8_t(data[pos + 2]) & 0b00111111);
   79|  48.8k|      if (code_point < 0x800 || (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (79:11): [True: 28, False: 48.7k]
  |  Branch (79:34): [True: 536, False: 48.2k]
  |  Branch (79:57): [True: 16, False: 520]
  ------------------
   80|     44|        return 0;
   81|     44|      }
   82|  48.7k|      *utf32_output++ = char32_t(code_point);
   83|  48.7k|      pos += 3;
   84|  48.7k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (84:16): [True: 4.50k, False: 356]
  ------------------
   85|       |      // we have a 4-byte UTF-8 word.
   86|  4.50k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (86:11): [True: 24, False: 4.48k]
  ------------------
   87|     24|        return 0;
   88|     24|      } // minimal bound checking
   89|  4.48k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (89:11): [True: 36, False: 4.44k]
  ------------------
   90|     36|        return 0;
   91|     36|      }
   92|  4.44k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (92:11): [True: 20, False: 4.42k]
  ------------------
   93|     20|        return 0;
   94|     20|      }
   95|  4.42k|      if ((uint8_t(data[pos + 3]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (95:11): [True: 12, False: 4.41k]
  ------------------
   96|     12|        return 0;
   97|     12|      }
   98|       |
   99|       |      // range check
  100|  4.41k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  101|  4.41k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 12 |
  102|  4.41k|                            (uint8_t(data[pos + 2]) & 0b00111111) << 6 |
  103|  4.41k|                            (uint8_t(data[pos + 3]) & 0b00111111);
  104|  4.41k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (104:11): [True: 50, False: 4.36k]
  |  Branch (104:35): [True: 42, False: 4.32k]
  ------------------
  105|     92|        return 0;
  106|     92|      }
  107|  4.32k|      *utf32_output++ = char32_t(code_point);
  108|  4.32k|      pos += 4;
  109|  4.32k|    } else {
  110|    356|      return 0;
  111|    356|    }
  112|   738k|  }
  113|    788|  return utf32_output - start;
  114|  1.72k|}

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

_ZNK7simdutf8fallback14implementation13validate_utf8EPKcm:
   37|  3.48k|implementation::validate_utf8(const char *buf, size_t len) const noexcept {
   38|  3.48k|  return scalar::utf8::validate(buf, len);
   39|  3.48k|}
_ZNK7simdutf8fallback14implementation25validate_utf8_with_errorsEPKcm:
   44|  3.48k|    const char *buf, size_t len) const noexcept {
   45|  3.48k|  return scalar::utf8::validate_with_errors(buf, len);
   46|  3.48k|}
_ZNK7simdutf8fallback14implementation16validate_utf16leEPKDsm:
   77|  1.35k|                                 size_t len) const noexcept {
   78|  1.35k|  return scalar::utf16::validate<endianness::LITTLE>(buf, len);
   79|  1.35k|}
_ZNK7simdutf8fallback14implementation16validate_utf16beEPKDsm:
   85|  1.33k|                                 size_t len) const noexcept {
   86|  1.33k|  return scalar::utf16::validate<endianness::BIG>(buf, len);
   87|  1.33k|}
_ZNK7simdutf8fallback14implementation28validate_utf16le_with_errorsEPKDsm:
   90|  1.35k|    const char16_t *buf, size_t len) const noexcept {
   91|  1.35k|  return scalar::utf16::validate_with_errors<endianness::LITTLE>(buf, len);
   92|  1.35k|}
_ZNK7simdutf8fallback14implementation28validate_utf16be_with_errorsEPKDsm:
   95|  1.33k|    const char16_t *buf, size_t len) const noexcept {
   96|  1.33k|  return scalar::utf16::validate_with_errors<endianness::BIG>(buf, len);
   97|  1.33k|}
_ZNK7simdutf8fallback14implementation14validate_utf32EPKDim:
  114|  2.63k|implementation::validate_utf32(const char32_t *buf, size_t len) const noexcept {
  115|  2.63k|  return scalar::utf32::validate(buf, len);
  116|  2.63k|}
_ZNK7simdutf8fallback14implementation26validate_utf32_with_errorsEPKDim:
  121|  2.63k|    const char32_t *buf, size_t len) const noexcept {
  122|  2.63k|  return scalar::utf32::validate_with_errors(buf, len);
  123|  2.63k|}
_ZNK7simdutf8fallback14implementation22convert_latin1_to_utf8EPKcmPc:
  128|    604|    const char *buf, size_t len, char *utf8_output) const noexcept {
  129|    604|  return scalar::latin1_to_utf8::convert(buf, len, utf8_output);
  130|    604|}
_ZNK7simdutf8fallback14implementation25convert_latin1_to_utf16leEPKcmPDs:
  135|     76|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  136|     76|  return scalar::latin1_to_utf16::convert<endianness::LITTLE>(buf, len,
  137|     76|                                                              utf16_output);
  138|     76|}
_ZNK7simdutf8fallback14implementation25convert_latin1_to_utf16beEPKcmPDs:
  141|     96|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  142|     96|  return scalar::latin1_to_utf16::convert<endianness::BIG>(buf, len,
  143|     96|                                                           utf16_output);
  144|     96|}
_ZNK7simdutf8fallback14implementation23convert_latin1_to_utf32EPKcmPDi:
  149|    124|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  150|    124|  return scalar::latin1_to_utf32::convert(buf, len, utf32_output);
  151|    124|}
_ZNK7simdutf8fallback14implementation22convert_utf8_to_latin1EPKcmPc:
  156|    586|    const char *buf, size_t len, char *latin1_output) const noexcept {
  157|    586|  return scalar::utf8_to_latin1::convert(buf, len, latin1_output);
  158|    586|}
_ZNK7simdutf8fallback14implementation34convert_utf8_to_latin1_with_errorsEPKcmPc:
  161|    512|    const char *buf, size_t len, char *latin1_output) const noexcept {
  162|    512|  return scalar::utf8_to_latin1::convert_with_errors(buf, len, latin1_output);
  163|    512|}
_ZNK7simdutf8fallback14implementation23convert_utf8_to_utf16leEPKcmPDs:
  173|    776|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  174|    776|  return scalar::utf8_to_utf16::convert<endianness::LITTLE>(buf, len,
  175|    776|                                                            utf16_output);
  176|    776|}
_ZNK7simdutf8fallback14implementation23convert_utf8_to_utf16beEPKcmPDs:
  179|    794|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  180|    794|  return scalar::utf8_to_utf16::convert<endianness::BIG>(buf, len,
  181|    794|                                                         utf16_output);
  182|    794|}
_ZNK7simdutf8fallback14implementation35convert_utf8_to_utf16le_with_errorsEPKcmPDs:
  185|    610|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  186|    610|  return scalar::utf8_to_utf16::convert_with_errors<endianness::LITTLE>(
  187|    610|      buf, len, utf16_output);
  188|    610|}
_ZNK7simdutf8fallback14implementation35convert_utf8_to_utf16be_with_errorsEPKcmPDs:
  191|    706|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  192|    706|  return scalar::utf8_to_utf16::convert_with_errors<endianness::BIG>(
  193|    706|      buf, len, utf16_output);
  194|    706|}
_ZNK7simdutf8fallback14implementation29convert_valid_utf8_to_utf16leEPKcmPDs:
  197|    450|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  198|    450|  return scalar::utf8_to_utf16::convert_valid<endianness::LITTLE>(buf, len,
  199|    450|                                                                  utf16_output);
  200|    450|}
_ZNK7simdutf8fallback14implementation29convert_valid_utf8_to_utf16beEPKcmPDs:
  203|    510|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  204|    510|  return scalar::utf8_to_utf16::convert_valid<endianness::BIG>(buf, len,
  205|    510|                                                               utf16_output);
  206|    510|}
_ZNK7simdutf8fallback14implementation21convert_utf8_to_utf32EPKcmPDi:
  211|    758|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  212|    758|  return scalar::utf8_to_utf32::convert(buf, len, utf32_output);
  213|    758|}
_ZNK7simdutf8fallback14implementation33convert_utf8_to_utf32_with_errorsEPKcmPDi:
  216|    746|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  217|    746|  return scalar::utf8_to_utf32::convert_with_errors(buf, len, utf32_output);
  218|    746|}
_ZNK7simdutf8fallback14implementation27convert_valid_utf8_to_utf32EPKcmPDi:
  221|    464|    const char *input, size_t size, char32_t *utf32_output) const noexcept {
  222|    464|  return scalar::utf8_to_utf32::convert_valid(input, size, utf32_output);
  223|    464|}
_ZNK7simdutf8fallback14implementation25convert_utf16le_to_latin1EPKDsmPc:
  228|    124|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  229|    124|  return scalar::utf16_to_latin1::convert<endianness::LITTLE>(buf, len,
  230|    124|                                                              latin1_output);
  231|    124|}
_ZNK7simdutf8fallback14implementation25convert_utf16be_to_latin1EPKDsmPc:
  234|    114|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  235|    114|  return scalar::utf16_to_latin1::convert<endianness::BIG>(buf, len,
  236|    114|                                                           latin1_output);
  237|    114|}
_ZNK7simdutf8fallback14implementation37convert_utf16le_to_latin1_with_errorsEPKDsmPc:
  241|    278|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  242|    278|  return scalar::utf16_to_latin1::convert_with_errors<endianness::LITTLE>(
  243|    278|      buf, len, latin1_output);
  244|    278|}
_ZNK7simdutf8fallback14implementation37convert_utf16be_to_latin1_with_errorsEPKDsmPc:
  248|    266|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  249|    266|  return scalar::utf16_to_latin1::convert_with_errors<endianness::BIG>(
  250|    266|      buf, len, latin1_output);
  251|    266|}
_ZNK7simdutf8fallback14implementation23convert_utf16le_to_utf8EPKDsmPc:
  268|    436|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  269|    436|  return scalar::utf16_to_utf8::convert<endianness::LITTLE>(buf, len,
  270|    436|                                                            utf8_output);
  271|    436|}
_ZNK7simdutf8fallback14implementation23convert_utf16be_to_utf8EPKDsmPc:
  274|    346|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  275|    346|  return scalar::utf16_to_utf8::convert<endianness::BIG>(buf, len, utf8_output);
  276|    346|}
_ZNK7simdutf8fallback14implementation35convert_utf16le_to_utf8_with_errorsEPKDsmPc:
  279|    642|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  280|    642|  return scalar::utf16_to_utf8::convert_with_errors<endianness::LITTLE>(
  281|    642|      buf, len, utf8_output);
  282|    642|}
_ZNK7simdutf8fallback14implementation35convert_utf16be_to_utf8_with_errorsEPKDsmPc:
  285|    654|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  286|    654|  return scalar::utf16_to_utf8::convert_with_errors<endianness::BIG>(
  287|    654|      buf, len, utf8_output);
  288|    654|}
_ZNK7simdutf8fallback14implementation29convert_valid_utf16le_to_utf8EPKDsmPc:
  291|    406|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  292|    406|  return scalar::utf16_to_utf8::convert_valid<endianness::LITTLE>(buf, len,
  293|    406|                                                                  utf8_output);
  294|    406|}
_ZNK7simdutf8fallback14implementation29convert_valid_utf16be_to_utf8EPKDsmPc:
  297|    452|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  298|    452|  return scalar::utf16_to_utf8::convert_valid<endianness::BIG>(buf, len,
  299|    452|                                                               utf8_output);
  300|    452|}
_ZNK7simdutf8fallback14implementation23convert_utf32_to_latin1EPKDimPc:
  305|    228|    const char32_t *buf, size_t len, char *latin1_output) const noexcept {
  306|    228|  return scalar::utf32_to_latin1::convert(buf, len, latin1_output);
  307|    228|}
_ZNK7simdutf8fallback14implementation35convert_utf32_to_latin1_with_errorsEPKDimPc:
  310|    436|    const char32_t *buf, size_t len, char *latin1_output) const noexcept {
  311|    436|  return scalar::utf32_to_latin1::convert_with_errors(buf, len, latin1_output);
  312|    436|}
_ZNK7simdutf8fallback14implementation21convert_utf32_to_utf8EPKDimPc:
  322|    648|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  323|    648|  return scalar::utf32_to_utf8::convert(buf, len, utf8_output);
  324|    648|}
_ZNK7simdutf8fallback14implementation33convert_utf32_to_utf8_with_errorsEPKDimPc:
  327|    832|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  328|    832|  return scalar::utf32_to_utf8::convert_with_errors(buf, len, utf8_output);
  329|    832|}
_ZNK7simdutf8fallback14implementation27convert_valid_utf32_to_utf8EPKDimPc:
  332|    216|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  333|    216|  return scalar::utf32_to_utf8::convert_valid(buf, len, utf8_output);
  334|    216|}
_ZNK7simdutf8fallback14implementation24convert_utf32_to_utf16leEPKDimPDs:
  339|    542|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  340|    542|  return scalar::utf32_to_utf16::convert<endianness::LITTLE>(buf, len,
  341|    542|                                                             utf16_output);
  342|    542|}
_ZNK7simdutf8fallback14implementation24convert_utf32_to_utf16beEPKDimPDs:
  345|    540|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  346|    540|  return scalar::utf32_to_utf16::convert<endianness::BIG>(buf, len,
  347|    540|                                                          utf16_output);
  348|    540|}
_ZNK7simdutf8fallback14implementation36convert_utf32_to_utf16le_with_errorsEPKDimPDs:
  351|    674|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  352|    674|  return scalar::utf32_to_utf16::convert_with_errors<endianness::LITTLE>(
  353|    674|      buf, len, utf16_output);
  354|    674|}
_ZNK7simdutf8fallback14implementation36convert_utf32_to_utf16be_with_errorsEPKDimPDs:
  357|    694|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  358|    694|  return scalar::utf32_to_utf16::convert_with_errors<endianness::BIG>(
  359|    694|      buf, len, utf16_output);
  360|    694|}
_ZNK7simdutf8fallback14implementation30convert_valid_utf32_to_utf16leEPKDimPDs:
  363|    280|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  364|    280|  return scalar::utf32_to_utf16::convert_valid<endianness::LITTLE>(
  365|    280|      buf, len, utf16_output);
  366|    280|}
_ZNK7simdutf8fallback14implementation30convert_valid_utf32_to_utf16beEPKDimPDs:
  369|    134|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  370|    134|  return scalar::utf32_to_utf16::convert_valid<endianness::BIG>(buf, len,
  371|    134|                                                                utf16_output);
  372|    134|}
_ZNK7simdutf8fallback14implementation24convert_utf16le_to_utf32EPKDsmPDi:
  375|    326|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  376|    326|  return scalar::utf16_to_utf32::convert<endianness::LITTLE>(buf, len,
  377|    326|                                                             utf32_output);
  378|    326|}
_ZNK7simdutf8fallback14implementation24convert_utf16be_to_utf32EPKDsmPDi:
  381|    280|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  382|    280|  return scalar::utf16_to_utf32::convert<endianness::BIG>(buf, len,
  383|    280|                                                          utf32_output);
  384|    280|}
_ZNK7simdutf8fallback14implementation36convert_utf16le_to_utf32_with_errorsEPKDsmPDi:
  387|    334|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  388|    334|  return scalar::utf16_to_utf32::convert_with_errors<endianness::LITTLE>(
  389|    334|      buf, len, utf32_output);
  390|    334|}
_ZNK7simdutf8fallback14implementation36convert_utf16be_to_utf32_with_errorsEPKDsmPDi:
  393|    346|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  394|    346|  return scalar::utf16_to_utf32::convert_with_errors<endianness::BIG>(
  395|    346|      buf, len, utf32_output);
  396|    346|}
_ZNK7simdutf8fallback14implementation30convert_valid_utf16le_to_utf32EPKDsmPDi:
  399|    128|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  400|    128|  return scalar::utf16_to_utf32::convert_valid<endianness::LITTLE>(
  401|    128|      buf, len, utf32_output);
  402|    128|}
_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.35k|    const char16_t *input, size_t length) const noexcept {
  420|  1.35k|  return scalar::utf16::count_code_points<endianness::LITTLE>(input, length);
  421|  1.35k|}
_ZNK7simdutf8fallback14implementation13count_utf16beEPKDsm:
  424|  1.33k|    const char16_t *input, size_t length) const noexcept {
  425|  1.33k|  return scalar::utf16::count_code_points<endianness::BIG>(input, length);
  426|  1.33k|}
_ZNK7simdutf8fallback14implementation10count_utf8EPKcm:
  431|  3.48k|implementation::count_utf8(const char *input, size_t length) const noexcept {
  432|  3.48k|  return scalar::utf8::count_code_points(input, length);
  433|  3.48k|}
_ZNK7simdutf8fallback14implementation23latin1_length_from_utf8EPKcm:
  438|    549|    const char *buf, size_t len) const noexcept {
  439|    549|  return scalar::utf8::count_code_points(buf, len);
  440|    549|}
_ZNK7simdutf8fallback14implementation23utf8_length_from_latin1EPKcm:
  445|    302|    const char *input, size_t length) const noexcept {
  446|    302|  return scalar::latin1_to_utf8::utf8_length_from_latin1(input, length);
  447|    302|}
_ZNK7simdutf8fallback14implementation24utf8_length_from_utf16leEPKDsm:
  452|    754|    const char16_t *input, size_t length) const noexcept {
  453|    754|  return scalar::utf16::utf8_length_from_utf16<endianness::LITTLE>(input,
  454|    754|                                                                   length);
  455|    754|}
_ZNK7simdutf8fallback14implementation24utf8_length_from_utf16beEPKDsm:
  458|    748|    const char16_t *input, size_t length) const noexcept {
  459|    748|  return scalar::utf16::utf8_length_from_utf16<endianness::BIG>(input, length);
  460|    748|}
_ZNK7simdutf8fallback14implementation25utf32_length_from_utf16leEPKDsm:
  465|    400|    const char16_t *input, size_t length) const noexcept {
  466|    400|  return scalar::utf16::utf32_length_from_utf16<endianness::LITTLE>(input,
  467|    400|                                                                    length);
  468|    400|}
_ZNK7simdutf8fallback14implementation25utf32_length_from_utf16beEPKDsm:
  471|    400|    const char16_t *input, size_t length) const noexcept {
  472|    400|  return scalar::utf16::utf32_length_from_utf16<endianness::BIG>(input, length);
  473|    400|}
_ZNK7simdutf8fallback14implementation22utf16_length_from_utf8EPKcm:
  478|  1.94k|    const char *input, size_t length) const noexcept {
  479|  1.94k|  return scalar::utf8::utf16_length_from_utf8(input, length);
  480|  1.94k|}
_ZNK7simdutf8fallback14implementation22utf8_length_from_utf32EPKDim:
  513|    860|    const char32_t *input, size_t length) const noexcept {
  514|    860|  return scalar::utf32::utf8_length_from_utf32(input, length);
  515|    860|}
_ZNK7simdutf8fallback14implementation23utf16_length_from_utf32EPKDim:
  520|  1.44k|    const char32_t *input, size_t length) const noexcept {
  521|  1.44k|  return scalar::utf32::utf16_length_from_utf32(input, length);
  522|  1.44k|}
_ZNK7simdutf8fallback14implementation22utf32_length_from_utf8EPKcm:
  527|    994|    const char *input, size_t length) const noexcept {
  528|    994|  return scalar::utf8::count_code_points(input, length);
  529|    994|}

simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_116buf_block_readerILm64EE13get_remainderEPh:
   57|  6.11k|buf_block_reader<STEP_SIZE>::get_remainder(uint8_t *dst) const {
   58|  6.11k|  if (len == idx) {
  ------------------
  |  Branch (58:7): [True: 32, False: 6.08k]
  ------------------
   59|     32|    return 0;
   60|     32|  } // memcpy(dst, null, 0) will trigger an error with some sanitizers
   61|  6.08k|  std::memset(dst, 0x20,
   62|  6.08k|              STEP_SIZE); // std::memset STEP_SIZE because it is more efficient
   63|       |                          // to write out 8 or 16 bytes at once.
   64|  6.08k|  std::memcpy(dst, buf + idx, len - idx);
   65|  6.08k|  return len - idx;
   66|  6.11k|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_116buf_block_readerILm64EE13get_remainderEPh:
   57|  6.11k|buf_block_reader<STEP_SIZE>::get_remainder(uint8_t *dst) const {
   58|  6.11k|  if (len == idx) {
  ------------------
  |  Branch (58:7): [True: 32, False: 6.08k]
  ------------------
   59|     32|    return 0;
   60|     32|  } // memcpy(dst, null, 0) will trigger an error with some sanitizers
   61|  6.08k|  std::memset(dst, 0x20,
   62|  6.08k|              STEP_SIZE); // std::memset STEP_SIZE because it is more efficient
   63|       |                          // to write out 8 or 16 bytes at once.
   64|  6.08k|  std::memcpy(dst, buf + idx, len - idx);
   65|  6.08k|  return len - idx;
   66|  6.11k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_116buf_block_readerILm64EEC2EPKhm:
   36|  6.97k|    : buf{_buf}, len{_len}, lenminusstep{len < STEP_SIZE ? 0 : len - STEP_SIZE},
  ------------------
  |  Branch (36:42): [True: 2.64k, False: 4.32k]
  ------------------
   37|  6.97k|      idx{0} {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_116buf_block_readerILm64EE14has_full_blockEv:
   45|  4.87M|simdutf_really_inline bool buf_block_reader<STEP_SIZE>::has_full_block() const {
   46|  4.87M|  return idx < lenminusstep;
   47|  4.87M|}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_116buf_block_readerILm64EE10full_blockEv:
   51|  4.86M|buf_block_reader<STEP_SIZE>::full_block() const {
   52|  4.86M|  return &buf[idx];
   53|  4.86M|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_116buf_block_readerILm64EE7advanceEv:
   69|  4.87M|simdutf_really_inline void buf_block_reader<STEP_SIZE>::advance() {
   70|  4.87M|  idx += STEP_SIZE;
   71|  4.87M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_116buf_block_readerILm64EEC2EPKhm:
   36|  6.97k|    : buf{_buf}, len{_len}, lenminusstep{len < STEP_SIZE ? 0 : len - STEP_SIZE},
  ------------------
  |  Branch (36:42): [True: 2.64k, False: 4.32k]
  ------------------
   37|  6.97k|      idx{0} {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_116buf_block_readerILm64EE14has_full_blockEv:
   45|  4.87M|simdutf_really_inline bool buf_block_reader<STEP_SIZE>::has_full_block() const {
   46|  4.87M|  return idx < lenminusstep;
   47|  4.87M|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_116buf_block_readerILm64EE10full_blockEv:
   51|  4.86M|buf_block_reader<STEP_SIZE>::full_block() const {
   52|  4.86M|  return &buf[idx];
   53|  4.86M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_116buf_block_readerILm64EE7advanceEv:
   69|  4.87M|simdutf_really_inline void buf_block_reader<STEP_SIZE>::advance() {
   70|  4.87M|  idx += STEP_SIZE;
   71|  4.87M|}

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1631utf8_length_from_utf16_bytemaskILNS_10endiannessE0EEEmPKDsm:
   10|    754|                                                             size_t size) {
   11|    754|  size_t pos = 0;
   12|       |
   13|    754|  using vector_u16 = simd16<uint16_t>;
   14|    754|  constexpr size_t N = vector_u16::ELEMENTS;
   15|       |
   16|    754|  const auto one = vector_u16::splat(1);
   17|       |
   18|    754|  auto v_count = vector_u16::zero();
   19|       |
   20|       |  // each char16 yields at least one byte
   21|    754|  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|    754|  constexpr size_t max_iterations = 65535 / 2;
   26|    754|  size_t iteration = max_iterations;
   27|       |
   28|  1.05M|  for (; pos < size / N * N; pos += N) {
  ------------------
  |  Branch (28:10): [True: 1.05M, False: 754]
  ------------------
   29|  1.05M|    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.05M|    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.05M|    const auto c0 = min(input & uint16_t(0xff80), one);
   39|       |
   40|       |    // c1 - chars that yield 3-byte UTF-8 codes (including surrogates)
   41|  1.05M|    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.05M|    v_count += c0;
   68|  1.05M|    v_count += c1;
   69|  1.05M|    v_count += vector_u16(is_surrogate);
   70|       |
   71|  1.05M|    iteration -= 1;
   72|  1.05M|    if (iteration == 0) {
  ------------------
  |  Branch (72:9): [True: 19, False: 1.05M]
  ------------------
   73|     19|      count += v_count.sum();
   74|     19|      v_count = vector_u16::zero();
   75|     19|      iteration = max_iterations;
   76|     19|    }
   77|  1.05M|  }
   78|       |
   79|    754|  if (iteration > 0) {
  ------------------
  |  Branch (79:7): [True: 754, False: 0]
  ------------------
   80|    754|    count += v_count.sum();
   81|    754|  }
   82|       |
   83|    754|  return count + scalar::utf16::utf8_length_from_utf16<big_endian>(in + pos,
   84|    754|                                                                   size - pos);
   85|    754|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1631utf8_length_from_utf16_bytemaskILNS_10endiannessE1EEEmPKDsm:
   10|    748|                                                             size_t size) {
   11|    748|  size_t pos = 0;
   12|       |
   13|    748|  using vector_u16 = simd16<uint16_t>;
   14|    748|  constexpr size_t N = vector_u16::ELEMENTS;
   15|       |
   16|    748|  const auto one = vector_u16::splat(1);
   17|       |
   18|    748|  auto v_count = vector_u16::zero();
   19|       |
   20|       |  // each char16 yields at least one byte
   21|    748|  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|    748|  constexpr size_t max_iterations = 65535 / 2;
   26|    748|  size_t iteration = max_iterations;
   27|       |
   28|   949k|  for (; pos < size / N * N; pos += N) {
  ------------------
  |  Branch (28:10): [True: 949k, False: 748]
  ------------------
   29|   949k|    auto input = vector_u16::load(reinterpret_cast<const uint16_t *>(in + pos));
   30|   949k|    if constexpr (!match_system(big_endian)) {
   31|   949k|      input = input.swap_bytes();
   32|   949k|    }
   33|       |    // 0xd800 .. 0xdbff - low surrogate
   34|       |    // 0xdc00 .. 0xdfff - high surrogate
   35|   949k|    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|   949k|    const auto c0 = min(input & uint16_t(0xff80), one);
   39|       |
   40|       |    // c1 - chars that yield 3-byte UTF-8 codes (including surrogates)
   41|   949k|    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|   949k|    v_count += c0;
   68|   949k|    v_count += c1;
   69|   949k|    v_count += vector_u16(is_surrogate);
   70|       |
   71|   949k|    iteration -= 1;
   72|   949k|    if (iteration == 0) {
  ------------------
  |  Branch (72:9): [True: 18, False: 949k]
  ------------------
   73|     18|      count += v_count.sum();
   74|     18|      v_count = vector_u16::zero();
   75|     18|      iteration = max_iterations;
   76|     18|    }
   77|   949k|  }
   78|       |
   79|    748|  if (iteration > 0) {
  ------------------
  |  Branch (79:7): [True: 748, False: 0]
  ------------------
   80|    748|    count += v_count.sum();
   81|    748|  }
   82|       |
   83|    748|  return count + scalar::utf16::utf8_length_from_utf16<big_endian>(in + pos,
   84|    748|                                                                   size - pos);
   85|    748|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1631utf8_length_from_utf16_bytemaskILNS_10endiannessE0EEEmPKDsm:
   10|    754|                                                             size_t size) {
   11|    754|  size_t pos = 0;
   12|       |
   13|    754|  using vector_u16 = simd16<uint16_t>;
   14|    754|  constexpr size_t N = vector_u16::ELEMENTS;
   15|       |
   16|    754|  const auto one = vector_u16::splat(1);
   17|       |
   18|    754|  auto v_count = vector_u16::zero();
   19|       |
   20|       |  // each char16 yields at least one byte
   21|    754|  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|    754|  constexpr size_t max_iterations = 65535 / 2;
   26|    754|  size_t iteration = max_iterations;
   27|       |
   28|  2.11M|  for (; pos < size / N * N; pos += N) {
  ------------------
  |  Branch (28:10): [True: 2.11M, False: 754]
  ------------------
   29|  2.11M|    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.11M|    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.11M|    const auto c0 = min(input & uint16_t(0xff80), one);
   39|       |
   40|       |    // c1 - chars that yield 3-byte UTF-8 codes (including surrogates)
   41|  2.11M|    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.11M|    v_count += c0;
   68|  2.11M|    v_count += c1;
   69|  2.11M|    v_count += vector_u16(is_surrogate);
   70|       |
   71|  2.11M|    iteration -= 1;
   72|  2.11M|    if (iteration == 0) {
  ------------------
  |  Branch (72:9): [True: 50, False: 2.11M]
  ------------------
   73|     50|      count += v_count.sum();
   74|     50|      v_count = vector_u16::zero();
   75|     50|      iteration = max_iterations;
   76|     50|    }
   77|  2.11M|  }
   78|       |
   79|    754|  if (iteration > 0) {
  ------------------
  |  Branch (79:7): [True: 754, False: 0]
  ------------------
   80|    754|    count += v_count.sum();
   81|    754|  }
   82|       |
   83|    754|  return count + scalar::utf16::utf8_length_from_utf16<big_endian>(in + pos,
   84|    754|                                                                   size - pos);
   85|    754|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1631utf8_length_from_utf16_bytemaskILNS_10endiannessE1EEEmPKDsm:
   10|    748|                                                             size_t size) {
   11|    748|  size_t pos = 0;
   12|       |
   13|    748|  using vector_u16 = simd16<uint16_t>;
   14|    748|  constexpr size_t N = vector_u16::ELEMENTS;
   15|       |
   16|    748|  const auto one = vector_u16::splat(1);
   17|       |
   18|    748|  auto v_count = vector_u16::zero();
   19|       |
   20|       |  // each char16 yields at least one byte
   21|    748|  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|    748|  constexpr size_t max_iterations = 65535 / 2;
   26|    748|  size_t iteration = max_iterations;
   27|       |
   28|  1.89M|  for (; pos < size / N * N; pos += N) {
  ------------------
  |  Branch (28:10): [True: 1.89M, False: 748]
  ------------------
   29|  1.89M|    auto input = vector_u16::load(reinterpret_cast<const uint16_t *>(in + pos));
   30|  1.89M|    if constexpr (!match_system(big_endian)) {
   31|  1.89M|      input = input.swap_bytes();
   32|  1.89M|    }
   33|       |    // 0xd800 .. 0xdbff - low surrogate
   34|       |    // 0xdc00 .. 0xdfff - high surrogate
   35|  1.89M|    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.89M|    const auto c0 = min(input & uint16_t(0xff80), one);
   39|       |
   40|       |    // c1 - chars that yield 3-byte UTF-8 codes (including surrogates)
   41|  1.89M|    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.89M|    v_count += c0;
   68|  1.89M|    v_count += c1;
   69|  1.89M|    v_count += vector_u16(is_surrogate);
   70|       |
   71|  1.89M|    iteration -= 1;
   72|  1.89M|    if (iteration == 0) {
  ------------------
  |  Branch (72:9): [True: 46, False: 1.89M]
  ------------------
   73|     46|      count += v_count.sum();
   74|     46|      v_count = vector_u16::zero();
   75|     46|      iteration = max_iterations;
   76|     46|    }
   77|  1.89M|  }
   78|       |
   79|    748|  if (iteration > 0) {
  ------------------
  |  Branch (79:7): [True: 748, False: 0]
  ------------------
   80|    748|    count += v_count.sum();
   81|    748|  }
   82|       |
   83|    748|  return count + scalar::utf16::utf8_length_from_utf16<big_endian>(in + pos,
   84|    748|                                                                   size - pos);
   85|    748|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf3222utf8_length_from_utf32EPKDim:
   11|    860|                                                    size_t length) {
   12|    860|  using vector_u32 = simd32<uint32_t>;
   13|       |
   14|    860|  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|    860|  const size_t max_increment = 3;
   19|       |
   20|    860|  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|    860|  const auto v_ffffff80 = vector_u32::splat(0xffffff80);
   28|    860|  const auto v_fffff800 = vector_u32::splat(0xfffff800);
   29|    860|  const auto v_ffff0000 = vector_u32::splat(0xffff0000);
   30|    860|  const auto one = vector_u32::splat(1);
   31|    860|#endif // SIMDUTF_SIMD_HAS_UNSIGNED_CMP
   32|       |
   33|    860|  size_t counter = 0;
   34|       |
   35|       |  // 1. vectorized loop unrolled 4 times
   36|    860|  {
   37|       |    // we use vector of uint32 counters, this is why this limit is used
   38|    860|    const size_t max_iterations =
   39|    860|        std::numeric_limits<uint32_t>::max() / (max_increment * 4);
   40|    860|    size_t blocks = length / (N * 4);
   41|    860|    length -= blocks * (N * 4);
   42|  1.05k|    while (blocks != 0) {
  ------------------
  |  Branch (42:12): [True: 198, False: 860]
  ------------------
   43|    198|      const size_t iterations = min(blocks, max_iterations);
   44|    198|      blocks -= iterations;
   45|       |
   46|    198|      simd32<uint32_t> acc = vector_u32::zero();
   47|  87.1k|      for (size_t i = 0; i < iterations; i++) {
  ------------------
  |  Branch (47:26): [True: 86.9k, False: 198]
  ------------------
   48|  86.9k|        const auto in0 = vector_u32(input + 0 * N);
   49|  86.9k|        const auto in1 = vector_u32(input + 1 * N);
   50|  86.9k|        const auto in2 = vector_u32(input + 2 * N);
   51|  86.9k|        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|  86.9k|        acc += min(one, in0 & v_ffffff80);
   70|  86.9k|        acc += min(one, in1 & v_ffffff80);
   71|  86.9k|        acc += min(one, in2 & v_ffffff80);
   72|  86.9k|        acc += min(one, in3 & v_ffffff80);
   73|       |
   74|  86.9k|        acc += min(one, in0 & v_fffff800);
   75|  86.9k|        acc += min(one, in1 & v_fffff800);
   76|  86.9k|        acc += min(one, in2 & v_fffff800);
   77|  86.9k|        acc += min(one, in3 & v_fffff800);
   78|       |
   79|  86.9k|        acc += min(one, in0 & v_ffff0000);
   80|  86.9k|        acc += min(one, in1 & v_ffff0000);
   81|  86.9k|        acc += min(one, in2 & v_ffff0000);
   82|  86.9k|        acc += min(one, in3 & v_ffff0000);
   83|  86.9k|#endif // SIMDUTF_SIMD_HAS_UNSIGNED_CMP
   84|       |
   85|  86.9k|        input += 4 * N;
   86|  86.9k|      }
   87|       |
   88|    198|      counter += acc.sum();
   89|    198|    }
   90|    860|  }
   91|       |
   92|       |  // 2. vectorized loop for tail
   93|    860|  {
   94|    860|    const size_t max_iterations =
   95|    860|        std::numeric_limits<uint32_t>::max() / max_increment;
   96|    860|    size_t blocks = length / N;
   97|    860|    length -= blocks * N;
   98|  1.28k|    while (blocks != 0) {
  ------------------
  |  Branch (98:12): [True: 425, False: 860]
  ------------------
   99|    425|      const size_t iterations = min(blocks, max_iterations);
  100|    425|      blocks -= iterations;
  101|       |
  102|    425|      auto acc = vector_u32::zero();
  103|  1.43k|      for (size_t i = 0; i < iterations; i++) {
  ------------------
  |  Branch (103:26): [True: 1.01k, False: 425]
  ------------------
  104|  1.01k|        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.01k|        acc += min(one, in & v_ffffff80);
  112|  1.01k|        acc += min(one, in & v_fffff800);
  113|  1.01k|        acc += min(one, in & v_ffff0000);
  114|  1.01k|#endif // SIMDUTF_SIMD_HAS_UNSIGNED_CMP
  115|       |
  116|  1.01k|        input += N;
  117|  1.01k|      }
  118|       |
  119|    425|      counter += acc.sum();
  120|    425|    }
  121|    860|  }
  122|       |
  123|    860|  const size_t consumed = input - start;
  124|    860|  if (consumed != 0) {
  ------------------
  |  Branch (124:7): [True: 468, False: 392]
  ------------------
  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|    468|    counter += consumed;
  128|    468|  }
  129|       |
  130|    860|  return counter + scalar::utf32::utf8_length_from_utf32(input, length);
  131|    860|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf323minImEET_S4_S4_:
    8|    623|template <typename T> T min(T a, T b) { return a <= b ? a : b; }
  ------------------
  |  Branch (8:48): [True: 623, False: 0]
  ------------------
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf3222utf8_length_from_utf32EPKDim:
   11|    860|                                                    size_t length) {
   12|    860|  using vector_u32 = simd32<uint32_t>;
   13|       |
   14|    860|  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|    860|  const size_t max_increment = 3;
   19|       |
   20|    860|  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|    860|  const auto v_ffffff80 = vector_u32::splat(0xffffff80);
   28|    860|  const auto v_fffff800 = vector_u32::splat(0xfffff800);
   29|    860|  const auto v_ffff0000 = vector_u32::splat(0xffff0000);
   30|    860|  const auto one = vector_u32::splat(1);
   31|    860|#endif // SIMDUTF_SIMD_HAS_UNSIGNED_CMP
   32|       |
   33|    860|  size_t counter = 0;
   34|       |
   35|       |  // 1. vectorized loop unrolled 4 times
   36|    860|  {
   37|       |    // we use vector of uint32 counters, this is why this limit is used
   38|    860|    const size_t max_iterations =
   39|    860|        std::numeric_limits<uint32_t>::max() / (max_increment * 4);
   40|    860|    size_t blocks = length / (N * 4);
   41|    860|    length -= blocks * (N * 4);
   42|  1.29k|    while (blocks != 0) {
  ------------------
  |  Branch (42:12): [True: 431, False: 860]
  ------------------
   43|    431|      const size_t iterations = min(blocks, max_iterations);
   44|    431|      blocks -= iterations;
   45|       |
   46|    431|      simd32<uint32_t> acc = vector_u32::zero();
   47|   174k|      for (size_t i = 0; i < iterations; i++) {
  ------------------
  |  Branch (47:26): [True: 174k, False: 431]
  ------------------
   48|   174k|        const auto in0 = vector_u32(input + 0 * N);
   49|   174k|        const auto in1 = vector_u32(input + 1 * N);
   50|   174k|        const auto in2 = vector_u32(input + 2 * N);
   51|   174k|        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|   174k|        acc += min(one, in0 & v_ffffff80);
   70|   174k|        acc += min(one, in1 & v_ffffff80);
   71|   174k|        acc += min(one, in2 & v_ffffff80);
   72|   174k|        acc += min(one, in3 & v_ffffff80);
   73|       |
   74|   174k|        acc += min(one, in0 & v_fffff800);
   75|   174k|        acc += min(one, in1 & v_fffff800);
   76|   174k|        acc += min(one, in2 & v_fffff800);
   77|   174k|        acc += min(one, in3 & v_fffff800);
   78|       |
   79|   174k|        acc += min(one, in0 & v_ffff0000);
   80|   174k|        acc += min(one, in1 & v_ffff0000);
   81|   174k|        acc += min(one, in2 & v_ffff0000);
   82|   174k|        acc += min(one, in3 & v_ffff0000);
   83|   174k|#endif // SIMDUTF_SIMD_HAS_UNSIGNED_CMP
   84|       |
   85|   174k|        input += 4 * N;
   86|   174k|      }
   87|       |
   88|    431|      counter += acc.sum();
   89|    431|    }
   90|    860|  }
   91|       |
   92|       |  // 2. vectorized loop for tail
   93|    860|  {
   94|    860|    const size_t max_iterations =
   95|    860|        std::numeric_limits<uint32_t>::max() / max_increment;
   96|    860|    size_t blocks = length / N;
   97|    860|    length -= blocks * N;
   98|  1.32k|    while (blocks != 0) {
  ------------------
  |  Branch (98:12): [True: 464, False: 860]
  ------------------
   99|    464|      const size_t iterations = min(blocks, max_iterations);
  100|    464|      blocks -= iterations;
  101|       |
  102|    464|      auto acc = vector_u32::zero();
  103|  1.58k|      for (size_t i = 0; i < iterations; i++) {
  ------------------
  |  Branch (103:26): [True: 1.12k, False: 464]
  ------------------
  104|  1.12k|        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.12k|        acc += min(one, in & v_ffffff80);
  112|  1.12k|        acc += min(one, in & v_fffff800);
  113|  1.12k|        acc += min(one, in & v_ffff0000);
  114|  1.12k|#endif // SIMDUTF_SIMD_HAS_UNSIGNED_CMP
  115|       |
  116|  1.12k|        input += N;
  117|  1.12k|      }
  118|       |
  119|    464|      counter += acc.sum();
  120|    464|    }
  121|    860|  }
  122|       |
  123|    860|  const size_t consumed = input - start;
  124|    860|  if (consumed != 0) {
  ------------------
  |  Branch (124:7): [True: 505, False: 355]
  ------------------
  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|    505|    counter += consumed;
  128|    505|  }
  129|       |
  130|    860|  return counter + scalar::utf32::utf8_length_from_utf32(input, length);
  131|    860|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf323minImEET_S4_S4_:
    8|    895|template <typename T> T min(T a, T b) { return a <= b ? a : b; }
  ------------------
  |  Branch (8:48): [True: 895, False: 0]
  ------------------

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14utf826count_code_points_bytemaskEPKcm:
   21|  4.03k|count_code_points_bytemask(const char *in, size_t size) {
   22|  4.03k|  using vector_i8 = simd8<int8_t>;
   23|  4.03k|  using vector_u8 = simd8<uint8_t>;
   24|  4.03k|  using vector_u64 = simd64<uint64_t>;
   25|       |
   26|  4.03k|  constexpr size_t N = vector_i8::SIZE;
   27|  4.03k|  constexpr size_t max_iterations = 255 / 4;
   28|       |
   29|  4.03k|  size_t pos = 0;
   30|  4.03k|  size_t count = 0;
   31|       |
   32|  4.03k|  auto counters = vector_u64::zero();
   33|  4.03k|  auto local = vector_u8::zero();
   34|  4.03k|  size_t iterations = 0;
   35|  1.69M|  for (; pos + 4 * N <= size; pos += 4 * N) {
  ------------------
  |  Branch (35:10): [True: 1.68M, False: 4.03k]
  ------------------
   36|  1.68M|    const auto input0 =
   37|  1.68M|        simd8<int8_t>::load(reinterpret_cast<const int8_t *>(in + pos + 0 * N));
   38|  1.68M|    const auto input1 =
   39|  1.68M|        simd8<int8_t>::load(reinterpret_cast<const int8_t *>(in + pos + 1 * N));
   40|  1.68M|    const auto input2 =
   41|  1.68M|        simd8<int8_t>::load(reinterpret_cast<const int8_t *>(in + pos + 2 * N));
   42|  1.68M|    const auto input3 =
   43|  1.68M|        simd8<int8_t>::load(reinterpret_cast<const int8_t *>(in + pos + 3 * N));
   44|  1.68M|    const auto mask0 = input0 > int8_t(-65);
   45|  1.68M|    const auto mask1 = input1 > int8_t(-65);
   46|  1.68M|    const auto mask2 = input2 > int8_t(-65);
   47|  1.68M|    const auto mask3 = input3 > int8_t(-65);
   48|       |
   49|  1.68M|    local -= vector_u8(mask0);
   50|  1.68M|    local -= vector_u8(mask1);
   51|  1.68M|    local -= vector_u8(mask2);
   52|  1.68M|    local -= vector_u8(mask3);
   53|       |
   54|  1.68M|    iterations += 1;
   55|  1.68M|    if (iterations == max_iterations) {
  ------------------
  |  Branch (55:9): [True: 26.5k, False: 1.66M]
  ------------------
   56|  26.5k|      counters += sum_8bytes(local);
   57|  26.5k|      local = vector_u8::zero();
   58|  26.5k|      iterations = 0;
   59|  26.5k|    }
   60|  1.68M|  }
   61|       |
   62|  4.03k|  if (iterations > 0) {
  ------------------
  |  Branch (62:7): [True: 1.52k, False: 2.51k]
  ------------------
   63|  1.52k|    count += local.sum_bytes();
   64|  1.52k|  }
   65|       |
   66|  4.03k|  count += counters.sum();
   67|       |
   68|  4.03k|  return count + scalar::utf8::count_code_points(in + pos, size - pos);
   69|  4.03k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14utf817count_code_pointsEPKcm:
    8|    994|simdutf_really_inline size_t count_code_points(const char *in, size_t size) {
    9|    994|  size_t pos = 0;
   10|    994|  size_t count = 0;
   11|   753k|  for (; pos + 64 <= size; pos += 64) {
  ------------------
  |  Branch (11:10): [True: 752k, False: 994]
  ------------------
   12|   752k|    simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
   13|   752k|    uint64_t utf8_continuation_mask = input.gt(-65);
   14|   752k|    count += count_ones(utf8_continuation_mask);
   15|   752k|  }
   16|    994|  return count + scalar::utf8::count_code_points(in + pos, size - pos);
   17|    994|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14utf826count_code_points_bytemaskEPKcm:
   21|  4.03k|count_code_points_bytemask(const char *in, size_t size) {
   22|  4.03k|  using vector_i8 = simd8<int8_t>;
   23|  4.03k|  using vector_u8 = simd8<uint8_t>;
   24|  4.03k|  using vector_u64 = simd64<uint64_t>;
   25|       |
   26|  4.03k|  constexpr size_t N = vector_i8::SIZE;
   27|  4.03k|  constexpr size_t max_iterations = 255 / 4;
   28|       |
   29|  4.03k|  size_t pos = 0;
   30|  4.03k|  size_t count = 0;
   31|       |
   32|  4.03k|  auto counters = vector_u64::zero();
   33|  4.03k|  auto local = vector_u8::zero();
   34|  4.03k|  size_t iterations = 0;
   35|  3.38M|  for (; pos + 4 * N <= size; pos += 4 * N) {
  ------------------
  |  Branch (35:10): [True: 3.37M, False: 4.03k]
  ------------------
   36|  3.37M|    const auto input0 =
   37|  3.37M|        simd8<int8_t>::load(reinterpret_cast<const int8_t *>(in + pos + 0 * N));
   38|  3.37M|    const auto input1 =
   39|  3.37M|        simd8<int8_t>::load(reinterpret_cast<const int8_t *>(in + pos + 1 * N));
   40|  3.37M|    const auto input2 =
   41|  3.37M|        simd8<int8_t>::load(reinterpret_cast<const int8_t *>(in + pos + 2 * N));
   42|  3.37M|    const auto input3 =
   43|  3.37M|        simd8<int8_t>::load(reinterpret_cast<const int8_t *>(in + pos + 3 * N));
   44|  3.37M|    const auto mask0 = input0 > int8_t(-65);
   45|  3.37M|    const auto mask1 = input1 > int8_t(-65);
   46|  3.37M|    const auto mask2 = input2 > int8_t(-65);
   47|  3.37M|    const auto mask3 = input3 > int8_t(-65);
   48|       |
   49|  3.37M|    local -= vector_u8(mask0);
   50|  3.37M|    local -= vector_u8(mask1);
   51|  3.37M|    local -= vector_u8(mask2);
   52|  3.37M|    local -= vector_u8(mask3);
   53|       |
   54|  3.37M|    iterations += 1;
   55|  3.37M|    if (iterations == max_iterations) {
  ------------------
  |  Branch (55:9): [True: 53.3k, False: 3.32M]
  ------------------
   56|  53.3k|      counters += sum_8bytes(local);
   57|  53.3k|      local = vector_u8::zero();
   58|  53.3k|      iterations = 0;
   59|  53.3k|    }
   60|  3.37M|  }
   61|       |
   62|  4.03k|  if (iterations > 0) {
  ------------------
  |  Branch (62:7): [True: 2.47k, False: 1.56k]
  ------------------
   63|  2.47k|    count += local.sum_bytes();
   64|  2.47k|  }
   65|       |
   66|  4.03k|  count += counters.sum();
   67|       |
   68|  4.03k|  return count + scalar::utf8::count_code_points(in + pos, size - pos);
   69|  4.03k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14utf817count_code_pointsEPKcm:
    8|    994|simdutf_really_inline size_t count_code_points(const char *in, size_t size) {
    9|    994|  size_t pos = 0;
   10|    994|  size_t count = 0;
   11|   753k|  for (; pos + 64 <= size; pos += 64) {
  ------------------
  |  Branch (11:10): [True: 752k, False: 994]
  ------------------
   12|   752k|    simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
   13|   752k|    uint64_t utf8_continuation_mask = input.gt(-65);
   14|   752k|    count += count_ones(utf8_continuation_mask);
   15|   752k|  }
   16|    994|  return count + scalar::utf8::count_code_points(in + pos, size - pos);
   17|    994|}

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_114utf8_to_latin121validating_transcoderC2Ev:
  101|  1.09k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_114utf8_to_latin121validating_transcoder7convertEPKcmPc:
  115|    586|                                       char *latin1_output) {
  116|    586|    size_t pos = 0;
  117|    586|    char *start{latin1_output};
  118|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  119|       |    // of 8 bytes when calling convert_masked_utf8_to_latin1. If you skip the
  120|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  121|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  122|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  123|       |    // back from the end counting 16 leading bytes, to give us a good margin.
  124|    586|    size_t leading_byte = 0;
  125|    586|    size_t margin = size;
  126|  9.85k|    for (; margin > 0 && leading_byte < 16; margin--) {
  ------------------
  |  Branch (126:12): [True: 9.71k, False: 140]
  |  Branch (126:26): [True: 9.26k, False: 446]
  ------------------
  127|  9.26k|      leading_byte += (int8_t(in[margin - 1]) >
  128|  9.26k|                       -65); // twos complement of -65 is 1011 1111 ...
  129|  9.26k|    }
  130|       |    // If the input is long enough, then we have that margin-1 is the eight last
  131|       |    // leading byte.
  132|    586|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  133|   657k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (133:12): [True: 656k, False: 556]
  ------------------
  134|   656k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  135|   656k|      if (input.is_ascii()) {
  ------------------
  |  Branch (135:11): [True: 606k, False: 50.5k]
  ------------------
  136|   606k|        input.store((int8_t *)latin1_output);
  137|   606k|        latin1_output += 64;
  138|   606k|        pos += 64;
  139|   606k|      } else {
  140|       |        // you might think that a for-loop would work, but under Visual Studio,
  141|       |        // it is not good enough.
  142|  50.5k|        static_assert(
  143|  50.5k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  144|  50.5k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  145|  50.5k|            "We support either two or four chunks per 64-byte block.");
  146|  50.5k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  147|  50.5k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  148|  50.5k|          this->check_utf8_bytes(input.chunks[0], zero);
  149|  50.5k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  150|       |        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  151|       |          this->check_utf8_bytes(input.chunks[0], zero);
  152|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  153|       |          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  154|       |          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  155|       |        }
  156|  50.5k|        uint64_t utf8_continuation_mask =
  157|  50.5k|            input.lt(-65 + 1); // -64 is 1100 0000 in twos complement. Note: in
  158|       |                               // this case, we also have ASCII to account for.
  159|  50.5k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (159:13): [True: 30, False: 50.4k]
  ------------------
  160|     30|          return 0; // error
  161|     30|        }
  162|  50.4k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  163|  50.4k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  164|       |        // We process in blocks of up to 12 bytes except possibly
  165|       |        // for fast paths which may process up to 16 bytes. For the
  166|       |        // slow path to work, we should have at least 12 input bytes left.
  167|  50.4k|        size_t max_starting_point = (pos + 64) - 12;
  168|       |        // Next loop is going to run at least five times.
  169|   501k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (169:16): [True: 450k, False: 50.4k]
  ------------------
  170|       |          // Performance note: our ability to compute 'consumed' and
  171|       |          // then shift and recompute is critical. If there is a
  172|       |          // latency of, say, 4 cycles on getting 'consumed', then
  173|       |          // the inner loop might have a total latency of about 6 cycles.
  174|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  175|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  176|       |          // for this section of the code. Hence, there is a limit
  177|       |          // to how much we can further increase this latency before
  178|       |          // it seriously harms performance.
  179|   450k|          size_t consumed = convert_masked_utf8_to_latin1(
  180|   450k|              in + pos, utf8_end_of_code_point_mask, latin1_output);
  181|   450k|          pos += consumed;
  182|   450k|          utf8_end_of_code_point_mask >>= consumed;
  183|   450k|        }
  184|       |        // At this point there may remain between 0 and 12 bytes in the
  185|       |        // 64-byte block. These bytes will be processed again. So we have an
  186|       |        // 80% efficiency (in the worst case). In practice we expect an
  187|       |        // 85% to 90% efficiency.
  188|  50.4k|      }
  189|   656k|    }
  190|    556|    if (errors()) {
  ------------------
  |  Branch (190:9): [True: 232, False: 324]
  ------------------
  191|    232|      return 0;
  192|    232|    }
  193|    324|    if (pos < size) {
  ------------------
  |  Branch (193:9): [True: 320, False: 4]
  ------------------
  194|    320|      size_t howmany =
  195|    320|          scalar::utf8_to_latin1::convert(in + pos, size - pos, latin1_output);
  196|    320|      if (howmany == 0) {
  ------------------
  |  Branch (196:11): [True: 152, False: 168]
  ------------------
  197|    152|        return 0;
  198|    152|      }
  199|    168|      latin1_output += howmany;
  200|    168|    }
  201|    172|    return latin1_output - start;
  202|    324|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_114utf8_to_latin121validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  106|   132k|                                              const simd8<uint8_t> prev_input) {
  107|       |    // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+
  108|       |    // lead bytes (2, 3, 4-byte leads become large positive numbers instead of
  109|       |    // small negative numbers)
  110|   132k|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  111|   132k|    this->error |= check_special_cases(input, prev1);
  112|   132k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_114utf8_to_latin119check_special_casesENS1_4simd5simd8IhEES5_:
    8|   132k|check_special_cases(const simd8<uint8_t> input, const simd8<uint8_t> prev1) {
    9|       |  // For UTF-8 to Latin 1, we can allow any ASCII character, and any
   10|       |  // continuation byte, but the non-ASCII leading bytes must be 0b11000011 or
   11|       |  // 0b11000010 and nothing else.
   12|       |  //
   13|       |  // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII)
   14|       |  // Bit 1 = Too Long (ASCII followed by continuation)
   15|       |  // Bit 2 = Overlong 3-byte
   16|       |  // Bit 4 = Surrogate
   17|       |  // Bit 5 = Overlong 2-byte
   18|       |  // Bit 7 = Two Continuations
   19|   132k|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   20|       |                                               // 11______ 11______
   21|   132k|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   22|   132k|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   23|   132k|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   24|   132k|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   25|   132k|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   26|   132k|  constexpr const uint8_t TOO_LARGE = 1 << 3;  // 11110100 1001____
   27|       |                                               // 11110100 101_____
   28|       |                                               // 11110101 1001____
   29|       |                                               // 11110101 101_____
   30|       |                                               // 1111011_ 1001____
   31|       |                                               // 1111011_ 101_____
   32|       |                                               // 11111___ 1001____
   33|       |                                               // 11111___ 101_____
   34|   132k|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   35|       |  // 11110101 1000____
   36|       |  // 1111011_ 1000____
   37|       |  // 11111___ 1000____
   38|   132k|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   39|   132k|  constexpr const uint8_t FORBIDDEN = 0xff;
   40|       |
   41|   132k|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   42|       |      // 0_______ ________ <ASCII in byte 1>
   43|   132k|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   44|   132k|      TOO_LONG,
   45|       |      // 10______ ________ <continuation in byte 1>
   46|   132k|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   47|       |      // 1100____ ________ <two byte lead in byte 1>
   48|   132k|      TOO_SHORT | OVERLONG_2,
   49|       |      // 1101____ ________ <two byte lead in byte 1>
   50|   132k|      FORBIDDEN,
   51|       |      // 1110____ ________ <three byte lead in byte 1>
   52|   132k|      FORBIDDEN,
   53|       |      // 1111____ ________ <four+ byte lead in byte 1>
   54|   132k|      FORBIDDEN);
   55|   132k|  constexpr const uint8_t CARRY =
   56|   132k|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   57|   132k|  const simd8<uint8_t> byte_1_low =
   58|   132k|      (prev1 & 0x0F)
   59|   132k|          .lookup_16<uint8_t>(
   60|       |              // ____0000 ________
   61|   132k|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   62|       |              // ____0001 ________
   63|   132k|              CARRY | OVERLONG_2,
   64|       |              // ____001_ ________
   65|   132k|              CARRY, CARRY,
   66|       |
   67|       |              // ____0100 ________
   68|   132k|              FORBIDDEN,
   69|       |              // ____0101 ________
   70|   132k|              FORBIDDEN,
   71|       |              // ____011_ ________
   72|   132k|              FORBIDDEN, FORBIDDEN,
   73|       |
   74|       |              // ____1___ ________
   75|   132k|              FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
   76|       |              // ____1101 ________
   77|   132k|              FORBIDDEN, FORBIDDEN, FORBIDDEN);
   78|   132k|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   79|       |      // ________ 0_______ <ASCII in byte 2>
   80|   132k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   81|   132k|      TOO_SHORT, TOO_SHORT,
   82|       |
   83|       |      // ________ 1000____
   84|   132k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   85|   132k|          OVERLONG_4,
   86|       |      // ________ 1001____
   87|   132k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   88|       |      // ________ 101_____
   89|   132k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   90|   132k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   91|       |
   92|       |      // ________ 11______
   93|   132k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   94|   132k|  return (byte_1_high & byte_1_low & byte_2_high);
   95|   132k|}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_114utf8_to_latin121validating_transcoder6errorsEv:
  308|  16.4k|  simdutf_really_inline bool errors() const {
  309|  16.4k|    return this->error.any_bits_set_anywhere();
  310|  16.4k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_114utf8_to_latin121validating_transcoder19convert_with_errorsEPKcmPc:
  205|    512|                                                   char *latin1_output) {
  206|    512|    size_t pos = 0;
  207|    512|    char *start{latin1_output};
  208|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  209|       |    // of 8 bytes when calling convert_masked_utf8_to_latin1. If you skip the
  210|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  211|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  212|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  213|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  214|    512|    size_t leading_byte = 0;
  215|    512|    size_t margin = size;
  216|  4.89k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (216:12): [True: 4.77k, False: 120]
  |  Branch (216:26): [True: 4.37k, False: 392]
  ------------------
  217|  4.37k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  218|  4.37k|    }
  219|       |    // If the input is long enough, then we have that margin-1 is the eight last
  220|       |    // leading byte.
  221|    512|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  222|   313k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (222:12): [True: 312k, False: 418]
  ------------------
  223|   312k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  224|   312k|      if (input.is_ascii()) {
  ------------------
  |  Branch (224:11): [True: 297k, False: 15.5k]
  ------------------
  225|   297k|        input.store((int8_t *)latin1_output);
  226|   297k|        latin1_output += 64;
  227|   297k|        pos += 64;
  228|   297k|      } else {
  229|       |        // you might think that a for-loop would work, but under Visual Studio,
  230|       |        // it is not good enough.
  231|  15.5k|        static_assert(
  232|  15.5k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  233|  15.5k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  234|  15.5k|            "We support either two or four chunks per 64-byte block.");
  235|  15.5k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  236|  15.5k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  237|  15.5k|          this->check_utf8_bytes(input.chunks[0], zero);
  238|  15.5k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  239|       |        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  240|       |          this->check_utf8_bytes(input.chunks[0], zero);
  241|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  242|       |          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  243|       |          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  244|       |        }
  245|  15.5k|        if (errors()) {
  ------------------
  |  Branch (245:13): [True: 94, False: 15.4k]
  ------------------
  246|       |          // rewind_and_convert_with_errors will seek a potential error from
  247|       |          // in+pos onward, with the ability to go back up to pos bytes, and
  248|       |          // read size-pos bytes forward.
  249|     94|          result res = scalar::utf8_to_latin1::rewind_and_convert_with_errors(
  250|     94|              pos, in + pos, size - pos, latin1_output);
  251|     94|          res.count += pos;
  252|     94|          return res;
  253|     94|        }
  254|  15.4k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  255|  15.4k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  256|  15.4k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  257|       |        // We process in blocks of up to 12 bytes except possibly
  258|       |        // for fast paths which may process up to 16 bytes. For the
  259|       |        // slow path to work, we should have at least 12 input bytes left.
  260|  15.4k|        size_t max_starting_point = (pos + 64) - 12;
  261|       |        // Next loop is going to run at least five times.
  262|   153k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (262:16): [True: 138k, False: 15.4k]
  ------------------
  263|       |          // Performance note: our ability to compute 'consumed' and
  264|       |          // then shift and recompute is critical. If there is a
  265|       |          // latency of, say, 4 cycles on getting 'consumed', then
  266|       |          // the inner loop might have a total latency of about 6 cycles.
  267|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  268|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  269|       |          // for this section of the code. Hence, there is a limit
  270|       |          // to how much we can further increase this latency before
  271|       |          // it seriously harms performance.
  272|   138k|          size_t consumed = convert_masked_utf8_to_latin1(
  273|   138k|              in + pos, utf8_end_of_code_point_mask, latin1_output);
  274|   138k|          pos += consumed;
  275|   138k|          utf8_end_of_code_point_mask >>= consumed;
  276|   138k|        }
  277|       |        // At this point there may remain between 0 and 12 bytes in the
  278|       |        // 64-byte block. These bytes will be processed again. So we have an
  279|       |        // 80% efficiency (in the worst case). In practice we expect an
  280|       |        // 85% to 90% efficiency.
  281|  15.4k|      }
  282|   312k|    }
  283|    418|    if (errors()) {
  ------------------
  |  Branch (283:9): [True: 0, False: 418]
  ------------------
  284|       |      // rewind_and_convert_with_errors will seek a potential error from in+pos
  285|       |      // onward, with the ability to go back up to pos bytes, and read size-pos
  286|       |      // bytes forward.
  287|      0|      result res = scalar::utf8_to_latin1::rewind_and_convert_with_errors(
  288|      0|          pos, in + pos, size - pos, latin1_output);
  289|      0|      res.count += pos;
  290|      0|      return res;
  291|      0|    }
  292|    418|    if (pos < size) {
  ------------------
  |  Branch (292:9): [True: 414, False: 4]
  ------------------
  293|       |      // rewind_and_convert_with_errors will seek a potential error from in+pos
  294|       |      // onward, with the ability to go back up to pos bytes, and read size-pos
  295|       |      // bytes forward.
  296|    414|      result res = scalar::utf8_to_latin1::rewind_and_convert_with_errors(
  297|    414|          pos, in + pos, size - pos, latin1_output);
  298|    414|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (298:11): [True: 192, False: 222]
  ------------------
  299|    192|        res.count += pos;
  300|    192|        return res;
  301|    222|      } else { // In case of success, we want the number of word written
  302|    222|        latin1_output += res.count;
  303|    222|      }
  304|    414|    }
  305|    226|    return result(error_code::SUCCESS, latin1_output - start);
  306|    418|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114utf8_to_latin121validating_transcoderC2Ev:
  101|  1.09k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114utf8_to_latin121validating_transcoder7convertEPKcmPc:
  115|    586|                                       char *latin1_output) {
  116|    586|    size_t pos = 0;
  117|    586|    char *start{latin1_output};
  118|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  119|       |    // of 8 bytes when calling convert_masked_utf8_to_latin1. If you skip the
  120|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  121|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  122|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  123|       |    // back from the end counting 16 leading bytes, to give us a good margin.
  124|    586|    size_t leading_byte = 0;
  125|    586|    size_t margin = size;
  126|  9.85k|    for (; margin > 0 && leading_byte < 16; margin--) {
  ------------------
  |  Branch (126:12): [True: 9.71k, False: 140]
  |  Branch (126:26): [True: 9.26k, False: 446]
  ------------------
  127|  9.26k|      leading_byte += (int8_t(in[margin - 1]) >
  128|  9.26k|                       -65); // twos complement of -65 is 1011 1111 ...
  129|  9.26k|    }
  130|       |    // If the input is long enough, then we have that margin-1 is the eight last
  131|       |    // leading byte.
  132|    586|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  133|   657k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (133:12): [True: 656k, False: 556]
  ------------------
  134|   656k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  135|   656k|      if (input.is_ascii()) {
  ------------------
  |  Branch (135:11): [True: 606k, False: 50.5k]
  ------------------
  136|   606k|        input.store((int8_t *)latin1_output);
  137|   606k|        latin1_output += 64;
  138|   606k|        pos += 64;
  139|   606k|      } else {
  140|       |        // you might think that a for-loop would work, but under Visual Studio,
  141|       |        // it is not good enough.
  142|  50.5k|        static_assert(
  143|  50.5k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  144|  50.5k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  145|  50.5k|            "We support either two or four chunks per 64-byte block.");
  146|  50.5k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  147|       |        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  148|       |          this->check_utf8_bytes(input.chunks[0], zero);
  149|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  150|  50.5k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  151|  50.5k|          this->check_utf8_bytes(input.chunks[0], zero);
  152|  50.5k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  153|  50.5k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  154|  50.5k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  155|  50.5k|        }
  156|  50.5k|        uint64_t utf8_continuation_mask =
  157|  50.5k|            input.lt(-65 + 1); // -64 is 1100 0000 in twos complement. Note: in
  158|       |                               // this case, we also have ASCII to account for.
  159|  50.5k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (159:13): [True: 30, False: 50.4k]
  ------------------
  160|     30|          return 0; // error
  161|     30|        }
  162|  50.4k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  163|  50.4k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  164|       |        // We process in blocks of up to 12 bytes except possibly
  165|       |        // for fast paths which may process up to 16 bytes. For the
  166|       |        // slow path to work, we should have at least 12 input bytes left.
  167|  50.4k|        size_t max_starting_point = (pos + 64) - 12;
  168|       |        // Next loop is going to run at least five times.
  169|   501k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (169:16): [True: 450k, False: 50.4k]
  ------------------
  170|       |          // Performance note: our ability to compute 'consumed' and
  171|       |          // then shift and recompute is critical. If there is a
  172|       |          // latency of, say, 4 cycles on getting 'consumed', then
  173|       |          // the inner loop might have a total latency of about 6 cycles.
  174|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  175|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  176|       |          // for this section of the code. Hence, there is a limit
  177|       |          // to how much we can further increase this latency before
  178|       |          // it seriously harms performance.
  179|   450k|          size_t consumed = convert_masked_utf8_to_latin1(
  180|   450k|              in + pos, utf8_end_of_code_point_mask, latin1_output);
  181|   450k|          pos += consumed;
  182|   450k|          utf8_end_of_code_point_mask >>= consumed;
  183|   450k|        }
  184|       |        // At this point there may remain between 0 and 12 bytes in the
  185|       |        // 64-byte block. These bytes will be processed again. So we have an
  186|       |        // 80% efficiency (in the worst case). In practice we expect an
  187|       |        // 85% to 90% efficiency.
  188|  50.4k|      }
  189|   656k|    }
  190|    556|    if (errors()) {
  ------------------
  |  Branch (190:9): [True: 232, False: 324]
  ------------------
  191|    232|      return 0;
  192|    232|    }
  193|    324|    if (pos < size) {
  ------------------
  |  Branch (193:9): [True: 320, False: 4]
  ------------------
  194|    320|      size_t howmany =
  195|    320|          scalar::utf8_to_latin1::convert(in + pos, size - pos, latin1_output);
  196|    320|      if (howmany == 0) {
  ------------------
  |  Branch (196:11): [True: 152, False: 168]
  ------------------
  197|    152|        return 0;
  198|    152|      }
  199|    168|      latin1_output += howmany;
  200|    168|    }
  201|    172|    return latin1_output - start;
  202|    324|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114utf8_to_latin121validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  106|   264k|                                              const simd8<uint8_t> prev_input) {
  107|       |    // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+
  108|       |    // lead bytes (2, 3, 4-byte leads become large positive numbers instead of
  109|       |    // small negative numbers)
  110|   264k|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  111|   264k|    this->error |= check_special_cases(input, prev1);
  112|   264k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114utf8_to_latin119check_special_casesENS1_4simd5simd8IhEES5_:
    8|   264k|check_special_cases(const simd8<uint8_t> input, const simd8<uint8_t> prev1) {
    9|       |  // For UTF-8 to Latin 1, we can allow any ASCII character, and any
   10|       |  // continuation byte, but the non-ASCII leading bytes must be 0b11000011 or
   11|       |  // 0b11000010 and nothing else.
   12|       |  //
   13|       |  // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII)
   14|       |  // Bit 1 = Too Long (ASCII followed by continuation)
   15|       |  // Bit 2 = Overlong 3-byte
   16|       |  // Bit 4 = Surrogate
   17|       |  // Bit 5 = Overlong 2-byte
   18|       |  // Bit 7 = Two Continuations
   19|   264k|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   20|       |                                               // 11______ 11______
   21|   264k|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   22|   264k|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   23|   264k|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   24|   264k|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   25|   264k|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   26|   264k|  constexpr const uint8_t TOO_LARGE = 1 << 3;  // 11110100 1001____
   27|       |                                               // 11110100 101_____
   28|       |                                               // 11110101 1001____
   29|       |                                               // 11110101 101_____
   30|       |                                               // 1111011_ 1001____
   31|       |                                               // 1111011_ 101_____
   32|       |                                               // 11111___ 1001____
   33|       |                                               // 11111___ 101_____
   34|   264k|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   35|       |  // 11110101 1000____
   36|       |  // 1111011_ 1000____
   37|       |  // 11111___ 1000____
   38|   264k|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   39|   264k|  constexpr const uint8_t FORBIDDEN = 0xff;
   40|       |
   41|   264k|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   42|       |      // 0_______ ________ <ASCII in byte 1>
   43|   264k|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   44|   264k|      TOO_LONG,
   45|       |      // 10______ ________ <continuation in byte 1>
   46|   264k|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   47|       |      // 1100____ ________ <two byte lead in byte 1>
   48|   264k|      TOO_SHORT | OVERLONG_2,
   49|       |      // 1101____ ________ <two byte lead in byte 1>
   50|   264k|      FORBIDDEN,
   51|       |      // 1110____ ________ <three byte lead in byte 1>
   52|   264k|      FORBIDDEN,
   53|       |      // 1111____ ________ <four+ byte lead in byte 1>
   54|   264k|      FORBIDDEN);
   55|   264k|  constexpr const uint8_t CARRY =
   56|   264k|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   57|   264k|  const simd8<uint8_t> byte_1_low =
   58|   264k|      (prev1 & 0x0F)
   59|   264k|          .lookup_16<uint8_t>(
   60|       |              // ____0000 ________
   61|   264k|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   62|       |              // ____0001 ________
   63|   264k|              CARRY | OVERLONG_2,
   64|       |              // ____001_ ________
   65|   264k|              CARRY, CARRY,
   66|       |
   67|       |              // ____0100 ________
   68|   264k|              FORBIDDEN,
   69|       |              // ____0101 ________
   70|   264k|              FORBIDDEN,
   71|       |              // ____011_ ________
   72|   264k|              FORBIDDEN, FORBIDDEN,
   73|       |
   74|       |              // ____1___ ________
   75|   264k|              FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
   76|       |              // ____1101 ________
   77|   264k|              FORBIDDEN, FORBIDDEN, FORBIDDEN);
   78|   264k|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   79|       |      // ________ 0_______ <ASCII in byte 2>
   80|   264k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   81|   264k|      TOO_SHORT, TOO_SHORT,
   82|       |
   83|       |      // ________ 1000____
   84|   264k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   85|   264k|          OVERLONG_4,
   86|       |      // ________ 1001____
   87|   264k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   88|       |      // ________ 101_____
   89|   264k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   90|   264k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   91|       |
   92|       |      // ________ 11______
   93|   264k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   94|   264k|  return (byte_1_high & byte_1_low & byte_2_high);
   95|   264k|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_114utf8_to_latin121validating_transcoder6errorsEv:
  308|  16.4k|  simdutf_really_inline bool errors() const {
  309|  16.4k|    return this->error.any_bits_set_anywhere();
  310|  16.4k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114utf8_to_latin121validating_transcoder19convert_with_errorsEPKcmPc:
  205|    512|                                                   char *latin1_output) {
  206|    512|    size_t pos = 0;
  207|    512|    char *start{latin1_output};
  208|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  209|       |    // of 8 bytes when calling convert_masked_utf8_to_latin1. If you skip the
  210|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  211|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  212|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  213|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  214|    512|    size_t leading_byte = 0;
  215|    512|    size_t margin = size;
  216|  4.89k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (216:12): [True: 4.77k, False: 120]
  |  Branch (216:26): [True: 4.37k, False: 392]
  ------------------
  217|  4.37k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  218|  4.37k|    }
  219|       |    // If the input is long enough, then we have that margin-1 is the eight last
  220|       |    // leading byte.
  221|    512|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  222|   313k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (222:12): [True: 312k, False: 418]
  ------------------
  223|   312k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  224|   312k|      if (input.is_ascii()) {
  ------------------
  |  Branch (224:11): [True: 297k, False: 15.5k]
  ------------------
  225|   297k|        input.store((int8_t *)latin1_output);
  226|   297k|        latin1_output += 64;
  227|   297k|        pos += 64;
  228|   297k|      } else {
  229|       |        // you might think that a for-loop would work, but under Visual Studio,
  230|       |        // it is not good enough.
  231|  15.5k|        static_assert(
  232|  15.5k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  233|  15.5k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  234|  15.5k|            "We support either two or four chunks per 64-byte block.");
  235|  15.5k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  236|       |        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  237|       |          this->check_utf8_bytes(input.chunks[0], zero);
  238|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  239|  15.5k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  240|  15.5k|          this->check_utf8_bytes(input.chunks[0], zero);
  241|  15.5k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  242|  15.5k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  243|  15.5k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  244|  15.5k|        }
  245|  15.5k|        if (errors()) {
  ------------------
  |  Branch (245:13): [True: 94, False: 15.4k]
  ------------------
  246|       |          // rewind_and_convert_with_errors will seek a potential error from
  247|       |          // in+pos onward, with the ability to go back up to pos bytes, and
  248|       |          // read size-pos bytes forward.
  249|     94|          result res = scalar::utf8_to_latin1::rewind_and_convert_with_errors(
  250|     94|              pos, in + pos, size - pos, latin1_output);
  251|     94|          res.count += pos;
  252|     94|          return res;
  253|     94|        }
  254|  15.4k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  255|  15.4k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  256|  15.4k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  257|       |        // We process in blocks of up to 12 bytes except possibly
  258|       |        // for fast paths which may process up to 16 bytes. For the
  259|       |        // slow path to work, we should have at least 12 input bytes left.
  260|  15.4k|        size_t max_starting_point = (pos + 64) - 12;
  261|       |        // Next loop is going to run at least five times.
  262|   153k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (262:16): [True: 138k, False: 15.4k]
  ------------------
  263|       |          // Performance note: our ability to compute 'consumed' and
  264|       |          // then shift and recompute is critical. If there is a
  265|       |          // latency of, say, 4 cycles on getting 'consumed', then
  266|       |          // the inner loop might have a total latency of about 6 cycles.
  267|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  268|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  269|       |          // for this section of the code. Hence, there is a limit
  270|       |          // to how much we can further increase this latency before
  271|       |          // it seriously harms performance.
  272|   138k|          size_t consumed = convert_masked_utf8_to_latin1(
  273|   138k|              in + pos, utf8_end_of_code_point_mask, latin1_output);
  274|   138k|          pos += consumed;
  275|   138k|          utf8_end_of_code_point_mask >>= consumed;
  276|   138k|        }
  277|       |        // At this point there may remain between 0 and 12 bytes in the
  278|       |        // 64-byte block. These bytes will be processed again. So we have an
  279|       |        // 80% efficiency (in the worst case). In practice we expect an
  280|       |        // 85% to 90% efficiency.
  281|  15.4k|      }
  282|   312k|    }
  283|    418|    if (errors()) {
  ------------------
  |  Branch (283:9): [True: 0, False: 418]
  ------------------
  284|       |      // rewind_and_convert_with_errors will seek a potential error from in+pos
  285|       |      // onward, with the ability to go back up to pos bytes, and read size-pos
  286|       |      // bytes forward.
  287|      0|      result res = scalar::utf8_to_latin1::rewind_and_convert_with_errors(
  288|      0|          pos, in + pos, size - pos, latin1_output);
  289|      0|      res.count += pos;
  290|      0|      return res;
  291|      0|    }
  292|    418|    if (pos < size) {
  ------------------
  |  Branch (292:9): [True: 414, False: 4]
  ------------------
  293|       |      // rewind_and_convert_with_errors will seek a potential error from in+pos
  294|       |      // onward, with the ability to go back up to pos bytes, and read size-pos
  295|       |      // bytes forward.
  296|    414|      result res = scalar::utf8_to_latin1::rewind_and_convert_with_errors(
  297|    414|          pos, in + pos, size - pos, latin1_output);
  298|    414|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (298:11): [True: 192, False: 222]
  ------------------
  299|    192|        res.count += pos;
  300|    192|        return res;
  301|    222|      } else { // In case of success, we want the number of word written
  302|    222|        latin1_output += res.count;
  303|    222|      }
  304|    414|    }
  305|    226|    return result(error_code::SUCCESS, latin1_output - start);
  306|    418|  }

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoderC2Ev:
  114|  2.88k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoderC2Ev:
  114|  2.88k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder7convertILNS_10endiannessE0EEEmPKcmPDs:
  130|    776|                                       char16_t *utf16_output) {
  131|    776|    size_t pos = 0;
  132|    776|    char16_t *start{utf16_output};
  133|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  134|       |    // of 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the
  135|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  136|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  137|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  138|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  139|    776|    size_t leading_byte = 0;
  140|    776|    size_t margin = size;
  141|  7.21k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (141:12): [True: 6.96k, False: 252]
  |  Branch (141:26): [True: 6.44k, False: 524]
  ------------------
  142|  6.44k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  143|  6.44k|    }
  144|       |    // If the input is long enough, then we have that margin-1 is the eight last
  145|       |    // leading byte.
  146|    776|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  147|   502k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (147:12): [True: 501k, False: 756]
  ------------------
  148|   501k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  149|   501k|      if (input.is_ascii()) {
  ------------------
  |  Branch (149:11): [True: 444k, False: 56.9k]
  ------------------
  150|   444k|        input.store_ascii_as_utf16<endian>(utf16_output);
  151|   444k|        utf16_output += 64;
  152|   444k|        pos += 64;
  153|   444k|      } else {
  154|       |        // you might think that a for-loop would work, but under Visual Studio,
  155|       |        // it is not good enough.
  156|  56.9k|        static_assert(
  157|  56.9k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  158|  56.9k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  159|  56.9k|            "We support either two or four chunks per 64-byte block.");
  160|  56.9k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  161|  56.9k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  162|  56.9k|          this->check_utf8_bytes(input.chunks[0], zero);
  163|  56.9k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  164|       |        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  165|       |          this->check_utf8_bytes(input.chunks[0], zero);
  166|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  167|       |          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  168|       |          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  169|       |        }
  170|  56.9k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  171|  56.9k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (171:13): [True: 20, False: 56.9k]
  ------------------
  172|     20|          return 0; // error
  173|     20|        }
  174|  56.9k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  175|  56.9k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  176|       |        // We process in blocks of up to 12 bytes except possibly
  177|       |        // for fast paths which may process up to 16 bytes. For the
  178|       |        // slow path to work, we should have at least 12 input bytes left.
  179|  56.9k|        size_t max_starting_point = (pos + 64) - 12;
  180|       |        // Next loop is going to run at least five times.
  181|   558k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (181:16): [True: 501k, False: 56.9k]
  ------------------
  182|       |          // Performance note: our ability to compute 'consumed' and
  183|       |          // then shift and recompute is critical. If there is a
  184|       |          // latency of, say, 4 cycles on getting 'consumed', then
  185|       |          // the inner loop might have a total latency of about 6 cycles.
  186|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  187|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  188|       |          // for this section of the code. Hence, there is a limit
  189|       |          // to how much we can further increase this latency before
  190|       |          // it seriously harms performance.
  191|   501k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  192|   501k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  193|   501k|          pos += consumed;
  194|   501k|          utf8_end_of_code_point_mask >>= consumed;
  195|   501k|        }
  196|       |        // At this point there may remain between 0 and 12 bytes in the
  197|       |        // 64-byte block. These bytes will be processed again. So we have an
  198|       |        // 80% efficiency (in the worst case). In practice we expect an
  199|       |        // 85% to 90% efficiency.
  200|  56.9k|      }
  201|   501k|    }
  202|    756|    if (errors()) {
  ------------------
  |  Branch (202:9): [True: 308, False: 448]
  ------------------
  203|    308|      return 0;
  204|    308|    }
  205|    448|    if (pos < size) {
  ------------------
  |  Branch (205:9): [True: 446, False: 2]
  ------------------
  206|    446|      size_t howmany = scalar::utf8_to_utf16::convert<endian>(
  207|    446|          in + pos, size - pos, utf16_output);
  208|    446|      if (howmany == 0) {
  ------------------
  |  Branch (208:11): [True: 204, False: 242]
  ------------------
  209|    204|        return 0;
  210|    204|      }
  211|    242|      utf16_output += howmany;
  212|    242|    }
  213|    244|    return utf16_output - start;
  214|    448|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  119|   803k|                                              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|   803k|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  124|   803k|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  125|   803k|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  126|   803k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1619check_special_casesENS1_4simd5simd8IhEES5_:
    8|   803k|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|   803k|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   16|       |                                               // 11______ 11______
   17|   803k|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   18|   803k|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   19|   803k|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   20|   803k|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   21|   803k|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   22|   803k|  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|   803k|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   31|       |  // 11110101 1000____
   32|       |  // 1111011_ 1000____
   33|       |  // 11111___ 1000____
   34|   803k|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   35|       |
   36|   803k|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   37|       |      // 0_______ ________ <ASCII in byte 1>
   38|   803k|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   39|   803k|      TOO_LONG,
   40|       |      // 10______ ________ <continuation in byte 1>
   41|   803k|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   42|       |      // 1100____ ________ <two byte lead in byte 1>
   43|   803k|      TOO_SHORT | OVERLONG_2,
   44|       |      // 1101____ ________ <two byte lead in byte 1>
   45|   803k|      TOO_SHORT,
   46|       |      // 1110____ ________ <three byte lead in byte 1>
   47|   803k|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   48|       |      // 1111____ ________ <four+ byte lead in byte 1>
   49|   803k|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   50|   803k|  constexpr const uint8_t CARRY =
   51|   803k|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   52|   803k|  const simd8<uint8_t> byte_1_low =
   53|   803k|      (prev1 & 0x0F)
   54|   803k|          .lookup_16<uint8_t>(
   55|       |              // ____0000 ________
   56|   803k|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   57|       |              // ____0001 ________
   58|   803k|              CARRY | OVERLONG_2,
   59|       |              // ____001_ ________
   60|   803k|              CARRY, CARRY,
   61|       |
   62|       |              // ____0100 ________
   63|   803k|              CARRY | TOO_LARGE,
   64|       |              // ____0101 ________
   65|   803k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   66|       |              // ____011_ ________
   67|   803k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   68|   803k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|       |
   70|       |              // ____1___ ________
   71|   803k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   72|   803k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|   803k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|   803k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|   803k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|       |              // ____1101 ________
   77|   803k|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   78|   803k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   79|   803k|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   80|   803k|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   81|       |      // ________ 0_______ <ASCII in byte 2>
   82|   803k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   83|   803k|      TOO_SHORT, TOO_SHORT,
   84|       |
   85|       |      // ________ 1000____
   86|   803k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   87|   803k|          OVERLONG_4,
   88|       |      // ________ 1001____
   89|   803k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   90|       |      // ________ 101_____
   91|   803k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   92|   803k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|       |
   94|       |      // ________ 11______
   95|   803k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   96|   803k|  return (byte_1_high & byte_1_low & byte_2_high);
   97|   803k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1623check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  101|   803k|                        const simd8<uint8_t> sc) {
  102|   803k|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  103|   803k|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  104|   803k|  simd8<uint8_t> must23 =
  105|   803k|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  106|   803k|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  107|   803k|  return must23_80 ^ sc;
  108|   803k|}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder6errorsEv:
  324|   166k|  simdutf_really_inline bool errors() const {
  325|   166k|    return this->error.any_bits_set_anywhere();
  326|   166k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder7convertILNS_10endiannessE1EEEmPKcmPDs:
  130|    794|                                       char16_t *utf16_output) {
  131|    794|    size_t pos = 0;
  132|    794|    char16_t *start{utf16_output};
  133|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  134|       |    // of 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the
  135|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  136|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  137|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  138|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  139|    794|    size_t leading_byte = 0;
  140|    794|    size_t margin = size;
  141|  7.34k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (141:12): [True: 7.10k, False: 246]
  |  Branch (141:26): [True: 6.55k, False: 548]
  ------------------
  142|  6.55k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  143|  6.55k|    }
  144|       |    // If the input is long enough, then we have that margin-1 is the eight last
  145|       |    // leading byte.
  146|    794|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  147|   674k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (147:12): [True: 674k, False: 770]
  ------------------
  148|   674k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  149|   674k|      if (input.is_ascii()) {
  ------------------
  |  Branch (149:11): [True: 492k, False: 181k]
  ------------------
  150|   492k|        input.store_ascii_as_utf16<endian>(utf16_output);
  151|   492k|        utf16_output += 64;
  152|   492k|        pos += 64;
  153|   492k|      } else {
  154|       |        // you might think that a for-loop would work, but under Visual Studio,
  155|       |        // it is not good enough.
  156|   181k|        static_assert(
  157|   181k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  158|   181k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  159|   181k|            "We support either two or four chunks per 64-byte block.");
  160|   181k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  161|   181k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  162|   181k|          this->check_utf8_bytes(input.chunks[0], zero);
  163|   181k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  164|       |        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  165|       |          this->check_utf8_bytes(input.chunks[0], zero);
  166|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  167|       |          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  168|       |          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  169|       |        }
  170|   181k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  171|   181k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (171:13): [True: 24, False: 181k]
  ------------------
  172|     24|          return 0; // error
  173|     24|        }
  174|   181k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  175|   181k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  176|       |        // We process in blocks of up to 12 bytes except possibly
  177|       |        // for fast paths which may process up to 16 bytes. For the
  178|       |        // slow path to work, we should have at least 12 input bytes left.
  179|   181k|        size_t max_starting_point = (pos + 64) - 12;
  180|       |        // Next loop is going to run at least five times.
  181|  1.79M|        while (pos < max_starting_point) {
  ------------------
  |  Branch (181:16): [True: 1.61M, False: 181k]
  ------------------
  182|       |          // Performance note: our ability to compute 'consumed' and
  183|       |          // then shift and recompute is critical. If there is a
  184|       |          // latency of, say, 4 cycles on getting 'consumed', then
  185|       |          // the inner loop might have a total latency of about 6 cycles.
  186|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  187|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  188|       |          // for this section of the code. Hence, there is a limit
  189|       |          // to how much we can further increase this latency before
  190|       |          // it seriously harms performance.
  191|  1.61M|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  192|  1.61M|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  193|  1.61M|          pos += consumed;
  194|  1.61M|          utf8_end_of_code_point_mask >>= consumed;
  195|  1.61M|        }
  196|       |        // At this point there may remain between 0 and 12 bytes in the
  197|       |        // 64-byte block. These bytes will be processed again. So we have an
  198|       |        // 80% efficiency (in the worst case). In practice we expect an
  199|       |        // 85% to 90% efficiency.
  200|   181k|      }
  201|   674k|    }
  202|    770|    if (errors()) {
  ------------------
  |  Branch (202:9): [True: 328, False: 442]
  ------------------
  203|    328|      return 0;
  204|    328|    }
  205|    442|    if (pos < size) {
  ------------------
  |  Branch (205:9): [True: 440, False: 2]
  ------------------
  206|    440|      size_t howmany = scalar::utf8_to_utf16::convert<endian>(
  207|    440|          in + pos, size - pos, utf16_output);
  208|    440|      if (howmany == 0) {
  ------------------
  |  Branch (208:11): [True: 206, False: 234]
  ------------------
  209|    206|        return 0;
  210|    206|      }
  211|    234|      utf16_output += howmany;
  212|    234|    }
  213|    236|    return utf16_output - start;
  214|    442|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder19convert_with_errorsILNS_10endiannessE0EEENS_6resultEPKcmPDs:
  218|    610|                                                   char16_t *utf16_output) {
  219|    610|    size_t pos = 0;
  220|    610|    char16_t *start{utf16_output};
  221|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  222|       |    // of 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the
  223|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  224|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  225|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  226|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  227|    610|    size_t leading_byte = 0;
  228|    610|    size_t margin = size;
  229|  5.37k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (229:12): [True: 5.13k, False: 242]
  |  Branch (229:26): [True: 4.76k, False: 368]
  ------------------
  230|  4.76k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  231|  4.76k|    }
  232|       |    // If the input is long enough, then we have that margin-1 is the eight last
  233|       |    // leading byte.
  234|    610|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  235|   384k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (235:12): [True: 384k, False: 522]
  ------------------
  236|   384k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  237|   384k|      if (input.is_ascii()) {
  ------------------
  |  Branch (237:11): [True: 294k, False: 89.8k]
  ------------------
  238|   294k|        input.store_ascii_as_utf16<endian>(utf16_output);
  239|   294k|        utf16_output += 64;
  240|   294k|        pos += 64;
  241|   294k|      } else {
  242|       |        // you might think that a for-loop would work, but under Visual Studio,
  243|       |        // it is not good enough.
  244|  89.8k|        static_assert(
  245|  89.8k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  246|  89.8k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  247|  89.8k|            "We support either two or four chunks per 64-byte block.");
  248|  89.8k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  249|  89.8k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  250|  89.8k|          this->check_utf8_bytes(input.chunks[0], zero);
  251|  89.8k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  252|       |        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  253|       |          this->check_utf8_bytes(input.chunks[0], zero);
  254|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  255|       |          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  256|       |          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  257|       |        }
  258|  89.8k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  259|  89.8k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (259:13): [True: 88, False: 89.7k]
  |  Branch (259:25): [True: 0, False: 89.7k]
  ------------------
  260|       |          // rewind_and_convert_with_errors will seek a potential error from
  261|       |          // in+pos onward, with the ability to go back up to pos bytes, and
  262|       |          // read size-pos bytes forward.
  263|     88|          result res =
  264|     88|              scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  265|     88|                  pos, in + pos, size - pos, utf16_output);
  266|     88|          res.count += pos;
  267|     88|          return res;
  268|     88|        }
  269|  89.7k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  270|  89.7k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  271|       |        // We process in blocks of up to 12 bytes except possibly
  272|       |        // for fast paths which may process up to 16 bytes. For the
  273|       |        // slow path to work, we should have at least 12 input bytes left.
  274|  89.7k|        size_t max_starting_point = (pos + 64) - 12;
  275|       |        // Next loop is going to run at least five times.
  276|   885k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (276:16): [True: 795k, False: 89.7k]
  ------------------
  277|       |          // Performance note: our ability to compute 'consumed' and
  278|       |          // then shift and recompute is critical. If there is a
  279|       |          // latency of, say, 4 cycles on getting 'consumed', then
  280|       |          // the inner loop might have a total latency of about 6 cycles.
  281|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  282|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  283|       |          // for this section of the code. Hence, there is a limit
  284|       |          // to how much we can further increase this latency before
  285|       |          // it seriously harms performance.
  286|   795k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  287|   795k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  288|   795k|          pos += consumed;
  289|   795k|          utf8_end_of_code_point_mask >>= consumed;
  290|   795k|        }
  291|       |        // At this point there may remain between 0 and 12 bytes in the
  292|       |        // 64-byte block. These bytes will be processed again. So we have an
  293|       |        // 80% efficiency (in the worst case). In practice we expect an
  294|       |        // 85% to 90% efficiency.
  295|  89.7k|      }
  296|   384k|    }
  297|    522|    if (errors()) {
  ------------------
  |  Branch (297:9): [True: 0, False: 522]
  ------------------
  298|       |      // rewind_and_convert_with_errors will seek a potential error from in+pos
  299|       |      // onward, with the ability to go back up to pos bytes, and read size-pos
  300|       |      // bytes forward.
  301|      0|      result res =
  302|      0|          scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  303|      0|              pos, in + pos, size - pos, utf16_output);
  304|      0|      res.count += pos;
  305|      0|      return res;
  306|      0|    }
  307|    522|    if (pos < size) {
  ------------------
  |  Branch (307:9): [True: 518, False: 4]
  ------------------
  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|    518|      result res =
  312|    518|          scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  313|    518|              pos, in + pos, size - pos, utf16_output);
  314|    518|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (314:11): [True: 280, False: 238]
  ------------------
  315|    280|        res.count += pos;
  316|    280|        return res;
  317|    280|      } else { // In case of success, we want the number of word written
  318|    238|        utf16_output += res.count;
  319|    238|      }
  320|    518|    }
  321|    242|    return result(error_code::SUCCESS, utf16_output - start);
  322|    522|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder19convert_with_errorsILNS_10endiannessE1EEENS_6resultEPKcmPDs:
  218|    706|                                                   char16_t *utf16_output) {
  219|    706|    size_t pos = 0;
  220|    706|    char16_t *start{utf16_output};
  221|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  222|       |    // of 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the
  223|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  224|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  225|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  226|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  227|    706|    size_t leading_byte = 0;
  228|    706|    size_t margin = size;
  229|  6.20k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (229:12): [True: 5.96k, False: 236]
  |  Branch (229:26): [True: 5.49k, False: 470]
  ------------------
  230|  5.49k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  231|  5.49k|    }
  232|       |    // If the input is long enough, then we have that margin-1 is the eight last
  233|       |    // leading byte.
  234|    706|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  235|   365k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (235:12): [True: 365k, False: 634]
  ------------------
  236|   365k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  237|   365k|      if (input.is_ascii()) {
  ------------------
  |  Branch (237:11): [True: 291k, False: 73.6k]
  ------------------
  238|   291k|        input.store_ascii_as_utf16<endian>(utf16_output);
  239|   291k|        utf16_output += 64;
  240|   291k|        pos += 64;
  241|   291k|      } else {
  242|       |        // you might think that a for-loop would work, but under Visual Studio,
  243|       |        // it is not good enough.
  244|  73.6k|        static_assert(
  245|  73.6k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  246|  73.6k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  247|  73.6k|            "We support either two or four chunks per 64-byte block.");
  248|  73.6k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  249|  73.6k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  250|  73.6k|          this->check_utf8_bytes(input.chunks[0], zero);
  251|  73.6k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  252|       |        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  253|       |          this->check_utf8_bytes(input.chunks[0], zero);
  254|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  255|       |          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  256|       |          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  257|       |        }
  258|  73.6k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  259|  73.6k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (259:13): [True: 72, False: 73.5k]
  |  Branch (259:25): [True: 0, False: 73.5k]
  ------------------
  260|       |          // rewind_and_convert_with_errors will seek a potential error from
  261|       |          // in+pos onward, with the ability to go back up to pos bytes, and
  262|       |          // read size-pos bytes forward.
  263|     72|          result res =
  264|     72|              scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  265|     72|                  pos, in + pos, size - pos, utf16_output);
  266|     72|          res.count += pos;
  267|     72|          return res;
  268|     72|        }
  269|  73.5k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  270|  73.5k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  271|       |        // We process in blocks of up to 12 bytes except possibly
  272|       |        // for fast paths which may process up to 16 bytes. For the
  273|       |        // slow path to work, we should have at least 12 input bytes left.
  274|  73.5k|        size_t max_starting_point = (pos + 64) - 12;
  275|       |        // Next loop is going to run at least five times.
  276|   725k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (276:16): [True: 651k, False: 73.5k]
  ------------------
  277|       |          // Performance note: our ability to compute 'consumed' and
  278|       |          // then shift and recompute is critical. If there is a
  279|       |          // latency of, say, 4 cycles on getting 'consumed', then
  280|       |          // the inner loop might have a total latency of about 6 cycles.
  281|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  282|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  283|       |          // for this section of the code. Hence, there is a limit
  284|       |          // to how much we can further increase this latency before
  285|       |          // it seriously harms performance.
  286|   651k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  287|   651k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  288|   651k|          pos += consumed;
  289|   651k|          utf8_end_of_code_point_mask >>= consumed;
  290|   651k|        }
  291|       |        // At this point there may remain between 0 and 12 bytes in the
  292|       |        // 64-byte block. These bytes will be processed again. So we have an
  293|       |        // 80% efficiency (in the worst case). In practice we expect an
  294|       |        // 85% to 90% efficiency.
  295|  73.5k|      }
  296|   365k|    }
  297|    634|    if (errors()) {
  ------------------
  |  Branch (297:9): [True: 0, False: 634]
  ------------------
  298|       |      // rewind_and_convert_with_errors will seek a potential error from in+pos
  299|       |      // onward, with the ability to go back up to pos bytes, and read size-pos
  300|       |      // bytes forward.
  301|      0|      result res =
  302|      0|          scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  303|      0|              pos, in + pos, size - pos, utf16_output);
  304|      0|      res.count += pos;
  305|      0|      return res;
  306|      0|    }
  307|    634|    if (pos < size) {
  ------------------
  |  Branch (307:9): [True: 630, False: 4]
  ------------------
  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|    630|      result res =
  312|    630|          scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  313|    630|              pos, in + pos, size - pos, utf16_output);
  314|    630|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (314:11): [True: 322, False: 308]
  ------------------
  315|    322|        res.count += pos;
  316|    322|        return res;
  317|    322|      } else { // In case of success, we want the number of word written
  318|    308|        utf16_output += res.count;
  319|    308|      }
  320|    630|    }
  321|    312|    return result(error_code::SUCCESS, utf16_output - start);
  322|    634|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder7convertILNS_10endiannessE0EEEmPKcmPDs:
  130|    776|                                       char16_t *utf16_output) {
  131|    776|    size_t pos = 0;
  132|    776|    char16_t *start{utf16_output};
  133|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  134|       |    // of 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the
  135|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  136|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  137|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  138|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  139|    776|    size_t leading_byte = 0;
  140|    776|    size_t margin = size;
  141|  7.21k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (141:12): [True: 6.96k, False: 252]
  |  Branch (141:26): [True: 6.44k, False: 524]
  ------------------
  142|  6.44k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  143|  6.44k|    }
  144|       |    // If the input is long enough, then we have that margin-1 is the eight last
  145|       |    // leading byte.
  146|    776|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  147|   502k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (147:12): [True: 501k, False: 756]
  ------------------
  148|   501k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  149|   501k|      if (input.is_ascii()) {
  ------------------
  |  Branch (149:11): [True: 444k, False: 56.9k]
  ------------------
  150|   444k|        input.store_ascii_as_utf16<endian>(utf16_output);
  151|   444k|        utf16_output += 64;
  152|   444k|        pos += 64;
  153|   444k|      } else {
  154|       |        // you might think that a for-loop would work, but under Visual Studio,
  155|       |        // it is not good enough.
  156|  56.9k|        static_assert(
  157|  56.9k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  158|  56.9k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  159|  56.9k|            "We support either two or four chunks per 64-byte block.");
  160|  56.9k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  161|       |        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  162|       |          this->check_utf8_bytes(input.chunks[0], zero);
  163|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  164|  56.9k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  165|  56.9k|          this->check_utf8_bytes(input.chunks[0], zero);
  166|  56.9k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  167|  56.9k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  168|  56.9k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  169|  56.9k|        }
  170|  56.9k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  171|  56.9k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (171:13): [True: 20, False: 56.9k]
  ------------------
  172|     20|          return 0; // error
  173|     20|        }
  174|  56.9k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  175|  56.9k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  176|       |        // We process in blocks of up to 12 bytes except possibly
  177|       |        // for fast paths which may process up to 16 bytes. For the
  178|       |        // slow path to work, we should have at least 12 input bytes left.
  179|  56.9k|        size_t max_starting_point = (pos + 64) - 12;
  180|       |        // Next loop is going to run at least five times.
  181|   558k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (181:16): [True: 501k, False: 56.9k]
  ------------------
  182|       |          // Performance note: our ability to compute 'consumed' and
  183|       |          // then shift and recompute is critical. If there is a
  184|       |          // latency of, say, 4 cycles on getting 'consumed', then
  185|       |          // the inner loop might have a total latency of about 6 cycles.
  186|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  187|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  188|       |          // for this section of the code. Hence, there is a limit
  189|       |          // to how much we can further increase this latency before
  190|       |          // it seriously harms performance.
  191|   501k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  192|   501k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  193|   501k|          pos += consumed;
  194|   501k|          utf8_end_of_code_point_mask >>= consumed;
  195|   501k|        }
  196|       |        // At this point there may remain between 0 and 12 bytes in the
  197|       |        // 64-byte block. These bytes will be processed again. So we have an
  198|       |        // 80% efficiency (in the worst case). In practice we expect an
  199|       |        // 85% to 90% efficiency.
  200|  56.9k|      }
  201|   501k|    }
  202|    756|    if (errors()) {
  ------------------
  |  Branch (202:9): [True: 308, False: 448]
  ------------------
  203|    308|      return 0;
  204|    308|    }
  205|    448|    if (pos < size) {
  ------------------
  |  Branch (205:9): [True: 446, False: 2]
  ------------------
  206|    446|      size_t howmany = scalar::utf8_to_utf16::convert<endian>(
  207|    446|          in + pos, size - pos, utf16_output);
  208|    446|      if (howmany == 0) {
  ------------------
  |  Branch (208:11): [True: 204, False: 242]
  ------------------
  209|    204|        return 0;
  210|    204|      }
  211|    242|      utf16_output += howmany;
  212|    242|    }
  213|    244|    return utf16_output - start;
  214|    448|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  119|  1.60M|                                              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.60M|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  124|  1.60M|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  125|  1.60M|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  126|  1.60M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1619check_special_casesENS1_4simd5simd8IhEES5_:
    8|  1.60M|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.60M|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   16|       |                                               // 11______ 11______
   17|  1.60M|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   18|  1.60M|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   19|  1.60M|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   20|  1.60M|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   21|  1.60M|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   22|  1.60M|  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.60M|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   31|       |  // 11110101 1000____
   32|       |  // 1111011_ 1000____
   33|       |  // 11111___ 1000____
   34|  1.60M|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   35|       |
   36|  1.60M|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   37|       |      // 0_______ ________ <ASCII in byte 1>
   38|  1.60M|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   39|  1.60M|      TOO_LONG,
   40|       |      // 10______ ________ <continuation in byte 1>
   41|  1.60M|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   42|       |      // 1100____ ________ <two byte lead in byte 1>
   43|  1.60M|      TOO_SHORT | OVERLONG_2,
   44|       |      // 1101____ ________ <two byte lead in byte 1>
   45|  1.60M|      TOO_SHORT,
   46|       |      // 1110____ ________ <three byte lead in byte 1>
   47|  1.60M|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   48|       |      // 1111____ ________ <four+ byte lead in byte 1>
   49|  1.60M|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   50|  1.60M|  constexpr const uint8_t CARRY =
   51|  1.60M|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   52|  1.60M|  const simd8<uint8_t> byte_1_low =
   53|  1.60M|      (prev1 & 0x0F)
   54|  1.60M|          .lookup_16<uint8_t>(
   55|       |              // ____0000 ________
   56|  1.60M|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   57|       |              // ____0001 ________
   58|  1.60M|              CARRY | OVERLONG_2,
   59|       |              // ____001_ ________
   60|  1.60M|              CARRY, CARRY,
   61|       |
   62|       |              // ____0100 ________
   63|  1.60M|              CARRY | TOO_LARGE,
   64|       |              // ____0101 ________
   65|  1.60M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   66|       |              // ____011_ ________
   67|  1.60M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   68|  1.60M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|       |
   70|       |              // ____1___ ________
   71|  1.60M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   72|  1.60M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|  1.60M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|  1.60M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|  1.60M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|       |              // ____1101 ________
   77|  1.60M|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   78|  1.60M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   79|  1.60M|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   80|  1.60M|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   81|       |      // ________ 0_______ <ASCII in byte 2>
   82|  1.60M|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   83|  1.60M|      TOO_SHORT, TOO_SHORT,
   84|       |
   85|       |      // ________ 1000____
   86|  1.60M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   87|  1.60M|          OVERLONG_4,
   88|       |      // ________ 1001____
   89|  1.60M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   90|       |      // ________ 101_____
   91|  1.60M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   92|  1.60M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|       |
   94|       |      // ________ 11______
   95|  1.60M|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   96|  1.60M|  return (byte_1_high & byte_1_low & byte_2_high);
   97|  1.60M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1623check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  101|  1.60M|                        const simd8<uint8_t> sc) {
  102|  1.60M|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  103|  1.60M|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  104|  1.60M|  simd8<uint8_t> must23 =
  105|  1.60M|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  106|  1.60M|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  107|  1.60M|  return must23_80 ^ sc;
  108|  1.60M|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder6errorsEv:
  324|   166k|  simdutf_really_inline bool errors() const {
  325|   166k|    return this->error.any_bits_set_anywhere();
  326|   166k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder7convertILNS_10endiannessE1EEEmPKcmPDs:
  130|    794|                                       char16_t *utf16_output) {
  131|    794|    size_t pos = 0;
  132|    794|    char16_t *start{utf16_output};
  133|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  134|       |    // of 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the
  135|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  136|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  137|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  138|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  139|    794|    size_t leading_byte = 0;
  140|    794|    size_t margin = size;
  141|  7.34k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (141:12): [True: 7.10k, False: 246]
  |  Branch (141:26): [True: 6.55k, False: 548]
  ------------------
  142|  6.55k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  143|  6.55k|    }
  144|       |    // If the input is long enough, then we have that margin-1 is the eight last
  145|       |    // leading byte.
  146|    794|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  147|   674k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (147:12): [True: 674k, False: 770]
  ------------------
  148|   674k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  149|   674k|      if (input.is_ascii()) {
  ------------------
  |  Branch (149:11): [True: 492k, False: 181k]
  ------------------
  150|   492k|        input.store_ascii_as_utf16<endian>(utf16_output);
  151|   492k|        utf16_output += 64;
  152|   492k|        pos += 64;
  153|   492k|      } else {
  154|       |        // you might think that a for-loop would work, but under Visual Studio,
  155|       |        // it is not good enough.
  156|   181k|        static_assert(
  157|   181k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  158|   181k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  159|   181k|            "We support either two or four chunks per 64-byte block.");
  160|   181k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  161|       |        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  162|       |          this->check_utf8_bytes(input.chunks[0], zero);
  163|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  164|   181k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  165|   181k|          this->check_utf8_bytes(input.chunks[0], zero);
  166|   181k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  167|   181k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  168|   181k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  169|   181k|        }
  170|   181k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  171|   181k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (171:13): [True: 24, False: 181k]
  ------------------
  172|     24|          return 0; // error
  173|     24|        }
  174|   181k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  175|   181k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  176|       |        // We process in blocks of up to 12 bytes except possibly
  177|       |        // for fast paths which may process up to 16 bytes. For the
  178|       |        // slow path to work, we should have at least 12 input bytes left.
  179|   181k|        size_t max_starting_point = (pos + 64) - 12;
  180|       |        // Next loop is going to run at least five times.
  181|  1.79M|        while (pos < max_starting_point) {
  ------------------
  |  Branch (181:16): [True: 1.61M, False: 181k]
  ------------------
  182|       |          // Performance note: our ability to compute 'consumed' and
  183|       |          // then shift and recompute is critical. If there is a
  184|       |          // latency of, say, 4 cycles on getting 'consumed', then
  185|       |          // the inner loop might have a total latency of about 6 cycles.
  186|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  187|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  188|       |          // for this section of the code. Hence, there is a limit
  189|       |          // to how much we can further increase this latency before
  190|       |          // it seriously harms performance.
  191|  1.61M|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  192|  1.61M|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  193|  1.61M|          pos += consumed;
  194|  1.61M|          utf8_end_of_code_point_mask >>= consumed;
  195|  1.61M|        }
  196|       |        // At this point there may remain between 0 and 12 bytes in the
  197|       |        // 64-byte block. These bytes will be processed again. So we have an
  198|       |        // 80% efficiency (in the worst case). In practice we expect an
  199|       |        // 85% to 90% efficiency.
  200|   181k|      }
  201|   674k|    }
  202|    770|    if (errors()) {
  ------------------
  |  Branch (202:9): [True: 328, False: 442]
  ------------------
  203|    328|      return 0;
  204|    328|    }
  205|    442|    if (pos < size) {
  ------------------
  |  Branch (205:9): [True: 440, False: 2]
  ------------------
  206|    440|      size_t howmany = scalar::utf8_to_utf16::convert<endian>(
  207|    440|          in + pos, size - pos, utf16_output);
  208|    440|      if (howmany == 0) {
  ------------------
  |  Branch (208:11): [True: 206, False: 234]
  ------------------
  209|    206|        return 0;
  210|    206|      }
  211|    234|      utf16_output += howmany;
  212|    234|    }
  213|    236|    return utf16_output - start;
  214|    442|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder19convert_with_errorsILNS_10endiannessE0EEENS_6resultEPKcmPDs:
  218|    610|                                                   char16_t *utf16_output) {
  219|    610|    size_t pos = 0;
  220|    610|    char16_t *start{utf16_output};
  221|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  222|       |    // of 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the
  223|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  224|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  225|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  226|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  227|    610|    size_t leading_byte = 0;
  228|    610|    size_t margin = size;
  229|  5.37k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (229:12): [True: 5.13k, False: 242]
  |  Branch (229:26): [True: 4.76k, False: 368]
  ------------------
  230|  4.76k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  231|  4.76k|    }
  232|       |    // If the input is long enough, then we have that margin-1 is the eight last
  233|       |    // leading byte.
  234|    610|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  235|   384k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (235:12): [True: 384k, False: 522]
  ------------------
  236|   384k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  237|   384k|      if (input.is_ascii()) {
  ------------------
  |  Branch (237:11): [True: 294k, False: 89.8k]
  ------------------
  238|   294k|        input.store_ascii_as_utf16<endian>(utf16_output);
  239|   294k|        utf16_output += 64;
  240|   294k|        pos += 64;
  241|   294k|      } else {
  242|       |        // you might think that a for-loop would work, but under Visual Studio,
  243|       |        // it is not good enough.
  244|  89.8k|        static_assert(
  245|  89.8k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  246|  89.8k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  247|  89.8k|            "We support either two or four chunks per 64-byte block.");
  248|  89.8k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  249|       |        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  250|       |          this->check_utf8_bytes(input.chunks[0], zero);
  251|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  252|  89.8k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  253|  89.8k|          this->check_utf8_bytes(input.chunks[0], zero);
  254|  89.8k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  255|  89.8k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  256|  89.8k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  257|  89.8k|        }
  258|  89.8k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  259|  89.8k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (259:13): [True: 88, False: 89.7k]
  |  Branch (259:25): [True: 0, False: 89.7k]
  ------------------
  260|       |          // rewind_and_convert_with_errors will seek a potential error from
  261|       |          // in+pos onward, with the ability to go back up to pos bytes, and
  262|       |          // read size-pos bytes forward.
  263|     88|          result res =
  264|     88|              scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  265|     88|                  pos, in + pos, size - pos, utf16_output);
  266|     88|          res.count += pos;
  267|     88|          return res;
  268|     88|        }
  269|  89.7k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  270|  89.7k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  271|       |        // We process in blocks of up to 12 bytes except possibly
  272|       |        // for fast paths which may process up to 16 bytes. For the
  273|       |        // slow path to work, we should have at least 12 input bytes left.
  274|  89.7k|        size_t max_starting_point = (pos + 64) - 12;
  275|       |        // Next loop is going to run at least five times.
  276|   885k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (276:16): [True: 795k, False: 89.7k]
  ------------------
  277|       |          // Performance note: our ability to compute 'consumed' and
  278|       |          // then shift and recompute is critical. If there is a
  279|       |          // latency of, say, 4 cycles on getting 'consumed', then
  280|       |          // the inner loop might have a total latency of about 6 cycles.
  281|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  282|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  283|       |          // for this section of the code. Hence, there is a limit
  284|       |          // to how much we can further increase this latency before
  285|       |          // it seriously harms performance.
  286|   795k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  287|   795k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  288|   795k|          pos += consumed;
  289|   795k|          utf8_end_of_code_point_mask >>= consumed;
  290|   795k|        }
  291|       |        // At this point there may remain between 0 and 12 bytes in the
  292|       |        // 64-byte block. These bytes will be processed again. So we have an
  293|       |        // 80% efficiency (in the worst case). In practice we expect an
  294|       |        // 85% to 90% efficiency.
  295|  89.7k|      }
  296|   384k|    }
  297|    522|    if (errors()) {
  ------------------
  |  Branch (297:9): [True: 0, False: 522]
  ------------------
  298|       |      // rewind_and_convert_with_errors will seek a potential error from in+pos
  299|       |      // onward, with the ability to go back up to pos bytes, and read size-pos
  300|       |      // bytes forward.
  301|      0|      result res =
  302|      0|          scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  303|      0|              pos, in + pos, size - pos, utf16_output);
  304|      0|      res.count += pos;
  305|      0|      return res;
  306|      0|    }
  307|    522|    if (pos < size) {
  ------------------
  |  Branch (307:9): [True: 518, False: 4]
  ------------------
  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|    518|      result res =
  312|    518|          scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  313|    518|              pos, in + pos, size - pos, utf16_output);
  314|    518|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (314:11): [True: 280, False: 238]
  ------------------
  315|    280|        res.count += pos;
  316|    280|        return res;
  317|    280|      } else { // In case of success, we want the number of word written
  318|    238|        utf16_output += res.count;
  319|    238|      }
  320|    518|    }
  321|    242|    return result(error_code::SUCCESS, utf16_output - start);
  322|    522|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder19convert_with_errorsILNS_10endiannessE1EEENS_6resultEPKcmPDs:
  218|    706|                                                   char16_t *utf16_output) {
  219|    706|    size_t pos = 0;
  220|    706|    char16_t *start{utf16_output};
  221|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  222|       |    // of 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the
  223|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  224|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  225|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  226|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  227|    706|    size_t leading_byte = 0;
  228|    706|    size_t margin = size;
  229|  6.20k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (229:12): [True: 5.96k, False: 236]
  |  Branch (229:26): [True: 5.49k, False: 470]
  ------------------
  230|  5.49k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  231|  5.49k|    }
  232|       |    // If the input is long enough, then we have that margin-1 is the eight last
  233|       |    // leading byte.
  234|    706|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  235|   365k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (235:12): [True: 365k, False: 634]
  ------------------
  236|   365k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  237|   365k|      if (input.is_ascii()) {
  ------------------
  |  Branch (237:11): [True: 291k, False: 73.6k]
  ------------------
  238|   291k|        input.store_ascii_as_utf16<endian>(utf16_output);
  239|   291k|        utf16_output += 64;
  240|   291k|        pos += 64;
  241|   291k|      } else {
  242|       |        // you might think that a for-loop would work, but under Visual Studio,
  243|       |        // it is not good enough.
  244|  73.6k|        static_assert(
  245|  73.6k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  246|  73.6k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  247|  73.6k|            "We support either two or four chunks per 64-byte block.");
  248|  73.6k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  249|       |        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  250|       |          this->check_utf8_bytes(input.chunks[0], zero);
  251|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  252|  73.6k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  253|  73.6k|          this->check_utf8_bytes(input.chunks[0], zero);
  254|  73.6k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  255|  73.6k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  256|  73.6k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  257|  73.6k|        }
  258|  73.6k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  259|  73.6k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (259:13): [True: 72, False: 73.5k]
  |  Branch (259:25): [True: 0, False: 73.5k]
  ------------------
  260|       |          // rewind_and_convert_with_errors will seek a potential error from
  261|       |          // in+pos onward, with the ability to go back up to pos bytes, and
  262|       |          // read size-pos bytes forward.
  263|     72|          result res =
  264|     72|              scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  265|     72|                  pos, in + pos, size - pos, utf16_output);
  266|     72|          res.count += pos;
  267|     72|          return res;
  268|     72|        }
  269|  73.5k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  270|  73.5k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  271|       |        // We process in blocks of up to 12 bytes except possibly
  272|       |        // for fast paths which may process up to 16 bytes. For the
  273|       |        // slow path to work, we should have at least 12 input bytes left.
  274|  73.5k|        size_t max_starting_point = (pos + 64) - 12;
  275|       |        // Next loop is going to run at least five times.
  276|   725k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (276:16): [True: 651k, False: 73.5k]
  ------------------
  277|       |          // Performance note: our ability to compute 'consumed' and
  278|       |          // then shift and recompute is critical. If there is a
  279|       |          // latency of, say, 4 cycles on getting 'consumed', then
  280|       |          // the inner loop might have a total latency of about 6 cycles.
  281|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  282|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  283|       |          // for this section of the code. Hence, there is a limit
  284|       |          // to how much we can further increase this latency before
  285|       |          // it seriously harms performance.
  286|   651k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  287|   651k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  288|   651k|          pos += consumed;
  289|   651k|          utf8_end_of_code_point_mask >>= consumed;
  290|   651k|        }
  291|       |        // At this point there may remain between 0 and 12 bytes in the
  292|       |        // 64-byte block. These bytes will be processed again. So we have an
  293|       |        // 80% efficiency (in the worst case). In practice we expect an
  294|       |        // 85% to 90% efficiency.
  295|  73.5k|      }
  296|   365k|    }
  297|    634|    if (errors()) {
  ------------------
  |  Branch (297:9): [True: 0, False: 634]
  ------------------
  298|       |      // rewind_and_convert_with_errors will seek a potential error from in+pos
  299|       |      // onward, with the ability to go back up to pos bytes, and read size-pos
  300|       |      // bytes forward.
  301|      0|      result res =
  302|      0|          scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  303|      0|              pos, in + pos, size - pos, utf16_output);
  304|      0|      res.count += pos;
  305|      0|      return res;
  306|      0|    }
  307|    634|    if (pos < size) {
  ------------------
  |  Branch (307:9): [True: 630, False: 4]
  ------------------
  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|    630|      result res =
  312|    630|          scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  313|    630|              pos, in + pos, size - pos, utf16_output);
  314|    630|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (314:11): [True: 322, False: 308]
  ------------------
  315|    322|        res.count += pos;
  316|    322|        return res;
  317|    322|      } else { // In case of success, we want the number of word written
  318|    308|        utf16_output += res.count;
  319|    308|      }
  320|    630|    }
  321|    312|    return result(error_code::SUCCESS, utf16_output - start);
  322|    634|  }

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1613convert_validILNS_10endiannessE0EEEmPKcmPDs:
   10|    450|                                         char16_t *utf16_output) noexcept {
   11|       |  // The implementation is not specific to haswell and should be moved to the
   12|       |  // generic directory.
   13|    450|  size_t pos = 0;
   14|    450|  char16_t *start{utf16_output};
   15|    450|  const size_t safety_margin = 16; // to avoid overruns!
   16|   473k|  while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (16:10): [True: 472k, False: 450]
  ------------------
   17|       |    // this loop could be unrolled further. For example, we could process the
   18|       |    // mask far more than 64 bytes.
   19|   472k|    simd8x64<int8_t> in(reinterpret_cast<const int8_t *>(input + pos));
   20|   472k|    if (in.is_ascii()) {
  ------------------
  |  Branch (20:9): [True: 261k, False: 211k]
  ------------------
   21|   261k|      in.store_ascii_as_utf16<endian>(utf16_output);
   22|   261k|      utf16_output += 64;
   23|   261k|      pos += 64;
   24|   261k|    } 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|   211k|      uint64_t utf8_continuation_mask = in.lt(-65 + 1);
   29|       |      // -65 is 0b10111111 in two-complement's, so largest possible continuation
   30|       |      // byte
   31|   211k|      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|   211k|      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|   211k|      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|  2.09M|      while (pos < max_starting_point) {
  ------------------
  |  Branch (41:14): [True: 1.88M, False: 211k]
  ------------------
   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.88M|        size_t consumed = convert_masked_utf8_to_utf16<endian>(
   56|  1.88M|            input + pos, utf8_end_of_code_point_mask, utf16_output);
   57|  1.88M|        pos += consumed;
   58|  1.88M|        utf8_end_of_code_point_mask >>= consumed;
   59|  1.88M|      }
   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|   211k|    }
   65|   472k|  }
   66|    450|  utf16_output += scalar::utf8_to_utf16::convert_valid<endian>(
   67|    450|      input + pos, size - pos, utf16_output);
   68|    450|  return utf16_output - start;
   69|    450|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1613convert_validILNS_10endiannessE1EEEmPKcmPDs:
   10|    510|                                         char16_t *utf16_output) noexcept {
   11|       |  // The implementation is not specific to haswell and should be moved to the
   12|       |  // generic directory.
   13|    510|  size_t pos = 0;
   14|    510|  char16_t *start{utf16_output};
   15|    510|  const size_t safety_margin = 16; // to avoid overruns!
   16|   435k|  while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (16:10): [True: 434k, False: 510]
  ------------------
   17|       |    // this loop could be unrolled further. For example, we could process the
   18|       |    // mask far more than 64 bytes.
   19|   434k|    simd8x64<int8_t> in(reinterpret_cast<const int8_t *>(input + pos));
   20|   434k|    if (in.is_ascii()) {
  ------------------
  |  Branch (20:9): [True: 349k, False: 85.6k]
  ------------------
   21|   349k|      in.store_ascii_as_utf16<endian>(utf16_output);
   22|   349k|      utf16_output += 64;
   23|   349k|      pos += 64;
   24|   349k|    } 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|  85.6k|      uint64_t utf8_continuation_mask = in.lt(-65 + 1);
   29|       |      // -65 is 0b10111111 in two-complement's, so largest possible continuation
   30|       |      // byte
   31|  85.6k|      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|  85.6k|      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|  85.6k|      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|   819k|      while (pos < max_starting_point) {
  ------------------
  |  Branch (41:14): [True: 734k, False: 85.6k]
  ------------------
   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|   734k|        size_t consumed = convert_masked_utf8_to_utf16<endian>(
   56|   734k|            input + pos, utf8_end_of_code_point_mask, utf16_output);
   57|   734k|        pos += consumed;
   58|   734k|        utf8_end_of_code_point_mask >>= consumed;
   59|   734k|      }
   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|  85.6k|    }
   65|   434k|  }
   66|    510|  utf16_output += scalar::utf8_to_utf16::convert_valid<endian>(
   67|    510|      input + pos, size - pos, utf16_output);
   68|    510|  return utf16_output - start;
   69|    510|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1613convert_validILNS_10endiannessE0EEEmPKcmPDs:
   10|    450|                                         char16_t *utf16_output) noexcept {
   11|       |  // The implementation is not specific to haswell and should be moved to the
   12|       |  // generic directory.
   13|    450|  size_t pos = 0;
   14|    450|  char16_t *start{utf16_output};
   15|    450|  const size_t safety_margin = 16; // to avoid overruns!
   16|   473k|  while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (16:10): [True: 472k, False: 450]
  ------------------
   17|       |    // this loop could be unrolled further. For example, we could process the
   18|       |    // mask far more than 64 bytes.
   19|   472k|    simd8x64<int8_t> in(reinterpret_cast<const int8_t *>(input + pos));
   20|   472k|    if (in.is_ascii()) {
  ------------------
  |  Branch (20:9): [True: 261k, False: 211k]
  ------------------
   21|   261k|      in.store_ascii_as_utf16<endian>(utf16_output);
   22|   261k|      utf16_output += 64;
   23|   261k|      pos += 64;
   24|   261k|    } 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|   211k|      uint64_t utf8_continuation_mask = in.lt(-65 + 1);
   29|       |      // -65 is 0b10111111 in two-complement's, so largest possible continuation
   30|       |      // byte
   31|   211k|      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|   211k|      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|   211k|      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|  2.09M|      while (pos < max_starting_point) {
  ------------------
  |  Branch (41:14): [True: 1.88M, False: 211k]
  ------------------
   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.88M|        size_t consumed = convert_masked_utf8_to_utf16<endian>(
   56|  1.88M|            input + pos, utf8_end_of_code_point_mask, utf16_output);
   57|  1.88M|        pos += consumed;
   58|  1.88M|        utf8_end_of_code_point_mask >>= consumed;
   59|  1.88M|      }
   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|   211k|    }
   65|   472k|  }
   66|    450|  utf16_output += scalar::utf8_to_utf16::convert_valid<endian>(
   67|    450|      input + pos, size - pos, utf16_output);
   68|    450|  return utf16_output - start;
   69|    450|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1613convert_validILNS_10endiannessE1EEEmPKcmPDs:
   10|    510|                                         char16_t *utf16_output) noexcept {
   11|       |  // The implementation is not specific to haswell and should be moved to the
   12|       |  // generic directory.
   13|    510|  size_t pos = 0;
   14|    510|  char16_t *start{utf16_output};
   15|    510|  const size_t safety_margin = 16; // to avoid overruns!
   16|   435k|  while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (16:10): [True: 434k, False: 510]
  ------------------
   17|       |    // this loop could be unrolled further. For example, we could process the
   18|       |    // mask far more than 64 bytes.
   19|   434k|    simd8x64<int8_t> in(reinterpret_cast<const int8_t *>(input + pos));
   20|   434k|    if (in.is_ascii()) {
  ------------------
  |  Branch (20:9): [True: 349k, False: 85.6k]
  ------------------
   21|   349k|      in.store_ascii_as_utf16<endian>(utf16_output);
   22|   349k|      utf16_output += 64;
   23|   349k|      pos += 64;
   24|   349k|    } 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|  85.6k|      uint64_t utf8_continuation_mask = in.lt(-65 + 1);
   29|       |      // -65 is 0b10111111 in two-complement's, so largest possible continuation
   30|       |      // byte
   31|  85.6k|      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|  85.6k|      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|  85.6k|      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|   819k|      while (pos < max_starting_point) {
  ------------------
  |  Branch (41:14): [True: 734k, False: 85.6k]
  ------------------
   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|   734k|        size_t consumed = convert_masked_utf8_to_utf16<endian>(
   56|   734k|            input + pos, utf8_end_of_code_point_mask, utf16_output);
   57|   734k|        pos += consumed;
   58|   734k|        utf8_end_of_code_point_mask >>= consumed;
   59|   734k|      }
   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|  85.6k|    }
   65|   434k|  }
   66|    510|  utf16_output += scalar::utf8_to_utf16::convert_valid<endian>(
   67|    510|      input + pos, size - pos, utf16_output);
   68|    510|  return utf16_output - start;
   69|    510|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3221validating_transcoderC2Ev:
  114|  1.50k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3221validating_transcoder7convertEPKcmPDi:
  129|    758|                                       char32_t *utf32_output) {
  130|    758|    size_t pos = 0;
  131|    758|    char32_t *start{utf32_output};
  132|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  133|       |    // of 8 words when calling convert_masked_utf8_to_utf32. If you skip the
  134|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  135|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  136|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  137|       |    // back from the end counting 16 leading bytes, to give us a good margin.
  138|    758|    size_t leading_byte = 0;
  139|    758|    size_t margin = size;
  140|  7.04k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (140:12): [True: 6.79k, False: 250]
  |  Branch (140:26): [True: 6.28k, False: 508]
  ------------------
  141|  6.28k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  142|  6.28k|    }
  143|       |    // If the input is long enough, then we have that margin-1 is the fourth
  144|       |    // last leading byte.
  145|    758|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  146|   624k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (146:12): [True: 624k, False: 738]
  ------------------
  147|   624k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  148|   624k|      if (input.is_ascii()) {
  ------------------
  |  Branch (148:11): [True: 475k, False: 148k]
  ------------------
  149|   475k|        input.store_ascii_as_utf32(utf32_output);
  150|   475k|        utf32_output += 64;
  151|   475k|        pos += 64;
  152|   475k|      } else {
  153|       |        // you might think that a for-loop would work, but under Visual Studio,
  154|       |        // it is not good enough.
  155|   148k|        static_assert(
  156|   148k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  157|   148k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  158|   148k|            "We support either two or four chunks per 64-byte block.");
  159|   148k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  160|   148k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  161|   148k|          this->check_utf8_bytes(input.chunks[0], zero);
  162|   148k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  163|       |        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  164|       |          this->check_utf8_bytes(input.chunks[0], zero);
  165|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  166|       |          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  167|       |          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  168|       |        }
  169|   148k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  170|   148k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (170:13): [True: 20, False: 148k]
  ------------------
  171|     20|          return 0; // we have an error
  172|     20|        }
  173|   148k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  174|   148k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  175|       |        // We process in blocks of up to 12 bytes except possibly
  176|       |        // for fast paths which may process up to 16 bytes. For the
  177|       |        // slow path to work, we should have at least 12 input bytes left.
  178|   148k|        size_t max_starting_point = (pos + 64) - 12;
  179|       |        // Next loop is going to run at least five times.
  180|  1.47M|        while (pos < max_starting_point) {
  ------------------
  |  Branch (180:16): [True: 1.32M, False: 148k]
  ------------------
  181|       |          // Performance note: our ability to compute 'consumed' and
  182|       |          // then shift and recompute is critical. If there is a
  183|       |          // latency of, say, 4 cycles on getting 'consumed', then
  184|       |          // the inner loop might have a total latency of about 6 cycles.
  185|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  186|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  187|       |          // for this section of the code. Hence, there is a limit
  188|       |          // to how much we can further increase this latency before
  189|       |          // it seriously harms performance.
  190|  1.32M|          size_t consumed = convert_masked_utf8_to_utf32(
  191|  1.32M|              in + pos, utf8_end_of_code_point_mask, utf32_output);
  192|  1.32M|          pos += consumed;
  193|  1.32M|          utf8_end_of_code_point_mask >>= consumed;
  194|  1.32M|        }
  195|       |        // At this point there may remain between 0 and 12 bytes in the
  196|       |        // 64-byte block. These bytes will be processed again. So we have an
  197|       |        // 80% efficiency (in the worst case). In practice we expect an
  198|       |        // 85% to 90% efficiency.
  199|   148k|      }
  200|   624k|    }
  201|    738|    if (errors()) {
  ------------------
  |  Branch (201:9): [True: 252, False: 486]
  ------------------
  202|    252|      return 0;
  203|    252|    }
  204|    486|    if (pos < size) {
  ------------------
  |  Branch (204:9): [True: 484, False: 2]
  ------------------
  205|    484|      size_t howmany =
  206|    484|          scalar::utf8_to_utf32::convert(in + pos, size - pos, utf32_output);
  207|    484|      if (howmany == 0) {
  ------------------
  |  Branch (207:11): [True: 222, False: 262]
  ------------------
  208|    222|        return 0;
  209|    222|      }
  210|    262|      utf32_output += howmany;
  211|    262|    }
  212|    264|    return utf32_output - start;
  213|    486|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3221validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  119|   438k|                                              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|   438k|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  124|   438k|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  125|   438k|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  126|   438k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3219check_special_casesENS1_4simd5simd8IhEES5_:
    8|   438k|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|   438k|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   16|       |                                               // 11______ 11______
   17|   438k|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   18|   438k|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   19|   438k|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   20|   438k|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   21|   438k|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   22|   438k|  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|   438k|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   31|       |  // 11110101 1000____
   32|       |  // 1111011_ 1000____
   33|       |  // 11111___ 1000____
   34|   438k|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   35|       |
   36|   438k|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   37|       |      // 0_______ ________ <ASCII in byte 1>
   38|   438k|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   39|   438k|      TOO_LONG,
   40|       |      // 10______ ________ <continuation in byte 1>
   41|   438k|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   42|       |      // 1100____ ________ <two byte lead in byte 1>
   43|   438k|      TOO_SHORT | OVERLONG_2,
   44|       |      // 1101____ ________ <two byte lead in byte 1>
   45|   438k|      TOO_SHORT,
   46|       |      // 1110____ ________ <three byte lead in byte 1>
   47|   438k|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   48|       |      // 1111____ ________ <four+ byte lead in byte 1>
   49|   438k|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   50|   438k|  constexpr const uint8_t CARRY =
   51|   438k|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   52|   438k|  const simd8<uint8_t> byte_1_low =
   53|   438k|      (prev1 & 0x0F)
   54|   438k|          .lookup_16<uint8_t>(
   55|       |              // ____0000 ________
   56|   438k|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   57|       |              // ____0001 ________
   58|   438k|              CARRY | OVERLONG_2,
   59|       |              // ____001_ ________
   60|   438k|              CARRY, CARRY,
   61|       |
   62|       |              // ____0100 ________
   63|   438k|              CARRY | TOO_LARGE,
   64|       |              // ____0101 ________
   65|   438k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   66|       |              // ____011_ ________
   67|   438k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   68|   438k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|       |
   70|       |              // ____1___ ________
   71|   438k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   72|   438k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|   438k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|   438k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|   438k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|       |              // ____1101 ________
   77|   438k|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   78|   438k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   79|   438k|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   80|   438k|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   81|       |      // ________ 0_______ <ASCII in byte 2>
   82|   438k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   83|   438k|      TOO_SHORT, TOO_SHORT,
   84|       |
   85|       |      // ________ 1000____
   86|   438k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   87|   438k|          OVERLONG_4,
   88|       |      // ________ 1001____
   89|   438k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   90|       |      // ________ 101_____
   91|   438k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   92|   438k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|       |
   94|       |      // ________ 11______
   95|   438k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   96|   438k|  return (byte_1_high & byte_1_low & byte_2_high);
   97|   438k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3223check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  101|   438k|                        const simd8<uint8_t> sc) {
  102|   438k|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  103|   438k|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  104|   438k|  simd8<uint8_t> must23 =
  105|   438k|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  106|   438k|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  107|   438k|  return must23_80 ^ sc;
  108|   438k|}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3221validating_transcoder6errorsEv:
  310|  72.3k|  simdutf_really_inline bool errors() const {
  311|  72.3k|    return this->error.any_bits_set_anywhere();
  312|  72.3k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3221validating_transcoder19convert_with_errorsEPKcmPDi:
  216|    746|                                                   char32_t *utf32_output) {
  217|    746|    size_t pos = 0;
  218|    746|    char32_t *start{utf32_output};
  219|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  220|       |    // of 8 bytes when calling convert_masked_utf8_to_utf32. If you skip the
  221|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  222|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  223|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  224|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  225|    746|    size_t leading_byte = 0;
  226|    746|    size_t margin = size;
  227|  6.90k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (227:12): [True: 6.65k, False: 254]
  |  Branch (227:26): [True: 6.15k, False: 492]
  ------------------
  228|  6.15k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  229|  6.15k|    }
  230|       |    // If the input is long enough, then we have that margin-1 is the fourth
  231|       |    // last leading byte.
  232|    746|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  233|   438k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (233:12): [True: 437k, False: 662]
  ------------------
  234|   437k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  235|   437k|      if (input.is_ascii()) {
  ------------------
  |  Branch (235:11): [True: 366k, False: 70.9k]
  ------------------
  236|   366k|        input.store_ascii_as_utf32(utf32_output);
  237|   366k|        utf32_output += 64;
  238|   366k|        pos += 64;
  239|   366k|      } else {
  240|       |        // you might think that a for-loop would work, but under Visual Studio,
  241|       |        // it is not good enough.
  242|  70.9k|        static_assert(
  243|  70.9k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  244|  70.9k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  245|  70.9k|            "We support either two or four chunks per 64-byte block.");
  246|  70.9k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  247|  70.9k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  248|  70.9k|          this->check_utf8_bytes(input.chunks[0], zero);
  249|  70.9k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  250|       |        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  251|       |          this->check_utf8_bytes(input.chunks[0], zero);
  252|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  253|       |          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  254|       |          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  255|       |        }
  256|  70.9k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  257|  70.9k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (257:13): [True: 84, False: 70.8k]
  |  Branch (257:25): [True: 0, False: 70.8k]
  ------------------
  258|     84|          result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(
  259|     84|              pos, in + pos, size - pos, utf32_output);
  260|     84|          res.count += pos;
  261|     84|          return res;
  262|     84|        }
  263|  70.8k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  264|  70.8k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  265|       |        // We process in blocks of up to 12 bytes except possibly
  266|       |        // for fast paths which may process up to 16 bytes. For the
  267|       |        // slow path to work, we should have at least 12 input bytes left.
  268|  70.8k|        size_t max_starting_point = (pos + 64) - 12;
  269|       |        // Next loop is going to run at least five times.
  270|   696k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (270:16): [True: 625k, False: 70.8k]
  ------------------
  271|       |          // Performance note: our ability to compute 'consumed' and
  272|       |          // then shift and recompute is critical. If there is a
  273|       |          // latency of, say, 4 cycles on getting 'consumed', then
  274|       |          // the inner loop might have a total latency of about 6 cycles.
  275|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  276|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  277|       |          // for this section of the code. Hence, there is a limit
  278|       |          // to how much we can further increase this latency before
  279|       |          // it seriously harms performance.
  280|   625k|          size_t consumed = convert_masked_utf8_to_utf32(
  281|   625k|              in + pos, utf8_end_of_code_point_mask, utf32_output);
  282|   625k|          pos += consumed;
  283|   625k|          utf8_end_of_code_point_mask >>= consumed;
  284|   625k|        }
  285|       |        // At this point there may remain between 0 and 12 bytes in the
  286|       |        // 64-byte block. These bytes will be processed again. So we have an
  287|       |        // 80% efficiency (in the worst case). In practice we expect an
  288|       |        // 85% to 90% efficiency.
  289|  70.8k|      }
  290|   437k|    }
  291|    662|    if (errors()) {
  ------------------
  |  Branch (291:9): [True: 0, False: 662]
  ------------------
  292|      0|      result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(
  293|      0|          pos, in + pos, size - pos, utf32_output);
  294|      0|      res.count += pos;
  295|      0|      return res;
  296|      0|    }
  297|    662|    if (pos < size) {
  ------------------
  |  Branch (297:9): [True: 658, False: 4]
  ------------------
  298|    658|      result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(
  299|    658|          pos, in + pos, size - pos, utf32_output);
  300|    658|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (300:11): [True: 350, False: 308]
  ------------------
  301|    350|        res.count += pos;
  302|    350|        return res;
  303|    350|      } else { // In case of success, we want the number of word written
  304|    308|        utf32_output += res.count;
  305|    308|      }
  306|    658|    }
  307|    312|    return result(error_code::SUCCESS, utf32_output - start);
  308|    662|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3221validating_transcoderC2Ev:
  114|  1.50k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3221validating_transcoder7convertEPKcmPDi:
  129|    758|                                       char32_t *utf32_output) {
  130|    758|    size_t pos = 0;
  131|    758|    char32_t *start{utf32_output};
  132|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  133|       |    // of 8 words when calling convert_masked_utf8_to_utf32. If you skip the
  134|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  135|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  136|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  137|       |    // back from the end counting 16 leading bytes, to give us a good margin.
  138|    758|    size_t leading_byte = 0;
  139|    758|    size_t margin = size;
  140|  7.04k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (140:12): [True: 6.79k, False: 250]
  |  Branch (140:26): [True: 6.28k, False: 508]
  ------------------
  141|  6.28k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  142|  6.28k|    }
  143|       |    // If the input is long enough, then we have that margin-1 is the fourth
  144|       |    // last leading byte.
  145|    758|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  146|   624k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (146:12): [True: 624k, False: 738]
  ------------------
  147|   624k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  148|   624k|      if (input.is_ascii()) {
  ------------------
  |  Branch (148:11): [True: 475k, False: 148k]
  ------------------
  149|   475k|        input.store_ascii_as_utf32(utf32_output);
  150|   475k|        utf32_output += 64;
  151|   475k|        pos += 64;
  152|   475k|      } else {
  153|       |        // you might think that a for-loop would work, but under Visual Studio,
  154|       |        // it is not good enough.
  155|   148k|        static_assert(
  156|   148k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  157|   148k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  158|   148k|            "We support either two or four chunks per 64-byte block.");
  159|   148k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  160|       |        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  161|       |          this->check_utf8_bytes(input.chunks[0], zero);
  162|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  163|   148k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  164|   148k|          this->check_utf8_bytes(input.chunks[0], zero);
  165|   148k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  166|   148k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  167|   148k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  168|   148k|        }
  169|   148k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  170|   148k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (170:13): [True: 20, False: 148k]
  ------------------
  171|     20|          return 0; // we have an error
  172|     20|        }
  173|   148k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  174|   148k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  175|       |        // We process in blocks of up to 12 bytes except possibly
  176|       |        // for fast paths which may process up to 16 bytes. For the
  177|       |        // slow path to work, we should have at least 12 input bytes left.
  178|   148k|        size_t max_starting_point = (pos + 64) - 12;
  179|       |        // Next loop is going to run at least five times.
  180|  1.47M|        while (pos < max_starting_point) {
  ------------------
  |  Branch (180:16): [True: 1.32M, False: 148k]
  ------------------
  181|       |          // Performance note: our ability to compute 'consumed' and
  182|       |          // then shift and recompute is critical. If there is a
  183|       |          // latency of, say, 4 cycles on getting 'consumed', then
  184|       |          // the inner loop might have a total latency of about 6 cycles.
  185|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  186|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  187|       |          // for this section of the code. Hence, there is a limit
  188|       |          // to how much we can further increase this latency before
  189|       |          // it seriously harms performance.
  190|  1.32M|          size_t consumed = convert_masked_utf8_to_utf32(
  191|  1.32M|              in + pos, utf8_end_of_code_point_mask, utf32_output);
  192|  1.32M|          pos += consumed;
  193|  1.32M|          utf8_end_of_code_point_mask >>= consumed;
  194|  1.32M|        }
  195|       |        // At this point there may remain between 0 and 12 bytes in the
  196|       |        // 64-byte block. These bytes will be processed again. So we have an
  197|       |        // 80% efficiency (in the worst case). In practice we expect an
  198|       |        // 85% to 90% efficiency.
  199|   148k|      }
  200|   624k|    }
  201|    738|    if (errors()) {
  ------------------
  |  Branch (201:9): [True: 252, False: 486]
  ------------------
  202|    252|      return 0;
  203|    252|    }
  204|    486|    if (pos < size) {
  ------------------
  |  Branch (204:9): [True: 484, False: 2]
  ------------------
  205|    484|      size_t howmany =
  206|    484|          scalar::utf8_to_utf32::convert(in + pos, size - pos, utf32_output);
  207|    484|      if (howmany == 0) {
  ------------------
  |  Branch (207:11): [True: 222, False: 262]
  ------------------
  208|    222|        return 0;
  209|    222|      }
  210|    262|      utf32_output += howmany;
  211|    262|    }
  212|    264|    return utf32_output - start;
  213|    486|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3221validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  119|   877k|                                              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|   877k|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  124|   877k|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  125|   877k|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  126|   877k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3219check_special_casesENS1_4simd5simd8IhEES5_:
    8|   877k|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|   877k|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   16|       |                                               // 11______ 11______
   17|   877k|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   18|   877k|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   19|   877k|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   20|   877k|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   21|   877k|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   22|   877k|  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|   877k|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   31|       |  // 11110101 1000____
   32|       |  // 1111011_ 1000____
   33|       |  // 11111___ 1000____
   34|   877k|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   35|       |
   36|   877k|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   37|       |      // 0_______ ________ <ASCII in byte 1>
   38|   877k|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   39|   877k|      TOO_LONG,
   40|       |      // 10______ ________ <continuation in byte 1>
   41|   877k|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   42|       |      // 1100____ ________ <two byte lead in byte 1>
   43|   877k|      TOO_SHORT | OVERLONG_2,
   44|       |      // 1101____ ________ <two byte lead in byte 1>
   45|   877k|      TOO_SHORT,
   46|       |      // 1110____ ________ <three byte lead in byte 1>
   47|   877k|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   48|       |      // 1111____ ________ <four+ byte lead in byte 1>
   49|   877k|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   50|   877k|  constexpr const uint8_t CARRY =
   51|   877k|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   52|   877k|  const simd8<uint8_t> byte_1_low =
   53|   877k|      (prev1 & 0x0F)
   54|   877k|          .lookup_16<uint8_t>(
   55|       |              // ____0000 ________
   56|   877k|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   57|       |              // ____0001 ________
   58|   877k|              CARRY | OVERLONG_2,
   59|       |              // ____001_ ________
   60|   877k|              CARRY, CARRY,
   61|       |
   62|       |              // ____0100 ________
   63|   877k|              CARRY | TOO_LARGE,
   64|       |              // ____0101 ________
   65|   877k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   66|       |              // ____011_ ________
   67|   877k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   68|   877k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|       |
   70|       |              // ____1___ ________
   71|   877k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   72|   877k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|   877k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|   877k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|   877k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|       |              // ____1101 ________
   77|   877k|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   78|   877k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   79|   877k|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   80|   877k|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   81|       |      // ________ 0_______ <ASCII in byte 2>
   82|   877k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   83|   877k|      TOO_SHORT, TOO_SHORT,
   84|       |
   85|       |      // ________ 1000____
   86|   877k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   87|   877k|          OVERLONG_4,
   88|       |      // ________ 1001____
   89|   877k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   90|       |      // ________ 101_____
   91|   877k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   92|   877k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|       |
   94|       |      // ________ 11______
   95|   877k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   96|   877k|  return (byte_1_high & byte_1_low & byte_2_high);
   97|   877k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3223check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  101|   877k|                        const simd8<uint8_t> sc) {
  102|   877k|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  103|   877k|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  104|   877k|  simd8<uint8_t> must23 =
  105|   877k|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  106|   877k|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  107|   877k|  return must23_80 ^ sc;
  108|   877k|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3221validating_transcoder6errorsEv:
  310|  72.3k|  simdutf_really_inline bool errors() const {
  311|  72.3k|    return this->error.any_bits_set_anywhere();
  312|  72.3k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3221validating_transcoder19convert_with_errorsEPKcmPDi:
  216|    746|                                                   char32_t *utf32_output) {
  217|    746|    size_t pos = 0;
  218|    746|    char32_t *start{utf32_output};
  219|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  220|       |    // of 8 bytes when calling convert_masked_utf8_to_utf32. If you skip the
  221|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  222|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  223|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  224|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  225|    746|    size_t leading_byte = 0;
  226|    746|    size_t margin = size;
  227|  6.90k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (227:12): [True: 6.65k, False: 254]
  |  Branch (227:26): [True: 6.15k, False: 492]
  ------------------
  228|  6.15k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  229|  6.15k|    }
  230|       |    // If the input is long enough, then we have that margin-1 is the fourth
  231|       |    // last leading byte.
  232|    746|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  233|   438k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (233:12): [True: 437k, False: 662]
  ------------------
  234|   437k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  235|   437k|      if (input.is_ascii()) {
  ------------------
  |  Branch (235:11): [True: 366k, False: 70.9k]
  ------------------
  236|   366k|        input.store_ascii_as_utf32(utf32_output);
  237|   366k|        utf32_output += 64;
  238|   366k|        pos += 64;
  239|   366k|      } else {
  240|       |        // you might think that a for-loop would work, but under Visual Studio,
  241|       |        // it is not good enough.
  242|  70.9k|        static_assert(
  243|  70.9k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  244|  70.9k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  245|  70.9k|            "We support either two or four chunks per 64-byte block.");
  246|  70.9k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  247|       |        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  248|       |          this->check_utf8_bytes(input.chunks[0], zero);
  249|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  250|  70.9k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  251|  70.9k|          this->check_utf8_bytes(input.chunks[0], zero);
  252|  70.9k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  253|  70.9k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  254|  70.9k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  255|  70.9k|        }
  256|  70.9k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  257|  70.9k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (257:13): [True: 84, False: 70.8k]
  |  Branch (257:25): [True: 0, False: 70.8k]
  ------------------
  258|     84|          result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(
  259|     84|              pos, in + pos, size - pos, utf32_output);
  260|     84|          res.count += pos;
  261|     84|          return res;
  262|     84|        }
  263|  70.8k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  264|  70.8k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  265|       |        // We process in blocks of up to 12 bytes except possibly
  266|       |        // for fast paths which may process up to 16 bytes. For the
  267|       |        // slow path to work, we should have at least 12 input bytes left.
  268|  70.8k|        size_t max_starting_point = (pos + 64) - 12;
  269|       |        // Next loop is going to run at least five times.
  270|   696k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (270:16): [True: 625k, False: 70.8k]
  ------------------
  271|       |          // Performance note: our ability to compute 'consumed' and
  272|       |          // then shift and recompute is critical. If there is a
  273|       |          // latency of, say, 4 cycles on getting 'consumed', then
  274|       |          // the inner loop might have a total latency of about 6 cycles.
  275|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  276|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  277|       |          // for this section of the code. Hence, there is a limit
  278|       |          // to how much we can further increase this latency before
  279|       |          // it seriously harms performance.
  280|   625k|          size_t consumed = convert_masked_utf8_to_utf32(
  281|   625k|              in + pos, utf8_end_of_code_point_mask, utf32_output);
  282|   625k|          pos += consumed;
  283|   625k|          utf8_end_of_code_point_mask >>= consumed;
  284|   625k|        }
  285|       |        // At this point there may remain between 0 and 12 bytes in the
  286|       |        // 64-byte block. These bytes will be processed again. So we have an
  287|       |        // 80% efficiency (in the worst case). In practice we expect an
  288|       |        // 85% to 90% efficiency.
  289|  70.8k|      }
  290|   437k|    }
  291|    662|    if (errors()) {
  ------------------
  |  Branch (291:9): [True: 0, False: 662]
  ------------------
  292|      0|      result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(
  293|      0|          pos, in + pos, size - pos, utf32_output);
  294|      0|      res.count += pos;
  295|      0|      return res;
  296|      0|    }
  297|    662|    if (pos < size) {
  ------------------
  |  Branch (297:9): [True: 658, False: 4]
  ------------------
  298|    658|      result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(
  299|    658|          pos, in + pos, size - pos, utf32_output);
  300|    658|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (300:11): [True: 350, False: 308]
  ------------------
  301|    350|        res.count += pos;
  302|    350|        return res;
  303|    350|      } else { // In case of success, we want the number of word written
  304|    308|        utf32_output += res.count;
  305|    308|      }
  306|    658|    }
  307|    312|    return result(error_code::SUCCESS, utf32_output - start);
  308|    662|  }

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3213convert_validEPKcmPDi:
    9|    464|                                         char32_t *utf32_output) noexcept {
   10|    464|  size_t pos = 0;
   11|    464|  char32_t *start{utf32_output};
   12|    464|  const size_t safety_margin = 16; // to avoid overruns!
   13|   428k|  while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (13:10): [True: 427k, False: 464]
  ------------------
   14|   427k|    simd8x64<int8_t> in(reinterpret_cast<const int8_t *>(input + pos));
   15|   427k|    if (in.is_ascii()) {
  ------------------
  |  Branch (15:9): [True: 355k, False: 72.5k]
  ------------------
   16|   355k|      in.store_ascii_as_utf32(utf32_output);
   17|   355k|      utf32_output += 64;
   18|   355k|      pos += 64;
   19|   355k|    } else {
   20|       |      // -65 is 0b10111111 in two-complement's, so largest possible continuation
   21|       |      // byte
   22|  72.5k|      uint64_t utf8_continuation_mask = in.lt(-65 + 1);
   23|  72.5k|      uint64_t utf8_leading_mask = ~utf8_continuation_mask;
   24|  72.5k|      uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
   25|  72.5k|      size_t max_starting_point = (pos + 64) - 12;
   26|   704k|      while (pos < max_starting_point) {
  ------------------
  |  Branch (26:14): [True: 632k, False: 72.5k]
  ------------------
   27|   632k|        size_t consumed = convert_masked_utf8_to_utf32(
   28|   632k|            input + pos, utf8_end_of_code_point_mask, utf32_output);
   29|   632k|        pos += consumed;
   30|   632k|        utf8_end_of_code_point_mask >>= consumed;
   31|   632k|      }
   32|  72.5k|    }
   33|   427k|  }
   34|    464|  utf32_output += scalar::utf8_to_utf32::convert_valid(input + pos, size - pos,
   35|    464|                                                       utf32_output);
   36|    464|  return utf32_output - start;
   37|    464|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3213convert_validEPKcmPDi:
    9|    464|                                         char32_t *utf32_output) noexcept {
   10|    464|  size_t pos = 0;
   11|    464|  char32_t *start{utf32_output};
   12|    464|  const size_t safety_margin = 16; // to avoid overruns!
   13|   428k|  while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (13:10): [True: 427k, False: 464]
  ------------------
   14|   427k|    simd8x64<int8_t> in(reinterpret_cast<const int8_t *>(input + pos));
   15|   427k|    if (in.is_ascii()) {
  ------------------
  |  Branch (15:9): [True: 355k, False: 72.5k]
  ------------------
   16|   355k|      in.store_ascii_as_utf32(utf32_output);
   17|   355k|      utf32_output += 64;
   18|   355k|      pos += 64;
   19|   355k|    } else {
   20|       |      // -65 is 0b10111111 in two-complement's, so largest possible continuation
   21|       |      // byte
   22|  72.5k|      uint64_t utf8_continuation_mask = in.lt(-65 + 1);
   23|  72.5k|      uint64_t utf8_leading_mask = ~utf8_continuation_mask;
   24|  72.5k|      uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
   25|  72.5k|      size_t max_starting_point = (pos + 64) - 12;
   26|   704k|      while (pos < max_starting_point) {
  ------------------
  |  Branch (26:14): [True: 632k, False: 72.5k]
  ------------------
   27|   632k|        size_t consumed = convert_masked_utf8_to_utf32(
   28|   632k|            input + pos, utf8_end_of_code_point_mask, utf32_output);
   29|   632k|        pos += consumed;
   30|   632k|        utf8_end_of_code_point_mask >>= consumed;
   31|   632k|      }
   32|  72.5k|    }
   33|   427k|  }
   34|    464|  utf32_output += scalar::utf8_to_utf32::convert_valid(input + pos, size - pos,
   35|    464|                                                       utf32_output);
   36|    464|  return utf32_output - start;
   37|    464|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation12utf8_checker16check_next_inputERKNS1_4simd8simd8x64IhEE:
  187|  4.87M|  simdutf_really_inline void check_next_input(const simd8x64<uint8_t> &input) {
  188|  4.87M|    if (simdutf_likely(is_ascii(input))) {
  ------------------
  |  |   90|  4.87M|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 3.99M, False: 881k]
  |  |  ------------------
  ------------------
  189|  3.99M|      this->error |= this->prev_incomplete;
  190|  3.99M|    } else {
  191|       |      // you might think that a for-loop would work, but under Visual Studio, it
  192|       |      // is not good enough.
  193|   881k|      static_assert((simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  194|   881k|                        (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  195|   881k|                    "We support either two or four chunks per 64-byte block.");
  196|   881k|      if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  197|   881k|        this->check_utf8_bytes(input.chunks[0], this->prev_input_block);
  198|   881k|        this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  199|       |      } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  200|       |        this->check_utf8_bytes(input.chunks[0], this->prev_input_block);
  201|       |        this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  202|       |        this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  203|       |        this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  204|       |      }
  205|   881k|      this->prev_incomplete =
  206|   881k|          is_incomplete(input.chunks[simd8x64<uint8_t>::NUM_CHUNKS - 1]);
  207|   881k|      this->prev_input_block = input.chunks[simd8x64<uint8_t>::NUM_CHUNKS - 1];
  208|   881k|    }
  209|  4.87M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation12utf8_checker16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  169|  1.76M|                                              const simd8<uint8_t> prev_input) {
  170|       |    // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+
  171|       |    // lead bytes (2, 3, 4-byte leads become large positive numbers instead of
  172|       |    // small negative numbers)
  173|  1.76M|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  174|  1.76M|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  175|  1.76M|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  176|  1.76M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation19check_special_casesENS1_4simd5simd8IhEES5_:
    9|  1.76M|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.76M|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   17|       |                                               // 11______ 11______
   18|  1.76M|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   19|  1.76M|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   20|  1.76M|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   21|  1.76M|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   22|  1.76M|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   23|  1.76M|  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.76M|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   32|       |  // 11110101 1000____
   33|       |  // 1111011_ 1000____
   34|       |  // 11111___ 1000____
   35|  1.76M|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   36|       |
   37|  1.76M|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   38|       |      // 0_______ ________ <ASCII in byte 1>
   39|  1.76M|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   40|  1.76M|      TOO_LONG,
   41|       |      // 10______ ________ <continuation in byte 1>
   42|  1.76M|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   43|       |      // 1100____ ________ <two byte lead in byte 1>
   44|  1.76M|      TOO_SHORT | OVERLONG_2,
   45|       |      // 1101____ ________ <two byte lead in byte 1>
   46|  1.76M|      TOO_SHORT,
   47|       |      // 1110____ ________ <three byte lead in byte 1>
   48|  1.76M|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   49|       |      // 1111____ ________ <four+ byte lead in byte 1>
   50|  1.76M|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   51|  1.76M|  constexpr const uint8_t CARRY =
   52|  1.76M|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   53|  1.76M|  const simd8<uint8_t> byte_1_low =
   54|  1.76M|      (prev1 & 0x0F)
   55|  1.76M|          .lookup_16<uint8_t>(
   56|       |              // ____0000 ________
   57|  1.76M|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   58|       |              // ____0001 ________
   59|  1.76M|              CARRY | OVERLONG_2,
   60|       |              // ____001_ ________
   61|  1.76M|              CARRY, CARRY,
   62|       |
   63|       |              // ____0100 ________
   64|  1.76M|              CARRY | TOO_LARGE,
   65|       |              // ____0101 ________
   66|  1.76M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   67|       |              // ____011_ ________
   68|  1.76M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|  1.76M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   70|       |
   71|       |              // ____1___ ________
   72|  1.76M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|  1.76M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|  1.76M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|  1.76M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|  1.76M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   77|       |              // ____1101 ________
   78|  1.76M|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   79|  1.76M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   80|  1.76M|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   81|  1.76M|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   82|       |      // ________ 0_______ <ASCII in byte 2>
   83|  1.76M|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   84|  1.76M|      TOO_SHORT, TOO_SHORT,
   85|       |
   86|       |      // ________ 1000____
   87|  1.76M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   88|  1.76M|          OVERLONG_4,
   89|       |      // ________ 1001____
   90|  1.76M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   91|       |      // ________ 101_____
   92|  1.76M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|  1.76M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   94|       |
   95|       |      // ________ 11______
   96|  1.76M|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   97|  1.76M|  return (byte_1_high & byte_1_low & byte_2_high);
   98|  1.76M|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation23check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  102|  1.76M|                        const simd8<uint8_t> sc) {
  103|  1.76M|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  104|  1.76M|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  105|  1.76M|  simd8<uint8_t> must23 =
  106|  1.76M|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  107|  1.76M|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  108|  1.76M|  return must23_80 ^ sc;
  109|  1.76M|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation13is_incompleteENS1_4simd5simd8IhEE:
  115|   881k|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|   881k|  static const uint8_t max_array[32] = {255,
  120|   881k|                                        255,
  121|   881k|                                        255,
  122|   881k|                                        255,
  123|   881k|                                        255,
  124|   881k|                                        255,
  125|   881k|                                        255,
  126|   881k|                                        255,
  127|   881k|                                        255,
  128|   881k|                                        255,
  129|   881k|                                        255,
  130|   881k|                                        255,
  131|   881k|                                        255,
  132|   881k|                                        255,
  133|   881k|                                        255,
  134|   881k|                                        255,
  135|   881k|                                        255,
  136|   881k|                                        255,
  137|   881k|                                        255,
  138|   881k|                                        255,
  139|   881k|                                        255,
  140|   881k|                                        255,
  141|   881k|                                        255,
  142|   881k|                                        255,
  143|   881k|                                        255,
  144|   881k|                                        255,
  145|   881k|                                        255,
  146|   881k|                                        255,
  147|   881k|                                        255,
  148|   881k|                                        0b11110000u - 1,
  149|   881k|                                        0b11100000u - 1,
  150|   881k|                                        0b11000000u - 1};
  151|   881k|  const simd8<uint8_t> max_value(
  152|   881k|      &max_array[sizeof(max_array) - sizeof(simd8<uint8_t>)]);
  153|   881k|  return input.gt_bits(max_value);
  154|   881k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation12utf8_checker9check_eofEv:
  181|  6.11k|  simdutf_really_inline void check_eof() {
  182|       |    // If the previous block had incomplete UTF-8 characters at the end, an
  183|       |    // ASCII block can't possibly finish them.
  184|  6.11k|    this->error |= this->prev_incomplete;
  185|  6.11k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_115utf8_validation12utf8_checker6errorsEv:
  212|  2.04M|  simdutf_really_inline bool errors() const {
  213|  2.04M|    return this->error.any_bits_set_anywhere();
  214|  2.04M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation12utf8_checker16check_next_inputERKNS1_4simd8simd8x64IhEE:
  187|  4.87M|  simdutf_really_inline void check_next_input(const simd8x64<uint8_t> &input) {
  188|  4.87M|    if (simdutf_likely(is_ascii(input))) {
  ------------------
  |  |   90|  4.87M|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 3.99M, False: 881k]
  |  |  ------------------
  ------------------
  189|  3.99M|      this->error |= this->prev_incomplete;
  190|  3.99M|    } else {
  191|       |      // you might think that a for-loop would work, but under Visual Studio, it
  192|       |      // is not good enough.
  193|   881k|      static_assert((simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  194|   881k|                        (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  195|   881k|                    "We support either two or four chunks per 64-byte block.");
  196|       |      if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  197|       |        this->check_utf8_bytes(input.chunks[0], this->prev_input_block);
  198|       |        this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  199|   881k|      } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  200|   881k|        this->check_utf8_bytes(input.chunks[0], this->prev_input_block);
  201|   881k|        this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  202|   881k|        this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  203|   881k|        this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  204|   881k|      }
  205|   881k|      this->prev_incomplete =
  206|   881k|          is_incomplete(input.chunks[simd8x64<uint8_t>::NUM_CHUNKS - 1]);
  207|   881k|      this->prev_input_block = input.chunks[simd8x64<uint8_t>::NUM_CHUNKS - 1];
  208|   881k|    }
  209|  4.87M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation12utf8_checker16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  169|  3.52M|                                              const simd8<uint8_t> prev_input) {
  170|       |    // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+
  171|       |    // lead bytes (2, 3, 4-byte leads become large positive numbers instead of
  172|       |    // small negative numbers)
  173|  3.52M|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  174|  3.52M|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  175|  3.52M|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  176|  3.52M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation19check_special_casesENS1_4simd5simd8IhEES5_:
    9|  3.52M|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.52M|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   17|       |                                               // 11______ 11______
   18|  3.52M|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   19|  3.52M|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   20|  3.52M|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   21|  3.52M|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   22|  3.52M|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   23|  3.52M|  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.52M|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   32|       |  // 11110101 1000____
   33|       |  // 1111011_ 1000____
   34|       |  // 11111___ 1000____
   35|  3.52M|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   36|       |
   37|  3.52M|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   38|       |      // 0_______ ________ <ASCII in byte 1>
   39|  3.52M|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   40|  3.52M|      TOO_LONG,
   41|       |      // 10______ ________ <continuation in byte 1>
   42|  3.52M|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   43|       |      // 1100____ ________ <two byte lead in byte 1>
   44|  3.52M|      TOO_SHORT | OVERLONG_2,
   45|       |      // 1101____ ________ <two byte lead in byte 1>
   46|  3.52M|      TOO_SHORT,
   47|       |      // 1110____ ________ <three byte lead in byte 1>
   48|  3.52M|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   49|       |      // 1111____ ________ <four+ byte lead in byte 1>
   50|  3.52M|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   51|  3.52M|  constexpr const uint8_t CARRY =
   52|  3.52M|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   53|  3.52M|  const simd8<uint8_t> byte_1_low =
   54|  3.52M|      (prev1 & 0x0F)
   55|  3.52M|          .lookup_16<uint8_t>(
   56|       |              // ____0000 ________
   57|  3.52M|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   58|       |              // ____0001 ________
   59|  3.52M|              CARRY | OVERLONG_2,
   60|       |              // ____001_ ________
   61|  3.52M|              CARRY, CARRY,
   62|       |
   63|       |              // ____0100 ________
   64|  3.52M|              CARRY | TOO_LARGE,
   65|       |              // ____0101 ________
   66|  3.52M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   67|       |              // ____011_ ________
   68|  3.52M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|  3.52M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   70|       |
   71|       |              // ____1___ ________
   72|  3.52M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|  3.52M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|  3.52M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|  3.52M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|  3.52M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   77|       |              // ____1101 ________
   78|  3.52M|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   79|  3.52M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   80|  3.52M|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   81|  3.52M|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   82|       |      // ________ 0_______ <ASCII in byte 2>
   83|  3.52M|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   84|  3.52M|      TOO_SHORT, TOO_SHORT,
   85|       |
   86|       |      // ________ 1000____
   87|  3.52M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   88|  3.52M|          OVERLONG_4,
   89|       |      // ________ 1001____
   90|  3.52M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   91|       |      // ________ 101_____
   92|  3.52M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|  3.52M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   94|       |
   95|       |      // ________ 11______
   96|  3.52M|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   97|  3.52M|  return (byte_1_high & byte_1_low & byte_2_high);
   98|  3.52M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation23check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  102|  3.52M|                        const simd8<uint8_t> sc) {
  103|  3.52M|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  104|  3.52M|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  105|  3.52M|  simd8<uint8_t> must23 =
  106|  3.52M|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  107|  3.52M|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  108|  3.52M|  return must23_80 ^ sc;
  109|  3.52M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation13is_incompleteENS1_4simd5simd8IhEE:
  115|   881k|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|   881k|  static const uint8_t max_array[32] = {255,
  120|   881k|                                        255,
  121|   881k|                                        255,
  122|   881k|                                        255,
  123|   881k|                                        255,
  124|   881k|                                        255,
  125|   881k|                                        255,
  126|   881k|                                        255,
  127|   881k|                                        255,
  128|   881k|                                        255,
  129|   881k|                                        255,
  130|   881k|                                        255,
  131|   881k|                                        255,
  132|   881k|                                        255,
  133|   881k|                                        255,
  134|   881k|                                        255,
  135|   881k|                                        255,
  136|   881k|                                        255,
  137|   881k|                                        255,
  138|   881k|                                        255,
  139|   881k|                                        255,
  140|   881k|                                        255,
  141|   881k|                                        255,
  142|   881k|                                        255,
  143|   881k|                                        255,
  144|   881k|                                        255,
  145|   881k|                                        255,
  146|   881k|                                        255,
  147|   881k|                                        255,
  148|   881k|                                        0b11110000u - 1,
  149|   881k|                                        0b11100000u - 1,
  150|   881k|                                        0b11000000u - 1};
  151|   881k|  const simd8<uint8_t> max_value(
  152|   881k|      &max_array[sizeof(max_array) - sizeof(simd8<uint8_t>)]);
  153|   881k|  return input.gt_bits(max_value);
  154|   881k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation12utf8_checker9check_eofEv:
  181|  6.11k|  simdutf_really_inline void check_eof() {
  182|       |    // If the previous block had incomplete UTF-8 characters at the end, an
  183|       |    // ASCII block can't possibly finish them.
  184|  6.11k|    this->error |= this->prev_incomplete;
  185|  6.11k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_115utf8_validation12utf8_checker6errorsEv:
  212|  2.04M|  simdutf_really_inline bool errors() const {
  213|  2.04M|    return this->error.any_bits_set_anywhere();
  214|  2.04M|  }

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation21generic_validate_utf8EPKcm:
   27|  3.48k|bool generic_validate_utf8(const char *input, size_t length) {
   28|  3.48k|  return generic_validate_utf8<utf8_checker>(
   29|  3.48k|      reinterpret_cast<const uint8_t *>(input), length);
   30|  3.48k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation21generic_validate_utf8INS2_12utf8_checkerEEEbPKhm:
   10|  3.48k|bool generic_validate_utf8(const uint8_t *input, size_t length) {
   11|  3.48k|  checker c{};
   12|  3.48k|  buf_block_reader<64> reader(input, length);
   13|  2.82M|  while (reader.has_full_block()) {
  ------------------
  |  Branch (13:10): [True: 2.82M, False: 3.48k]
  ------------------
   14|  2.82M|    simd::simd8x64<uint8_t> in(reader.full_block());
   15|  2.82M|    c.check_next_input(in);
   16|  2.82M|    reader.advance();
   17|  2.82M|  }
   18|  3.48k|  uint8_t block[64]{};
   19|  3.48k|  reader.get_remainder(block);
   20|  3.48k|  simd::simd8x64<uint8_t> in(block);
   21|  3.48k|  c.check_next_input(in);
   22|  3.48k|  reader.advance();
   23|  3.48k|  c.check_eof();
   24|  3.48k|  return !c.errors();
   25|  3.48k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation33generic_validate_utf8_with_errorsEPKcm:
   76|  3.48k|result generic_validate_utf8_with_errors(const char *input, size_t length) {
   77|  3.48k|  return generic_validate_utf8_with_errors<utf8_checker>(
   78|  3.48k|      reinterpret_cast<const uint8_t *>(input), length);
   79|  3.48k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation33generic_validate_utf8_with_errorsINS2_12utf8_checkerEEENS_6resultEPKhm:
   36|  3.48k|result generic_validate_utf8_with_errors(const uint8_t *input, size_t length) {
   37|  3.48k|  checker c{};
   38|  3.48k|  buf_block_reader<64> reader(input, length);
   39|  3.48k|  size_t count{0};
   40|  2.04M|  while (reader.has_full_block()) {
  ------------------
  |  Branch (40:10): [True: 2.04M, False: 2.62k]
  ------------------
   41|  2.04M|    simd::simd8x64<uint8_t> in(reader.full_block());
   42|  2.04M|    c.check_next_input(in);
   43|  2.04M|    if (c.errors()) {
  ------------------
  |  Branch (43:9): [True: 858, False: 2.03M]
  ------------------
   44|    858|      if (count != 0) {
  ------------------
  |  Branch (44:11): [True: 233, False: 625]
  ------------------
   45|    233|        count--;
   46|    233|      } // Sometimes the error is only detected in the next chunk
   47|    858|      result res = scalar::utf8::rewind_and_validate_with_errors(
   48|    858|          reinterpret_cast<const char *>(input),
   49|    858|          reinterpret_cast<const char *>(input + count), length - count);
   50|    858|      res.count += count;
   51|    858|      return res;
   52|    858|    }
   53|  2.03M|    reader.advance();
   54|  2.03M|    count += 64;
   55|  2.03M|  }
   56|  2.62k|  uint8_t block[64]{};
   57|  2.62k|  reader.get_remainder(block);
   58|  2.62k|  simd::simd8x64<uint8_t> in(block);
   59|  2.62k|  c.check_next_input(in);
   60|  2.62k|  reader.advance();
   61|  2.62k|  c.check_eof();
   62|  2.62k|  if (c.errors()) {
  ------------------
  |  Branch (62:7): [True: 901, False: 1.72k]
  ------------------
   63|    901|    if (count != 0) {
  ------------------
  |  Branch (63:9): [True: 234, False: 667]
  ------------------
   64|    234|      count--;
   65|    234|    } // Sometimes the error is only detected in the next chunk
   66|    901|    result res = scalar::utf8::rewind_and_validate_with_errors(
   67|    901|        reinterpret_cast<const char *>(input),
   68|    901|        reinterpret_cast<const char *>(input) + count, length - count);
   69|    901|    res.count += count;
   70|    901|    return res;
   71|  1.72k|  } else {
   72|  1.72k|    return result(error_code::SUCCESS, length);
   73|  1.72k|  }
   74|  2.62k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation21generic_validate_utf8EPKcm:
   27|  3.48k|bool generic_validate_utf8(const char *input, size_t length) {
   28|  3.48k|  return generic_validate_utf8<utf8_checker>(
   29|  3.48k|      reinterpret_cast<const uint8_t *>(input), length);
   30|  3.48k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation21generic_validate_utf8INS2_12utf8_checkerEEEbPKhm:
   10|  3.48k|bool generic_validate_utf8(const uint8_t *input, size_t length) {
   11|  3.48k|  checker c{};
   12|  3.48k|  buf_block_reader<64> reader(input, length);
   13|  2.82M|  while (reader.has_full_block()) {
  ------------------
  |  Branch (13:10): [True: 2.82M, False: 3.48k]
  ------------------
   14|  2.82M|    simd::simd8x64<uint8_t> in(reader.full_block());
   15|  2.82M|    c.check_next_input(in);
   16|  2.82M|    reader.advance();
   17|  2.82M|  }
   18|  3.48k|  uint8_t block[64]{};
   19|  3.48k|  reader.get_remainder(block);
   20|  3.48k|  simd::simd8x64<uint8_t> in(block);
   21|  3.48k|  c.check_next_input(in);
   22|  3.48k|  reader.advance();
   23|  3.48k|  c.check_eof();
   24|  3.48k|  return !c.errors();
   25|  3.48k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation33generic_validate_utf8_with_errorsEPKcm:
   76|  3.48k|result generic_validate_utf8_with_errors(const char *input, size_t length) {
   77|  3.48k|  return generic_validate_utf8_with_errors<utf8_checker>(
   78|  3.48k|      reinterpret_cast<const uint8_t *>(input), length);
   79|  3.48k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation33generic_validate_utf8_with_errorsINS2_12utf8_checkerEEENS_6resultEPKhm:
   36|  3.48k|result generic_validate_utf8_with_errors(const uint8_t *input, size_t length) {
   37|  3.48k|  checker c{};
   38|  3.48k|  buf_block_reader<64> reader(input, length);
   39|  3.48k|  size_t count{0};
   40|  2.04M|  while (reader.has_full_block()) {
  ------------------
  |  Branch (40:10): [True: 2.04M, False: 2.62k]
  ------------------
   41|  2.04M|    simd::simd8x64<uint8_t> in(reader.full_block());
   42|  2.04M|    c.check_next_input(in);
   43|  2.04M|    if (c.errors()) {
  ------------------
  |  Branch (43:9): [True: 858, False: 2.03M]
  ------------------
   44|    858|      if (count != 0) {
  ------------------
  |  Branch (44:11): [True: 233, False: 625]
  ------------------
   45|    233|        count--;
   46|    233|      } // Sometimes the error is only detected in the next chunk
   47|    858|      result res = scalar::utf8::rewind_and_validate_with_errors(
   48|    858|          reinterpret_cast<const char *>(input),
   49|    858|          reinterpret_cast<const char *>(input + count), length - count);
   50|    858|      res.count += count;
   51|    858|      return res;
   52|    858|    }
   53|  2.03M|    reader.advance();
   54|  2.03M|    count += 64;
   55|  2.03M|  }
   56|  2.62k|  uint8_t block[64]{};
   57|  2.62k|  reader.get_remainder(block);
   58|  2.62k|  simd::simd8x64<uint8_t> in(block);
   59|  2.62k|  c.check_next_input(in);
   60|  2.62k|  reader.advance();
   61|  2.62k|  c.check_eof();
   62|  2.62k|  if (c.errors()) {
  ------------------
  |  Branch (62:7): [True: 901, False: 1.72k]
  ------------------
   63|    901|    if (count != 0) {
  ------------------
  |  Branch (63:9): [True: 234, False: 667]
  ------------------
   64|    234|      count--;
   65|    234|    } // Sometimes the error is only detected in the next chunk
   66|    901|    result res = scalar::utf8::rewind_and_validate_with_errors(
   67|    901|        reinterpret_cast<const char *>(input),
   68|    901|        reinterpret_cast<const char *>(input) + count, length - count);
   69|    901|    res.count += count;
   70|    901|    return res;
   71|  1.72k|  } else {
   72|  1.72k|    return result(error_code::SUCCESS, length);
   73|  1.72k|  }
   74|  2.62k|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE0EEEKNS_6resultEPKDsm:
   49|  2.69k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  2.69k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.69k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 17, False: 2.67k]
  |  |  ------------------
  ------------------
   51|     17|    return result(error_code::SUCCESS, 0);
   52|     17|  }
   53|       |
   54|  2.67k|  const char16_t *start = input;
   55|  2.67k|  const char16_t *end = input + size;
   56|       |
   57|  2.67k|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|  2.67k|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|  2.67k|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|  2.67k|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|  2.54M|  while (input + simd16<uint16_t>::SIZE * 2 < end) {
  ------------------
  |  Branch (62:10): [True: 2.54M, False: 2.50k]
  ------------------
   63|       |    // 0. Load data: since the validation takes into account only higher
   64|       |    //    byte of each word, we compress the two vectors into one which
   65|       |    //    consists only the higher bytes.
   66|  2.54M|    auto in0 = simd16<uint16_t>(input);
   67|  2.54M|    auto in1 =
   68|  2.54M|        simd16<uint16_t>(input + simd16<uint16_t>::SIZE / sizeof(char16_t));
   69|       |
   70|       |    // Function `utf16_gather_high_bytes` consumes two vectors of UTF-16
   71|       |    // and yields a single vector having only higher bytes of characters.
   72|  2.54M|    const auto in = utf16_gather_high_bytes<big_endian>(in0, in1);
   73|       |
   74|       |    // 1. Check whether we have any 0xD800..DFFF word (0b1101'1xxx'yyyy'yyyy).
   75|  2.54M|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   76|  2.54M|    const uint16_t surrogates_bitmask =
   77|  2.54M|        static_cast<uint16_t>(surrogates_wordmask.to_bitmask());
   78|  2.54M|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (78:9): [True: 2.52M, False: 19.6k]
  ------------------
   79|  2.52M|      input += 16;
   80|  2.52M|    } else {
   81|       |      // 2. We have some surrogates that have to be distinguished:
   82|       |      //    - low  surrogates: 0b1101'10xx'yyyy'yyyy (0xD800..0xDBFF)
   83|       |      //    - high surrogates: 0b1101'11xx'yyyy'yyyy (0xDC00..0xDFFF)
   84|       |      //
   85|       |      //    Fact: high surrogate has 11th bit set (3rd bit in the higher byte)
   86|       |
   87|       |      // V - non-surrogate code units
   88|       |      //     V = not surrogates_wordmask
   89|  19.6k|      const uint16_t V = static_cast<uint16_t>(~surrogates_bitmask);
   90|       |
   91|       |      // H - word-mask for high surrogates: the six highest bits are 0b1101'11
   92|  19.6k|      const auto vH = (in & v_fc) == v_dc;
   93|  19.6k|      const uint16_t H = static_cast<uint16_t>(vH.to_bitmask());
   94|       |
   95|       |      // L - word mask for low surrogates
   96|       |      //     L = not H and surrogates_wordmask
   97|  19.6k|      const uint16_t L = static_cast<uint16_t>(~H & surrogates_bitmask);
   98|       |
   99|  19.6k|      const uint16_t a = static_cast<uint16_t>(
  100|  19.6k|          L & (H >> 1)); // A low surrogate must be followed by high one.
  101|       |                         // (A low surrogate placed in the 7th register's word
  102|       |                         // is an exception we handle.)
  103|  19.6k|      const uint16_t b = static_cast<uint16_t>(
  104|  19.6k|          a << 1); // Just mark that the opinput - startite fact is hold,
  105|       |                   // thanks to that we have only two masks for valid case.
  106|  19.6k|      const uint16_t c = static_cast<uint16_t>(
  107|  19.6k|          V | a | b); // Combine all the masks into the final one.
  108|       |
  109|  19.6k|      if (c == 0xffff) {
  ------------------
  |  Branch (109:11): [True: 14.7k, False: 4.94k]
  ------------------
  110|       |        // The whole input register contains valid UTF-16, i.e.,
  111|       |        // either single code units or proper surrogate pairs.
  112|  14.7k|        input += 16;
  113|  14.7k|      } else if (c == 0x7fff) {
  ------------------
  |  Branch (113:18): [True: 4.77k, False: 176]
  ------------------
  114|       |        // The 15 lower code units of the input register contains valid UTF-16.
  115|       |        // The 15th word may be either a low or high surrogate. It the next
  116|       |        // iteration we 1) check if the low surrogate is followed by a high
  117|       |        // one, 2) reject sole high surrogate.
  118|  4.77k|        input += 15;
  119|  4.77k|      } else {
  120|    176|        return result(error_code::SURROGATE, input - start);
  121|    176|      }
  122|  19.6k|    }
  123|  2.54M|  }
  124|       |
  125|  2.50k|  return result(error_code::SUCCESS, input - start);
  126|  2.67k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE1EEEKNS_6resultEPKDsm:
   49|  2.66k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  2.66k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.66k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 16, False: 2.64k]
  |  |  ------------------
  ------------------
   51|     16|    return result(error_code::SUCCESS, 0);
   52|     16|  }
   53|       |
   54|  2.64k|  const char16_t *start = input;
   55|  2.64k|  const char16_t *end = input + size;
   56|       |
   57|  2.64k|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|  2.64k|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|  2.64k|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|  2.64k|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|  2.61M|  while (input + simd16<uint16_t>::SIZE * 2 < end) {
  ------------------
  |  Branch (62:10): [True: 2.61M, False: 2.44k]
  ------------------
   63|       |    // 0. Load data: since the validation takes into account only higher
   64|       |    //    byte of each word, we compress the two vectors into one which
   65|       |    //    consists only the higher bytes.
   66|  2.61M|    auto in0 = simd16<uint16_t>(input);
   67|  2.61M|    auto in1 =
   68|  2.61M|        simd16<uint16_t>(input + simd16<uint16_t>::SIZE / sizeof(char16_t));
   69|       |
   70|       |    // Function `utf16_gather_high_bytes` consumes two vectors of UTF-16
   71|       |    // and yields a single vector having only higher bytes of characters.
   72|  2.61M|    const auto in = utf16_gather_high_bytes<big_endian>(in0, in1);
   73|       |
   74|       |    // 1. Check whether we have any 0xD800..DFFF word (0b1101'1xxx'yyyy'yyyy).
   75|  2.61M|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   76|  2.61M|    const uint16_t surrogates_bitmask =
   77|  2.61M|        static_cast<uint16_t>(surrogates_wordmask.to_bitmask());
   78|  2.61M|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (78:9): [True: 2.59M, False: 18.0k]
  ------------------
   79|  2.59M|      input += 16;
   80|  2.59M|    } else {
   81|       |      // 2. We have some surrogates that have to be distinguished:
   82|       |      //    - low  surrogates: 0b1101'10xx'yyyy'yyyy (0xD800..0xDBFF)
   83|       |      //    - high surrogates: 0b1101'11xx'yyyy'yyyy (0xDC00..0xDFFF)
   84|       |      //
   85|       |      //    Fact: high surrogate has 11th bit set (3rd bit in the higher byte)
   86|       |
   87|       |      // V - non-surrogate code units
   88|       |      //     V = not surrogates_wordmask
   89|  18.0k|      const uint16_t V = static_cast<uint16_t>(~surrogates_bitmask);
   90|       |
   91|       |      // H - word-mask for high surrogates: the six highest bits are 0b1101'11
   92|  18.0k|      const auto vH = (in & v_fc) == v_dc;
   93|  18.0k|      const uint16_t H = static_cast<uint16_t>(vH.to_bitmask());
   94|       |
   95|       |      // L - word mask for low surrogates
   96|       |      //     L = not H and surrogates_wordmask
   97|  18.0k|      const uint16_t L = static_cast<uint16_t>(~H & surrogates_bitmask);
   98|       |
   99|  18.0k|      const uint16_t a = static_cast<uint16_t>(
  100|  18.0k|          L & (H >> 1)); // A low surrogate must be followed by high one.
  101|       |                         // (A low surrogate placed in the 7th register's word
  102|       |                         // is an exception we handle.)
  103|  18.0k|      const uint16_t b = static_cast<uint16_t>(
  104|  18.0k|          a << 1); // Just mark that the opinput - startite fact is hold,
  105|       |                   // thanks to that we have only two masks for valid case.
  106|  18.0k|      const uint16_t c = static_cast<uint16_t>(
  107|  18.0k|          V | a | b); // Combine all the masks into the final one.
  108|       |
  109|  18.0k|      if (c == 0xffff) {
  ------------------
  |  Branch (109:11): [True: 13.4k, False: 4.56k]
  ------------------
  110|       |        // The whole input register contains valid UTF-16, i.e.,
  111|       |        // either single code units or proper surrogate pairs.
  112|  13.4k|        input += 16;
  113|  13.4k|      } else if (c == 0x7fff) {
  ------------------
  |  Branch (113:18): [True: 4.36k, False: 204]
  ------------------
  114|       |        // The 15 lower code units of the input register contains valid UTF-16.
  115|       |        // The 15th word may be either a low or high surrogate. It the next
  116|       |        // iteration we 1) check if the low surrogate is followed by a high
  117|       |        // one, 2) reject sole high surrogate.
  118|  4.36k|        input += 15;
  119|  4.36k|      } else {
  120|    204|        return result(error_code::SURROGATE, input - start);
  121|    204|      }
  122|  18.0k|    }
  123|  2.61M|  }
  124|       |
  125|  2.44k|  return result(error_code::SUCCESS, input - start);
  126|  2.64k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE0EEEKNS_6resultEPKDsm:
   49|  2.69k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  2.69k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.69k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 17, False: 2.67k]
  |  |  ------------------
  ------------------
   51|     17|    return result(error_code::SUCCESS, 0);
   52|     17|  }
   53|       |
   54|  2.67k|  const char16_t *start = input;
   55|  2.67k|  const char16_t *end = input + size;
   56|       |
   57|  2.67k|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|  2.67k|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|  2.67k|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|  2.67k|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|  2.54M|  while (input + simd16<uint16_t>::SIZE * 2 < end) {
  ------------------
  |  Branch (62:10): [True: 2.54M, False: 2.39k]
  ------------------
   63|       |    // 0. Load data: since the validation takes into account only higher
   64|       |    //    byte of each word, we compress the two vectors into one which
   65|       |    //    consists only the higher bytes.
   66|  2.54M|    auto in0 = simd16<uint16_t>(input);
   67|  2.54M|    auto in1 =
   68|  2.54M|        simd16<uint16_t>(input + simd16<uint16_t>::SIZE / sizeof(char16_t));
   69|       |
   70|       |    // Function `utf16_gather_high_bytes` consumes two vectors of UTF-16
   71|       |    // and yields a single vector having only higher bytes of characters.
   72|  2.54M|    const auto in = utf16_gather_high_bytes<big_endian>(in0, in1);
   73|       |
   74|       |    // 1. Check whether we have any 0xD800..DFFF word (0b1101'1xxx'yyyy'yyyy).
   75|  2.54M|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   76|  2.54M|    const uint16_t surrogates_bitmask =
   77|  2.54M|        static_cast<uint16_t>(surrogates_wordmask.to_bitmask());
   78|  2.54M|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (78:9): [True: 2.52M, False: 20.1k]
  ------------------
   79|  2.52M|      input += 16;
   80|  2.52M|    } else {
   81|       |      // 2. We have some surrogates that have to be distinguished:
   82|       |      //    - low  surrogates: 0b1101'10xx'yyyy'yyyy (0xD800..0xDBFF)
   83|       |      //    - high surrogates: 0b1101'11xx'yyyy'yyyy (0xDC00..0xDFFF)
   84|       |      //
   85|       |      //    Fact: high surrogate has 11th bit set (3rd bit in the higher byte)
   86|       |
   87|       |      // V - non-surrogate code units
   88|       |      //     V = not surrogates_wordmask
   89|  20.1k|      const uint16_t V = static_cast<uint16_t>(~surrogates_bitmask);
   90|       |
   91|       |      // H - word-mask for high surrogates: the six highest bits are 0b1101'11
   92|  20.1k|      const auto vH = (in & v_fc) == v_dc;
   93|  20.1k|      const uint16_t H = static_cast<uint16_t>(vH.to_bitmask());
   94|       |
   95|       |      // L - word mask for low surrogates
   96|       |      //     L = not H and surrogates_wordmask
   97|  20.1k|      const uint16_t L = static_cast<uint16_t>(~H & surrogates_bitmask);
   98|       |
   99|  20.1k|      const uint16_t a = static_cast<uint16_t>(
  100|  20.1k|          L & (H >> 1)); // A low surrogate must be followed by high one.
  101|       |                         // (A low surrogate placed in the 7th register's word
  102|       |                         // is an exception we handle.)
  103|  20.1k|      const uint16_t b = static_cast<uint16_t>(
  104|  20.1k|          a << 1); // Just mark that the opinput - startite fact is hold,
  105|       |                   // thanks to that we have only two masks for valid case.
  106|  20.1k|      const uint16_t c = static_cast<uint16_t>(
  107|  20.1k|          V | a | b); // Combine all the masks into the final one.
  108|       |
  109|  20.1k|      if (c == 0xffff) {
  ------------------
  |  Branch (109:11): [True: 15.0k, False: 5.11k]
  ------------------
  110|       |        // The whole input register contains valid UTF-16, i.e.,
  111|       |        // either single code units or proper surrogate pairs.
  112|  15.0k|        input += 16;
  113|  15.0k|      } else if (c == 0x7fff) {
  ------------------
  |  Branch (113:18): [True: 4.83k, False: 278]
  ------------------
  114|       |        // The 15 lower code units of the input register contains valid UTF-16.
  115|       |        // The 15th word may be either a low or high surrogate. It the next
  116|       |        // iteration we 1) check if the low surrogate is followed by a high
  117|       |        // one, 2) reject sole high surrogate.
  118|  4.83k|        input += 15;
  119|  4.83k|      } else {
  120|    278|        return result(error_code::SURROGATE, input - start);
  121|    278|      }
  122|  20.1k|    }
  123|  2.54M|  }
  124|       |
  125|  2.39k|  return result(error_code::SUCCESS, input - start);
  126|  2.67k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE1EEEKNS_6resultEPKDsm:
   49|  2.66k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  2.66k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.66k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 16, False: 2.64k]
  |  |  ------------------
  ------------------
   51|     16|    return result(error_code::SUCCESS, 0);
   52|     16|  }
   53|       |
   54|  2.64k|  const char16_t *start = input;
   55|  2.64k|  const char16_t *end = input + size;
   56|       |
   57|  2.64k|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|  2.64k|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|  2.64k|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|  2.64k|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|  2.61M|  while (input + simd16<uint16_t>::SIZE * 2 < end) {
  ------------------
  |  Branch (62:10): [True: 2.61M, False: 2.33k]
  ------------------
   63|       |    // 0. Load data: since the validation takes into account only higher
   64|       |    //    byte of each word, we compress the two vectors into one which
   65|       |    //    consists only the higher bytes.
   66|  2.61M|    auto in0 = simd16<uint16_t>(input);
   67|  2.61M|    auto in1 =
   68|  2.61M|        simd16<uint16_t>(input + simd16<uint16_t>::SIZE / sizeof(char16_t));
   69|       |
   70|       |    // Function `utf16_gather_high_bytes` consumes two vectors of UTF-16
   71|       |    // and yields a single vector having only higher bytes of characters.
   72|  2.61M|    const auto in = utf16_gather_high_bytes<big_endian>(in0, in1);
   73|       |
   74|       |    // 1. Check whether we have any 0xD800..DFFF word (0b1101'1xxx'yyyy'yyyy).
   75|  2.61M|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   76|  2.61M|    const uint16_t surrogates_bitmask =
   77|  2.61M|        static_cast<uint16_t>(surrogates_wordmask.to_bitmask());
   78|  2.61M|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (78:9): [True: 2.59M, False: 18.5k]
  ------------------
   79|  2.59M|      input += 16;
   80|  2.59M|    } else {
   81|       |      // 2. We have some surrogates that have to be distinguished:
   82|       |      //    - low  surrogates: 0b1101'10xx'yyyy'yyyy (0xD800..0xDBFF)
   83|       |      //    - high surrogates: 0b1101'11xx'yyyy'yyyy (0xDC00..0xDFFF)
   84|       |      //
   85|       |      //    Fact: high surrogate has 11th bit set (3rd bit in the higher byte)
   86|       |
   87|       |      // V - non-surrogate code units
   88|       |      //     V = not surrogates_wordmask
   89|  18.5k|      const uint16_t V = static_cast<uint16_t>(~surrogates_bitmask);
   90|       |
   91|       |      // H - word-mask for high surrogates: the six highest bits are 0b1101'11
   92|  18.5k|      const auto vH = (in & v_fc) == v_dc;
   93|  18.5k|      const uint16_t H = static_cast<uint16_t>(vH.to_bitmask());
   94|       |
   95|       |      // L - word mask for low surrogates
   96|       |      //     L = not H and surrogates_wordmask
   97|  18.5k|      const uint16_t L = static_cast<uint16_t>(~H & surrogates_bitmask);
   98|       |
   99|  18.5k|      const uint16_t a = static_cast<uint16_t>(
  100|  18.5k|          L & (H >> 1)); // A low surrogate must be followed by high one.
  101|       |                         // (A low surrogate placed in the 7th register's word
  102|       |                         // is an exception we handle.)
  103|  18.5k|      const uint16_t b = static_cast<uint16_t>(
  104|  18.5k|          a << 1); // Just mark that the opinput - startite fact is hold,
  105|       |                   // thanks to that we have only two masks for valid case.
  106|  18.5k|      const uint16_t c = static_cast<uint16_t>(
  107|  18.5k|          V | a | b); // Combine all the masks into the final one.
  108|       |
  109|  18.5k|      if (c == 0xffff) {
  ------------------
  |  Branch (109:11): [True: 13.7k, False: 4.78k]
  ------------------
  110|       |        // The whole input register contains valid UTF-16, i.e.,
  111|       |        // either single code units or proper surrogate pairs.
  112|  13.7k|        input += 16;
  113|  13.7k|      } else if (c == 0x7fff) {
  ------------------
  |  Branch (113:18): [True: 4.47k, False: 310]
  ------------------
  114|       |        // The 15 lower code units of the input register contains valid UTF-16.
  115|       |        // The 15th word may be either a low or high surrogate. It the next
  116|       |        // iteration we 1) check if the low surrogate is followed by a high
  117|       |        // one, 2) reject sole high surrogate.
  118|  4.47k|        input += 15;
  119|  4.47k|      } else {
  120|    310|        return result(error_code::SURROGATE, input - start);
  121|    310|      }
  122|  18.5k|    }
  123|  2.61M|  }
  124|       |
  125|  2.33k|  return result(error_code::SUCCESS, input - start);
  126|  2.64k|}

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

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_128avx2_convert_latin1_to_utf32EPKcmPDi:
    3|    124|                             char32_t *utf32_output) {
    4|    124|  size_t rounded_len = ((len | 7) ^ 7); // Round down to nearest multiple of 8
    5|       |
    6|   867k|  for (size_t i = 0; i < rounded_len; i += 8) {
  ------------------
  |  Branch (6:22): [True: 867k, False: 124]
  ------------------
    7|       |    // Load 8 Latin1 characters into a 64-bit register
    8|   867k|    __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|   867k|    __m256i out = _mm256_cvtepu8_epi32(in);
   13|       |
   14|       |    // Store the results back to memory
   15|   867k|    _mm256_storeu_si256((__m256i *)&utf32_output[i], out);
   16|   867k|  }
   17|       |
   18|       |  // return pointers pointing to where we left off
   19|    124|  return std::make_pair(buf + rounded_len, utf32_output + rounded_len);
   20|    124|}

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

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_127avx2_convert_utf16_to_utf32ILNS_10endiannessE0EEENSt3__14pairIPKDsPDiEES7_mS8_:
   57|    454|                            char32_t *utf32_output) {
   58|    454|  const char16_t *end = buf + len;
   59|    454|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
   60|    454|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
   61|       |
   62|   274k|  while (end - buf >= 16) {
  ------------------
  |  Branch (62:10): [True: 273k, False: 336]
  ------------------
   63|   273k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
   64|   273k|    if (big_endian) {
  ------------------
  |  Branch (64:9): [Folded, False: 273k]
  ------------------
   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|   273k|    const __m256i surrogates_bytemask =
   75|   273k|        _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|   273k|    const uint32_t surrogates_bitmask =
   80|   273k|        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|   273k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (83:9): [True: 268k, False: 5.60k]
  ------------------
   84|       |      // case: we extend all sixteen 16-bit code units to sixteen 32-bit code
   85|       |      // units
   86|   268k|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
   87|   268k|                          _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in)));
   88|   268k|      _mm256_storeu_si256(
   89|   268k|          reinterpret_cast<__m256i *>(utf32_output + 8),
   90|   268k|          _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1)));
   91|   268k|      utf32_output += 16;
   92|   268k|      buf += 16;
   93|       |      // surrogate pair(s) in a register
   94|   268k|    } 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.60k|      size_t forward = 15;
   99|  5.60k|      size_t k = 0;
  100|  5.60k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (100:11): [True: 0, False: 5.60k]
  ------------------
  101|      0|        forward = size_t(end - buf - 1);
  102|      0|      }
  103|  82.2k|      for (; k < forward; k++) {
  ------------------
  |  Branch (103:14): [True: 76.7k, False: 5.48k]
  ------------------
  104|  76.7k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  105|  76.7k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (105:13): [True: 70.1k, False: 6.66k]
  ------------------
  106|       |          // No surrogate pair
  107|  70.1k|          *utf32_output++ = char32_t(word);
  108|  70.1k|        } else {
  109|       |          // must be a surrogate pair
  110|  6.66k|          uint16_t diff = uint16_t(word - 0xD800);
  111|  6.66k|          uint16_t next_word =
  112|  6.66k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  113|  6.66k|          k++;
  114|  6.66k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  115|  6.66k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (115:15): [True: 118, False: 6.54k]
  ------------------
  116|    118|            return std::make_pair(nullptr, utf32_output);
  117|    118|          }
  118|  6.54k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  119|  6.54k|          *utf32_output++ = char32_t(value);
  120|  6.54k|        }
  121|  76.7k|      }
  122|  5.48k|      buf += k;
  123|  5.48k|    }
  124|   273k|  } // while
  125|    336|  return std::make_pair(buf, utf32_output);
  126|    454|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_127avx2_convert_utf16_to_utf32ILNS_10endiannessE1EEENSt3__14pairIPKDsPDiEES7_mS8_:
   57|    422|                            char32_t *utf32_output) {
   58|    422|  const char16_t *end = buf + len;
   59|    422|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
   60|    422|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
   61|       |
   62|   369k|  while (end - buf >= 16) {
  ------------------
  |  Branch (62:10): [True: 369k, False: 340]
  ------------------
   63|   369k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
   64|   369k|    if (big_endian) {
  ------------------
  |  Branch (64:9): [True: 369k, Folded]
  ------------------
   65|   369k|      const __m256i swap = _mm256_setr_epi8(
   66|   369k|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   67|   369k|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   68|   369k|      in = _mm256_shuffle_epi8(in, swap);
   69|   369k|    }
   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|   369k|    const __m256i surrogates_bytemask =
   75|   369k|        _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|   369k|    const uint32_t surrogates_bitmask =
   80|   369k|        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|   369k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (83:9): [True: 367k, False: 1.46k]
  ------------------
   84|       |      // case: we extend all sixteen 16-bit code units to sixteen 32-bit code
   85|       |      // units
   86|   367k|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
   87|   367k|                          _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in)));
   88|   367k|      _mm256_storeu_si256(
   89|   367k|          reinterpret_cast<__m256i *>(utf32_output + 8),
   90|   367k|          _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1)));
   91|   367k|      utf32_output += 16;
   92|   367k|      buf += 16;
   93|       |      // surrogate pair(s) in a register
   94|   367k|    } 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|  1.46k|      size_t forward = 15;
   99|  1.46k|      size_t k = 0;
  100|  1.46k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (100:11): [True: 0, False: 1.46k]
  ------------------
  101|      0|        forward = size_t(end - buf - 1);
  102|      0|      }
  103|  20.6k|      for (; k < forward; k++) {
  ------------------
  |  Branch (103:14): [True: 19.2k, False: 1.38k]
  ------------------
  104|  19.2k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  105|  19.2k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (105:13): [True: 16.9k, False: 2.24k]
  ------------------
  106|       |          // No surrogate pair
  107|  16.9k|          *utf32_output++ = char32_t(word);
  108|  16.9k|        } else {
  109|       |          // must be a surrogate pair
  110|  2.24k|          uint16_t diff = uint16_t(word - 0xD800);
  111|  2.24k|          uint16_t next_word =
  112|  2.24k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  113|  2.24k|          k++;
  114|  2.24k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  115|  2.24k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (115:15): [True: 82, False: 2.16k]
  ------------------
  116|     82|            return std::make_pair(nullptr, utf32_output);
  117|     82|          }
  118|  2.16k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  119|  2.16k|          *utf32_output++ = char32_t(value);
  120|  2.16k|        }
  121|  19.2k|      }
  122|  1.38k|      buf += k;
  123|  1.38k|    }
  124|   369k|  } // while
  125|    340|  return std::make_pair(buf, utf32_output);
  126|    422|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_139avx2_convert_utf16_to_utf32_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPDiEEPKDsmS7_:
  138|    334|                                        char32_t *utf32_output) {
  139|    334|  const char16_t *start = buf;
  140|    334|  const char16_t *end = buf + len;
  141|    334|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
  142|    334|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
  143|       |
  144|   160k|  while (end - buf >= 16) {
  ------------------
  |  Branch (144:10): [True: 160k, False: 226]
  ------------------
  145|   160k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
  146|   160k|    if (big_endian) {
  ------------------
  |  Branch (146:9): [Folded, False: 160k]
  ------------------
  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|   160k|    const __m256i surrogates_bytemask =
  157|   160k|        _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|   160k|    const uint32_t surrogates_bitmask =
  162|   160k|        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|   160k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (165:9): [True: 154k, False: 5.22k]
  ------------------
  166|       |      // case: we extend all sixteen 16-bit code units to sixteen 32-bit code
  167|       |      // units
  168|   154k|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
  169|   154k|                          _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in)));
  170|   154k|      _mm256_storeu_si256(
  171|   154k|          reinterpret_cast<__m256i *>(utf32_output + 8),
  172|   154k|          _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1)));
  173|   154k|      utf32_output += 16;
  174|   154k|      buf += 16;
  175|       |      // surrogate pair(s) in a register
  176|   154k|    } 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.22k|      size_t forward = 15;
  181|  5.22k|      size_t k = 0;
  182|  5.22k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (182:11): [True: 0, False: 5.22k]
  ------------------
  183|      0|        forward = size_t(end - buf - 1);
  184|      0|      }
  185|  73.9k|      for (; k < forward; k++) {
  ------------------
  |  Branch (185:14): [True: 68.8k, False: 5.11k]
  ------------------
  186|  68.8k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  187|  68.8k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (187:13): [True: 59.3k, False: 9.44k]
  ------------------
  188|       |          // No surrogate pair
  189|  59.3k|          *utf32_output++ = char32_t(word);
  190|  59.3k|        } else {
  191|       |          // must be a surrogate pair
  192|  9.44k|          uint16_t diff = uint16_t(word - 0xD800);
  193|  9.44k|          uint16_t next_word =
  194|  9.44k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  195|  9.44k|          k++;
  196|  9.44k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  197|  9.44k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (197:15): [True: 108, False: 9.33k]
  ------------------
  198|    108|            return std::make_pair(
  199|    108|                result(error_code::SURROGATE, buf - start + k - 1),
  200|    108|                utf32_output);
  201|    108|          }
  202|  9.33k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  203|  9.33k|          *utf32_output++ = char32_t(value);
  204|  9.33k|        }
  205|  68.8k|      }
  206|  5.11k|      buf += k;
  207|  5.11k|    }
  208|   160k|  } // while
  209|    226|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output);
  210|    334|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_139avx2_convert_utf16_to_utf32_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPDiEEPKDsmS7_:
  138|    346|                                        char32_t *utf32_output) {
  139|    346|  const char16_t *start = buf;
  140|    346|  const char16_t *end = buf + len;
  141|    346|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
  142|    346|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
  143|       |
  144|   151k|  while (end - buf >= 16) {
  ------------------
  |  Branch (144:10): [True: 151k, False: 254]
  ------------------
  145|   151k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
  146|   151k|    if (big_endian) {
  ------------------
  |  Branch (146:9): [True: 151k, Folded]
  ------------------
  147|   151k|      const __m256i swap = _mm256_setr_epi8(
  148|   151k|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
  149|   151k|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
  150|   151k|      in = _mm256_shuffle_epi8(in, swap);
  151|   151k|    }
  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|   151k|    const __m256i surrogates_bytemask =
  157|   151k|        _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|   151k|    const uint32_t surrogates_bitmask =
  162|   151k|        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|   151k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (165:9): [True: 146k, False: 5.28k]
  ------------------
  166|       |      // case: we extend all sixteen 16-bit code units to sixteen 32-bit code
  167|       |      // units
  168|   146k|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
  169|   146k|                          _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in)));
  170|   146k|      _mm256_storeu_si256(
  171|   146k|          reinterpret_cast<__m256i *>(utf32_output + 8),
  172|   146k|          _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1)));
  173|   146k|      utf32_output += 16;
  174|   146k|      buf += 16;
  175|       |      // surrogate pair(s) in a register
  176|   146k|    } 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.28k|      size_t forward = 15;
  181|  5.28k|      size_t k = 0;
  182|  5.28k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (182:11): [True: 0, False: 5.28k]
  ------------------
  183|      0|        forward = size_t(end - buf - 1);
  184|      0|      }
  185|  74.7k|      for (; k < forward; k++) {
  ------------------
  |  Branch (185:14): [True: 69.5k, False: 5.18k]
  ------------------
  186|  69.5k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  187|  69.5k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (187:13): [True: 59.7k, False: 9.78k]
  ------------------
  188|       |          // No surrogate pair
  189|  59.7k|          *utf32_output++ = char32_t(word);
  190|  59.7k|        } else {
  191|       |          // must be a surrogate pair
  192|  9.78k|          uint16_t diff = uint16_t(word - 0xD800);
  193|  9.78k|          uint16_t next_word =
  194|  9.78k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  195|  9.78k|          k++;
  196|  9.78k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  197|  9.78k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (197:15): [True: 92, False: 9.69k]
  ------------------
  198|     92|            return std::make_pair(
  199|     92|                result(error_code::SURROGATE, buf - start + k - 1),
  200|     92|                utf32_output);
  201|     92|          }
  202|  9.69k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  203|  9.69k|          *utf32_output++ = char32_t(value);
  204|  9.69k|        }
  205|  69.5k|      }
  206|  5.18k|      buf += k;
  207|  5.18k|    }
  208|   151k|  } // while
  209|    254|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output);
  210|    346|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_126avx2_convert_utf16_to_utf8ILNS_10endiannessE0EEENSt3__14pairIPKDsPcEES7_mS8_:
   56|    842|avx2_convert_utf16_to_utf8(const char16_t *buf, size_t len, char *utf8_output) {
   57|    842|  const char16_t *end = buf + len;
   58|    842|  const __m256i v_0000 = _mm256_setzero_si256();
   59|    842|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
   60|    842|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
   61|    842|  const __m256i v_c080 = _mm256_set1_epi16((int16_t)0xc080);
   62|    842|  const size_t safety_margin =
   63|    842|      12; // to avoid overruns, see issue
   64|       |          // https://github.com/simdutf/simdutf/issues/92
   65|       |
   66|   923k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (66:10): [True: 922k, False: 724]
  ------------------
   67|   922k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
   68|   922k|    if (big_endian) {
  ------------------
  |  Branch (68:9): [Folded, False: 922k]
  ------------------
   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|   922k|    const __m256i v_ff80 = _mm256_set1_epi16((int16_t)0xff80);
   76|   922k|    if (_mm256_testz_si256(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (76:9): [True: 713k, False: 209k]
  ------------------
   77|       |      // 1. pack the bytes
   78|   713k|      const __m128i utf8_packed = _mm_packus_epi16(
   79|   713k|          _mm256_castsi256_si128(in), _mm256_extractf128_si256(in, 1));
   80|       |      // 2. store (16 bytes)
   81|   713k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   82|       |      // 3. adjust pointers
   83|   713k|      buf += 16;
   84|   713k|      utf8_output += 16;
   85|   713k|      continue; // we are done for this round!
   86|   713k|    }
   87|       |    // no bits set above 7th bit
   88|   209k|    const __m256i one_byte_bytemask =
   89|   209k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_ff80), v_0000);
   90|   209k|    const uint32_t one_byte_bitmask =
   91|   209k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_byte_bytemask));
   92|       |
   93|       |    // no bits set above 11th bit
   94|   209k|    const __m256i one_or_two_bytes_bytemask =
   95|   209k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_0000);
   96|   209k|    const uint32_t one_or_two_bytes_bitmask =
   97|   209k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_or_two_bytes_bytemask));
   98|   209k|    if (one_or_two_bytes_bitmask == 0xffffffff) {
  ------------------
  |  Branch (98:9): [True: 126k, False: 83.2k]
  ------------------
   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|   126k|      const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00);
  104|   126k|      const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f);
  105|       |
  106|       |      // t0 = [000a|aaaa|bbbb|bb00]
  107|   126k|      const __m256i t0 = _mm256_slli_epi16(in, 2);
  108|       |      // t1 = [000a|aaaa|0000|0000]
  109|   126k|      const __m256i t1 = _mm256_and_si256(t0, v_1f00);
  110|       |      // t2 = [0000|0000|00bb|bbbb]
  111|   126k|      const __m256i t2 = _mm256_and_si256(in, v_003f);
  112|       |      // t3 = [000a|aaaa|00bb|bbbb]
  113|   126k|      const __m256i t3 = _mm256_or_si256(t1, t2);
  114|       |      // t4 = [110a|aaaa|10bb|bbbb]
  115|   126k|      const __m256i t4 = _mm256_or_si256(t3, v_c080);
  116|       |
  117|       |      // 2. merge ASCII and 2-byte codewords
  118|   126k|      const __m256i utf8_unpacked =
  119|   126k|          _mm256_blendv_epi8(t4, in, one_byte_bytemask);
  120|       |
  121|       |      // 3. prepare bitmask for 8-bit lookup
  122|   126k|      const uint32_t M0 = one_byte_bitmask & 0x55555555;
  123|   126k|      const uint32_t M1 = M0 >> 7;
  124|   126k|      const uint32_t M2 = (M1 | M0) & 0x00ff00ff;
  125|       |      // 4. pack the bytes
  126|       |
  127|   126k|      const uint8_t *row =
  128|   126k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0];
  129|   126k|      const uint8_t *row_2 =
  130|   126k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2 >>
  131|   126k|                                                                       16)][0];
  132|       |
  133|   126k|      const __m128i shuffle = _mm_loadu_si128((__m128i *)(row + 1));
  134|   126k|      const __m128i shuffle_2 = _mm_loadu_si128((__m128i *)(row_2 + 1));
  135|       |
  136|   126k|      const __m256i utf8_packed = _mm256_shuffle_epi8(
  137|   126k|          utf8_unpacked, _mm256_setr_m128i(shuffle, shuffle_2));
  ------------------
  |  |    7|   126k|      _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1),                  \
  |  |    8|   126k|                                _mm256_castsi128_si256(xmm2), 2)
  ------------------
  138|       |      // 5. store bytes
  139|   126k|      _mm_storeu_si128((__m128i *)utf8_output,
  140|   126k|                       _mm256_castsi256_si128(utf8_packed));
  141|   126k|      utf8_output += row[0];
  142|   126k|      _mm_storeu_si128((__m128i *)utf8_output,
  143|   126k|                       _mm256_extractf128_si256(utf8_packed, 1));
  144|   126k|      utf8_output += row_2[0];
  145|       |
  146|       |      // 6. adjust pointers
  147|   126k|      buf += 16;
  148|   126k|      continue;
  149|   126k|    }
  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|  83.2k|    const __m256i surrogates_bytemask =
  154|  83.2k|        _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|  83.2k|    const uint32_t surrogates_bitmask =
  159|  83.2k|        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|  83.2k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (162:9): [True: 76.0k, False: 7.18k]
  ------------------
  163|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  164|  76.0k|      const __m256i dup_even = _mm256_setr_epi16(
  165|  76.0k|          0x0000, 0x0202, 0x0404, 0x0606, 0x0808, 0x0a0a, 0x0c0c, 0x0e0e,
  166|  76.0k|          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|  76.0k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  196|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  197|  76.0k|      const __m256i t0 = _mm256_shuffle_epi8(in, dup_even);
  198|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  199|  76.0k|      const __m256i t1 = _mm256_and_si256(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  195|  76.0k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  200|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  201|  76.0k|      const __m256i t2 = _mm256_or_si256(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  195|  76.0k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  202|       |
  203|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  204|  76.0k|      const __m256i s0 = _mm256_srli_epi16(in, 4);
  205|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  206|  76.0k|      const __m256i s1 = _mm256_and_si256(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  195|  76.0k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  207|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  208|  76.0k|      const __m256i s2 = _mm256_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  195|  76.0k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  209|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  210|  76.0k|      const __m256i s3 = _mm256_or_si256(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  195|  76.0k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  211|  76.0k|      const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask,
  212|  76.0k|                                             simdutf_vec(0b0100000000000000));
  ------------------
  |  |  195|  76.0k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  213|  76.0k|      const __m256i s4 = _mm256_xor_si256(s3, m0);
  214|  76.0k|#undef simdutf_vec
  215|       |
  216|       |      // 4. expand code units 16-bit => 32-bit
  217|  76.0k|      const __m256i out0 = _mm256_unpacklo_epi16(t2, s4);
  218|  76.0k|      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|  76.0k|      const uint32_t mask = (one_byte_bitmask & 0x55555555) |
  222|  76.0k|                            (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|  76.0k|      const uint8_t mask0 = uint8_t(mask);
  243|  76.0k|      const uint8_t *row0 =
  244|  76.0k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  245|  76.0k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  246|  76.0k|      const __m128i utf8_0 =
  247|  76.0k|          _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0);
  248|       |
  249|  76.0k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  250|  76.0k|      const uint8_t *row1 =
  251|  76.0k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  252|  76.0k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  253|  76.0k|      const __m128i utf8_1 =
  254|  76.0k|          _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1);
  255|       |
  256|  76.0k|      const uint8_t mask2 = static_cast<uint8_t>(mask >> 16);
  257|  76.0k|      const uint8_t *row2 =
  258|  76.0k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0];
  259|  76.0k|      const __m128i shuffle2 = _mm_loadu_si128((__m128i *)(row2 + 1));
  260|  76.0k|      const __m128i utf8_2 =
  261|  76.0k|          _mm_shuffle_epi8(_mm256_extractf128_si256(out0, 1), shuffle2);
  262|       |
  263|  76.0k|      const uint8_t mask3 = static_cast<uint8_t>(mask >> 24);
  264|  76.0k|      const uint8_t *row3 =
  265|  76.0k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0];
  266|  76.0k|      const __m128i shuffle3 = _mm_loadu_si128((__m128i *)(row3 + 1));
  267|  76.0k|      const __m128i utf8_3 =
  268|  76.0k|          _mm_shuffle_epi8(_mm256_extractf128_si256(out1, 1), shuffle3);
  269|       |
  270|  76.0k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  271|  76.0k|      utf8_output += row0[0];
  272|  76.0k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  273|  76.0k|      utf8_output += row1[0];
  274|  76.0k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_2);
  275|  76.0k|      utf8_output += row2[0];
  276|  76.0k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_3);
  277|  76.0k|      utf8_output += row3[0];
  278|  76.0k|      buf += 16;
  279|       |      // surrogate pair(s) in a register
  280|  76.0k|    } 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|  7.18k|      size_t forward = 15;
  285|  7.18k|      size_t k = 0;
  286|  7.18k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (286:11): [True: 0, False: 7.18k]
  ------------------
  287|      0|        forward = size_t(end - buf - 1);
  288|      0|      }
  289|   106k|      for (; k < forward; k++) {
  ------------------
  |  Branch (289:14): [True: 99.1k, False: 7.06k]
  ------------------
  290|  99.1k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  291|  99.1k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (291:13): [True: 14.5k, False: 84.5k]
  ------------------
  292|  14.5k|          *utf8_output++ = char(word);
  293|  84.5k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (293:20): [True: 4.35k, False: 80.2k]
  ------------------
  294|  4.35k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  295|  4.35k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  296|  80.2k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (296:20): [True: 72.2k, False: 7.94k]
  ------------------
  297|  72.2k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  298|  72.2k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  299|  72.2k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  300|  72.2k|        } else {
  301|       |          // must be a surrogate pair
  302|  7.94k|          uint16_t diff = uint16_t(word - 0xD800);
  303|  7.94k|          uint16_t next_word =
  304|  7.94k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  305|  7.94k|          k++;
  306|  7.94k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  307|  7.94k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (307:15): [True: 118, False: 7.82k]
  ------------------
  308|    118|            return std::make_pair(nullptr, utf8_output);
  309|    118|          }
  310|  7.82k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  311|  7.82k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  312|  7.82k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  313|  7.82k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  314|  7.82k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  315|  7.82k|        }
  316|  99.1k|      }
  317|  7.06k|      buf += k;
  318|  7.06k|    }
  319|  83.2k|  } // while
  320|    724|  return std::make_pair(buf, utf8_output);
  321|    842|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_126avx2_convert_utf16_to_utf8ILNS_10endiannessE1EEENSt3__14pairIPKDsPcEES7_mS8_:
   56|    798|avx2_convert_utf16_to_utf8(const char16_t *buf, size_t len, char *utf8_output) {
   57|    798|  const char16_t *end = buf + len;
   58|    798|  const __m256i v_0000 = _mm256_setzero_si256();
   59|    798|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
   60|    798|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
   61|    798|  const __m256i v_c080 = _mm256_set1_epi16((int16_t)0xc080);
   62|    798|  const size_t safety_margin =
   63|    798|      12; // to avoid overruns, see issue
   64|       |          // https://github.com/simdutf/simdutf/issues/92
   65|       |
   66|   957k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (66:10): [True: 956k, False: 692]
  ------------------
   67|   956k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
   68|   956k|    if (big_endian) {
  ------------------
  |  Branch (68:9): [True: 956k, Folded]
  ------------------
   69|   956k|      const __m256i swap = _mm256_setr_epi8(
   70|   956k|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   71|   956k|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   72|   956k|      in = _mm256_shuffle_epi8(in, swap);
   73|   956k|    }
   74|       |    // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes
   75|   956k|    const __m256i v_ff80 = _mm256_set1_epi16((int16_t)0xff80);
   76|   956k|    if (_mm256_testz_si256(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (76:9): [True: 702k, False: 253k]
  ------------------
   77|       |      // 1. pack the bytes
   78|   702k|      const __m128i utf8_packed = _mm_packus_epi16(
   79|   702k|          _mm256_castsi256_si128(in), _mm256_extractf128_si256(in, 1));
   80|       |      // 2. store (16 bytes)
   81|   702k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   82|       |      // 3. adjust pointers
   83|   702k|      buf += 16;
   84|   702k|      utf8_output += 16;
   85|   702k|      continue; // we are done for this round!
   86|   702k|    }
   87|       |    // no bits set above 7th bit
   88|   253k|    const __m256i one_byte_bytemask =
   89|   253k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_ff80), v_0000);
   90|   253k|    const uint32_t one_byte_bitmask =
   91|   253k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_byte_bytemask));
   92|       |
   93|       |    // no bits set above 11th bit
   94|   253k|    const __m256i one_or_two_bytes_bytemask =
   95|   253k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_0000);
   96|   253k|    const uint32_t one_or_two_bytes_bitmask =
   97|   253k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_or_two_bytes_bytemask));
   98|   253k|    if (one_or_two_bytes_bitmask == 0xffffffff) {
  ------------------
  |  Branch (98:9): [True: 13.2k, False: 240k]
  ------------------
   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|  13.2k|      const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00);
  104|  13.2k|      const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f);
  105|       |
  106|       |      // t0 = [000a|aaaa|bbbb|bb00]
  107|  13.2k|      const __m256i t0 = _mm256_slli_epi16(in, 2);
  108|       |      // t1 = [000a|aaaa|0000|0000]
  109|  13.2k|      const __m256i t1 = _mm256_and_si256(t0, v_1f00);
  110|       |      // t2 = [0000|0000|00bb|bbbb]
  111|  13.2k|      const __m256i t2 = _mm256_and_si256(in, v_003f);
  112|       |      // t3 = [000a|aaaa|00bb|bbbb]
  113|  13.2k|      const __m256i t3 = _mm256_or_si256(t1, t2);
  114|       |      // t4 = [110a|aaaa|10bb|bbbb]
  115|  13.2k|      const __m256i t4 = _mm256_or_si256(t3, v_c080);
  116|       |
  117|       |      // 2. merge ASCII and 2-byte codewords
  118|  13.2k|      const __m256i utf8_unpacked =
  119|  13.2k|          _mm256_blendv_epi8(t4, in, one_byte_bytemask);
  120|       |
  121|       |      // 3. prepare bitmask for 8-bit lookup
  122|  13.2k|      const uint32_t M0 = one_byte_bitmask & 0x55555555;
  123|  13.2k|      const uint32_t M1 = M0 >> 7;
  124|  13.2k|      const uint32_t M2 = (M1 | M0) & 0x00ff00ff;
  125|       |      // 4. pack the bytes
  126|       |
  127|  13.2k|      const uint8_t *row =
  128|  13.2k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0];
  129|  13.2k|      const uint8_t *row_2 =
  130|  13.2k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2 >>
  131|  13.2k|                                                                       16)][0];
  132|       |
  133|  13.2k|      const __m128i shuffle = _mm_loadu_si128((__m128i *)(row + 1));
  134|  13.2k|      const __m128i shuffle_2 = _mm_loadu_si128((__m128i *)(row_2 + 1));
  135|       |
  136|  13.2k|      const __m256i utf8_packed = _mm256_shuffle_epi8(
  137|  13.2k|          utf8_unpacked, _mm256_setr_m128i(shuffle, shuffle_2));
  ------------------
  |  |    7|  13.2k|      _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1),                  \
  |  |    8|  13.2k|                                _mm256_castsi128_si256(xmm2), 2)
  ------------------
  138|       |      // 5. store bytes
  139|  13.2k|      _mm_storeu_si128((__m128i *)utf8_output,
  140|  13.2k|                       _mm256_castsi256_si128(utf8_packed));
  141|  13.2k|      utf8_output += row[0];
  142|  13.2k|      _mm_storeu_si128((__m128i *)utf8_output,
  143|  13.2k|                       _mm256_extractf128_si256(utf8_packed, 1));
  144|  13.2k|      utf8_output += row_2[0];
  145|       |
  146|       |      // 6. adjust pointers
  147|  13.2k|      buf += 16;
  148|  13.2k|      continue;
  149|  13.2k|    }
  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|   240k|    const __m256i surrogates_bytemask =
  154|   240k|        _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|   240k|    const uint32_t surrogates_bitmask =
  159|   240k|        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|   240k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (162:9): [True: 236k, False: 4.17k]
  ------------------
  163|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  164|   236k|      const __m256i dup_even = _mm256_setr_epi16(
  165|   236k|          0x0000, 0x0202, 0x0404, 0x0606, 0x0808, 0x0a0a, 0x0c0c, 0x0e0e,
  166|   236k|          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|   236k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  196|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  197|   236k|      const __m256i t0 = _mm256_shuffle_epi8(in, dup_even);
  198|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  199|   236k|      const __m256i t1 = _mm256_and_si256(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  195|   236k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  200|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  201|   236k|      const __m256i t2 = _mm256_or_si256(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  195|   236k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  202|       |
  203|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  204|   236k|      const __m256i s0 = _mm256_srli_epi16(in, 4);
  205|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  206|   236k|      const __m256i s1 = _mm256_and_si256(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  195|   236k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  207|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  208|   236k|      const __m256i s2 = _mm256_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  195|   236k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  209|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  210|   236k|      const __m256i s3 = _mm256_or_si256(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  195|   236k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  211|   236k|      const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask,
  212|   236k|                                             simdutf_vec(0b0100000000000000));
  ------------------
  |  |  195|   236k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  213|   236k|      const __m256i s4 = _mm256_xor_si256(s3, m0);
  214|   236k|#undef simdutf_vec
  215|       |
  216|       |      // 4. expand code units 16-bit => 32-bit
  217|   236k|      const __m256i out0 = _mm256_unpacklo_epi16(t2, s4);
  218|   236k|      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|   236k|      const uint32_t mask = (one_byte_bitmask & 0x55555555) |
  222|   236k|                            (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|   236k|      const uint8_t mask0 = uint8_t(mask);
  243|   236k|      const uint8_t *row0 =
  244|   236k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  245|   236k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  246|   236k|      const __m128i utf8_0 =
  247|   236k|          _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0);
  248|       |
  249|   236k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  250|   236k|      const uint8_t *row1 =
  251|   236k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  252|   236k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  253|   236k|      const __m128i utf8_1 =
  254|   236k|          _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1);
  255|       |
  256|   236k|      const uint8_t mask2 = static_cast<uint8_t>(mask >> 16);
  257|   236k|      const uint8_t *row2 =
  258|   236k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0];
  259|   236k|      const __m128i shuffle2 = _mm_loadu_si128((__m128i *)(row2 + 1));
  260|   236k|      const __m128i utf8_2 =
  261|   236k|          _mm_shuffle_epi8(_mm256_extractf128_si256(out0, 1), shuffle2);
  262|       |
  263|   236k|      const uint8_t mask3 = static_cast<uint8_t>(mask >> 24);
  264|   236k|      const uint8_t *row3 =
  265|   236k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0];
  266|   236k|      const __m128i shuffle3 = _mm_loadu_si128((__m128i *)(row3 + 1));
  267|   236k|      const __m128i utf8_3 =
  268|   236k|          _mm_shuffle_epi8(_mm256_extractf128_si256(out1, 1), shuffle3);
  269|       |
  270|   236k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  271|   236k|      utf8_output += row0[0];
  272|   236k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  273|   236k|      utf8_output += row1[0];
  274|   236k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_2);
  275|   236k|      utf8_output += row2[0];
  276|   236k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_3);
  277|   236k|      utf8_output += row3[0];
  278|   236k|      buf += 16;
  279|       |      // surrogate pair(s) in a register
  280|   236k|    } 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|  4.17k|      size_t forward = 15;
  285|  4.17k|      size_t k = 0;
  286|  4.17k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (286:11): [True: 0, False: 4.17k]
  ------------------
  287|      0|        forward = size_t(end - buf - 1);
  288|      0|      }
  289|  61.0k|      for (; k < forward; k++) {
  ------------------
  |  Branch (289:14): [True: 56.9k, False: 4.07k]
  ------------------
  290|  56.9k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  291|  56.9k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (291:13): [True: 8.41k, False: 48.5k]
  ------------------
  292|  8.41k|          *utf8_output++ = char(word);
  293|  48.5k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (293:20): [True: 2.49k, False: 46.0k]
  ------------------
  294|  2.49k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  295|  2.49k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  296|  46.0k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (296:20): [True: 41.0k, False: 4.95k]
  ------------------
  297|  41.0k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  298|  41.0k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  299|  41.0k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  300|  41.0k|        } else {
  301|       |          // must be a surrogate pair
  302|  4.95k|          uint16_t diff = uint16_t(word - 0xD800);
  303|  4.95k|          uint16_t next_word =
  304|  4.95k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  305|  4.95k|          k++;
  306|  4.95k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  307|  4.95k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (307:15): [True: 106, False: 4.85k]
  ------------------
  308|    106|            return std::make_pair(nullptr, utf8_output);
  309|    106|          }
  310|  4.85k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  311|  4.85k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  312|  4.85k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  313|  4.85k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  314|  4.85k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  315|  4.85k|        }
  316|  56.9k|      }
  317|  4.07k|      buf += k;
  318|  4.07k|    }
  319|   240k|  } // while
  320|    692|  return std::make_pair(buf, utf8_output);
  321|    798|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_138avx2_convert_utf16_to_utf8_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
  333|    642|                                       char *utf8_output) {
  334|    642|  const char16_t *start = buf;
  335|    642|  const char16_t *end = buf + len;
  336|       |
  337|    642|  const __m256i v_0000 = _mm256_setzero_si256();
  338|    642|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
  339|    642|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
  340|    642|  const __m256i v_c080 = _mm256_set1_epi16((int16_t)0xc080);
  341|    642|  const size_t safety_margin =
  342|    642|      12; // to avoid overruns, see issue
  343|       |          // https://github.com/simdutf/simdutf/issues/92
  344|       |
  345|   646k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (345:10): [True: 646k, False: 484]
  ------------------
  346|   646k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
  347|   646k|    if (big_endian) {
  ------------------
  |  Branch (347:9): [Folded, False: 646k]
  ------------------
  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|   646k|    const __m256i v_ff80 = _mm256_set1_epi16((int16_t)0xff80);
  355|   646k|    if (_mm256_testz_si256(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (355:9): [True: 308k, False: 337k]
  ------------------
  356|       |      // 1. pack the bytes
  357|   308k|      const __m128i utf8_packed = _mm_packus_epi16(
  358|   308k|          _mm256_castsi256_si128(in), _mm256_extractf128_si256(in, 1));
  359|       |      // 2. store (16 bytes)
  360|   308k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  361|       |      // 3. adjust pointers
  362|   308k|      buf += 16;
  363|   308k|      utf8_output += 16;
  364|   308k|      continue; // we are done for this round!
  365|   308k|    }
  366|       |    // no bits set above 7th bit
  367|   337k|    const __m256i one_byte_bytemask =
  368|   337k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_ff80), v_0000);
  369|   337k|    const uint32_t one_byte_bitmask =
  370|   337k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_byte_bytemask));
  371|       |
  372|       |    // no bits set above 11th bit
  373|   337k|    const __m256i one_or_two_bytes_bytemask =
  374|   337k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_0000);
  375|   337k|    const uint32_t one_or_two_bytes_bitmask =
  376|   337k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_or_two_bytes_bytemask));
  377|   337k|    if (one_or_two_bytes_bitmask == 0xffffffff) {
  ------------------
  |  Branch (377:9): [True: 62.4k, False: 275k]
  ------------------
  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|  62.4k|      const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00);
  383|  62.4k|      const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f);
  384|       |
  385|       |      // t0 = [000a|aaaa|bbbb|bb00]
  386|  62.4k|      const __m256i t0 = _mm256_slli_epi16(in, 2);
  387|       |      // t1 = [000a|aaaa|0000|0000]
  388|  62.4k|      const __m256i t1 = _mm256_and_si256(t0, v_1f00);
  389|       |      // t2 = [0000|0000|00bb|bbbb]
  390|  62.4k|      const __m256i t2 = _mm256_and_si256(in, v_003f);
  391|       |      // t3 = [000a|aaaa|00bb|bbbb]
  392|  62.4k|      const __m256i t3 = _mm256_or_si256(t1, t2);
  393|       |      // t4 = [110a|aaaa|10bb|bbbb]
  394|  62.4k|      const __m256i t4 = _mm256_or_si256(t3, v_c080);
  395|       |
  396|       |      // 2. merge ASCII and 2-byte codewords
  397|  62.4k|      const __m256i utf8_unpacked =
  398|  62.4k|          _mm256_blendv_epi8(t4, in, one_byte_bytemask);
  399|       |
  400|       |      // 3. prepare bitmask for 8-bit lookup
  401|  62.4k|      const uint32_t M0 = one_byte_bitmask & 0x55555555;
  402|  62.4k|      const uint32_t M1 = M0 >> 7;
  403|  62.4k|      const uint32_t M2 = (M1 | M0) & 0x00ff00ff;
  404|       |      // 4. pack the bytes
  405|       |
  406|  62.4k|      const uint8_t *row =
  407|  62.4k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0];
  408|  62.4k|      const uint8_t *row_2 =
  409|  62.4k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2 >>
  410|  62.4k|                                                                       16)][0];
  411|       |
  412|  62.4k|      const __m128i shuffle = _mm_loadu_si128((__m128i *)(row + 1));
  413|  62.4k|      const __m128i shuffle_2 = _mm_loadu_si128((__m128i *)(row_2 + 1));
  414|       |
  415|  62.4k|      const __m256i utf8_packed = _mm256_shuffle_epi8(
  416|  62.4k|          utf8_unpacked, _mm256_setr_m128i(shuffle, shuffle_2));
  ------------------
  |  |    7|  62.4k|      _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1),                  \
  |  |    8|  62.4k|                                _mm256_castsi128_si256(xmm2), 2)
  ------------------
  417|       |      // 5. store bytes
  418|  62.4k|      _mm_storeu_si128((__m128i *)utf8_output,
  419|  62.4k|                       _mm256_castsi256_si128(utf8_packed));
  420|  62.4k|      utf8_output += row[0];
  421|  62.4k|      _mm_storeu_si128((__m128i *)utf8_output,
  422|  62.4k|                       _mm256_extractf128_si256(utf8_packed, 1));
  423|  62.4k|      utf8_output += row_2[0];
  424|       |
  425|       |      // 6. adjust pointers
  426|  62.4k|      buf += 16;
  427|  62.4k|      continue;
  428|  62.4k|    }
  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|   275k|    const __m256i surrogates_bytemask =
  433|   275k|        _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|   275k|    const uint32_t surrogates_bitmask =
  438|   275k|        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|   275k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (441:9): [True: 272k, False: 2.72k]
  ------------------
  442|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  443|   272k|      const __m256i dup_even = _mm256_setr_epi16(
  444|   272k|          0x0000, 0x0202, 0x0404, 0x0606, 0x0808, 0x0a0a, 0x0c0c, 0x0e0e,
  445|   272k|          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|   272k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  475|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  476|   272k|      const __m256i t0 = _mm256_shuffle_epi8(in, dup_even);
  477|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  478|   272k|      const __m256i t1 = _mm256_and_si256(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  474|   272k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  479|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  480|   272k|      const __m256i t2 = _mm256_or_si256(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  474|   272k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  481|       |
  482|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  483|   272k|      const __m256i s0 = _mm256_srli_epi16(in, 4);
  484|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  485|   272k|      const __m256i s1 = _mm256_and_si256(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  474|   272k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  486|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  487|   272k|      const __m256i s2 = _mm256_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  474|   272k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  488|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  489|   272k|      const __m256i s3 = _mm256_or_si256(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  474|   272k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  490|   272k|      const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask,
  491|   272k|                                             simdutf_vec(0b0100000000000000));
  ------------------
  |  |  474|   272k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  492|   272k|      const __m256i s4 = _mm256_xor_si256(s3, m0);
  493|   272k|#undef simdutf_vec
  494|       |
  495|       |      // 4. expand code units 16-bit => 32-bit
  496|   272k|      const __m256i out0 = _mm256_unpacklo_epi16(t2, s4);
  497|   272k|      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|   272k|      const uint32_t mask = (one_byte_bitmask & 0x55555555) |
  501|   272k|                            (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|   272k|      const uint8_t mask0 = uint8_t(mask);
  522|   272k|      const uint8_t *row0 =
  523|   272k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  524|   272k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  525|   272k|      const __m128i utf8_0 =
  526|   272k|          _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0);
  527|       |
  528|   272k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  529|   272k|      const uint8_t *row1 =
  530|   272k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  531|   272k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  532|   272k|      const __m128i utf8_1 =
  533|   272k|          _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1);
  534|       |
  535|   272k|      const uint8_t mask2 = static_cast<uint8_t>(mask >> 16);
  536|   272k|      const uint8_t *row2 =
  537|   272k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0];
  538|   272k|      const __m128i shuffle2 = _mm_loadu_si128((__m128i *)(row2 + 1));
  539|   272k|      const __m128i utf8_2 =
  540|   272k|          _mm_shuffle_epi8(_mm256_extractf128_si256(out0, 1), shuffle2);
  541|       |
  542|   272k|      const uint8_t mask3 = static_cast<uint8_t>(mask >> 24);
  543|   272k|      const uint8_t *row3 =
  544|   272k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0];
  545|   272k|      const __m128i shuffle3 = _mm_loadu_si128((__m128i *)(row3 + 1));
  546|   272k|      const __m128i utf8_3 =
  547|   272k|          _mm_shuffle_epi8(_mm256_extractf128_si256(out1, 1), shuffle3);
  548|       |
  549|   272k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  550|   272k|      utf8_output += row0[0];
  551|   272k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  552|   272k|      utf8_output += row1[0];
  553|   272k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_2);
  554|   272k|      utf8_output += row2[0];
  555|   272k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_3);
  556|   272k|      utf8_output += row3[0];
  557|   272k|      buf += 16;
  558|       |      // surrogate pair(s) in a register
  559|   272k|    } 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.72k|      size_t forward = 15;
  564|  2.72k|      size_t k = 0;
  565|  2.72k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (565:11): [True: 0, False: 2.72k]
  ------------------
  566|      0|        forward = size_t(end - buf - 1);
  567|      0|      }
  568|  39.2k|      for (; k < forward; k++) {
  ------------------
  |  Branch (568:14): [True: 36.6k, False: 2.56k]
  ------------------
  569|  36.6k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  570|  36.6k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (570:13): [True: 6.43k, False: 30.2k]
  ------------------
  571|  6.43k|          *utf8_output++ = char(word);
  572|  30.2k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (572:20): [True: 1.80k, False: 28.4k]
  ------------------
  573|  1.80k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  574|  1.80k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  575|  28.4k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (575:20): [True: 25.3k, False: 3.06k]
  ------------------
  576|  25.3k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  577|  25.3k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  578|  25.3k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  579|  25.3k|        } else {
  580|       |          // must be a surrogate pair
  581|  3.06k|          uint16_t diff = uint16_t(word - 0xD800);
  582|  3.06k|          uint16_t next_word =
  583|  3.06k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  584|  3.06k|          k++;
  585|  3.06k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  586|  3.06k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (586:15): [True: 158, False: 2.90k]
  ------------------
  587|    158|            return std::make_pair(
  588|    158|                result(error_code::SURROGATE, buf - start + k - 1),
  589|    158|                utf8_output);
  590|    158|          }
  591|  2.90k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  592|  2.90k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  593|  2.90k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  594|  2.90k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  595|  2.90k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  596|  2.90k|        }
  597|  36.6k|      }
  598|  2.56k|      buf += k;
  599|  2.56k|    }
  600|   275k|  } // while
  601|    484|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output);
  602|    642|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_138avx2_convert_utf16_to_utf8_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
  333|    654|                                       char *utf8_output) {
  334|    654|  const char16_t *start = buf;
  335|    654|  const char16_t *end = buf + len;
  336|       |
  337|    654|  const __m256i v_0000 = _mm256_setzero_si256();
  338|    654|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
  339|    654|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
  340|    654|  const __m256i v_c080 = _mm256_set1_epi16((int16_t)0xc080);
  341|    654|  const size_t safety_margin =
  342|    654|      12; // to avoid overruns, see issue
  343|       |          // https://github.com/simdutf/simdutf/issues/92
  344|       |
  345|   487k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (345:10): [True: 486k, False: 474]
  ------------------
  346|   486k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
  347|   486k|    if (big_endian) {
  ------------------
  |  Branch (347:9): [True: 486k, Folded]
  ------------------
  348|   486k|      const __m256i swap = _mm256_setr_epi8(
  349|   486k|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
  350|   486k|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
  351|   486k|      in = _mm256_shuffle_epi8(in, swap);
  352|   486k|    }
  353|       |    // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes
  354|   486k|    const __m256i v_ff80 = _mm256_set1_epi16((int16_t)0xff80);
  355|   486k|    if (_mm256_testz_si256(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (355:9): [True: 368k, False: 117k]
  ------------------
  356|       |      // 1. pack the bytes
  357|   368k|      const __m128i utf8_packed = _mm_packus_epi16(
  358|   368k|          _mm256_castsi256_si128(in), _mm256_extractf128_si256(in, 1));
  359|       |      // 2. store (16 bytes)
  360|   368k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  361|       |      // 3. adjust pointers
  362|   368k|      buf += 16;
  363|   368k|      utf8_output += 16;
  364|   368k|      continue; // we are done for this round!
  365|   368k|    }
  366|       |    // no bits set above 7th bit
  367|   117k|    const __m256i one_byte_bytemask =
  368|   117k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_ff80), v_0000);
  369|   117k|    const uint32_t one_byte_bitmask =
  370|   117k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_byte_bytemask));
  371|       |
  372|       |    // no bits set above 11th bit
  373|   117k|    const __m256i one_or_two_bytes_bytemask =
  374|   117k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_0000);
  375|   117k|    const uint32_t one_or_two_bytes_bitmask =
  376|   117k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_or_two_bytes_bytemask));
  377|   117k|    if (one_or_two_bytes_bitmask == 0xffffffff) {
  ------------------
  |  Branch (377:9): [True: 25.8k, False: 92.0k]
  ------------------
  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|  25.8k|      const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00);
  383|  25.8k|      const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f);
  384|       |
  385|       |      // t0 = [000a|aaaa|bbbb|bb00]
  386|  25.8k|      const __m256i t0 = _mm256_slli_epi16(in, 2);
  387|       |      // t1 = [000a|aaaa|0000|0000]
  388|  25.8k|      const __m256i t1 = _mm256_and_si256(t0, v_1f00);
  389|       |      // t2 = [0000|0000|00bb|bbbb]
  390|  25.8k|      const __m256i t2 = _mm256_and_si256(in, v_003f);
  391|       |      // t3 = [000a|aaaa|00bb|bbbb]
  392|  25.8k|      const __m256i t3 = _mm256_or_si256(t1, t2);
  393|       |      // t4 = [110a|aaaa|10bb|bbbb]
  394|  25.8k|      const __m256i t4 = _mm256_or_si256(t3, v_c080);
  395|       |
  396|       |      // 2. merge ASCII and 2-byte codewords
  397|  25.8k|      const __m256i utf8_unpacked =
  398|  25.8k|          _mm256_blendv_epi8(t4, in, one_byte_bytemask);
  399|       |
  400|       |      // 3. prepare bitmask for 8-bit lookup
  401|  25.8k|      const uint32_t M0 = one_byte_bitmask & 0x55555555;
  402|  25.8k|      const uint32_t M1 = M0 >> 7;
  403|  25.8k|      const uint32_t M2 = (M1 | M0) & 0x00ff00ff;
  404|       |      // 4. pack the bytes
  405|       |
  406|  25.8k|      const uint8_t *row =
  407|  25.8k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0];
  408|  25.8k|      const uint8_t *row_2 =
  409|  25.8k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2 >>
  410|  25.8k|                                                                       16)][0];
  411|       |
  412|  25.8k|      const __m128i shuffle = _mm_loadu_si128((__m128i *)(row + 1));
  413|  25.8k|      const __m128i shuffle_2 = _mm_loadu_si128((__m128i *)(row_2 + 1));
  414|       |
  415|  25.8k|      const __m256i utf8_packed = _mm256_shuffle_epi8(
  416|  25.8k|          utf8_unpacked, _mm256_setr_m128i(shuffle, shuffle_2));
  ------------------
  |  |    7|  25.8k|      _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1),                  \
  |  |    8|  25.8k|                                _mm256_castsi128_si256(xmm2), 2)
  ------------------
  417|       |      // 5. store bytes
  418|  25.8k|      _mm_storeu_si128((__m128i *)utf8_output,
  419|  25.8k|                       _mm256_castsi256_si128(utf8_packed));
  420|  25.8k|      utf8_output += row[0];
  421|  25.8k|      _mm_storeu_si128((__m128i *)utf8_output,
  422|  25.8k|                       _mm256_extractf128_si256(utf8_packed, 1));
  423|  25.8k|      utf8_output += row_2[0];
  424|       |
  425|       |      // 6. adjust pointers
  426|  25.8k|      buf += 16;
  427|  25.8k|      continue;
  428|  25.8k|    }
  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|  92.0k|    const __m256i surrogates_bytemask =
  433|  92.0k|        _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|  92.0k|    const uint32_t surrogates_bitmask =
  438|  92.0k|        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|  92.0k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (441:9): [True: 84.2k, False: 7.81k]
  ------------------
  442|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  443|  84.2k|      const __m256i dup_even = _mm256_setr_epi16(
  444|  84.2k|          0x0000, 0x0202, 0x0404, 0x0606, 0x0808, 0x0a0a, 0x0c0c, 0x0e0e,
  445|  84.2k|          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|  84.2k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  475|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  476|  84.2k|      const __m256i t0 = _mm256_shuffle_epi8(in, dup_even);
  477|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  478|  84.2k|      const __m256i t1 = _mm256_and_si256(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  474|  84.2k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  479|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  480|  84.2k|      const __m256i t2 = _mm256_or_si256(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  474|  84.2k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  481|       |
  482|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  483|  84.2k|      const __m256i s0 = _mm256_srli_epi16(in, 4);
  484|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  485|  84.2k|      const __m256i s1 = _mm256_and_si256(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  474|  84.2k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  486|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  487|  84.2k|      const __m256i s2 = _mm256_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  474|  84.2k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  488|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  489|  84.2k|      const __m256i s3 = _mm256_or_si256(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  474|  84.2k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  490|  84.2k|      const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask,
  491|  84.2k|                                             simdutf_vec(0b0100000000000000));
  ------------------
  |  |  474|  84.2k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  492|  84.2k|      const __m256i s4 = _mm256_xor_si256(s3, m0);
  493|  84.2k|#undef simdutf_vec
  494|       |
  495|       |      // 4. expand code units 16-bit => 32-bit
  496|  84.2k|      const __m256i out0 = _mm256_unpacklo_epi16(t2, s4);
  497|  84.2k|      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|  84.2k|      const uint32_t mask = (one_byte_bitmask & 0x55555555) |
  501|  84.2k|                            (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|  84.2k|      const uint8_t mask0 = uint8_t(mask);
  522|  84.2k|      const uint8_t *row0 =
  523|  84.2k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  524|  84.2k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  525|  84.2k|      const __m128i utf8_0 =
  526|  84.2k|          _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0);
  527|       |
  528|  84.2k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  529|  84.2k|      const uint8_t *row1 =
  530|  84.2k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  531|  84.2k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  532|  84.2k|      const __m128i utf8_1 =
  533|  84.2k|          _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1);
  534|       |
  535|  84.2k|      const uint8_t mask2 = static_cast<uint8_t>(mask >> 16);
  536|  84.2k|      const uint8_t *row2 =
  537|  84.2k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0];
  538|  84.2k|      const __m128i shuffle2 = _mm_loadu_si128((__m128i *)(row2 + 1));
  539|  84.2k|      const __m128i utf8_2 =
  540|  84.2k|          _mm_shuffle_epi8(_mm256_extractf128_si256(out0, 1), shuffle2);
  541|       |
  542|  84.2k|      const uint8_t mask3 = static_cast<uint8_t>(mask >> 24);
  543|  84.2k|      const uint8_t *row3 =
  544|  84.2k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0];
  545|  84.2k|      const __m128i shuffle3 = _mm_loadu_si128((__m128i *)(row3 + 1));
  546|  84.2k|      const __m128i utf8_3 =
  547|  84.2k|          _mm_shuffle_epi8(_mm256_extractf128_si256(out1, 1), shuffle3);
  548|       |
  549|  84.2k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  550|  84.2k|      utf8_output += row0[0];
  551|  84.2k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  552|  84.2k|      utf8_output += row1[0];
  553|  84.2k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_2);
  554|  84.2k|      utf8_output += row2[0];
  555|  84.2k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_3);
  556|  84.2k|      utf8_output += row3[0];
  557|  84.2k|      buf += 16;
  558|       |      // surrogate pair(s) in a register
  559|  84.2k|    } 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|  7.81k|      size_t forward = 15;
  564|  7.81k|      size_t k = 0;
  565|  7.81k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (565:11): [True: 0, False: 7.81k]
  ------------------
  566|      0|        forward = size_t(end - buf - 1);
  567|      0|      }
  568|   115k|      for (; k < forward; k++) {
  ------------------
  |  Branch (568:14): [True: 107k, False: 7.63k]
  ------------------
  569|   107k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  570|   107k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (570:13): [True: 36.5k, False: 70.8k]
  ------------------
  571|  36.5k|          *utf8_output++ = char(word);
  572|  70.8k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (572:20): [True: 5.30k, False: 65.5k]
  ------------------
  573|  5.30k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  574|  5.30k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  575|  65.5k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (575:20): [True: 56.7k, False: 8.74k]
  ------------------
  576|  56.7k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  577|  56.7k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  578|  56.7k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  579|  56.7k|        } else {
  580|       |          // must be a surrogate pair
  581|  8.74k|          uint16_t diff = uint16_t(word - 0xD800);
  582|  8.74k|          uint16_t next_word =
  583|  8.74k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  584|  8.74k|          k++;
  585|  8.74k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  586|  8.74k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (586:15): [True: 180, False: 8.56k]
  ------------------
  587|    180|            return std::make_pair(
  588|    180|                result(error_code::SURROGATE, buf - start + k - 1),
  589|    180|                utf8_output);
  590|    180|          }
  591|  8.56k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  592|  8.56k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  593|  8.56k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  594|  8.56k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  595|  8.56k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  596|  8.56k|        }
  597|   107k|      }
  598|  7.63k|      buf += k;
  599|  7.63k|    }
  600|  92.0k|  } // while
  601|    474|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output);
  602|    654|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_128avx2_convert_utf32_to_latin1EPKDimPc:
    3|    228|                             char *latin1_output) {
    4|    228|  const size_t rounded_len =
    5|    228|      len & ~0x1F; // Round down to nearest multiple of 32
    6|       |
    7|    228|  const __m256i high_bytes_mask = _mm256_set1_epi32(0xFFFFFF00);
    8|       |
    9|  16.6k|  for (size_t i = 0; i < rounded_len; i += 4 * 8) {
  ------------------
  |  Branch (9:22): [True: 16.5k, False: 182]
  ------------------
   10|  16.5k|    __m256i a = _mm256_loadu_si256((__m256i *)(buf + 0 * 8));
   11|  16.5k|    __m256i b = _mm256_loadu_si256((__m256i *)(buf + 1 * 8));
   12|  16.5k|    __m256i c = _mm256_loadu_si256((__m256i *)(buf + 2 * 8));
   13|  16.5k|    __m256i d = _mm256_loadu_si256((__m256i *)(buf + 3 * 8));
   14|       |
   15|  16.5k|    const __m256i check_combined =
   16|  16.5k|        _mm256_or_si256(_mm256_or_si256(a, b), _mm256_or_si256(c, d));
   17|       |
   18|  16.5k|    if (!_mm256_testz_si256(check_combined, high_bytes_mask)) {
  ------------------
  |  Branch (18:9): [True: 46, False: 16.4k]
  ------------------
   19|     46|      return std::make_pair(nullptr, latin1_output);
   20|     46|    }
   21|       |
   22|  16.4k|    b = _mm256_slli_epi32(b, 1 * 8);
   23|  16.4k|    c = _mm256_slli_epi32(c, 2 * 8);
   24|  16.4k|    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|  16.4k|    const __m256i t0 =
   35|  16.4k|        _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|  16.4k|    const __m256i shuffle_bytes =
   40|  16.4k|        _mm256_setr_epi8(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15,
   41|  16.4k|                         0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15);
   42|       |
   43|  16.4k|    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|  16.4k|    const __m256i shuffle_dwords = _mm256_setr_epi32(0, 4, 1, 5, 2, 6, 3, 7);
   48|  16.4k|    const __m256i t2 = _mm256_permutevar8x32_epi32(t1, shuffle_dwords);
   49|       |// clang format on
   50|       |
   51|  16.4k|    _mm256_storeu_si256((__m256i *)latin1_output, t2);
   52|       |
   53|  16.4k|    latin1_output += 32;
   54|  16.4k|    buf += 32;
   55|  16.4k|  }
   56|       |
   57|    182|  return std::make_pair(buf, latin1_output);
   58|    228|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_140avx2_convert_utf32_to_latin1_with_errorsEPKDimPc:
   62|    436|                                         char *latin1_output) {
   63|    436|  const size_t rounded_len =
   64|    436|      len & ~0x1F; // Round down to nearest multiple of 32
   65|       |
   66|    436|  const char32_t *start = buf;
   67|       |
   68|    436|  const __m256i high_bytes_mask = _mm256_set1_epi32(0xFFFFFF00);
   69|       |
   70|  17.0k|  for (size_t i = 0; i < rounded_len; i += 4 * 8) {
  ------------------
  |  Branch (70:22): [True: 16.7k, False: 312]
  ------------------
   71|  16.7k|    __m256i a = _mm256_loadu_si256((__m256i *)(buf + 0 * 8));
   72|  16.7k|    __m256i b = _mm256_loadu_si256((__m256i *)(buf + 1 * 8));
   73|  16.7k|    __m256i c = _mm256_loadu_si256((__m256i *)(buf + 2 * 8));
   74|  16.7k|    __m256i d = _mm256_loadu_si256((__m256i *)(buf + 3 * 8));
   75|       |
   76|  16.7k|    const __m256i check_combined =
   77|  16.7k|        _mm256_or_si256(_mm256_or_si256(a, b), _mm256_or_si256(c, d));
   78|       |
   79|  16.7k|    if (!_mm256_testz_si256(check_combined, high_bytes_mask)) {
  ------------------
  |  Branch (79:9): [True: 124, False: 16.6k]
  ------------------
   80|       |      // Fallback to scalar code for handling errors
   81|    590|      for (int k = 0; k < 4 * 8; k++) {
  ------------------
  |  Branch (81:23): [True: 590, False: 0]
  ------------------
   82|    590|        char32_t codepoint = buf[k];
   83|    590|        if (codepoint <= 0xFF) {
  ------------------
  |  Branch (83:13): [True: 466, False: 124]
  ------------------
   84|    466|          *latin1_output++ = static_cast<char>(codepoint);
   85|    466|        } else {
   86|    124|          return std::make_pair(result(error_code::TOO_LARGE, buf - start + k),
   87|    124|                                latin1_output);
   88|    124|        }
   89|    590|      }
   90|    124|    }
   91|       |
   92|  16.6k|    b = _mm256_slli_epi32(b, 1 * 8);
   93|  16.6k|    c = _mm256_slli_epi32(c, 2 * 8);
   94|  16.6k|    d = _mm256_slli_epi32(d, 3 * 8);
   95|       |
   96|  16.6k|    const __m256i t0 =
   97|  16.6k|        _mm256_or_si256(_mm256_or_si256(a, b), _mm256_or_si256(c, d));
   98|       |
   99|  16.6k|    const __m256i shuffle_bytes =
  100|  16.6k|        _mm256_setr_epi8(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15,
  101|  16.6k|                         0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15);
  102|       |
  103|  16.6k|    const __m256i t1 = _mm256_shuffle_epi8(t0, shuffle_bytes);
  104|       |
  105|  16.6k|    const __m256i shuffle_dwords = _mm256_setr_epi32(0, 4, 1, 5, 2, 6, 3, 7);
  106|  16.6k|    const __m256i t2 = _mm256_permutevar8x32_epi32(t1, shuffle_dwords);
  107|       |
  108|  16.6k|    _mm256_storeu_si256((__m256i *)latin1_output, t2);
  109|       |
  110|  16.6k|    latin1_output += 32;
  111|  16.6k|    buf += 32;
  112|  16.6k|  }
  113|       |
  114|    312|  return std::make_pair(result(error_code::SUCCESS, buf - start),
  115|    312|                        latin1_output);
  116|    436|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_127avx2_convert_utf32_to_utf16ILNS_10endiannessE0EEENSt3__14pairIPKDiPDsEES7_mS8_:
    4|    822|                            char16_t *utf16_output) {
    5|    822|  const char32_t *end = buf + len;
    6|       |
    7|    822|  const size_t safety_margin =
    8|    822|      12; // to avoid overruns, see issue
    9|       |          // https://github.com/simdutf/simdutf/issues/92
   10|    822|  __m256i forbidden_bytemask = _mm256_setzero_si256();
   11|       |
   12|    822|  const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000);
   13|    822|  const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800);
   14|    822|  const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800);
   15|       |
   16|   151k|  while (end - buf >= std::ptrdiff_t(8 + safety_margin)) {
  ------------------
  |  Branch (16:10): [True: 151k, False: 662]
  ------------------
   17|   151k|    const __m256i in = _mm256_loadu_si256((__m256i *)buf);
   18|       |
   19|   151k|    if (simdutf_likely(_mm256_testz_si256(in, v_ffff0000))) {
  ------------------
  |  |   90|   151k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 147k, False: 4.26k]
  |  |  ------------------
  ------------------
   20|       |      // no bits set above 16th bit <=> can pack to UTF16
   21|       |      // without surrogate pairs
   22|   147k|      forbidden_bytemask = _mm256_or_si256(
   23|   147k|          forbidden_bytemask,
   24|   147k|          _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800));
   25|       |
   26|   147k|      __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),
   27|   147k|                                              _mm256_extractf128_si256(in, 1));
   28|   147k|      if (big_endian) {
  ------------------
  |  Branch (28:11): [Folded, False: 147k]
  ------------------
   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|   147k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
   34|   147k|      utf16_output += 8;
   35|   147k|      buf += 8;
   36|   147k|    } else {
   37|  4.26k|      size_t forward = 7;
   38|  4.26k|      size_t k = 0;
   39|  4.26k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (39:11): [True: 0, False: 4.26k]
  ------------------
   40|      0|        forward = size_t(end - buf - 1);
   41|      0|      }
   42|  33.3k|      for (; k < forward; k++) {
  ------------------
  |  Branch (42:14): [True: 29.2k, False: 4.10k]
  ------------------
   43|  29.2k|        uint32_t word = buf[k];
   44|  29.2k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (44:13): [True: 8.53k, False: 20.6k]
  ------------------
   45|       |          // will not generate a surrogate pair
   46|  8.53k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (46:15): [True: 820, False: 7.71k]
  |  Branch (46:33): [True: 24, False: 796]
  ------------------
   47|     24|            return std::make_pair(nullptr, utf16_output);
   48|     24|          }
   49|  8.50k|          *utf16_output++ =
   50|  8.50k|              big_endian
  ------------------
  |  Branch (50:15): [Folded, False: 8.50k]
  ------------------
   51|  8.50k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
   52|  8.50k|                  : char16_t(word);
   53|  20.6k|        } else {
   54|       |          // will generate a surrogate pair
   55|  20.6k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (55:15): [True: 136, False: 20.5k]
  ------------------
   56|    136|            return std::make_pair(nullptr, utf16_output);
   57|    136|          }
   58|  20.5k|          word -= 0x10000;
   59|  20.5k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   60|  20.5k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   61|  20.5k|          if (big_endian) {
  ------------------
  |  Branch (61:15): [Folded, False: 20.5k]
  ------------------
   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|  20.5k|          *utf16_output++ = char16_t(high_surrogate);
   68|  20.5k|          *utf16_output++ = char16_t(low_surrogate);
   69|  20.5k|        }
   70|  29.2k|      }
   71|  4.10k|      buf += k;
   72|  4.10k|    }
   73|   151k|  }
   74|       |
   75|       |  // check for invalid input
   76|    662|  if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (76:7): [True: 42, False: 620]
  ------------------
   77|     42|    return std::make_pair(nullptr, utf16_output);
   78|     42|  }
   79|       |
   80|    620|  return std::make_pair(buf, utf16_output);
   81|    662|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_127avx2_convert_utf32_to_utf16ILNS_10endiannessE1EEENSt3__14pairIPKDiPDsEES7_mS8_:
    4|    674|                            char16_t *utf16_output) {
    5|    674|  const char32_t *end = buf + len;
    6|       |
    7|    674|  const size_t safety_margin =
    8|    674|      12; // to avoid overruns, see issue
    9|       |          // https://github.com/simdutf/simdutf/issues/92
   10|    674|  __m256i forbidden_bytemask = _mm256_setzero_si256();
   11|       |
   12|    674|  const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000);
   13|    674|  const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800);
   14|    674|  const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800);
   15|       |
   16|  18.0k|  while (end - buf >= std::ptrdiff_t(8 + safety_margin)) {
  ------------------
  |  Branch (16:10): [True: 17.5k, False: 488]
  ------------------
   17|  17.5k|    const __m256i in = _mm256_loadu_si256((__m256i *)buf);
   18|       |
   19|  17.5k|    if (simdutf_likely(_mm256_testz_si256(in, v_ffff0000))) {
  ------------------
  |  |   90|  17.5k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 14.0k, False: 3.50k]
  |  |  ------------------
  ------------------
   20|       |      // no bits set above 16th bit <=> can pack to UTF16
   21|       |      // without surrogate pairs
   22|  14.0k|      forbidden_bytemask = _mm256_or_si256(
   23|  14.0k|          forbidden_bytemask,
   24|  14.0k|          _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800));
   25|       |
   26|  14.0k|      __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),
   27|  14.0k|                                              _mm256_extractf128_si256(in, 1));
   28|  14.0k|      if (big_endian) {
  ------------------
  |  Branch (28:11): [True: 14.0k, Folded]
  ------------------
   29|  14.0k|        const __m128i swap =
   30|  14.0k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   31|  14.0k|        utf16_packed = _mm_shuffle_epi8(utf16_packed, swap);
   32|  14.0k|      }
   33|  14.0k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
   34|  14.0k|      utf16_output += 8;
   35|  14.0k|      buf += 8;
   36|  14.0k|    } else {
   37|  3.50k|      size_t forward = 7;
   38|  3.50k|      size_t k = 0;
   39|  3.50k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (39:11): [True: 0, False: 3.50k]
  ------------------
   40|      0|        forward = size_t(end - buf - 1);
   41|      0|      }
   42|  27.1k|      for (; k < forward; k++) {
  ------------------
  |  Branch (42:14): [True: 23.8k, False: 3.32k]
  ------------------
   43|  23.8k|        uint32_t word = buf[k];
   44|  23.8k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (44:13): [True: 2.63k, False: 21.1k]
  ------------------
   45|       |          // will not generate a surrogate pair
   46|  2.63k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (46:15): [True: 440, False: 2.19k]
  |  Branch (46:33): [True: 4, False: 436]
  ------------------
   47|      4|            return std::make_pair(nullptr, utf16_output);
   48|      4|          }
   49|  2.62k|          *utf16_output++ =
   50|  2.62k|              big_endian
  ------------------
  |  Branch (50:15): [True: 2.62k, Folded]
  ------------------
   51|  2.62k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
   52|  2.62k|                  : char16_t(word);
   53|  21.1k|        } else {
   54|       |          // will generate a surrogate pair
   55|  21.1k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (55:15): [True: 182, False: 21.0k]
  ------------------
   56|    182|            return std::make_pair(nullptr, utf16_output);
   57|    182|          }
   58|  21.0k|          word -= 0x10000;
   59|  21.0k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   60|  21.0k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   61|  21.0k|          if (big_endian) {
  ------------------
  |  Branch (61:15): [True: 21.0k, Folded]
  ------------------
   62|  21.0k|            high_surrogate =
   63|  21.0k|                uint16_t((high_surrogate >> 8) | (high_surrogate << 8));
   64|  21.0k|            low_surrogate =
   65|  21.0k|                uint16_t((low_surrogate >> 8) | (low_surrogate << 8));
   66|  21.0k|          }
   67|  21.0k|          *utf16_output++ = char16_t(high_surrogate);
   68|  21.0k|          *utf16_output++ = char16_t(low_surrogate);
   69|  21.0k|        }
   70|  23.8k|      }
   71|  3.32k|      buf += k;
   72|  3.32k|    }
   73|  17.5k|  }
   74|       |
   75|       |  // check for invalid input
   76|    488|  if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (76:7): [True: 34, False: 454]
  ------------------
   77|     34|    return std::make_pair(nullptr, utf16_output);
   78|     34|  }
   79|       |
   80|    454|  return std::make_pair(buf, utf16_output);
   81|    488|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_139avx2_convert_utf32_to_utf16_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPDsEEPKDimS7_:
   86|    674|                                        char16_t *utf16_output) {
   87|    674|  const char32_t *start = buf;
   88|    674|  const char32_t *end = buf + len;
   89|       |
   90|    674|  const size_t safety_margin =
   91|    674|      12; // to avoid overruns, see issue
   92|       |          // https://github.com/simdutf/simdutf/issues/92
   93|       |
   94|    674|  const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000);
   95|    674|  const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800);
   96|    674|  const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800);
   97|       |
   98|  68.4k|  while (end - buf >= std::ptrdiff_t(8 + safety_margin)) {
  ------------------
  |  Branch (98:10): [True: 67.9k, False: 502]
  ------------------
   99|  67.9k|    const __m256i in = _mm256_loadu_si256((__m256i *)buf);
  100|       |
  101|  67.9k|    if (simdutf_likely(_mm256_testz_si256(in, v_ffff0000))) {
  ------------------
  |  |   90|  67.9k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 66.5k, False: 1.43k]
  |  |  ------------------
  ------------------
  102|       |      // no bits set above 16th bit <=> can pack to UTF16 without surrogate
  103|       |      // pairs
  104|  66.5k|      const __m256i forbidden_bytemask =
  105|  66.5k|          _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800);
  106|  66.5k|      if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) !=
  ------------------
  |  Branch (106:11): [True: 32, False: 66.5k]
  ------------------
  107|  66.5k|          0x0) {
  108|     32|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  109|     32|                              utf16_output);
  110|     32|      }
  111|       |
  112|  66.5k|      __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),
  113|  66.5k|                                              _mm256_extractf128_si256(in, 1));
  114|  66.5k|      if (big_endian) {
  ------------------
  |  Branch (114:11): [Folded, False: 66.5k]
  ------------------
  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|  66.5k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
  120|  66.5k|      utf16_output += 8;
  121|  66.5k|      buf += 8;
  122|  66.5k|    } else {
  123|  1.43k|      size_t forward = 7;
  124|  1.43k|      size_t k = 0;
  125|  1.43k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (125:11): [True: 0, False: 1.43k]
  ------------------
  126|      0|        forward = size_t(end - buf - 1);
  127|      0|      }
  128|  10.8k|      for (; k < forward; k++) {
  ------------------
  |  Branch (128:14): [True: 9.50k, False: 1.29k]
  ------------------
  129|  9.50k|        uint32_t word = buf[k];
  130|  9.50k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (130:13): [True: 4.44k, False: 5.06k]
  ------------------
  131|       |          // will not generate a surrogate pair
  132|  4.44k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (132:15): [True: 580, False: 3.86k]
  |  Branch (132:33): [True: 4, False: 576]
  ------------------
  133|      4|            return std::make_pair(
  134|      4|                result(error_code::SURROGATE, buf - start + k), utf16_output);
  135|      4|          }
  136|  4.44k|          *utf16_output++ =
  137|  4.44k|              big_endian
  ------------------
  |  Branch (137:15): [Folded, False: 4.44k]
  ------------------
  138|  4.44k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
  139|  4.44k|                  : char16_t(word);
  140|  5.06k|        } else {
  141|       |          // will generate a surrogate pair
  142|  5.06k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (142:15): [True: 136, False: 4.92k]
  ------------------
  143|    136|            return std::make_pair(
  144|    136|                result(error_code::TOO_LARGE, buf - start + k), utf16_output);
  145|    136|          }
  146|  4.92k|          word -= 0x10000;
  147|  4.92k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
  148|  4.92k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
  149|  4.92k|          if (big_endian) {
  ------------------
  |  Branch (149:15): [Folded, False: 4.92k]
  ------------------
  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|  4.92k|          *utf16_output++ = char16_t(high_surrogate);
  156|  4.92k|          *utf16_output++ = char16_t(low_surrogate);
  157|  4.92k|        }
  158|  9.50k|      }
  159|  1.29k|      buf += k;
  160|  1.29k|    }
  161|  67.9k|  }
  162|       |
  163|    502|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output);
  164|    674|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_139avx2_convert_utf32_to_utf16_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPDsEEPKDimS7_:
   86|    694|                                        char16_t *utf16_output) {
   87|    694|  const char32_t *start = buf;
   88|    694|  const char32_t *end = buf + len;
   89|       |
   90|    694|  const size_t safety_margin =
   91|    694|      12; // to avoid overruns, see issue
   92|       |          // https://github.com/simdutf/simdutf/issues/92
   93|       |
   94|    694|  const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000);
   95|    694|  const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800);
   96|    694|  const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800);
   97|       |
   98|  4.70k|  while (end - buf >= std::ptrdiff_t(8 + safety_margin)) {
  ------------------
  |  Branch (98:10): [True: 4.17k, False: 528]
  ------------------
   99|  4.17k|    const __m256i in = _mm256_loadu_si256((__m256i *)buf);
  100|       |
  101|  4.17k|    if (simdutf_likely(_mm256_testz_si256(in, v_ffff0000))) {
  ------------------
  |  |   90|  4.17k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 3.29k, False: 878]
  |  |  ------------------
  ------------------
  102|       |      // no bits set above 16th bit <=> can pack to UTF16 without surrogate
  103|       |      // pairs
  104|  3.29k|      const __m256i forbidden_bytemask =
  105|  3.29k|          _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800);
  106|  3.29k|      if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) !=
  ------------------
  |  Branch (106:11): [True: 6, False: 3.28k]
  ------------------
  107|  3.29k|          0x0) {
  108|      6|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  109|      6|                              utf16_output);
  110|      6|      }
  111|       |
  112|  3.28k|      __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),
  113|  3.28k|                                              _mm256_extractf128_si256(in, 1));
  114|  3.28k|      if (big_endian) {
  ------------------
  |  Branch (114:11): [True: 3.28k, Folded]
  ------------------
  115|  3.28k|        const __m128i swap =
  116|  3.28k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  117|  3.28k|        utf16_packed = _mm_shuffle_epi8(utf16_packed, swap);
  118|  3.28k|      }
  119|  3.28k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
  120|  3.28k|      utf16_output += 8;
  121|  3.28k|      buf += 8;
  122|  3.28k|    } else {
  123|    878|      size_t forward = 7;
  124|    878|      size_t k = 0;
  125|    878|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (125:11): [True: 0, False: 878]
  ------------------
  126|      0|        forward = size_t(end - buf - 1);
  127|      0|      }
  128|  6.28k|      for (; k < forward; k++) {
  ------------------
  |  Branch (128:14): [True: 5.56k, False: 718]
  ------------------
  129|  5.56k|        uint32_t word = buf[k];
  130|  5.56k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (130:13): [True: 2.66k, False: 2.89k]
  ------------------
  131|       |          // will not generate a surrogate pair
  132|  2.66k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (132:15): [True: 662, False: 2.00k]
  |  Branch (132:33): [True: 8, False: 654]
  ------------------
  133|      8|            return std::make_pair(
  134|      8|                result(error_code::SURROGATE, buf - start + k), utf16_output);
  135|      8|          }
  136|  2.65k|          *utf16_output++ =
  137|  2.65k|              big_endian
  ------------------
  |  Branch (137:15): [True: 2.65k, Folded]
  ------------------
  138|  2.65k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
  139|  2.65k|                  : char16_t(word);
  140|  2.89k|        } else {
  141|       |          // will generate a surrogate pair
  142|  2.89k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (142:15): [True: 152, False: 2.74k]
  ------------------
  143|    152|            return std::make_pair(
  144|    152|                result(error_code::TOO_LARGE, buf - start + k), utf16_output);
  145|    152|          }
  146|  2.74k|          word -= 0x10000;
  147|  2.74k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
  148|  2.74k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
  149|  2.74k|          if (big_endian) {
  ------------------
  |  Branch (149:15): [True: 2.74k, Folded]
  ------------------
  150|  2.74k|            high_surrogate =
  151|  2.74k|                uint16_t((high_surrogate >> 8) | (high_surrogate << 8));
  152|  2.74k|            low_surrogate =
  153|  2.74k|                uint16_t((low_surrogate >> 8) | (low_surrogate << 8));
  154|  2.74k|          }
  155|  2.74k|          *utf16_output++ = char16_t(high_surrogate);
  156|  2.74k|          *utf16_output++ = char16_t(low_surrogate);
  157|  2.74k|        }
  158|  5.56k|      }
  159|    718|      buf += k;
  160|    718|    }
  161|  4.17k|  }
  162|       |
  163|    528|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output);
  164|    694|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_126avx2_convert_utf32_to_utf8EPKDimPc:
    2|    864|avx2_convert_utf32_to_utf8(const char32_t *buf, size_t len, char *utf8_output) {
    3|    864|  const char32_t *end = buf + len;
    4|    864|  const __m256i v_0000 = _mm256_setzero_si256();
    5|    864|  const __m256i v_ffff0000 = _mm256_set1_epi32((uint32_t)0xffff0000);
    6|    864|  const __m256i v_ff80 = _mm256_set1_epi16((uint16_t)0xff80);
    7|    864|  const __m256i v_f800 = _mm256_set1_epi16((uint16_t)0xf800);
    8|    864|  const __m256i v_c080 = _mm256_set1_epi16((uint16_t)0xc080);
    9|    864|  const __m256i v_7fffffff = _mm256_set1_epi32((uint32_t)0x7fffffff);
   10|    864|  __m256i running_max = _mm256_setzero_si256();
   11|    864|  __m256i forbidden_bytemask = _mm256_setzero_si256();
   12|       |
   13|    864|  const size_t safety_margin =
   14|    864|      12; // to avoid overruns, see issue
   15|       |          // https://github.com/simdutf/simdutf/issues/92
   16|       |
   17|  39.2k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (17:10): [True: 38.5k, False: 650]
  ------------------
   18|  38.5k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
   19|  38.5k|    __m256i nextin = _mm256_loadu_si256((__m256i *)buf + 1);
   20|  38.5k|    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|  38.5k|    __m256i in_16 = _mm256_packus_epi32(_mm256_and_si256(in, v_7fffffff),
   25|  38.5k|                                        _mm256_and_si256(nextin, v_7fffffff));
   26|  38.5k|    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|  38.5k|    if (_mm256_testz_si256(in_16, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (31:9): [True: 33.9k, False: 4.60k]
  ------------------
   32|       |      // 1. pack the bytes
   33|  33.9k|      const __m128i utf8_packed = _mm_packus_epi16(
   34|  33.9k|          _mm256_castsi256_si128(in_16), _mm256_extractf128_si256(in_16, 1));
   35|       |      // 2. store (16 bytes)
   36|  33.9k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   37|       |      // 3. adjust pointers
   38|  33.9k|      buf += 16;
   39|  33.9k|      utf8_output += 16;
   40|  33.9k|      continue; // we are done for this round!
   41|  33.9k|    }
   42|       |    // no bits set above 7th bit
   43|  4.60k|    const __m256i one_byte_bytemask =
   44|  4.60k|        _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_ff80), v_0000);
   45|  4.60k|    const uint32_t one_byte_bitmask =
   46|  4.60k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_byte_bytemask));
   47|       |
   48|       |    // no bits set above 11th bit
   49|  4.60k|    const __m256i one_or_two_bytes_bytemask =
   50|  4.60k|        _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_0000);
   51|  4.60k|    const uint32_t one_or_two_bytes_bitmask =
   52|  4.60k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_or_two_bytes_bytemask));
   53|  4.60k|    if (one_or_two_bytes_bitmask == 0xffffffff) {
  ------------------
  |  Branch (53:9): [True: 1.76k, False: 2.83k]
  ------------------
   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.76k|      const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00);
   58|  1.76k|      const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f);
   59|       |
   60|       |      // t0 = [000a|aaaa|bbbb|bb00]
   61|  1.76k|      const __m256i t0 = _mm256_slli_epi16(in_16, 2);
   62|       |      // t1 = [000a|aaaa|0000|0000]
   63|  1.76k|      const __m256i t1 = _mm256_and_si256(t0, v_1f00);
   64|       |      // t2 = [0000|0000|00bb|bbbb]
   65|  1.76k|      const __m256i t2 = _mm256_and_si256(in_16, v_003f);
   66|       |      // t3 = [000a|aaaa|00bb|bbbb]
   67|  1.76k|      const __m256i t3 = _mm256_or_si256(t1, t2);
   68|       |      // t4 = [110a|aaaa|10bb|bbbb]
   69|  1.76k|      const __m256i t4 = _mm256_or_si256(t3, v_c080);
   70|       |
   71|       |      // 2. merge ASCII and 2-byte codewords
   72|  1.76k|      const __m256i utf8_unpacked =
   73|  1.76k|          _mm256_blendv_epi8(t4, in_16, one_byte_bytemask);
   74|       |
   75|       |      // 3. prepare bitmask for 8-bit lookup
   76|  1.76k|      const uint32_t M0 = one_byte_bitmask & 0x55555555;
   77|  1.76k|      const uint32_t M1 = M0 >> 7;
   78|  1.76k|      const uint32_t M2 = (M1 | M0) & 0x00ff00ff;
   79|       |      // 4. pack the bytes
   80|       |
   81|  1.76k|      const uint8_t *row =
   82|  1.76k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0];
   83|  1.76k|      const uint8_t *row_2 =
   84|  1.76k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2 >>
   85|  1.76k|                                                                       16)][0];
   86|       |
   87|  1.76k|      const __m128i shuffle = _mm_loadu_si128((__m128i *)(row + 1));
   88|  1.76k|      const __m128i shuffle_2 = _mm_loadu_si128((__m128i *)(row_2 + 1));
   89|       |
   90|  1.76k|      const __m256i utf8_packed = _mm256_shuffle_epi8(
   91|  1.76k|          utf8_unpacked, _mm256_setr_m128i(shuffle, shuffle_2));
  ------------------
  |  |    7|  1.76k|      _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1),                  \
  |  |    8|  1.76k|                                _mm256_castsi128_si256(xmm2), 2)
  ------------------
   92|       |      // 5. store bytes
   93|  1.76k|      _mm_storeu_si128((__m128i *)utf8_output,
   94|  1.76k|                       _mm256_castsi256_si128(utf8_packed));
   95|  1.76k|      utf8_output += row[0];
   96|  1.76k|      _mm_storeu_si128((__m128i *)utf8_output,
   97|  1.76k|                       _mm256_extractf128_si256(utf8_packed, 1));
   98|  1.76k|      utf8_output += row_2[0];
   99|       |
  100|       |      // 6. adjust pointers
  101|  1.76k|      buf += 16;
  102|  1.76k|      continue;
  103|  1.76k|    }
  104|       |    // Must check for overflow in packing
  105|  2.83k|    const __m256i saturation_bytemask = _mm256_cmpeq_epi32(
  106|  2.83k|        _mm256_and_si256(_mm256_or_si256(in, nextin), v_ffff0000), v_0000);
  107|  2.83k|    const uint32_t saturation_bitmask =
  108|  2.83k|        static_cast<uint32_t>(_mm256_movemask_epi8(saturation_bytemask));
  109|  2.83k|    if (saturation_bitmask == 0xffffffff) {
  ------------------
  |  Branch (109:9): [True: 1.04k, False: 1.78k]
  ------------------
  110|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  111|  1.04k|      const __m256i v_d800 = _mm256_set1_epi16((uint16_t)0xd800);
  112|  1.04k|      forbidden_bytemask = _mm256_or_si256(
  113|  1.04k|          forbidden_bytemask,
  114|  1.04k|          _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_d800));
  115|       |
  116|  1.04k|      const __m256i dup_even = _mm256_setr_epi16(
  117|  1.04k|          0x0000, 0x0202, 0x0404, 0x0606, 0x0808, 0x0a0a, 0x0c0c, 0x0e0e,
  118|  1.04k|          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|  1.04k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  148|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  149|  1.04k|      const __m256i t0 = _mm256_shuffle_epi8(in_16, dup_even);
  150|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  151|  1.04k|      const __m256i t1 = _mm256_and_si256(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  147|  1.04k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  152|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  153|  1.04k|      const __m256i t2 = _mm256_or_si256(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  147|  1.04k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  154|       |
  155|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  156|  1.04k|      const __m256i s0 = _mm256_srli_epi16(in_16, 4);
  157|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  158|  1.04k|      const __m256i s1 = _mm256_and_si256(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  147|  1.04k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  159|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  160|  1.04k|      const __m256i s2 = _mm256_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  147|  1.04k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  161|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  162|  1.04k|      const __m256i s3 = _mm256_or_si256(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  147|  1.04k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  163|  1.04k|      const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask,
  164|  1.04k|                                             simdutf_vec(0b0100000000000000));
  ------------------
  |  |  147|  1.04k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  165|  1.04k|      const __m256i s4 = _mm256_xor_si256(s3, m0);
  166|  1.04k|#undef simdutf_vec
  167|       |
  168|       |      // 4. expand code units 16-bit => 32-bit
  169|  1.04k|      const __m256i out0 = _mm256_unpacklo_epi16(t2, s4);
  170|  1.04k|      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|  1.04k|      const uint32_t mask = (one_byte_bitmask & 0x55555555) |
  174|  1.04k|                            (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|  1.04k|      const uint8_t mask0 = uint8_t(mask);
  195|  1.04k|      const uint8_t *row0 =
  196|  1.04k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  197|  1.04k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  198|  1.04k|      const __m128i utf8_0 =
  199|  1.04k|          _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0);
  200|       |
  201|  1.04k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  202|  1.04k|      const uint8_t *row1 =
  203|  1.04k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  204|  1.04k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  205|  1.04k|      const __m128i utf8_1 =
  206|  1.04k|          _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1);
  207|       |
  208|  1.04k|      const uint8_t mask2 = static_cast<uint8_t>(mask >> 16);
  209|  1.04k|      const uint8_t *row2 =
  210|  1.04k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0];
  211|  1.04k|      const __m128i shuffle2 = _mm_loadu_si128((__m128i *)(row2 + 1));
  212|  1.04k|      const __m128i utf8_2 =
  213|  1.04k|          _mm_shuffle_epi8(_mm256_extractf128_si256(out0, 1), shuffle2);
  214|       |
  215|  1.04k|      const uint8_t mask3 = static_cast<uint8_t>(mask >> 24);
  216|  1.04k|      const uint8_t *row3 =
  217|  1.04k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0];
  218|  1.04k|      const __m128i shuffle3 = _mm_loadu_si128((__m128i *)(row3 + 1));
  219|  1.04k|      const __m128i utf8_3 =
  220|  1.04k|          _mm_shuffle_epi8(_mm256_extractf128_si256(out1, 1), shuffle3);
  221|       |
  222|  1.04k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  223|  1.04k|      utf8_output += row0[0];
  224|  1.04k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  225|  1.04k|      utf8_output += row1[0];
  226|  1.04k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_2);
  227|  1.04k|      utf8_output += row2[0];
  228|  1.04k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_3);
  229|  1.04k|      utf8_output += row3[0];
  230|  1.04k|      buf += 16;
  231|  1.78k|    } 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.78k|      size_t forward = 15;
  237|  1.78k|      size_t k = 0;
  238|  1.78k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (238:11): [True: 0, False: 1.78k]
  ------------------
  239|      0|        forward = size_t(end - buf - 1);
  240|      0|      }
  241|  26.2k|      for (; k < forward; k++) {
  ------------------
  |  Branch (241:14): [True: 24.7k, False: 1.57k]
  ------------------
  242|  24.7k|        uint32_t word = buf[k];
  243|  24.7k|        if ((word & 0xFFFFFF80) == 0) { // 1-byte (ASCII)
  ------------------
  |  Branch (243:13): [True: 16.4k, False: 8.26k]
  ------------------
  244|  16.4k|          *utf8_output++ = char(word);
  245|  16.4k|        } else if ((word & 0xFFFFF800) == 0) { // 2-byte
  ------------------
  |  Branch (245:20): [True: 1.35k, False: 6.91k]
  ------------------
  246|  1.35k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  247|  1.35k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  248|  6.91k|        } else if ((word & 0xFFFF0000) == 0) { // 3-byte
  ------------------
  |  Branch (248:20): [True: 2.78k, False: 4.12k]
  ------------------
  249|  2.78k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (249:15): [True: 868, False: 1.91k]
  |  Branch (249:33): [True: 34, False: 834]
  ------------------
  250|     34|            return std::make_pair(nullptr, utf8_output);
  251|     34|          }
  252|  2.75k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  253|  2.75k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  254|  2.75k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  255|  4.12k|        } else { // 4-byte
  256|  4.12k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (256:15): [True: 180, False: 3.94k]
  ------------------
  257|    180|            return std::make_pair(nullptr, utf8_output);
  258|    180|          }
  259|  3.94k|          *utf8_output++ = char((word >> 18) | 0b11110000);
  260|  3.94k|          *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000);
  261|  3.94k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  262|  3.94k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  263|  3.94k|        }
  264|  24.7k|      }
  265|  1.57k|      buf += k;
  266|  1.57k|    }
  267|  2.83k|  } // while
  268|       |
  269|       |  // check for invalid input
  270|    650|  const __m256i v_10ffff = _mm256_set1_epi32((uint32_t)0x10ffff);
  271|    650|  if (static_cast<uint32_t>(_mm256_movemask_epi8(_mm256_cmpeq_epi32(
  ------------------
  |  Branch (271:7): [True: 24, False: 626]
  ------------------
  272|    650|          _mm256_max_epu32(running_max, v_10ffff), v_10ffff))) != 0xffffffff) {
  273|     24|    return std::make_pair(nullptr, utf8_output);
  274|     24|  }
  275|       |
  276|    626|  if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (276:7): [True: 54, False: 572]
  ------------------
  277|     54|    return std::make_pair(nullptr, utf8_output);
  278|     54|  }
  279|       |
  280|    572|  return std::make_pair(buf, utf8_output);
  281|    626|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_138avx2_convert_utf32_to_utf8_with_errorsEPKDimPc:
  285|    832|                                       char *utf8_output) {
  286|    832|  const char32_t *end = buf + len;
  287|    832|  const char32_t *start = buf;
  288|       |
  289|    832|  const __m256i v_0000 = _mm256_setzero_si256();
  290|    832|  const __m256i v_ffff0000 = _mm256_set1_epi32((uint32_t)0xffff0000);
  291|    832|  const __m256i v_ff80 = _mm256_set1_epi16((uint16_t)0xff80);
  292|    832|  const __m256i v_f800 = _mm256_set1_epi16((uint16_t)0xf800);
  293|    832|  const __m256i v_c080 = _mm256_set1_epi16((uint16_t)0xc080);
  294|    832|  const __m256i v_7fffffff = _mm256_set1_epi32((uint32_t)0x7fffffff);
  295|    832|  const __m256i v_10ffff = _mm256_set1_epi32((uint32_t)0x10ffff);
  296|       |
  297|    832|  const size_t safety_margin =
  298|    832|      12; // to avoid overruns, see issue
  299|       |          // https://github.com/simdutf/simdutf/issues/92
  300|       |
  301|  24.1k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (301:10): [True: 23.5k, False: 620]
  ------------------
  302|  23.5k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
  303|  23.5k|    __m256i nextin = _mm256_loadu_si256((__m256i *)buf + 1);
  304|       |    // Check for too large input
  305|  23.5k|    const __m256i max_input =
  306|  23.5k|        _mm256_max_epu32(_mm256_max_epu32(in, nextin), v_10ffff);
  307|  23.5k|    if (static_cast<uint32_t>(_mm256_movemask_epi8(
  ------------------
  |  Branch (307:9): [True: 144, False: 23.3k]
  ------------------
  308|  23.5k|            _mm256_cmpeq_epi32(max_input, v_10ffff))) != 0xffffffff) {
  309|    144|      return std::make_pair(result(error_code::TOO_LARGE, buf - start),
  310|    144|                            utf8_output);
  311|    144|    }
  312|       |
  313|       |    // Pack 32-bit UTF-32 code units to 16-bit UTF-16 code units with unsigned
  314|       |    // saturation
  315|  23.3k|    __m256i in_16 = _mm256_packus_epi32(_mm256_and_si256(in, v_7fffffff),
  316|  23.3k|                                        _mm256_and_si256(nextin, v_7fffffff));
  317|  23.3k|    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|  23.3k|    if (_mm256_testz_si256(in_16, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (322:9): [True: 20.3k, False: 3.02k]
  ------------------
  323|       |      // 1. pack the bytes
  324|  20.3k|      const __m128i utf8_packed = _mm_packus_epi16(
  325|  20.3k|          _mm256_castsi256_si128(in_16), _mm256_extractf128_si256(in_16, 1));
  326|       |      // 2. store (16 bytes)
  327|  20.3k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  328|       |      // 3. adjust pointers
  329|  20.3k|      buf += 16;
  330|  20.3k|      utf8_output += 16;
  331|  20.3k|      continue; // we are done for this round!
  332|  20.3k|    }
  333|       |    // no bits set above 7th bit
  334|  3.02k|    const __m256i one_byte_bytemask =
  335|  3.02k|        _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_ff80), v_0000);
  336|  3.02k|    const uint32_t one_byte_bitmask =
  337|  3.02k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_byte_bytemask));
  338|       |
  339|       |    // no bits set above 11th bit
  340|  3.02k|    const __m256i one_or_two_bytes_bytemask =
  341|  3.02k|        _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_0000);
  342|  3.02k|    const uint32_t one_or_two_bytes_bitmask =
  343|  3.02k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_or_two_bytes_bytemask));
  344|  3.02k|    if (one_or_two_bytes_bitmask == 0xffffffff) {
  ------------------
  |  Branch (344:9): [True: 1.53k, False: 1.48k]
  ------------------
  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.53k|      const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00);
  349|  1.53k|      const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f);
  350|       |
  351|       |      // t0 = [000a|aaaa|bbbb|bb00]
  352|  1.53k|      const __m256i t0 = _mm256_slli_epi16(in_16, 2);
  353|       |      // t1 = [000a|aaaa|0000|0000]
  354|  1.53k|      const __m256i t1 = _mm256_and_si256(t0, v_1f00);
  355|       |      // t2 = [0000|0000|00bb|bbbb]
  356|  1.53k|      const __m256i t2 = _mm256_and_si256(in_16, v_003f);
  357|       |      // t3 = [000a|aaaa|00bb|bbbb]
  358|  1.53k|      const __m256i t3 = _mm256_or_si256(t1, t2);
  359|       |      // t4 = [110a|aaaa|10bb|bbbb]
  360|  1.53k|      const __m256i t4 = _mm256_or_si256(t3, v_c080);
  361|       |
  362|       |      // 2. merge ASCII and 2-byte codewords
  363|  1.53k|      const __m256i utf8_unpacked =
  364|  1.53k|          _mm256_blendv_epi8(t4, in_16, one_byte_bytemask);
  365|       |
  366|       |      // 3. prepare bitmask for 8-bit lookup
  367|  1.53k|      const uint32_t M0 = one_byte_bitmask & 0x55555555;
  368|  1.53k|      const uint32_t M1 = M0 >> 7;
  369|  1.53k|      const uint32_t M2 = (M1 | M0) & 0x00ff00ff;
  370|       |      // 4. pack the bytes
  371|       |
  372|  1.53k|      const uint8_t *row =
  373|  1.53k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0];
  374|  1.53k|      const uint8_t *row_2 =
  375|  1.53k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2 >>
  376|  1.53k|                                                                       16)][0];
  377|       |
  378|  1.53k|      const __m128i shuffle = _mm_loadu_si128((__m128i *)(row + 1));
  379|  1.53k|      const __m128i shuffle_2 = _mm_loadu_si128((__m128i *)(row_2 + 1));
  380|       |
  381|  1.53k|      const __m256i utf8_packed = _mm256_shuffle_epi8(
  382|  1.53k|          utf8_unpacked, _mm256_setr_m128i(shuffle, shuffle_2));
  ------------------
  |  |    7|  1.53k|      _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1),                  \
  |  |    8|  1.53k|                                _mm256_castsi128_si256(xmm2), 2)
  ------------------
  383|       |      // 5. store bytes
  384|  1.53k|      _mm_storeu_si128((__m128i *)utf8_output,
  385|  1.53k|                       _mm256_castsi256_si128(utf8_packed));
  386|  1.53k|      utf8_output += row[0];
  387|  1.53k|      _mm_storeu_si128((__m128i *)utf8_output,
  388|  1.53k|                       _mm256_extractf128_si256(utf8_packed, 1));
  389|  1.53k|      utf8_output += row_2[0];
  390|       |
  391|       |      // 6. adjust pointers
  392|  1.53k|      buf += 16;
  393|  1.53k|      continue;
  394|  1.53k|    }
  395|       |    // Must check for overflow in packing
  396|  1.48k|    const __m256i saturation_bytemask = _mm256_cmpeq_epi32(
  397|  1.48k|        _mm256_and_si256(_mm256_or_si256(in, nextin), v_ffff0000), v_0000);
  398|  1.48k|    const uint32_t saturation_bitmask =
  399|  1.48k|        static_cast<uint32_t>(_mm256_movemask_epi8(saturation_bytemask));
  400|  1.48k|    if (saturation_bitmask == 0xffffffff) {
  ------------------
  |  Branch (400:9): [True: 650, False: 838]
  ------------------
  401|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  402|       |
  403|       |      // Check for illegal surrogate code units
  404|    650|      const __m256i v_d800 = _mm256_set1_epi16((uint16_t)0xd800);
  405|    650|      const __m256i forbidden_bytemask =
  406|    650|          _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_d800);
  407|    650|      if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) !=
  ------------------
  |  Branch (407:11): [True: 34, False: 616]
  ------------------
  408|    650|          0x0) {
  409|     34|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  410|     34|                              utf8_output);
  411|     34|      }
  412|       |
  413|    616|      const __m256i dup_even = _mm256_setr_epi16(
  414|    616|          0x0000, 0x0202, 0x0404, 0x0606, 0x0808, 0x0a0a, 0x0c0c, 0x0e0e,
  415|    616|          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|    616|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  445|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  446|    616|      const __m256i t0 = _mm256_shuffle_epi8(in_16, dup_even);
  447|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  448|    616|      const __m256i t1 = _mm256_and_si256(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  444|    616|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  449|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  450|    616|      const __m256i t2 = _mm256_or_si256(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  444|    616|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  451|       |
  452|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  453|    616|      const __m256i s0 = _mm256_srli_epi16(in_16, 4);
  454|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  455|    616|      const __m256i s1 = _mm256_and_si256(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  444|    616|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  456|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  457|    616|      const __m256i s2 = _mm256_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  444|    616|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  458|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  459|    616|      const __m256i s3 = _mm256_or_si256(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  444|    616|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  460|    616|      const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask,
  461|    616|                                             simdutf_vec(0b0100000000000000));
  ------------------
  |  |  444|    616|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  462|    616|      const __m256i s4 = _mm256_xor_si256(s3, m0);
  463|    616|#undef simdutf_vec
  464|       |
  465|       |      // 4. expand code units 16-bit => 32-bit
  466|    616|      const __m256i out0 = _mm256_unpacklo_epi16(t2, s4);
  467|    616|      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|    616|      const uint32_t mask = (one_byte_bitmask & 0x55555555) |
  471|    616|                            (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|    616|      const uint8_t mask0 = uint8_t(mask);
  492|    616|      const uint8_t *row0 =
  493|    616|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  494|    616|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  495|    616|      const __m128i utf8_0 =
  496|    616|          _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0);
  497|       |
  498|    616|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  499|    616|      const uint8_t *row1 =
  500|    616|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  501|    616|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  502|    616|      const __m128i utf8_1 =
  503|    616|          _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1);
  504|       |
  505|    616|      const uint8_t mask2 = static_cast<uint8_t>(mask >> 16);
  506|    616|      const uint8_t *row2 =
  507|    616|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0];
  508|    616|      const __m128i shuffle2 = _mm_loadu_si128((__m128i *)(row2 + 1));
  509|    616|      const __m128i utf8_2 =
  510|    616|          _mm_shuffle_epi8(_mm256_extractf128_si256(out0, 1), shuffle2);
  511|       |
  512|    616|      const uint8_t mask3 = static_cast<uint8_t>(mask >> 24);
  513|    616|      const uint8_t *row3 =
  514|    616|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0];
  515|    616|      const __m128i shuffle3 = _mm_loadu_si128((__m128i *)(row3 + 1));
  516|    616|      const __m128i utf8_3 =
  517|    616|          _mm_shuffle_epi8(_mm256_extractf128_si256(out1, 1), shuffle3);
  518|       |
  519|    616|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  520|    616|      utf8_output += row0[0];
  521|    616|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  522|    616|      utf8_output += row1[0];
  523|    616|      _mm_storeu_si128((__m128i *)utf8_output, utf8_2);
  524|    616|      utf8_output += row2[0];
  525|    616|      _mm_storeu_si128((__m128i *)utf8_output, utf8_3);
  526|    616|      utf8_output += row3[0];
  527|    616|      buf += 16;
  528|    838|    } 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|    838|      size_t forward = 15;
  534|    838|      size_t k = 0;
  535|    838|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (535:11): [True: 0, False: 838]
  ------------------
  536|      0|        forward = size_t(end - buf - 1);
  537|      0|      }
  538|  13.1k|      for (; k < forward; k++) {
  ------------------
  |  Branch (538:14): [True: 12.3k, False: 804]
  ------------------
  539|  12.3k|        uint32_t word = buf[k];
  540|  12.3k|        if ((word & 0xFFFFFF80) == 0) { // 1-byte (ASCII)
  ------------------
  |  Branch (540:13): [True: 4.71k, False: 7.59k]
  ------------------
  541|  4.71k|          *utf8_output++ = char(word);
  542|  7.59k|        } else if ((word & 0xFFFFF800) == 0) { // 2-byte
  ------------------
  |  Branch (542:20): [True: 1.09k, False: 6.50k]
  ------------------
  543|  1.09k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  544|  1.09k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  545|  6.50k|        } else if ((word & 0xFFFF0000) == 0) { // 3-byte
  ------------------
  |  Branch (545:20): [True: 3.42k, False: 3.08k]
  ------------------
  546|  3.42k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (546:15): [True: 1.93k, False: 1.49k]
  |  Branch (546:33): [True: 34, False: 1.89k]
  ------------------
  547|     34|            return std::make_pair(
  548|     34|                result(error_code::SURROGATE, buf - start + k), utf8_output);
  549|     34|          }
  550|  3.38k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  551|  3.38k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  552|  3.38k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  553|  3.38k|        } else { // 4-byte
  554|  3.08k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (554:15): [True: 0, False: 3.08k]
  ------------------
  555|      0|            return std::make_pair(
  556|      0|                result(error_code::TOO_LARGE, buf - start + k), utf8_output);
  557|      0|          }
  558|  3.08k|          *utf8_output++ = char((word >> 18) | 0b11110000);
  559|  3.08k|          *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000);
  560|  3.08k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  561|  3.08k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  562|  3.08k|        }
  563|  12.3k|      }
  564|    804|      buf += k;
  565|    804|    }
  566|  1.48k|  } // while
  567|       |
  568|    620|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output);
  569|    832|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_129convert_masked_utf8_to_latin1EPKcmRPc:
    9|   588k|                                     char *&latin1_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|   588k|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   21|       |
   22|   588k|  const uint16_t input_utf8_end_of_code_point_mask =
   23|   588k|      utf8_end_of_code_point_mask &
   24|   588k|      0xfff; // we are only processing 12 bytes in case it is not all ASCII
   25|       |
   26|   588k|  if (utf8_end_of_code_point_mask == 0xfff) {
  ------------------
  |  Branch (26:7): [True: 3.61k, False: 585k]
  ------------------
   27|       |    // We process the data in chunks of 12 bytes.
   28|  3.61k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(latin1_output), in);
   29|  3.61k|    latin1_output += 12; // We wrote 12 characters.
   30|  3.61k|    return 12;           // We consumed 1 bytes.
   31|  3.61k|  }
   32|       |  /// We do not have a fast path available, so we fallback.
   33|   585k|  const uint8_t idx =
   34|   585k|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0];
   35|   585k|  const uint8_t consumed =
   36|   585k|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1];
   37|       |  // this indicates an invalid input:
   38|   585k|  if (idx >= 64) {
  ------------------
  |  Branch (38:7): [True: 30.3k, False: 554k]
  ------------------
   39|  30.3k|    return consumed;
   40|  30.3k|  }
   41|       |  // Here we should have (idx < 64), if not, there is a bug in the validation or
   42|       |  // elsewhere. SIX (6) input code-code units this is a relatively easy scenario
   43|       |  // we process SIX (6) input code-code units. The max length in bytes of six
   44|       |  // code code units spanning between 1 and 2 bytes each is 12 bytes. On
   45|       |  // processors where pdep/pext is fast, we might be able to use a small lookup
   46|       |  // table.
   47|   554k|  const __m128i sh =
   48|   554k|      _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
   49|   554k|  const __m128i perm = _mm_shuffle_epi8(in, sh);
   50|   554k|  const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   51|   554k|  const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   52|   554k|  __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   53|   554k|  const __m128i latin1_packed = _mm_packus_epi16(composed, composed);
   54|       |  // writing 8 bytes even though we only care about the first 6 bytes.
   55|       |  // performance note: it would be faster to use _mm_storeu_si128, we should
   56|       |  // investigate.
   57|   554k|  _mm_storel_epi64((__m128i *)latin1_output, latin1_packed);
   58|   554k|  latin1_output += 6; // We wrote 6 bytes.
   59|   554k|  return consumed;
   60|   585k|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_128convert_masked_utf8_to_utf16ILNS_10endiannessE0EEEmPKcmRPDs:
   10|  3.17M|                                    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|  3.17M|  const __m128i swap =
   23|  3.17M|      _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   24|  3.17M|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   25|  3.17M|  const uint16_t input_utf8_end_of_code_point_mask =
   26|  3.17M|      utf8_end_of_code_point_mask & 0xfff;
   27|  3.17M|  if (utf8_end_of_code_point_mask == 0xfff) {
  ------------------
  |  Branch (27:7): [True: 10.8k, False: 3.16M]
  ------------------
   28|       |    // We process the data in chunks of 12 bytes.
   29|  10.8k|    __m256i ascii = _mm256_cvtepu8_epi16(in);
   30|  10.8k|    if (big_endian) {
  ------------------
  |  Branch (30:9): [Folded, False: 10.8k]
  ------------------
   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|  10.8k|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf16_output), ascii);
   37|  10.8k|    utf16_output += 12; // We wrote 12 16-bit characters.
   38|  10.8k|    return 12;          // We consumed 12 bytes.
   39|  10.8k|  }
   40|  3.16M|  if (((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa)) {
  ------------------
  |  Branch (40:7): [True: 15.9k, False: 3.15M]
  ------------------
   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|  15.9k|    const __m128i sh =
   45|  15.9k|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   46|  15.9k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   47|  15.9k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   48|  15.9k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   49|  15.9k|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   50|  15.9k|    if (big_endian)
  ------------------
  |  Branch (50:9): [Folded, False: 15.9k]
  ------------------
   51|      0|      composed = _mm_shuffle_epi8(composed, swap);
   52|  15.9k|    _mm_storeu_si128((__m128i *)utf16_output, composed);
   53|  15.9k|    utf16_output += 8; // We wrote 16 bytes, 8 code points.
   54|  15.9k|    return 16;
   55|  15.9k|  }
   56|  3.15M|  if (input_utf8_end_of_code_point_mask == 0x924) {
  ------------------
  |  Branch (56:7): [True: 2.28k, False: 3.14M]
  ------------------
   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.28k|    const __m128i sh =
   61|  2.28k|        _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1);
   62|  2.28k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   63|  2.28k|    const __m128i ascii =
   64|  2.28k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   65|  2.28k|    const __m128i middlebyte =
   66|  2.28k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
   67|  2.28k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
   68|  2.28k|    const __m128i highbyte =
   69|  2.28k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
   70|  2.28k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
   71|  2.28k|    const __m128i composed =
   72|  2.28k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
   73|  2.28k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
   74|  2.28k|    if (big_endian)
  ------------------
  |  Branch (74:9): [Folded, False: 2.28k]
  ------------------
   75|      0|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
   76|  2.28k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
   77|  2.28k|    utf16_output += 4;
   78|  2.28k|    return 12;
   79|  2.28k|  }
   80|       |
   81|  3.14M|  const uint8_t idx = simdutf::tables::utf8_to_utf16::utf8bigindex
   82|  3.14M|      [input_utf8_end_of_code_point_mask][0];
   83|  3.14M|  const uint8_t consumed = simdutf::tables::utf8_to_utf16::utf8bigindex
   84|  3.14M|      [input_utf8_end_of_code_point_mask][1];
   85|  3.14M|  if (idx < 64) {
  ------------------
  |  Branch (85:7): [True: 2.64M, 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|  2.64M|    const __m128i sh = _mm_loadu_si128(
   93|  2.64M|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
   94|  2.64M|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   95|  2.64M|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   96|  2.64M|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   97|  2.64M|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   98|  2.64M|    if (big_endian)
  ------------------
  |  Branch (98:9): [Folded, False: 2.64M]
  ------------------
   99|      0|      composed = _mm_shuffle_epi8(composed, swap);
  100|  2.64M|    _mm_storeu_si128((__m128i *)utf16_output, composed);
  101|  2.64M|    utf16_output += 6; // We wrote 12 bytes, 6 code points. There is a potential
  102|       |                       // overflow of 4 bytes.
  103|  2.64M|  } else if (idx < 145) {
  ------------------
  |  Branch (103:14): [True: 434k, False: 66.2k]
  ------------------
  104|       |    // FOUR (4) input code-code units
  105|   434k|    const __m128i sh = _mm_loadu_si128(
  106|   434k|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
  107|   434k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  108|   434k|    const __m128i ascii =
  109|   434k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
  110|   434k|    const __m128i middlebyte =
  111|   434k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
  112|   434k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  113|   434k|    const __m128i highbyte =
  114|   434k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
  115|   434k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
  116|   434k|    const __m128i composed =
  117|   434k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
  118|   434k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
  119|   434k|    if (big_endian)
  ------------------
  |  Branch (119:9): [Folded, False: 434k]
  ------------------
  120|      0|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
  121|   434k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
  122|   434k|    utf16_output += 4; // Here we overflow by 8 bytes.
  123|   434k|  } else if (idx < 209) {
  ------------------
  |  Branch (123:14): [True: 65.5k, False: 712]
  ------------------
  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|  65.5k|    const __m128i sh = _mm_loadu_si128(
  135|  65.5k|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
  136|  65.5k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  137|  65.5k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f));
  138|  65.5k|    const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00));
  139|  65.5k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  140|  65.5k|    __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000));
  141|       |    // correct for spurious high bit
  142|  65.5k|    const __m128i correct =
  143|  65.5k|        _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1);
  144|  65.5k|    middlehighbyte = _mm_xor_si128(correct, middlehighbyte);
  145|  65.5k|    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|  65.5k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0xff000000));
  149|  65.5k|    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|  65.5k|    const __m128i composed =
  155|  65.5k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted),
  156|  65.5k|                     _mm_or_si128(highbyte_shifted, middlehighbyte_shifted));
  157|  65.5k|    const __m128i composedminus =
  158|  65.5k|        _mm_sub_epi32(composed, _mm_set1_epi32(0x10000));
  159|  65.5k|    const __m128i lowtenbits =
  160|  65.5k|        _mm_and_si128(composedminus, _mm_set1_epi32(0x3ff));
  161|       |    // Notice the 0x3ff mask:
  162|  65.5k|    const __m128i hightenbits =
  163|  65.5k|        _mm_and_si128(_mm_srli_epi32(composedminus, 10), _mm_set1_epi32(0x3ff));
  164|  65.5k|    const __m128i lowtenbitsadd =
  165|  65.5k|        _mm_add_epi32(lowtenbits, _mm_set1_epi32(0xDC00));
  166|  65.5k|    const __m128i hightenbitsadd =
  167|  65.5k|        _mm_add_epi32(hightenbits, _mm_set1_epi32(0xD800));
  168|  65.5k|    const __m128i lowtenbitsaddshifted = _mm_slli_epi32(lowtenbitsadd, 16);
  169|  65.5k|    __m128i surrogates = _mm_or_si128(hightenbitsadd, lowtenbitsaddshifted);
  170|  65.5k|    uint32_t basic_buffer[4];
  171|  65.5k|    uint32_t basic_buffer_swap[4];
  172|  65.5k|    if (big_endian) {
  ------------------
  |  Branch (172:9): [Folded, False: 65.5k]
  ------------------
  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|  65.5k|    _mm_storeu_si128((__m128i *)basic_buffer, composed);
  178|  65.5k|    uint32_t surrogate_buffer[4];
  179|  65.5k|    _mm_storeu_si128((__m128i *)surrogate_buffer, surrogates);
  180|   262k|    for (size_t i = 0; i < 3; i++) {
  ------------------
  |  Branch (180:24): [True: 196k, False: 65.5k]
  ------------------
  181|   196k|      if (basic_buffer[i] > 0x3c00000) {
  ------------------
  |  Branch (181:11): [True: 54.1k, False: 142k]
  ------------------
  182|  54.1k|        utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff);
  183|  54.1k|        utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16);
  184|  54.1k|        utf16_output += 2;
  185|   142k|      } else {
  186|   142k|        utf16_output[0] = big_endian ? uint16_t(basic_buffer_swap[i])
  ------------------
  |  Branch (186:27): [Folded, False: 142k]
  ------------------
  187|   142k|                                     : uint16_t(basic_buffer[i]);
  188|   142k|        utf16_output++;
  189|   142k|      }
  190|   196k|    }
  191|  65.5k|  } else {
  192|       |    // here we know that there is an error but we do not handle errors
  193|    712|  }
  194|  3.14M|  return consumed;
  195|  3.15M|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_128convert_masked_utf8_to_utf16ILNS_10endiannessE1EEEmPKcmRPDs:
   10|  3.00M|                                    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|  3.00M|  const __m128i swap =
   23|  3.00M|      _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   24|  3.00M|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   25|  3.00M|  const uint16_t input_utf8_end_of_code_point_mask =
   26|  3.00M|      utf8_end_of_code_point_mask & 0xfff;
   27|  3.00M|  if (utf8_end_of_code_point_mask == 0xfff) {
  ------------------
  |  Branch (27:7): [True: 9.13k, False: 2.99M]
  ------------------
   28|       |    // We process the data in chunks of 12 bytes.
   29|  9.13k|    __m256i ascii = _mm256_cvtepu8_epi16(in);
   30|  9.13k|    if (big_endian) {
  ------------------
  |  Branch (30:9): [True: 9.13k, Folded]
  ------------------
   31|  9.13k|      const __m256i swap256 = _mm256_setr_epi8(
   32|  9.13k|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   33|  9.13k|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   34|  9.13k|      ascii = _mm256_shuffle_epi8(ascii, swap256);
   35|  9.13k|    }
   36|  9.13k|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf16_output), ascii);
   37|  9.13k|    utf16_output += 12; // We wrote 12 16-bit characters.
   38|  9.13k|    return 12;          // We consumed 12 bytes.
   39|  9.13k|  }
   40|  2.99M|  if (((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa)) {
  ------------------
  |  Branch (40:7): [True: 23.5k, False: 2.96M]
  ------------------
   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|  23.5k|    const __m128i sh =
   45|  23.5k|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   46|  23.5k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   47|  23.5k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   48|  23.5k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   49|  23.5k|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   50|  23.5k|    if (big_endian)
  ------------------
  |  Branch (50:9): [True: 23.5k, Folded]
  ------------------
   51|  23.5k|      composed = _mm_shuffle_epi8(composed, swap);
   52|  23.5k|    _mm_storeu_si128((__m128i *)utf16_output, composed);
   53|  23.5k|    utf16_output += 8; // We wrote 16 bytes, 8 code points.
   54|  23.5k|    return 16;
   55|  23.5k|  }
   56|  2.96M|  if (input_utf8_end_of_code_point_mask == 0x924) {
  ------------------
  |  Branch (56:7): [True: 5.17k, False: 2.96M]
  ------------------
   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|  5.17k|    const __m128i sh =
   61|  5.17k|        _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1);
   62|  5.17k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   63|  5.17k|    const __m128i ascii =
   64|  5.17k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   65|  5.17k|    const __m128i middlebyte =
   66|  5.17k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
   67|  5.17k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
   68|  5.17k|    const __m128i highbyte =
   69|  5.17k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
   70|  5.17k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
   71|  5.17k|    const __m128i composed =
   72|  5.17k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
   73|  5.17k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
   74|  5.17k|    if (big_endian)
  ------------------
  |  Branch (74:9): [True: 5.17k, Folded]
  ------------------
   75|  5.17k|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
   76|  5.17k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
   77|  5.17k|    utf16_output += 4;
   78|  5.17k|    return 12;
   79|  5.17k|  }
   80|       |
   81|  2.96M|  const uint8_t idx = simdutf::tables::utf8_to_utf16::utf8bigindex
   82|  2.96M|      [input_utf8_end_of_code_point_mask][0];
   83|  2.96M|  const uint8_t consumed = simdutf::tables::utf8_to_utf16::utf8bigindex
   84|  2.96M|      [input_utf8_end_of_code_point_mask][1];
   85|  2.96M|  if (idx < 64) {
  ------------------
  |  Branch (85:7): [True: 2.67M, False: 286k]
  ------------------
   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|  2.67M|    const __m128i sh = _mm_loadu_si128(
   93|  2.67M|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
   94|  2.67M|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   95|  2.67M|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   96|  2.67M|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   97|  2.67M|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   98|  2.67M|    if (big_endian)
  ------------------
  |  Branch (98:9): [True: 2.67M, Folded]
  ------------------
   99|  2.67M|      composed = _mm_shuffle_epi8(composed, swap);
  100|  2.67M|    _mm_storeu_si128((__m128i *)utf16_output, composed);
  101|  2.67M|    utf16_output += 6; // We wrote 12 bytes, 6 code points. There is a potential
  102|       |                       // overflow of 4 bytes.
  103|  2.67M|  } else if (idx < 145) {
  ------------------
  |  Branch (103:14): [True: 221k, False: 65.3k]
  ------------------
  104|       |    // FOUR (4) input code-code units
  105|   221k|    const __m128i sh = _mm_loadu_si128(
  106|   221k|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
  107|   221k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  108|   221k|    const __m128i ascii =
  109|   221k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
  110|   221k|    const __m128i middlebyte =
  111|   221k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
  112|   221k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  113|   221k|    const __m128i highbyte =
  114|   221k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
  115|   221k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
  116|   221k|    const __m128i composed =
  117|   221k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
  118|   221k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
  119|   221k|    if (big_endian)
  ------------------
  |  Branch (119:9): [True: 221k, Folded]
  ------------------
  120|   221k|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
  121|   221k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
  122|   221k|    utf16_output += 4; // Here we overflow by 8 bytes.
  123|   221k|  } else if (idx < 209) {
  ------------------
  |  Branch (123:14): [True: 64.0k, False: 1.31k]
  ------------------
  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|  64.0k|    const __m128i sh = _mm_loadu_si128(
  135|  64.0k|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
  136|  64.0k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  137|  64.0k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f));
  138|  64.0k|    const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00));
  139|  64.0k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  140|  64.0k|    __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000));
  141|       |    // correct for spurious high bit
  142|  64.0k|    const __m128i correct =
  143|  64.0k|        _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1);
  144|  64.0k|    middlehighbyte = _mm_xor_si128(correct, middlehighbyte);
  145|  64.0k|    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|  64.0k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0xff000000));
  149|  64.0k|    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|  64.0k|    const __m128i composed =
  155|  64.0k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted),
  156|  64.0k|                     _mm_or_si128(highbyte_shifted, middlehighbyte_shifted));
  157|  64.0k|    const __m128i composedminus =
  158|  64.0k|        _mm_sub_epi32(composed, _mm_set1_epi32(0x10000));
  159|  64.0k|    const __m128i lowtenbits =
  160|  64.0k|        _mm_and_si128(composedminus, _mm_set1_epi32(0x3ff));
  161|       |    // Notice the 0x3ff mask:
  162|  64.0k|    const __m128i hightenbits =
  163|  64.0k|        _mm_and_si128(_mm_srli_epi32(composedminus, 10), _mm_set1_epi32(0x3ff));
  164|  64.0k|    const __m128i lowtenbitsadd =
  165|  64.0k|        _mm_add_epi32(lowtenbits, _mm_set1_epi32(0xDC00));
  166|  64.0k|    const __m128i hightenbitsadd =
  167|  64.0k|        _mm_add_epi32(hightenbits, _mm_set1_epi32(0xD800));
  168|  64.0k|    const __m128i lowtenbitsaddshifted = _mm_slli_epi32(lowtenbitsadd, 16);
  169|  64.0k|    __m128i surrogates = _mm_or_si128(hightenbitsadd, lowtenbitsaddshifted);
  170|  64.0k|    uint32_t basic_buffer[4];
  171|  64.0k|    uint32_t basic_buffer_swap[4];
  172|  64.0k|    if (big_endian) {
  ------------------
  |  Branch (172:9): [True: 64.0k, Folded]
  ------------------
  173|  64.0k|      _mm_storeu_si128((__m128i *)basic_buffer_swap,
  174|  64.0k|                       _mm_shuffle_epi8(composed, swap));
  175|  64.0k|      surrogates = _mm_shuffle_epi8(surrogates, swap);
  176|  64.0k|    }
  177|  64.0k|    _mm_storeu_si128((__m128i *)basic_buffer, composed);
  178|  64.0k|    uint32_t surrogate_buffer[4];
  179|  64.0k|    _mm_storeu_si128((__m128i *)surrogate_buffer, surrogates);
  180|   256k|    for (size_t i = 0; i < 3; i++) {
  ------------------
  |  Branch (180:24): [True: 192k, False: 64.0k]
  ------------------
  181|   192k|      if (basic_buffer[i] > 0x3c00000) {
  ------------------
  |  Branch (181:11): [True: 53.9k, False: 138k]
  ------------------
  182|  53.9k|        utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff);
  183|  53.9k|        utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16);
  184|  53.9k|        utf16_output += 2;
  185|   138k|      } else {
  186|   138k|        utf16_output[0] = big_endian ? uint16_t(basic_buffer_swap[i])
  ------------------
  |  Branch (186:27): [True: 138k, Folded]
  ------------------
  187|   138k|                                     : uint16_t(basic_buffer[i]);
  188|   138k|        utf16_output++;
  189|   138k|      }
  190|   192k|    }
  191|  64.0k|  } else {
  192|       |    // here we know that there is an error but we do not handle errors
  193|  1.31k|  }
  194|  2.96M|  return consumed;
  195|  2.96M|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_128convert_masked_utf8_to_utf32EPKcmRPDi:
    9|  2.58M|                                    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|  2.58M|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   22|  2.58M|  const uint16_t input_utf8_end_of_code_point_mask =
   23|  2.58M|      utf8_end_of_code_point_mask & 0xfff;
   24|  2.58M|  if (utf8_end_of_code_point_mask == 0xfff) {
  ------------------
  |  Branch (24:7): [True: 7.57k, False: 2.57M]
  ------------------
   25|       |    // We process the data in chunks of 12 bytes.
   26|  7.57k|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
   27|  7.57k|                        _mm256_cvtepu8_epi32(in));
   28|  7.57k|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output + 8),
   29|  7.57k|                        _mm256_cvtepu8_epi32(_mm_srli_si128(in, 8)));
   30|  7.57k|    utf32_output += 12; // We wrote 12 32-bit characters.
   31|  7.57k|    return 12;          // We consumed 12 bytes.
   32|  7.57k|  }
   33|  2.57M|  if (((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa)) {
  ------------------
  |  Branch (33:7): [True: 17.0k, False: 2.56M]
  ------------------
   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|  17.0k|    const __m128i sh =
   38|  17.0k|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   39|  17.0k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   40|  17.0k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   41|  17.0k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   42|  17.0k|    const __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   43|  17.0k|    _mm256_storeu_si256((__m256i *)utf32_output,
   44|  17.0k|                        _mm256_cvtepu16_epi32(composed));
   45|  17.0k|    utf32_output += 8; // We wrote 16 bytes, 8 code points.
   46|  17.0k|    return 16;
   47|  17.0k|  }
   48|  2.56M|  if (input_utf8_end_of_code_point_mask == 0x924) {
  ------------------
  |  Branch (48:7): [True: 2.91k, False: 2.55M]
  ------------------
   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|  2.91k|    const __m128i sh =
   53|  2.91k|        _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1);
   54|  2.91k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   55|  2.91k|    const __m128i ascii =
   56|  2.91k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   57|  2.91k|    const __m128i middlebyte =
   58|  2.91k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
   59|  2.91k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
   60|  2.91k|    const __m128i highbyte =
   61|  2.91k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
   62|  2.91k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
   63|  2.91k|    const __m128i composed =
   64|  2.91k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
   65|  2.91k|    _mm_storeu_si128((__m128i *)utf32_output, composed);
   66|  2.91k|    utf32_output += 4;
   67|  2.91k|    return 12;
   68|  2.91k|  }
   69|       |  /// We do not have a fast path available, so we fallback.
   70|       |
   71|  2.55M|  const uint8_t idx =
   72|  2.55M|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0];
   73|  2.55M|  const uint8_t consumed =
   74|  2.55M|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1];
   75|  2.55M|  if (idx < 64) {
  ------------------
  |  Branch (75:7): [True: 2.25M, False: 304k]
  ------------------
   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|  2.25M|    const __m128i sh =
   83|  2.25M|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
   84|  2.25M|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   85|  2.25M|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   86|  2.25M|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   87|  2.25M|    const __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   88|  2.25M|    _mm256_storeu_si256((__m256i *)utf32_output,
   89|  2.25M|                        _mm256_cvtepu16_epi32(composed));
   90|  2.25M|    utf32_output += 6; // We wrote 24 bytes, 6 code points. There is a potential
   91|       |    // overflow of 32 - 24 = 8 bytes.
   92|  2.25M|  } else if (idx < 145) {
  ------------------
  |  Branch (92:14): [True: 253k, False: 51.8k]
  ------------------
   93|       |    // FOUR (4) input code-code units
   94|   253k|    const __m128i sh =
   95|   253k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
   96|   253k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   97|   253k|    const __m128i ascii =
   98|   253k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   99|   253k|    const __m128i middlebyte =
  100|   253k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
  101|   253k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  102|   253k|    const __m128i highbyte =
  103|   253k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
  104|   253k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
  105|   253k|    const __m128i composed =
  106|   253k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
  107|   253k|    _mm_storeu_si128((__m128i *)utf32_output, composed);
  108|   253k|    utf32_output += 4;
  109|   253k|  } else if (idx < 209) {
  ------------------
  |  Branch (109:14): [True: 51.1k, False: 668]
  ------------------
  110|       |    // TWO (2) input code-code units
  111|  51.1k|    const __m128i sh =
  112|  51.1k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  113|  51.1k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  114|  51.1k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f));
  115|  51.1k|    const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00));
  116|  51.1k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  117|  51.1k|    __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000));
  118|       |    // correct for spurious high bit
  119|  51.1k|    const __m128i correct =
  120|  51.1k|        _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1);
  121|  51.1k|    middlehighbyte = _mm_xor_si128(correct, middlehighbyte);
  122|  51.1k|    const __m128i middlehighbyte_shifted = _mm_srli_epi32(middlehighbyte, 4);
  123|  51.1k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0x07000000));
  124|  51.1k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 6);
  125|  51.1k|    const __m128i composed =
  126|  51.1k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted),
  127|  51.1k|                     _mm_or_si128(highbyte_shifted, middlehighbyte_shifted));
  128|  51.1k|    _mm_storeu_si128((__m128i *)utf32_output, composed);
  129|  51.1k|    utf32_output +=
  130|  51.1k|        3; // We wrote 3 * 4 bytes, there is a potential overflow of 4 bytes.
  131|  51.1k|  } else {
  132|       |    // here we know that there is an error but we do not handle errors
  133|    668|  }
  134|  2.55M|  return consumed;
  135|  2.56M|}

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

_ZNK7simdutf7haswell14implementation13validate_utf8EPKcm:
  266|  3.48k|implementation::validate_utf8(const char *buf, size_t len) const noexcept {
  267|  3.48k|  return haswell::utf8_validation::generic_validate_utf8(buf, len);
  268|  3.48k|}
_ZNK7simdutf7haswell14implementation25validate_utf8_with_errorsEPKcm:
  273|  3.48k|    const char *buf, size_t len) const noexcept {
  274|  3.48k|  return haswell::utf8_validation::generic_validate_utf8_with_errors(buf, len);
  275|  3.48k|}
_ZNK7simdutf7haswell14implementation16validate_utf16leEPKDsm:
  312|  1.35k|                                 size_t len) const noexcept {
  313|  1.35k|  if (simdutf_unlikely(len == 0)) {
  ------------------
  |  |   93|  1.35k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 17, False: 1.33k]
  |  |  ------------------
  ------------------
  314|       |    // empty input is valid UTF-16. protect the implementation from
  315|       |    // handling nullptr
  316|     17|    return true;
  317|     17|  }
  318|  1.33k|  const auto res =
  319|  1.33k|      haswell::utf16::validate_utf16_with_errors<endianness::LITTLE>(buf, len);
  320|  1.33k|  if (res.is_err()) {
  ------------------
  |  Branch (320:7): [True: 88, False: 1.25k]
  ------------------
  321|     88|    return false;
  322|     88|  }
  323|       |
  324|  1.25k|  if (res.count == len) {
  ------------------
  |  Branch (324:7): [True: 0, False: 1.25k]
  ------------------
  325|      0|    return true;
  326|      0|  }
  327|       |
  328|  1.25k|  return scalar::utf16::validate<endianness::LITTLE>(buf + res.count,
  329|  1.25k|                                                     len - res.count);
  330|  1.25k|}
_ZNK7simdutf7haswell14implementation16validate_utf16beEPKDsm:
  336|  1.33k|                                 size_t len) const noexcept {
  337|  1.33k|  if (simdutf_unlikely(len == 0)) {
  ------------------
  |  |   93|  1.33k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 16, False: 1.32k]
  |  |  ------------------
  ------------------
  338|       |    // empty input is valid UTF-16. protect the implementation from
  339|       |    // handling nullptr
  340|     16|    return true;
  341|     16|  }
  342|  1.32k|  const auto res =
  343|  1.32k|      haswell::utf16::validate_utf16_with_errors<endianness::BIG>(buf, len);
  344|  1.32k|  if (res.is_err()) {
  ------------------
  |  Branch (344:7): [True: 102, False: 1.22k]
  ------------------
  345|    102|    return false;
  346|    102|  }
  347|       |
  348|  1.22k|  if (res.count == len) {
  ------------------
  |  Branch (348:7): [True: 0, False: 1.22k]
  ------------------
  349|      0|    return true;
  350|      0|  }
  351|       |
  352|  1.22k|  return scalar::utf16::validate<endianness::BIG>(buf + res.count,
  353|  1.22k|                                                  len - res.count);
  354|  1.22k|}
_ZNK7simdutf7haswell14implementation28validate_utf16le_with_errorsEPKDsm:
  357|  1.35k|    const char16_t *buf, size_t len) const noexcept {
  358|       |
  359|  1.35k|  const result res =
  360|  1.35k|      haswell::utf16::validate_utf16_with_errors<endianness::LITTLE>(buf, len);
  361|  1.35k|  if (res.count != len) {
  ------------------
  |  Branch (361:7): [True: 1.33k, False: 17]
  ------------------
  362|  1.33k|    const result scalar_res =
  363|  1.33k|        scalar::utf16::validate_with_errors<endianness::LITTLE>(
  364|  1.33k|            buf + res.count, len - res.count);
  365|  1.33k|    return result(scalar_res.error, res.count + scalar_res.count);
  366|  1.33k|  } else {
  367|     17|    return res;
  368|     17|  }
  369|  1.35k|}
_ZNK7simdutf7haswell14implementation28validate_utf16be_with_errorsEPKDsm:
  372|  1.33k|    const char16_t *buf, size_t len) const noexcept {
  373|  1.33k|  const result res =
  374|  1.33k|      haswell::utf16::validate_utf16_with_errors<endianness::BIG>(buf, len);
  375|  1.33k|  if (res.count != len) {
  ------------------
  |  Branch (375:7): [True: 1.32k, False: 16]
  ------------------
  376|  1.32k|    const result scalar_res =
  377|  1.32k|        scalar::utf16::validate_with_errors<endianness::BIG>(buf + res.count,
  378|  1.32k|                                                             len - res.count);
  379|  1.32k|    return result(scalar_res.error, res.count + scalar_res.count);
  380|  1.32k|  } else {
  381|     16|    return res;
  382|     16|  }
  383|  1.33k|}
_ZNK7simdutf7haswell14implementation14validate_utf32EPKDim:
  398|  2.63k|implementation::validate_utf32(const char32_t *buf, size_t len) const noexcept {
  399|  2.63k|  return utf32::validate(buf, len);
  400|  2.63k|}
_ZNK7simdutf7haswell14implementation26validate_utf32_with_errorsEPKDim:
  405|  2.63k|    const char32_t *buf, size_t len) const noexcept {
  406|  2.63k|  return utf32::validate_with_errors(buf, len);
  407|  2.63k|}
_ZNK7simdutf7haswell14implementation22convert_latin1_to_utf8EPKcmPc:
  412|    604|    const char *buf, size_t len, char *utf8_output) const noexcept {
  413|    604|  std::pair<const char *, char *> ret =
  414|    604|      avx2_convert_latin1_to_utf8(buf, len, utf8_output);
  415|    604|  size_t converted_chars = ret.second - utf8_output;
  416|       |
  417|    604|  if (ret.first != buf + len) {
  ------------------
  |  Branch (417:7): [True: 600, False: 4]
  ------------------
  418|    600|    const size_t scalar_converted_chars = scalar::latin1_to_utf8::convert(
  419|    600|        ret.first, len - (ret.first - buf), ret.second);
  420|    600|    converted_chars += scalar_converted_chars;
  421|    600|  }
  422|       |
  423|    604|  return converted_chars;
  424|    604|}
_ZNK7simdutf7haswell14implementation25convert_latin1_to_utf16leEPKcmPDs:
  429|     76|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  430|     76|  std::pair<const char *, char16_t *> ret =
  431|     76|      avx2_convert_latin1_to_utf16<endianness::LITTLE>(buf, len, utf16_output);
  432|     76|  if (ret.first == nullptr) {
  ------------------
  |  Branch (432:7): [True: 4, False: 72]
  ------------------
  433|      4|    return 0;
  434|      4|  }
  435|     72|  size_t converted_chars = ret.second - utf16_output;
  436|     72|  if (ret.first != buf + len) {
  ------------------
  |  Branch (436:7): [True: 58, False: 14]
  ------------------
  437|     58|    const size_t scalar_converted_chars =
  438|     58|        scalar::latin1_to_utf16::convert<endianness::LITTLE>(
  439|     58|            ret.first, len - (ret.first - buf), ret.second);
  440|     58|    if (scalar_converted_chars == 0) {
  ------------------
  |  Branch (440:9): [True: 0, False: 58]
  ------------------
  441|      0|      return 0;
  442|      0|    }
  443|     58|    converted_chars += scalar_converted_chars;
  444|     58|  }
  445|     72|  return converted_chars;
  446|     72|}
_ZNK7simdutf7haswell14implementation25convert_latin1_to_utf16beEPKcmPDs:
  449|     96|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  450|     96|  std::pair<const char *, char16_t *> ret =
  451|     96|      avx2_convert_latin1_to_utf16<endianness::BIG>(buf, len, utf16_output);
  452|     96|  if (ret.first == nullptr) {
  ------------------
  |  Branch (452:7): [True: 4, False: 92]
  ------------------
  453|      4|    return 0;
  454|      4|  }
  455|     92|  size_t converted_chars = ret.second - utf16_output;
  456|     92|  if (ret.first != buf + len) {
  ------------------
  |  Branch (456:7): [True: 78, False: 14]
  ------------------
  457|     78|    const size_t scalar_converted_chars =
  458|     78|        scalar::latin1_to_utf16::convert<endianness::BIG>(
  459|     78|            ret.first, len - (ret.first - buf), ret.second);
  460|     78|    if (scalar_converted_chars == 0) {
  ------------------
  |  Branch (460:9): [True: 0, False: 78]
  ------------------
  461|      0|      return 0;
  462|      0|    }
  463|     78|    converted_chars += scalar_converted_chars;
  464|     78|  }
  465|     92|  return converted_chars;
  466|     92|}
_ZNK7simdutf7haswell14implementation23convert_latin1_to_utf32EPKcmPDi:
  471|    124|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  472|    124|  std::pair<const char *, char32_t *> ret =
  473|    124|      avx2_convert_latin1_to_utf32(buf, len, utf32_output);
  474|    124|  if (ret.first == nullptr) {
  ------------------
  |  Branch (474:7): [True: 4, False: 120]
  ------------------
  475|      4|    return 0;
  476|      4|  }
  477|    120|  size_t converted_chars = ret.second - utf32_output;
  478|    120|  if (ret.first != buf + len) {
  ------------------
  |  Branch (478:7): [True: 74, False: 46]
  ------------------
  479|     74|    const size_t scalar_converted_chars = scalar::latin1_to_utf32::convert(
  480|     74|        ret.first, len - (ret.first - buf), ret.second);
  481|     74|    if (scalar_converted_chars == 0) {
  ------------------
  |  Branch (481:9): [True: 0, False: 74]
  ------------------
  482|      0|      return 0;
  483|      0|    }
  484|     74|    converted_chars += scalar_converted_chars;
  485|     74|  }
  486|    120|  return converted_chars;
  487|    120|}
_ZNK7simdutf7haswell14implementation22convert_utf8_to_latin1EPKcmPc:
  492|    586|    const char *buf, size_t len, char *latin1_output) const noexcept {
  493|    586|  utf8_to_latin1::validating_transcoder converter;
  494|    586|  return converter.convert(buf, len, latin1_output);
  495|    586|}
_ZNK7simdutf7haswell14implementation34convert_utf8_to_latin1_with_errorsEPKcmPc:
  498|    512|    const char *buf, size_t len, char *latin1_output) const noexcept {
  499|    512|  utf8_to_latin1::validating_transcoder converter;
  500|    512|  return converter.convert_with_errors(buf, len, latin1_output);
  501|    512|}
_ZNK7simdutf7haswell14implementation23convert_utf8_to_utf16leEPKcmPDs:
  511|    776|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  512|    776|  utf8_to_utf16::validating_transcoder converter;
  513|    776|  return converter.convert<endianness::LITTLE>(buf, len, utf16_output);
  514|    776|}
_ZNK7simdutf7haswell14implementation23convert_utf8_to_utf16beEPKcmPDs:
  517|    794|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  518|    794|  utf8_to_utf16::validating_transcoder converter;
  519|    794|  return converter.convert<endianness::BIG>(buf, len, utf16_output);
  520|    794|}
_ZNK7simdutf7haswell14implementation35convert_utf8_to_utf16le_with_errorsEPKcmPDs:
  523|    610|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  524|    610|  utf8_to_utf16::validating_transcoder converter;
  525|    610|  return converter.convert_with_errors<endianness::LITTLE>(buf, len,
  526|    610|                                                           utf16_output);
  527|    610|}
_ZNK7simdutf7haswell14implementation35convert_utf8_to_utf16be_with_errorsEPKcmPDs:
  530|    706|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  531|    706|  utf8_to_utf16::validating_transcoder converter;
  532|    706|  return converter.convert_with_errors<endianness::BIG>(buf, len, utf16_output);
  533|    706|}
_ZNK7simdutf7haswell14implementation29convert_valid_utf8_to_utf16leEPKcmPDs:
  536|    450|    const char *input, size_t size, char16_t *utf16_output) const noexcept {
  537|    450|  return utf8_to_utf16::convert_valid<endianness::LITTLE>(input, size,
  538|    450|                                                          utf16_output);
  539|    450|}
_ZNK7simdutf7haswell14implementation29convert_valid_utf8_to_utf16beEPKcmPDs:
  542|    510|    const char *input, size_t size, char16_t *utf16_output) const noexcept {
  543|    510|  return utf8_to_utf16::convert_valid<endianness::BIG>(input, size,
  544|    510|                                                       utf16_output);
  545|    510|}
_ZNK7simdutf7haswell14implementation21convert_utf8_to_utf32EPKcmPDi:
  550|    758|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  551|    758|  utf8_to_utf32::validating_transcoder converter;
  552|    758|  return converter.convert(buf, len, utf32_output);
  553|    758|}
_ZNK7simdutf7haswell14implementation33convert_utf8_to_utf32_with_errorsEPKcmPDi:
  556|    746|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  557|    746|  utf8_to_utf32::validating_transcoder converter;
  558|    746|  return converter.convert_with_errors(buf, len, utf32_output);
  559|    746|}
_ZNK7simdutf7haswell14implementation27convert_valid_utf8_to_utf32EPKcmPDi:
  562|    464|    const char *input, size_t size, char32_t *utf32_output) const noexcept {
  563|    464|  return utf8_to_utf32::convert_valid(input, size, utf32_output);
  564|    464|}
_ZNK7simdutf7haswell14implementation25convert_utf16le_to_latin1EPKDsmPc:
  569|    124|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  570|    124|  std::pair<const char16_t *, char *> ret =
  571|    124|      haswell::avx2_convert_utf16_to_latin1<endianness::LITTLE>(buf, len,
  572|    124|                                                                latin1_output);
  573|    124|  if (ret.first == nullptr) {
  ------------------
  |  Branch (573:7): [True: 26, False: 98]
  ------------------
  574|     26|    return 0;
  575|     26|  }
  576|     98|  size_t saved_bytes = ret.second - latin1_output;
  577|     98|  if (ret.first != buf + len) {
  ------------------
  |  Branch (577:7): [True: 84, False: 14]
  ------------------
  578|     84|    const size_t scalar_saved_bytes =
  579|     84|        scalar::utf16_to_latin1::convert<endianness::LITTLE>(
  580|     84|            ret.first, len - (ret.first - buf), ret.second);
  581|     84|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (581:9): [True: 56, False: 28]
  ------------------
  582|     56|      return 0;
  583|     56|    }
  584|     28|    saved_bytes += scalar_saved_bytes;
  585|     28|  }
  586|     42|  return saved_bytes;
  587|     98|}
_ZNK7simdutf7haswell14implementation25convert_utf16be_to_latin1EPKDsmPc:
  590|    114|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  591|    114|  std::pair<const char16_t *, char *> ret =
  592|    114|      haswell::avx2_convert_utf16_to_latin1<endianness::BIG>(buf, len,
  593|    114|                                                             latin1_output);
  594|    114|  if (ret.first == nullptr) {
  ------------------
  |  Branch (594:7): [True: 28, False: 86]
  ------------------
  595|     28|    return 0;
  596|     28|  }
  597|     86|  size_t saved_bytes = ret.second - latin1_output;
  598|     86|  if (ret.first != buf + len) {
  ------------------
  |  Branch (598:7): [True: 74, False: 12]
  ------------------
  599|     74|    const size_t scalar_saved_bytes =
  600|     74|        scalar::utf16_to_latin1::convert<endianness::BIG>(
  601|     74|            ret.first, len - (ret.first - buf), ret.second);
  602|     74|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (602:9): [True: 38, False: 36]
  ------------------
  603|     38|      return 0;
  604|     38|    }
  605|     36|    saved_bytes += scalar_saved_bytes;
  606|     36|  }
  607|     48|  return saved_bytes;
  608|     86|}
_ZNK7simdutf7haswell14implementation37convert_utf16le_to_latin1_with_errorsEPKDsmPc:
  612|    278|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  613|    278|  std::pair<result, char *> ret =
  614|    278|      avx2_convert_utf16_to_latin1_with_errors<endianness::LITTLE>(
  615|    278|          buf, len, latin1_output);
  616|    278|  if (ret.first.error) {
  ------------------
  |  Branch (616:7): [True: 116, False: 162]
  ------------------
  617|    116|    return ret.first;
  618|    116|  } // Can return directly since scalar fallback already found correct
  619|       |    // ret.first.count
  620|    162|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (620:7): [True: 124, False: 38]
  ------------------
  621|    124|    result scalar_res =
  622|    124|        scalar::utf16_to_latin1::convert_with_errors<endianness::LITTLE>(
  623|    124|            buf + ret.first.count, len - ret.first.count, ret.second);
  624|    124|    if (scalar_res.error) {
  ------------------
  |  Branch (624:9): [True: 68, False: 56]
  ------------------
  625|     68|      scalar_res.count += ret.first.count;
  626|     68|      return scalar_res;
  627|     68|    } else {
  628|     56|      ret.second += scalar_res.count;
  629|     56|    }
  630|    124|  }
  631|     94|  ret.first.count =
  632|     94|      ret.second -
  633|     94|      latin1_output; // Set count to the number of 8-bit code units written
  634|     94|  return ret.first;
  635|    162|}
_ZNK7simdutf7haswell14implementation37convert_utf16be_to_latin1_with_errorsEPKDsmPc:
  639|    266|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  640|    266|  std::pair<result, char *> ret =
  641|    266|      avx2_convert_utf16_to_latin1_with_errors<endianness::BIG>(buf, len,
  642|    266|                                                                latin1_output);
  643|    266|  if (ret.first.error) {
  ------------------
  |  Branch (643:7): [True: 114, False: 152]
  ------------------
  644|    114|    return ret.first;
  645|    114|  } // Can return directly since scalar fallback already found correct
  646|       |    // ret.first.count
  647|    152|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (647:7): [True: 118, False: 34]
  ------------------
  648|    118|    result scalar_res =
  649|    118|        scalar::utf16_to_latin1::convert_with_errors<endianness::BIG>(
  650|    118|            buf + ret.first.count, len - ret.first.count, ret.second);
  651|    118|    if (scalar_res.error) {
  ------------------
  |  Branch (651:9): [True: 60, False: 58]
  ------------------
  652|     60|      scalar_res.count += ret.first.count;
  653|     60|      return scalar_res;
  654|     60|    } else {
  655|     58|      ret.second += scalar_res.count;
  656|     58|    }
  657|    118|  }
  658|     92|  ret.first.count =
  659|     92|      ret.second -
  660|     92|      latin1_output; // Set count to the number of 8-bit code units written
  661|     92|  return ret.first;
  662|    152|}
_ZNK7simdutf7haswell14implementation23convert_utf16le_to_utf8EPKDsmPc:
  679|    842|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  680|    842|  std::pair<const char16_t *, char *> ret =
  681|    842|      haswell::avx2_convert_utf16_to_utf8<endianness::LITTLE>(buf, len,
  682|    842|                                                              utf8_output);
  683|    842|  if (ret.first == nullptr) {
  ------------------
  |  Branch (683:7): [True: 124, False: 718]
  ------------------
  684|    124|    return 0;
  685|    124|  }
  686|    718|  size_t saved_bytes = ret.second - utf8_output;
  687|    718|  if (ret.first != buf + len) {
  ------------------
  |  Branch (687:7): [True: 716, False: 2]
  ------------------
  688|    716|    const size_t scalar_saved_bytes =
  689|    716|        scalar::utf16_to_utf8::convert<endianness::LITTLE>(
  690|    716|            ret.first, len - (ret.first - buf), ret.second);
  691|    716|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (691:9): [True: 80, False: 636]
  ------------------
  692|     80|      return 0;
  693|     80|    }
  694|    636|    saved_bytes += scalar_saved_bytes;
  695|    636|  }
  696|    638|  return saved_bytes;
  697|    718|}
_ZNK7simdutf7haswell14implementation23convert_utf16be_to_utf8EPKDsmPc:
  700|    798|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  701|    798|  std::pair<const char16_t *, char *> ret =
  702|    798|      haswell::avx2_convert_utf16_to_utf8<endianness::BIG>(buf, len,
  703|    798|                                                           utf8_output);
  704|    798|  if (ret.first == nullptr) {
  ------------------
  |  Branch (704:7): [True: 110, False: 688]
  ------------------
  705|    110|    return 0;
  706|    110|  }
  707|    688|  size_t saved_bytes = ret.second - utf8_output;
  708|    688|  if (ret.first != buf + len) {
  ------------------
  |  Branch (708:7): [True: 686, False: 2]
  ------------------
  709|    686|    const size_t scalar_saved_bytes =
  710|    686|        scalar::utf16_to_utf8::convert<endianness::BIG>(
  711|    686|            ret.first, len - (ret.first - buf), ret.second);
  712|    686|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (712:9): [True: 54, False: 632]
  ------------------
  713|     54|      return 0;
  714|     54|    }
  715|    632|    saved_bytes += scalar_saved_bytes;
  716|    632|  }
  717|    634|  return saved_bytes;
  718|    688|}
_ZNK7simdutf7haswell14implementation35convert_utf16le_to_utf8_with_errorsEPKDsmPc:
  721|    642|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  722|       |  // ret.first.count is always the position in the buffer, not the number of
  723|       |  // code units written even if finished
  724|    642|  std::pair<result, char *> ret =
  725|    642|      haswell::avx2_convert_utf16_to_utf8_with_errors<endianness::LITTLE>(
  726|    642|          buf, len, utf8_output);
  727|    642|  if (ret.first.error) {
  ------------------
  |  Branch (727:7): [True: 158, False: 484]
  ------------------
  728|    158|    return ret.first;
  729|    158|  } // Can return directly since scalar fallback already found correct
  730|       |    // ret.first.count
  731|    484|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (731:7): [True: 480, False: 4]
  ------------------
  732|    480|    result scalar_res =
  733|    480|        scalar::utf16_to_utf8::convert_with_errors<endianness::LITTLE>(
  734|    480|            buf + ret.first.count, len - ret.first.count, ret.second);
  735|    480|    if (scalar_res.error) {
  ------------------
  |  Branch (735:9): [True: 82, False: 398]
  ------------------
  736|     82|      scalar_res.count += ret.first.count;
  737|     82|      return scalar_res;
  738|    398|    } else {
  739|    398|      ret.second += scalar_res.count;
  740|    398|    }
  741|    480|  }
  742|    402|  ret.first.count =
  743|    402|      ret.second -
  744|    402|      utf8_output; // Set count to the number of 8-bit code units written
  745|    402|  return ret.first;
  746|    484|}
_ZNK7simdutf7haswell14implementation35convert_utf16be_to_utf8_with_errorsEPKDsmPc:
  749|    654|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  750|       |  // ret.first.count is always the position in the buffer, not the number of
  751|       |  // code units written even if finished
  752|    654|  std::pair<result, char *> ret =
  753|    654|      haswell::avx2_convert_utf16_to_utf8_with_errors<endianness::BIG>(
  754|    654|          buf, len, utf8_output);
  755|    654|  if (ret.first.error) {
  ------------------
  |  Branch (755:7): [True: 180, False: 474]
  ------------------
  756|    180|    return ret.first;
  757|    180|  } // Can return directly since scalar fallback already found correct
  758|       |    // ret.first.count
  759|    474|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (759:7): [True: 470, False: 4]
  ------------------
  760|    470|    result scalar_res =
  761|    470|        scalar::utf16_to_utf8::convert_with_errors<endianness::BIG>(
  762|    470|            buf + ret.first.count, len - ret.first.count, ret.second);
  763|    470|    if (scalar_res.error) {
  ------------------
  |  Branch (763:9): [True: 92, False: 378]
  ------------------
  764|     92|      scalar_res.count += ret.first.count;
  765|     92|      return scalar_res;
  766|    378|    } else {
  767|    378|      ret.second += scalar_res.count;
  768|    378|    }
  769|    470|  }
  770|    382|  ret.first.count =
  771|    382|      ret.second -
  772|    382|      utf8_output; // Set count to the number of 8-bit code units written
  773|    382|  return ret.first;
  774|    474|}
_ZNK7simdutf7haswell14implementation29convert_valid_utf16le_to_utf8EPKDsmPc:
  777|    406|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  778|    406|  return convert_utf16le_to_utf8(buf, len, utf8_output);
  779|    406|}
_ZNK7simdutf7haswell14implementation29convert_valid_utf16be_to_utf8EPKDsmPc:
  782|    452|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  783|    452|  return convert_utf16be_to_utf8(buf, len, utf8_output);
  784|    452|}
_ZNK7simdutf7haswell14implementation21convert_utf32_to_utf8EPKDimPc:
  789|    864|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  790|    864|  std::pair<const char32_t *, char *> ret =
  791|    864|      avx2_convert_utf32_to_utf8(buf, len, utf8_output);
  792|    864|  if (ret.first == nullptr) {
  ------------------
  |  Branch (792:7): [True: 298, False: 566]
  ------------------
  793|    298|    return 0;
  794|    298|  }
  795|    566|  size_t saved_bytes = ret.second - utf8_output;
  796|    566|  if (ret.first != buf + len) {
  ------------------
  |  Branch (796:7): [True: 564, False: 2]
  ------------------
  797|    564|    const size_t scalar_saved_bytes = scalar::utf32_to_utf8::convert(
  798|    564|        ret.first, len - (ret.first - buf), ret.second);
  799|    564|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (799:9): [True: 256, False: 308]
  ------------------
  800|    256|      return 0;
  801|    256|    }
  802|    308|    saved_bytes += scalar_saved_bytes;
  803|    308|  }
  804|    310|  return saved_bytes;
  805|    566|}
_ZNK7simdutf7haswell14implementation23convert_utf32_to_latin1EPKDimPc:
  810|    228|    const char32_t *buf, size_t len, char *latin1_output) const noexcept {
  811|    228|  std::pair<const char32_t *, char *> ret =
  812|    228|      avx2_convert_utf32_to_latin1(buf, len, latin1_output);
  813|    228|  if (ret.first == nullptr) {
  ------------------
  |  Branch (813:7): [True: 50, False: 178]
  ------------------
  814|     50|    return 0;
  815|     50|  }
  816|    178|  size_t saved_bytes = ret.second - latin1_output;
  817|    178|  if (ret.first != buf + len) {
  ------------------
  |  Branch (817:7): [True: 166, False: 12]
  ------------------
  818|    166|    const size_t scalar_saved_bytes = scalar::utf32_to_latin1::convert(
  819|    166|        ret.first, len - (ret.first - buf), ret.second);
  820|    166|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (820:9): [True: 124, False: 42]
  ------------------
  821|    124|      return 0;
  822|    124|    }
  823|     42|    saved_bytes += scalar_saved_bytes;
  824|     42|  }
  825|     54|  return saved_bytes;
  826|    178|}
_ZNK7simdutf7haswell14implementation35convert_utf32_to_latin1_with_errorsEPKDimPc:
  829|    436|    const char32_t *buf, size_t len, char *latin1_output) const noexcept {
  830|       |  // ret.first.count is always the position in the buffer, not the number of
  831|       |  // code units written even if finished
  832|    436|  std::pair<result, char *> ret =
  833|    436|      avx2_convert_utf32_to_latin1_with_errors(buf, len, latin1_output);
  834|    436|  if (ret.first.count != len) {
  ------------------
  |  Branch (834:7): [True: 418, False: 18]
  ------------------
  835|    418|    result scalar_res = scalar::utf32_to_latin1::convert_with_errors(
  836|    418|        buf + ret.first.count, len - ret.first.count, ret.second);
  837|    418|    if (scalar_res.error) {
  ------------------
  |  Branch (837:9): [True: 394, False: 24]
  ------------------
  838|    394|      scalar_res.count += ret.first.count;
  839|    394|      return scalar_res;
  840|    394|    } else {
  841|     24|      ret.second += scalar_res.count;
  842|     24|    }
  843|    418|  }
  844|     42|  ret.first.count =
  845|     42|      ret.second -
  846|     42|      latin1_output; // Set count to the number of 8-bit code units written
  847|     42|  return ret.first;
  848|    436|}
_ZNK7simdutf7haswell14implementation33convert_utf32_to_utf8_with_errorsEPKDimPc:
  858|    832|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  859|       |  // ret.first.count is always the position in the buffer, not the number of
  860|       |  // code units written even if finished
  861|    832|  std::pair<result, char *> ret =
  862|    832|      haswell::avx2_convert_utf32_to_utf8_with_errors(buf, len, utf8_output);
  863|    832|  if (ret.first.count != len) {
  ------------------
  |  Branch (863:7): [True: 828, False: 4]
  ------------------
  864|    828|    result scalar_res = scalar::utf32_to_utf8::convert_with_errors(
  865|    828|        buf + ret.first.count, len - ret.first.count, ret.second);
  866|    828|    if (scalar_res.error) {
  ------------------
  |  Branch (866:9): [True: 618, False: 210]
  ------------------
  867|    618|      scalar_res.count += ret.first.count;
  868|    618|      return scalar_res;
  869|    618|    } else {
  870|    210|      ret.second += scalar_res.count;
  871|    210|    }
  872|    828|  }
  873|    214|  ret.first.count =
  874|    214|      ret.second -
  875|    214|      utf8_output; // Set count to the number of 8-bit code units written
  876|    214|  return ret.first;
  877|    832|}
_ZNK7simdutf7haswell14implementation24convert_utf16le_to_utf32EPKDsmPDi:
  882|    454|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  883|    454|  std::pair<const char16_t *, char32_t *> ret =
  884|    454|      haswell::avx2_convert_utf16_to_utf32<endianness::LITTLE>(buf, len,
  885|    454|                                                               utf32_output);
  886|    454|  if (ret.first == nullptr) {
  ------------------
  |  Branch (886:7): [True: 124, False: 330]
  ------------------
  887|    124|    return 0;
  888|    124|  }
  889|    330|  size_t saved_bytes = ret.second - utf32_output;
  890|    330|  if (ret.first != buf + len) {
  ------------------
  |  Branch (890:7): [True: 274, False: 56]
  ------------------
  891|    274|    const size_t scalar_saved_bytes =
  892|    274|        scalar::utf16_to_utf32::convert<endianness::LITTLE>(
  893|    274|            ret.first, len - (ret.first - buf), ret.second);
  894|    274|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (894:9): [True: 82, False: 192]
  ------------------
  895|     82|      return 0;
  896|     82|    }
  897|    192|    saved_bytes += scalar_saved_bytes;
  898|    192|  }
  899|    248|  return saved_bytes;
  900|    330|}
_ZNK7simdutf7haswell14implementation24convert_utf16be_to_utf32EPKDsmPDi:
  903|    422|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  904|    422|  std::pair<const char16_t *, char32_t *> ret =
  905|    422|      haswell::avx2_convert_utf16_to_utf32<endianness::BIG>(buf, len,
  906|    422|                                                            utf32_output);
  907|    422|  if (ret.first == nullptr) {
  ------------------
  |  Branch (907:7): [True: 88, False: 334]
  ------------------
  908|     88|    return 0;
  909|     88|  }
  910|    334|  size_t saved_bytes = ret.second - utf32_output;
  911|    334|  if (ret.first != buf + len) {
  ------------------
  |  Branch (911:7): [True: 290, False: 44]
  ------------------
  912|    290|    const size_t scalar_saved_bytes =
  913|    290|        scalar::utf16_to_utf32::convert<endianness::BIG>(
  914|    290|            ret.first, len - (ret.first - buf), ret.second);
  915|    290|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (915:9): [True: 88, False: 202]
  ------------------
  916|     88|      return 0;
  917|     88|    }
  918|    202|    saved_bytes += scalar_saved_bytes;
  919|    202|  }
  920|    246|  return saved_bytes;
  921|    334|}
_ZNK7simdutf7haswell14implementation36convert_utf16le_to_utf32_with_errorsEPKDsmPDi:
  924|    334|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  925|       |  // ret.first.count is always the position in the buffer, not the number of
  926|       |  // code units written even if finished
  927|    334|  std::pair<result, char32_t *> ret =
  928|    334|      haswell::avx2_convert_utf16_to_utf32_with_errors<endianness::LITTLE>(
  929|    334|          buf, len, utf32_output);
  930|    334|  if (ret.first.error) {
  ------------------
  |  Branch (930:7): [True: 108, False: 226]
  ------------------
  931|    108|    return ret.first;
  932|    108|  } // Can return directly since scalar fallback already found correct
  933|       |    // ret.first.count
  934|    226|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (934:7): [True: 188, False: 38]
  ------------------
  935|    188|    result scalar_res =
  936|    188|        scalar::utf16_to_utf32::convert_with_errors<endianness::LITTLE>(
  937|    188|            buf + ret.first.count, len - ret.first.count, ret.second);
  938|    188|    if (scalar_res.error) {
  ------------------
  |  Branch (938:9): [True: 72, False: 116]
  ------------------
  939|     72|      scalar_res.count += ret.first.count;
  940|     72|      return scalar_res;
  941|    116|    } else {
  942|    116|      ret.second += scalar_res.count;
  943|    116|    }
  944|    188|  }
  945|    154|  ret.first.count =
  946|    154|      ret.second -
  947|    154|      utf32_output; // Set count to the number of 8-bit code units written
  948|    154|  return ret.first;
  949|    226|}
_ZNK7simdutf7haswell14implementation36convert_utf16be_to_utf32_with_errorsEPKDsmPDi:
  952|    346|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  953|       |  // ret.first.count is always the position in the buffer, not the number of
  954|       |  // code units written even if finished
  955|    346|  std::pair<result, char32_t *> ret =
  956|    346|      haswell::avx2_convert_utf16_to_utf32_with_errors<endianness::BIG>(
  957|    346|          buf, len, utf32_output);
  958|    346|  if (ret.first.error) {
  ------------------
  |  Branch (958:7): [True: 92, False: 254]
  ------------------
  959|     92|    return ret.first;
  960|     92|  } // Can return directly since scalar fallback already found correct
  961|       |    // ret.first.count
  962|    254|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (962:7): [True: 228, False: 26]
  ------------------
  963|    228|    result scalar_res =
  964|    228|        scalar::utf16_to_utf32::convert_with_errors<endianness::BIG>(
  965|    228|            buf + ret.first.count, len - ret.first.count, ret.second);
  966|    228|    if (scalar_res.error) {
  ------------------
  |  Branch (966:9): [True: 92, False: 136]
  ------------------
  967|     92|      scalar_res.count += ret.first.count;
  968|     92|      return scalar_res;
  969|    136|    } else {
  970|    136|      ret.second += scalar_res.count;
  971|    136|    }
  972|    228|  }
  973|    162|  ret.first.count =
  974|    162|      ret.second -
  975|    162|      utf32_output; // Set count to the number of 8-bit code units written
  976|    162|  return ret.first;
  977|    254|}
_ZNK7simdutf7haswell14implementation27convert_valid_utf32_to_utf8EPKDimPc:
  982|    216|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  983|    216|  return convert_utf32_to_utf8(buf, len, utf8_output);
  984|    216|}
_ZNK7simdutf7haswell14implementation24convert_utf32_to_utf16leEPKDimPDs:
  989|    822|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  990|    822|  std::pair<const char32_t *, char16_t *> ret =
  991|    822|      avx2_convert_utf32_to_utf16<endianness::LITTLE>(buf, len, utf16_output);
  992|    822|  if (ret.first == nullptr) {
  ------------------
  |  Branch (992:7): [True: 206, False: 616]
  ------------------
  993|    206|    return 0;
  994|    206|  }
  995|    616|  size_t saved_bytes = ret.second - utf16_output;
  996|    616|  if (ret.first != buf + len) {
  ------------------
  |  Branch (996:7): [True: 612, False: 4]
  ------------------
  997|    612|    const size_t scalar_saved_bytes =
  998|    612|        scalar::utf32_to_utf16::convert<endianness::LITTLE>(
  999|    612|            ret.first, len - (ret.first - buf), ret.second);
 1000|    612|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (1000:9): [True: 188, False: 424]
  ------------------
 1001|    188|      return 0;
 1002|    188|    }
 1003|    424|    saved_bytes += scalar_saved_bytes;
 1004|    424|  }
 1005|    428|  return saved_bytes;
 1006|    616|}
_ZNK7simdutf7haswell14implementation24convert_utf32_to_utf16beEPKDimPDs:
 1009|    674|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1010|    674|  std::pair<const char32_t *, char16_t *> ret =
 1011|    674|      avx2_convert_utf32_to_utf16<endianness::BIG>(buf, len, utf16_output);
 1012|    674|  if (ret.first == nullptr) {
  ------------------
  |  Branch (1012:7): [True: 224, False: 450]
  ------------------
 1013|    224|    return 0;
 1014|    224|  }
 1015|    450|  size_t saved_bytes = ret.second - utf16_output;
 1016|    450|  if (ret.first != buf + len) {
  ------------------
  |  Branch (1016:7): [True: 448, False: 2]
  ------------------
 1017|    448|    const size_t scalar_saved_bytes =
 1018|    448|        scalar::utf32_to_utf16::convert<endianness::BIG>(
 1019|    448|            ret.first, len - (ret.first - buf), ret.second);
 1020|    448|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (1020:9): [True: 196, False: 252]
  ------------------
 1021|    196|      return 0;
 1022|    196|    }
 1023|    252|    saved_bytes += scalar_saved_bytes;
 1024|    252|  }
 1025|    254|  return saved_bytes;
 1026|    450|}
_ZNK7simdutf7haswell14implementation36convert_utf32_to_utf16le_with_errorsEPKDimPDs:
 1029|    674|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1030|       |  // ret.first.count is always the position in the buffer, not the number of
 1031|       |  // code units written even if finished
 1032|    674|  std::pair<result, char16_t *> ret =
 1033|    674|      haswell::avx2_convert_utf32_to_utf16_with_errors<endianness::LITTLE>(
 1034|    674|          buf, len, utf16_output);
 1035|    674|  if (ret.first.count != len) {
  ------------------
  |  Branch (1035:7): [True: 670, False: 4]
  ------------------
 1036|    670|    result scalar_res =
 1037|    670|        scalar::utf32_to_utf16::convert_with_errors<endianness::LITTLE>(
 1038|    670|            buf + ret.first.count, len - ret.first.count, ret.second);
 1039|    670|    if (scalar_res.error) {
  ------------------
  |  Branch (1039:9): [True: 504, False: 166]
  ------------------
 1040|    504|      scalar_res.count += ret.first.count;
 1041|    504|      return scalar_res;
 1042|    504|    } else {
 1043|    166|      ret.second += scalar_res.count;
 1044|    166|    }
 1045|    670|  }
 1046|    170|  ret.first.count =
 1047|    170|      ret.second -
 1048|    170|      utf16_output; // Set count to the number of 8-bit code units written
 1049|    170|  return ret.first;
 1050|    674|}
_ZNK7simdutf7haswell14implementation36convert_utf32_to_utf16be_with_errorsEPKDimPDs:
 1053|    694|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1054|       |  // ret.first.count is always the position in the buffer, not the number of
 1055|       |  // code units written even if finished
 1056|    694|  std::pair<result, char16_t *> ret =
 1057|    694|      haswell::avx2_convert_utf32_to_utf16_with_errors<endianness::BIG>(
 1058|    694|          buf, len, utf16_output);
 1059|    694|  if (ret.first.count != len) {
  ------------------
  |  Branch (1059:7): [True: 690, False: 4]
  ------------------
 1060|    690|    result scalar_res =
 1061|    690|        scalar::utf32_to_utf16::convert_with_errors<endianness::BIG>(
 1062|    690|            buf + ret.first.count, len - ret.first.count, ret.second);
 1063|    690|    if (scalar_res.error) {
  ------------------
  |  Branch (1063:9): [True: 512, False: 178]
  ------------------
 1064|    512|      scalar_res.count += ret.first.count;
 1065|    512|      return scalar_res;
 1066|    512|    } else {
 1067|    178|      ret.second += scalar_res.count;
 1068|    178|    }
 1069|    690|  }
 1070|    182|  ret.first.count =
 1071|    182|      ret.second -
 1072|    182|      utf16_output; // Set count to the number of 8-bit code units written
 1073|    182|  return ret.first;
 1074|    694|}
_ZNK7simdutf7haswell14implementation30convert_valid_utf32_to_utf16leEPKDimPDs:
 1077|    280|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1078|    280|  return convert_utf32_to_utf16le(buf, len, utf16_output);
 1079|    280|}
_ZNK7simdutf7haswell14implementation30convert_valid_utf32_to_utf16beEPKDimPDs:
 1082|    134|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1083|    134|  return convert_utf32_to_utf16be(buf, len, utf16_output);
 1084|    134|}
_ZNK7simdutf7haswell14implementation30convert_valid_utf16le_to_utf32EPKDsmPDi:
 1087|    128|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
 1088|    128|  return convert_utf16le_to_utf32(buf, len, utf32_output);
 1089|    128|}
_ZNK7simdutf7haswell14implementation30convert_valid_utf16be_to_utf32EPKDsmPDi:
 1092|    142|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
 1093|    142|  return convert_utf16be_to_utf32(buf, len, utf32_output);
 1094|    142|}
_ZNK7simdutf7haswell14implementation13count_utf16leEPKDsm:
 1105|  1.35k|    const char16_t *input, size_t length) const noexcept {
 1106|  1.35k|  return utf16::count_code_points<endianness::LITTLE>(input, length);
 1107|  1.35k|}
_ZNK7simdutf7haswell14implementation13count_utf16beEPKDsm:
 1110|  1.33k|    const char16_t *input, size_t length) const noexcept {
 1111|  1.33k|  return utf16::count_code_points<endianness::BIG>(input, length);
 1112|  1.33k|}
_ZNK7simdutf7haswell14implementation10count_utf8EPKcm:
 1117|  4.03k|implementation::count_utf8(const char *in, size_t size) const noexcept {
 1118|  4.03k|  return utf8::count_code_points_bytemask(in, size);
 1119|  4.03k|}
_ZNK7simdutf7haswell14implementation23latin1_length_from_utf8EPKcm:
 1124|    549|    const char *buf, size_t len) const noexcept {
 1125|    549|  return count_utf8(buf, len);
 1126|    549|}
_ZNK7simdutf7haswell14implementation24utf8_length_from_utf16leEPKDsm:
 1131|    754|    const char16_t *input, size_t length) const noexcept {
 1132|    754|  return utf16::utf8_length_from_utf16_bytemask<endianness::LITTLE>(input,
 1133|    754|                                                                    length);
 1134|    754|}
_ZNK7simdutf7haswell14implementation24utf8_length_from_utf16beEPKDsm:
 1137|    748|    const char16_t *input, size_t length) const noexcept {
 1138|    748|  return utf16::utf8_length_from_utf16_bytemask<endianness::BIG>(input, length);
 1139|    748|}
_ZNK7simdutf7haswell14implementation25utf32_length_from_utf16leEPKDsm:
 1144|    400|    const char16_t *input, size_t length) const noexcept {
 1145|    400|  return utf16::utf32_length_from_utf16<endianness::LITTLE>(input, length);
 1146|    400|}
_ZNK7simdutf7haswell14implementation25utf32_length_from_utf16beEPKDsm:
 1149|    400|    const char16_t *input, size_t length) const noexcept {
 1150|    400|  return utf16::utf32_length_from_utf16<endianness::BIG>(input, length);
 1151|    400|}
_ZNK7simdutf7haswell14implementation22utf16_length_from_utf8EPKcm:
 1156|  1.94k|    const char *input, size_t length) const noexcept {
 1157|  1.94k|  return utf8::utf16_length_from_utf8_bytemask(input, length);
 1158|  1.94k|}
_ZNK7simdutf7haswell14implementation23utf8_length_from_latin1EPKcm:
 1203|    302|    const char *input, size_t len) const noexcept {
 1204|    302|  const uint8_t *data = reinterpret_cast<const uint8_t *>(input);
 1205|    302|  size_t answer = len / sizeof(__m256i) * sizeof(__m256i);
 1206|    302|  size_t i = 0;
 1207|    302|  if (answer >= 2048) { // long strings optimization
  ------------------
  |  Branch (1207:7): [True: 139, False: 163]
  ------------------
 1208|    139|    __m256i four_64bits = _mm256_setzero_si256();
 1209|  3.51k|    while (i + sizeof(__m256i) <= len) {
  ------------------
  |  Branch (1209:12): [True: 3.37k, False: 139]
  ------------------
 1210|  3.37k|      __m256i runner = _mm256_setzero_si256();
 1211|       |      // We can do up to 255 loops without overflow.
 1212|  3.37k|      size_t iterations = (len - i) / sizeof(__m256i);
 1213|  3.37k|      if (iterations > 255) {
  ------------------
  |  Branch (1213:11): [True: 3.23k, False: 139]
  ------------------
 1214|  3.23k|        iterations = 255;
 1215|  3.23k|      }
 1216|  3.37k|      size_t max_i = i + iterations * sizeof(__m256i) - sizeof(__m256i);
 1217|   210k|      for (; i + 4 * sizeof(__m256i) <= max_i; i += 4 * sizeof(__m256i)) {
  ------------------
  |  Branch (1217:14): [True: 206k, False: 3.37k]
  ------------------
 1218|   206k|        __m256i input1 = _mm256_loadu_si256((const __m256i *)(data + i));
 1219|   206k|        __m256i input2 =
 1220|   206k|            _mm256_loadu_si256((const __m256i *)(data + i + sizeof(__m256i)));
 1221|   206k|        __m256i input3 = _mm256_loadu_si256(
 1222|   206k|            (const __m256i *)(data + i + 2 * sizeof(__m256i)));
 1223|   206k|        __m256i input4 = _mm256_loadu_si256(
 1224|   206k|            (const __m256i *)(data + i + 3 * sizeof(__m256i)));
 1225|   206k|        __m256i input12 =
 1226|   206k|            _mm256_add_epi8(_mm256_cmpgt_epi8(_mm256_setzero_si256(), input1),
 1227|   206k|                            _mm256_cmpgt_epi8(_mm256_setzero_si256(), input2));
 1228|   206k|        __m256i input23 =
 1229|   206k|            _mm256_add_epi8(_mm256_cmpgt_epi8(_mm256_setzero_si256(), input3),
 1230|   206k|                            _mm256_cmpgt_epi8(_mm256_setzero_si256(), input4));
 1231|   206k|        __m256i input1234 = _mm256_add_epi8(input12, input23);
 1232|   206k|        runner = _mm256_sub_epi8(runner, input1234);
 1233|   206k|      }
 1234|  13.4k|      for (; i <= max_i; i += sizeof(__m256i)) {
  ------------------
  |  Branch (1234:14): [True: 10.0k, False: 3.37k]
  ------------------
 1235|  10.0k|        __m256i input_256_chunk =
 1236|  10.0k|            _mm256_loadu_si256((const __m256i *)(data + i));
 1237|  10.0k|        runner = _mm256_sub_epi8(
 1238|  10.0k|            runner, _mm256_cmpgt_epi8(_mm256_setzero_si256(), input_256_chunk));
 1239|  10.0k|      }
 1240|  3.37k|      four_64bits = _mm256_add_epi64(
 1241|  3.37k|          four_64bits, _mm256_sad_epu8(runner, _mm256_setzero_si256()));
 1242|  3.37k|    }
 1243|    139|    answer += _mm256_extract_epi64(four_64bits, 0) +
 1244|    139|              _mm256_extract_epi64(four_64bits, 1) +
 1245|    139|              _mm256_extract_epi64(four_64bits, 2) +
 1246|    139|              _mm256_extract_epi64(four_64bits, 3);
 1247|    163|  } else if (answer > 0) {
  ------------------
  |  Branch (1247:14): [True: 80, False: 83]
  ------------------
 1248|  1.40k|    for (; i + sizeof(__m256i) <= len; i += sizeof(__m256i)) {
  ------------------
  |  Branch (1248:12): [True: 1.32k, False: 80]
  ------------------
 1249|  1.32k|      __m256i latin = _mm256_loadu_si256((const __m256i *)(data + i));
 1250|  1.32k|      uint32_t non_ascii = _mm256_movemask_epi8(latin);
 1251|  1.32k|      answer += count_ones(non_ascii);
 1252|  1.32k|    }
 1253|     80|  }
 1254|    302|  return answer + scalar::latin1::utf8_length_from_latin1(
 1255|    302|                      reinterpret_cast<const char *>(data + i), len - i);
 1256|    302|}
_ZNK7simdutf7haswell14implementation22utf8_length_from_utf32EPKDim:
 1261|    860|    const char32_t *input, size_t length) const noexcept {
 1262|    860|  return utf32::utf8_length_from_utf32(input, length);
 1263|    860|}
_ZNK7simdutf7haswell14implementation23utf16_length_from_utf32EPKDim:
 1268|  1.44k|    const char32_t *input, size_t length) const noexcept {
 1269|  1.44k|  const __m256i v_00000000 = _mm256_setzero_si256();
 1270|  1.44k|  const __m256i v_ffff0000 = _mm256_set1_epi32((uint32_t)0xffff0000);
 1271|  1.44k|  size_t pos = 0;
 1272|  1.44k|  size_t count = 0;
 1273|   582k|  for (; pos + 8 <= length; pos += 8) {
  ------------------
  |  Branch (1273:10): [True: 581k, False: 1.44k]
  ------------------
 1274|   581k|    __m256i in = _mm256_loadu_si256((__m256i *)(input + pos));
 1275|   581k|    const __m256i surrogate_bytemask =
 1276|   581k|        _mm256_cmpeq_epi32(_mm256_and_si256(in, v_ffff0000), v_00000000);
 1277|   581k|    const uint32_t surrogate_bitmask =
 1278|   581k|        static_cast<uint32_t>(_mm256_movemask_epi8(surrogate_bytemask));
 1279|   581k|    size_t surrogate_count = (32 - count_ones(surrogate_bitmask)) / 4;
 1280|   581k|    count += 8 + surrogate_count;
 1281|   581k|  }
 1282|  1.44k|  return count +
 1283|  1.44k|         scalar::utf32::utf16_length_from_utf32(input + pos, length - pos);
 1284|  1.44k|}
_ZNK7simdutf7haswell14implementation22utf32_length_from_utf8EPKcm:
 1289|    994|    const char *input, size_t length) const noexcept {
 1290|    994|  return utf8::count_code_points(input, length);
 1291|    994|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_18is_asciiERKNS1_4simd8simd8x64IhEE:
   13|  4.87M|simdutf_really_inline bool is_ascii(const simd8x64<uint8_t> &input) {
   14|  4.87M|  return input.reduce_or().is_ascii();
   15|  4.87M|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_124must_be_2_3_continuationENS1_4simd5simd8IhEES4_:
   22|  3.00M|                         const simd8<uint8_t> prev3) {
   23|  3.00M|  simd8<uint8_t> is_third_byte =
   24|  3.00M|      prev2.saturating_sub(0xe0u - 0x80); // Only 111_____ will be > 0x80
   25|  3.00M|  simd8<uint8_t> is_fourth_byte =
   26|  3.00M|      prev3.saturating_sub(0xf0u - 0x80); // Only 1111____ will be > 0x80
   27|  3.00M|  return simd8<bool>(is_third_byte | is_fourth_byte);
   28|  3.00M|}

_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:
 1503|      1|available_implementation_list::begin() const noexcept {
 1504|      1|  return internal::get_available_implementation_pointers().begin();
 1505|      1|}
_ZNK7simdutf8internal29available_implementation_list3endEv:
 1507|      1|available_implementation_list::end() const noexcept {
 1508|      1|  return internal::get_available_implementation_pointers().end();
 1509|      1|}
_ZN7simdutf29get_available_implementationsEv:
 1558|      1|get_available_implementations() {
 1559|      1|#if !SIMDUTF_USE_STATIC_INITIALIZATION
 1560|      1|  static const internal::available_implementation_list
 1561|      1|      available_implementations_instance{};
 1562|      1|#endif
 1563|      1|  return available_implementations_instance;
 1564|      1|}
simdutf.cpp:_ZN7simdutf8internalL37get_available_implementation_pointersEv:
  933|      2|get_available_implementation_pointers() {
  934|      2|#if !SIMDUTF_USE_STATIC_INITIALIZATION
  935|      2|  static const std::initializer_list<const implementation *>
  936|      2|      available_implementation_pointers{
  937|      2|  #if SIMDUTF_IMPLEMENTATION_ICELAKE
  938|      2|          get_icelake_singleton(),
  939|      2|  #endif
  940|      2|  #if SIMDUTF_IMPLEMENTATION_HASWELL
  941|      2|          get_haswell_singleton(),
  942|      2|  #endif
  943|      2|  #if SIMDUTF_IMPLEMENTATION_WESTMERE
  944|      2|          get_westmere_singleton(),
  945|      2|  #endif
  946|       |  #if SIMDUTF_IMPLEMENTATION_ARM64
  947|       |          get_arm64_singleton(),
  948|       |  #endif
  949|       |  #if SIMDUTF_IMPLEMENTATION_PPC64
  950|       |          get_ppc64_singleton(),
  951|       |  #endif
  952|       |  #if SIMDUTF_IMPLEMENTATION_RVV
  953|       |          get_rvv_singleton(),
  954|       |  #endif
  955|       |  #if SIMDUTF_IMPLEMENTATION_LASX
  956|       |          get_lasx_singleton(),
  957|       |  #endif
  958|       |  #if SIMDUTF_IMPLEMENTATION_LSX
  959|       |          get_lsx_singleton(),
  960|       |  #endif
  961|      2|  #if SIMDUTF_IMPLEMENTATION_FALLBACK
  962|      2|          get_fallback_singleton(),
  963|      2|  #endif
  964|      2|      };
  965|      2|#endif
  966|      2|  return available_implementation_pointers;
  967|      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.52M|simdutf_really_inline long long int count_ones(uint64_t input_num) {
   15|       |  return _popcnt64(input_num);
   16|  3.52M|}

_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|  20.9k|  simdutf_really_inline simd8() : base8_numeric<uint8_t>() {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhEC2Ev:
  124|  20.9k|  simdutf_really_inline base8_numeric() : base8<T>() {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEEC2Ev:
   71|  20.9k|  simdutf_really_inline base8() : base<simd8<T>>() {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEC2Ev:
   14|  20.9k|  simdutf_really_inline base() : value{__m256i()} {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IhE9reduce_orEv:
  294|  4.87M|  simdutf_really_inline simd8<T> reduce_or() const {
  295|  4.87M|    return this->chunks[0] | this->chunks[1];
  296|  4.87M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEorES5_:
   50|  15.0M|  simdutf_really_inline Child operator|(const Child other) const {
   51|  15.0M|    return _mm256_or_si256(*this, other);
   52|  15.0M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5simd8IhEC2EDv4_x:
  193|   157M|      : base8_numeric<uint8_t>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhEC2EDv4_x:
  126|   157M|      : base8<T>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEEC2EDv4_x:
   73|   157M|  simdutf_really_inline base8(const __m256i _value) : base<simd8<T>>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEC2EDv4_x:
   17|   157M|  simdutf_really_inline base(const __m256i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE8is_asciiEv:
  234|  4.87M|  simdutf_really_inline bool is_ascii() const {
  235|  4.87M|    return _mm256_movemask_epi8(*this) == 0;
  236|  4.87M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEoRES5_:
   59|  7.13M|  simdutf_really_inline Child &operator|=(const Child other) {
   60|  7.13M|    auto this_cast = static_cast<Child *>(this);
   61|  7.13M|    *this_cast = *this_cast | other;
   62|  7.13M|    return *this_cast;
   63|  7.13M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEE4prevILi1EEENS4_IhEES8_:
   83|  3.13M|  simdutf_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
   84|       |    return _mm256_alignr_epi8(
   85|  3.13M|        *this, _mm256_permute2x128_si256(prev_chunk, *this, 0x21), 16 - N);
   86|  3.13M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE3shrILi4EEES4_v:
  245|  6.27M|  template <int N> simdutf_really_inline simd8<uint8_t> shr() const {
  246|  6.27M|    return simd8<uint8_t>(_mm256_srli_epi16(*this, N)) & uint8_t(0xFFu >> N);
  247|  6.27M|  }
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.41M|            L replace15) const {
  158|  9.41M|    return lookup_16(simd8<L>::repeat_16(
  159|  9.41M|        replace0, replace1, replace2, replace3, replace4, replace5, replace6,
  160|  9.41M|        replace7, replace8, replace9, replace10, replace11, replace12,
  161|  9.41M|        replace13, replace14, replace15));
  162|  9.41M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhE9lookup_16IhEENS2_5simd8IT_EES8_:
  148|  9.41M|  simdutf_really_inline simd8<L> lookup_16(simd8<L> lookup_table) const {
  149|  9.41M|    return _mm256_shuffle_epi8(lookup_table, *this);
  150|  9.41M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhE9repeat_16Ehhhhhhhhhhhhhhhh:
  118|  9.41M|                                                  T v14, T v15) {
  119|  9.41M|    return simd8<T>(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
  120|  9.41M|                    v14, v15, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
  121|  9.41M|                    v12, v13, v14, v15);
  122|  9.41M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5simd8IhEC2Ehhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh:
  207|  9.41M|      : simd8(_mm256_setr_epi8(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
  208|  9.41M|                               v12, v13, v14, v15, v16, v17, v18, v19, v20, v21,
  209|  9.41M|                               v22, v23, v24, v25, v26, v27, v28, v29, v30,
  210|  9.41M|                               v31)) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5simd8IhEC2Eh:
  195|  22.1M|  simdutf_really_inline simd8(uint8_t _value) : simd8(splat(_value)) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEE4prevILi2EEENS4_IhEES8_:
   83|  3.00M|  simdutf_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
   84|       |    return _mm256_alignr_epi8(
   85|  3.00M|        *this, _mm256_permute2x128_si256(prev_chunk, *this, 0x21), 16 - N);
   86|  3.00M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEE4prevILi3EEENS4_IhEES8_:
   83|  3.00M|  simdutf_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
   84|       |    return _mm256_alignr_epi8(
   85|  3.00M|        *this, _mm256_permute2x128_si256(prev_chunk, *this, 0x21), 16 - N);
   86|  3.00M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE14saturating_subES4_:
  214|  6.89M|  saturating_sub(const simd8<uint8_t> other) const {
  215|  6.89M|    return _mm256_subs_epu8(*this, other);
  216|  6.89M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5simd8IbEC2EDv4_x:
   95|  24.6M|  simdutf_really_inline simd8(const __m256i _value) : base8<bool>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5base8IbNS2_5simd8IbEEEC2EDv4_x:
   73|  24.6M|  simdutf_really_inline base8(const __m256i _value) : base<simd8<T>>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IbEEEC2EDv4_x:
   17|  24.6M|  simdutf_really_inline base(const __m256i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IbEEEcvRKDv4_xEv:
   19|  15.8M|  simdutf_really_inline operator const __m256i &() const { return this->value; }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEeoES5_:
   56|  3.00M|  simdutf_really_inline Child operator^(const Child other) const {
   57|  3.00M|    return _mm256_xor_si256(*this, other);
   58|  3.00M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5simd8IhEC2EPKh:
  197|   881k|  simdutf_really_inline simd8(const uint8_t values[32]) : simd8(load(values)) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhE4loadEPKh:
  111|  10.6M|  static simdutf_really_inline simd8<T> load(const T values[32]) {
  112|  10.6M|    return _mm256_loadu_si256(reinterpret_cast<const __m256i *>(values));
  113|  10.6M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE7gt_bitsES4_:
  225|   881k|  gt_bits(const simd8<uint8_t> other) const {
  226|   881k|    return this->saturating_sub(other);
  227|   881k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_6simd16ItEEEC2EDv4_x:
   17|  71.8M|  simdutf_really_inline base(const __m256i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_6simd16ItEEEcvRKDv4_xEv:
   19|   102M|  simdutf_really_inline operator const __m256i &() const { return this->value; }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IbE10to_bitmaskEv:
   99|  8.81M|  simdutf_really_inline uint32_t to_bitmask() const {
  100|  8.81M|    return uint32_t(_mm256_movemask_epi8(value));
  101|  8.81M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE21any_bits_set_anywhereEv:
  241|  2.30M|  simdutf_really_inline bool any_bits_set_anywhere() const {
  242|  2.30M|    return !bits_not_set_anywhere();
  243|  2.30M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE21bits_not_set_anywhereEv:
  237|  2.30M|  simdutf_really_inline bool bits_not_set_anywhere() const {
  238|  2.30M|    return _mm256_testz_si256(*this, *this);
  239|  2.30M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IaEC2EPKa:
  274|  6.04M|      : chunks{simd8<T>::load(ptr),
  275|  6.04M|               simd8<T>::load(ptr + sizeof(simd8<T>) / sizeof(T))} {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIaE4loadEPKa:
  111|  21.8M|  static simdutf_really_inline simd8<T> load(const T values[32]) {
  112|  21.8M|    return _mm256_loadu_si256(reinterpret_cast<const __m256i *>(values));
  113|  21.8M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5simd8IaEC2EDv4_x:
  169|  38.7M|      : base8_numeric<int8_t>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIaEC2EDv4_x:
  126|  38.7M|      : base8<T>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5base8IaNS2_5simd8IbEEEC2EDv4_x:
   73|  38.7M|  simdutf_really_inline base8(const __m256i _value) : base<simd8<T>>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IaEEEC2EDv4_x:
   17|  38.7M|  simdutf_really_inline base(const __m256i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IaE8is_asciiEv:
  298|  5.29M|  simdutf_really_inline bool is_ascii() const {
  299|  5.29M|    return this->reduce_or().is_ascii();
  300|  5.29M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IaE9reduce_orEv:
  294|  5.29M|  simdutf_really_inline simd8<T> reduce_or() const {
  295|  5.29M|    return this->chunks[0] | this->chunks[1];
  296|  5.29M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IaEEEorES5_:
   50|  5.29M|  simdutf_really_inline Child operator|(const Child other) const {
   51|  5.29M|    return _mm256_or_si256(*this, other);
   52|  5.29M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IaEEEcvRKDv4_xEv:
   19|  62.6M|  simdutf_really_inline operator const __m256i &() const { return this->value; }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IaE8is_asciiEv:
  177|  5.29M|  simdutf_really_inline bool is_ascii() const {
  178|  5.29M|    return _mm256_movemask_epi8(*this) == 0;
  179|  5.29M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IaE5storeEPa:
  277|   903k|  simdutf_really_inline void store(T *ptr) const {
  278|   903k|    this->chunks[0].store(ptr + sizeof(simd8<T>) * 0 / sizeof(T));
  279|   903k|    this->chunks[1].store(ptr + sizeof(simd8<T>) * 1 / sizeof(T));
  280|   903k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIaE5storeEPa:
  129|  1.80M|  simdutf_really_inline void store(T dst[32]) const {
  130|  1.80M|    return _mm256_storeu_si256(reinterpret_cast<__m256i *>(dst), *this);
  131|  1.80M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IaEcvNS3_IhEEEv:
  256|  2.06M|simdutf_really_inline simd8<int8_t>::operator simd8<uint8_t>() const {
  257|  2.06M|  return this->value;
  258|  2.06M|}
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|  11.6M|  static simdutf_really_inline simd8<T> splat(T _value) {
  106|  11.6M|    return _mm256_set1_epi8(_value);
  107|  11.6M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IaEltES4_:
  184|  2.11M|  simdutf_really_inline simd8<bool> operator<(const simd8<int8_t> other) const {
  185|  2.11M|    return _mm256_cmpgt_epi8(other, *this);
  186|  2.11M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IbEC2ENS2_5simd8IbEES6_:
  272|  1.80M|      : chunks{chunk0, chunk1} {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IbE10to_bitmaskEv:
  282|  1.80M|  simdutf_really_inline uint64_t to_bitmask() const {
  283|  1.80M|    uint64_t r_lo = uint32_t(this->chunks[0].to_bitmask());
  284|  1.80M|    uint64_t r_hi = this->chunks[1].to_bitmask();
  285|  1.80M|    return r_lo | (r_hi << 32);
  286|  1.80M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IaE20store_ascii_as_utf32EPDi:
  310|  1.19M|  simdutf_really_inline void store_ascii_as_utf32(char32_t *ptr) const {
  311|  1.19M|    this->chunks[0].store_ascii_as_utf32(ptr + sizeof(simd8<T>) * 0);
  312|  1.19M|    this->chunks[1].store_ascii_as_utf32(ptr + sizeof(simd8<T>) * 1);
  313|  1.19M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IaEEE20store_ascii_as_utf32EPDi:
   36|  2.39M|  simdutf_really_inline void store_ascii_as_utf32(char32_t *ptr) const {
   37|  2.39M|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(ptr),
   38|  2.39M|                        _mm256_cvtepu8_epi32(_mm256_castsi256_si128(*this)));
   39|  2.39M|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(ptr + 8),
   40|  2.39M|                        _mm256_cvtepu8_epi32(_mm256_castsi256_si128(
   41|  2.39M|                            _mm256_srli_si256(*this, 8))));
   42|  2.39M|    _mm256_storeu_si256(
   43|  2.39M|        reinterpret_cast<__m256i *>(ptr + 16),
   44|  2.39M|        _mm256_cvtepu8_epi32(_mm256_extractf128_si256(*this, 1)));
   45|  2.39M|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(ptr + 24),
   46|       |                        _mm256_cvtepu8_epi32(_mm_srli_si128(
   47|  2.39M|                            _mm256_extractf128_si256(*this, 1), 8)));
   48|  2.39M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhE4zeroEv:
  108|   106k|  static simdutf_really_inline simd8<T> zero() {
  109|   106k|    return _mm256_setzero_si256();
  110|   106k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IaEgtES4_:
  181|  11.3M|  simdutf_really_inline simd8<bool> operator>(const simd8<int8_t> other) const {
  182|  11.3M|    return _mm256_cmpgt_epi8(*this, other);
  183|  11.3M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5simd8IaEC2Ea:
  172|  9.79M|  simdutf_really_inline simd8(int8_t _value) : simd8(splat(_value)) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhEmIENS2_5simd8IhEE:
  137|  12.8M|  simdutf_really_inline simd8<T> &operator-=(const simd8<T> other) {
  138|  12.8M|    *this = *this - other;
  139|  12.8M|    return *static_cast<simd8<T> *>(this);
  140|  12.8M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhEmiENS2_5simd8IhEE:
  134|  12.8M|  simdutf_really_inline simd8<T> operator-(const simd8<T> other) const {
  135|  12.8M|    return _mm256_sub_epi8(*this, other);
  136|  12.8M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd10sum_8bytesENS2_5simd8IhEE:
  353|  50.3k|simdutf_really_inline simd64<uint64_t> sum_8bytes(const simd8<uint8_t> v) {
  354|  50.3k|  return _mm256_sad_epu8(v.value, simd8<uint8_t>::zero());
  355|  50.3k|}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE9sum_bytesEv:
  249|  2.77k|  simdutf_really_inline uint64_t sum_bytes() const {
  250|  2.77k|    const auto tmp = _mm256_sad_epu8(value, _mm256_setzero_si256());
  251|       |
  252|  2.77k|    return _mm256_extract_epi64(tmp, 0) + _mm256_extract_epi64(tmp, 1) +
  253|  2.77k|           _mm256_extract_epi64(tmp, 2) + _mm256_extract_epi64(tmp, 3);
  254|  2.77k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhEgeES4_:
  229|  3.04M|  operator>=(const simd8<uint8_t> other) const {
  230|  3.04M|    return other.min_val(*this) == other;
  231|  3.04M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE7min_valES4_:
  220|  3.04M|  min_val(const simd8<uint8_t> other) const {
  221|  3.04M|    return _mm256_min_epu8(other, *this);
  222|  3.04M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IaE2gtEa:
  331|   752k|  simdutf_really_inline uint64_t gt(const T m) const {
  332|   752k|    const simd8<T> mask = simd8<T>::splat(m);
  333|   752k|    return simd8x64<bool>(this->chunks[0] > mask, this->chunks[1] > mask)
  334|   752k|        .to_bitmask();
  335|   752k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_6simd16IbEEEC2EDv4_x:
   17|  15.1M|  simdutf_really_inline base(const __m256i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_6simd16IbEEEcvRKDv4_xEv:
   19|  15.1M|  simdutf_really_inline operator const __m256i &() const { return this->value; }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhE5splatEh:
  105|  22.1M|  static simdutf_really_inline simd8<T> splat(T _value) {
  106|  22.1M|    return _mm256_set1_epi8(_value);
  107|  22.1M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEcvRKDv4_xEv:
   19|   210M|  simdutf_really_inline operator const __m256i &() const { return this->value; }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simdeqENS2_5simd8IhEES4_:
   76|  8.23M|                                               const simd8<T> rhs) {
   77|  8.23M|    return _mm256_cmpeq_epi8(lhs, rhs);
   78|  8.23M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEanES5_:
   53|  23.8M|  simdutf_really_inline Child operator&(const Child other) const {
   54|  23.8M|    return _mm256_and_si256(*this, other);
   55|  23.8M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IhEC2EPKh:
  274|  4.87M|      : chunks{simd8<T>::load(ptr),
  275|  4.87M|               simd8<T>::load(ptr + sizeof(simd8<T>) / sizeof(T))} {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_6simd16ItEEEanES5_:
   53|  11.2M|  simdutf_really_inline Child operator&(const Child other) const {
   54|  11.2M|    return _mm256_and_si256(*this, other);
   55|  11.2M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IaE20store_ascii_as_utf16ILNS_10endiannessE0EEEvPDs:
  303|  1.00M|  simdutf_really_inline void store_ascii_as_utf16(char16_t *ptr) const {
  304|  1.00M|    this->chunks[0].template store_ascii_as_utf16<endian>(ptr +
  305|  1.00M|                                                          sizeof(simd8<T>) * 0);
  306|  1.00M|    this->chunks[1].template store_ascii_as_utf16<endian>(ptr +
  307|  1.00M|                                                          sizeof(simd8<T>) * 1);
  308|  1.00M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IaEEE20store_ascii_as_utf16ILNS_10endiannessE0EEEvPDs:
   22|  2.00M|  simdutf_really_inline void store_ascii_as_utf16(char16_t *ptr) const {
   23|  2.00M|    __m256i first = _mm256_cvtepu8_epi16(_mm256_castsi256_si128(*this));
   24|  2.00M|    __m256i second = _mm256_cvtepu8_epi16(_mm256_extractf128_si256(*this, 1));
   25|  2.00M|    if (big_endian) {
  ------------------
  |  Branch (25:9): [Folded, False: 2.00M]
  ------------------
   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.00M|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(ptr), first);
   33|  2.00M|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(ptr + 16), second);
   34|  2.00M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IaE20store_ascii_as_utf16ILNS_10endiannessE1EEEvPDs:
  303|  1.13M|  simdutf_really_inline void store_ascii_as_utf16(char16_t *ptr) const {
  304|  1.13M|    this->chunks[0].template store_ascii_as_utf16<endian>(ptr +
  305|  1.13M|                                                          sizeof(simd8<T>) * 0);
  306|  1.13M|    this->chunks[1].template store_ascii_as_utf16<endian>(ptr +
  307|  1.13M|                                                          sizeof(simd8<T>) * 1);
  308|  1.13M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IaEEE20store_ascii_as_utf16ILNS_10endiannessE1EEEvPDs:
   22|  2.26M|  simdutf_really_inline void store_ascii_as_utf16(char16_t *ptr) const {
   23|  2.26M|    __m256i first = _mm256_cvtepu8_epi16(_mm256_castsi256_si128(*this));
   24|  2.26M|    __m256i second = _mm256_cvtepu8_epi16(_mm256_extractf128_si256(*this, 1));
   25|  2.26M|    if (big_endian) {
  ------------------
  |  Branch (25:9): [True: 2.26M, Folded]
  ------------------
   26|  2.26M|      const __m256i swap = _mm256_setr_epi8(
   27|  2.26M|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   28|  2.26M|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   29|  2.26M|      first = _mm256_shuffle_epi8(first, swap);
   30|  2.26M|      second = _mm256_shuffle_epi8(second, swap);
   31|  2.26M|    }
   32|  2.26M|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(ptr), first);
   33|  2.26M|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(ptr + 16), second);
   34|  2.26M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_6simd16IbEEEorES5_:
   50|  4.38M|  simdutf_really_inline Child operator|(const Child other) const {
   51|  4.38M|    return _mm256_or_si256(*this, other);
   52|  4.38M|  }

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd16ItEC2EDv4_x:
   97|  71.8M|      : base16_numeric<uint16_t>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd14base16_numericItEC2EDv4_x:
   73|  71.8M|      : base16<T>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6base16ItNS2_6simd16IbEEEC2EDv4_x:
   20|  71.8M|      : base<simd16<T>>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd16ItE4packERKS4_S6_:
  149|  5.15M|                                                   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|  5.15M|    const __m128i lo_0 = _mm256_extracti128_si256(v0, 0);
  156|  5.15M|    const __m128i lo_1 = _mm256_extracti128_si256(v1, 0);
  157|       |
  158|       |    // get the 1st lanes
  159|  5.15M|    const __m128i hi_0 = _mm256_extracti128_si256(v0, 1);
  160|  5.15M|    const __m128i hi_1 = _mm256_extracti128_si256(v1, 1);
  161|       |
  162|       |    // build new vectors (shuffle lanes)
  163|  5.15M|    const __m256i t0 = _mm256_set_m128i(lo_1, lo_0);
  ------------------
  |  |    4|  5.15M|      _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1),                  \
  |  |    5|  5.15M|                                _mm256_castsi128_si256(xmm2), 2)
  ------------------
  164|  5.15M|    const __m256i t1 = _mm256_set_m128i(hi_1, hi_0);
  ------------------
  |  |    4|  5.15M|      _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1),                  \
  |  |    5|  5.15M|                                _mm256_castsi128_si256(xmm2), 2)
  ------------------
  165|       |
  166|       |    // pack code units in linear order from v0 and v1
  167|  5.15M|    return _mm256_packus_epi16(t0, t1);
  168|  5.15M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd9simd16x32ItEC2EPKt:
  202|  2.19M|      : chunks{simd16<T>::load(ptr),
  203|  2.19M|               simd16<T>::load(ptr + sizeof(simd16<T>) / sizeof(T))} {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd14base16_numericItE4loadEPKt:
   66|  16.7M|  static simdutf_really_inline simd16<T> load(const T values[8]) {
   67|  16.7M|    return _mm256_loadu_si256(reinterpret_cast<const __m256i *>(values));
   68|  16.7M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd9simd16x32ItE10swap_bytesEv:
  229|  1.03M|  simdutf_really_inline void swap_bytes() {
  230|  1.03M|    this->chunks[0] = this->chunks[0].swap_bytes();
  231|  1.03M|    this->chunks[1] = this->chunks[1].swap_bytes();
  232|  1.03M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd16ItE10swap_bytesEv:
  139|  3.02M|  simdutf_really_inline simd16<uint16_t> swap_bytes() const {
  140|  3.02M|    const __m256i swap = _mm256_setr_epi8(
  141|  3.02M|        1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
  142|  3.02M|        21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
  143|  3.02M|    return _mm256_shuffle_epi8(*this, swap);
  144|  3.02M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd14base16_numericItE5splatEt:
   58|  15.0M|  static simdutf_really_inline simd16<T> splat(T _value) {
   59|  15.0M|    return _mm256_set1_epi16(_value);
   60|  15.0M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simdeqENS2_6simd16ItEES4_:
   26|  10.7M|                                               const simd16<T> rhs) {
   27|  10.7M|    return _mm256_cmpeq_epi16(lhs, rhs);
   28|  10.7M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd16IbEC2EDv4_x:
   45|  15.1M|  simdutf_really_inline simd16(const __m256i _value) : base16<bool>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6base16IbNS2_6simd16IbEEEC2EDv4_x:
   20|  15.1M|      : base<simd16<T>>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd9simd16x32IbEC2ENS2_6simd16IbEES6_:
  200|  2.19M|      : chunks{chunk0, chunk1} {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd9simd16x32IbE10to_bitmaskEv:
  210|  2.19M|  simdutf_really_inline uint64_t to_bitmask() const {
  211|  2.19M|    uint64_t r_lo = uint32_t(this->chunks[0].to_bitmask());
  212|  2.19M|    uint64_t r_hi = this->chunks[1].to_bitmask();
  213|  2.19M|    return r_lo | (r_hi << 32);
  214|  2.19M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd16IbE10to_bitmaskEv:
   50|  4.38M|  simdutf_really_inline bitmask_type to_bitmask() const {
   51|  4.38M|    return _mm256_movemask_epi8(*this);
   52|  4.38M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd16ItE3shrILi8EEES4_v:
  134|  5.08M|  template <int N> simdutf_really_inline simd16<uint16_t> shr() const {
  135|  5.08M|    return simd16<uint16_t>(_mm256_srli_epi16(*this, N));
  136|  5.08M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd16ItEleES4_:
  117|  4.38M|  operator<=(const simd16<uint16_t> other) const {
  118|  4.38M|    return other.max_val(*this) == other;
  119|  4.38M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd16ItE7max_valES4_:
  108|  4.38M|  max_val(const simd16<uint16_t> other) const {
  109|  4.38M|    return _mm256_max_epu16(*this, other);
  110|  4.38M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd16ItEC2EPKDs:
  104|  10.3M|      : simd16(load(reinterpret_cast<const uint16_t *>(values))) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd16ItEC2Et:
  100|  10.6M|  simdutf_really_inline simd16(uint16_t _value) : simd16(splat(_value)) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd9simd16x32ItE12not_in_rangeEtt:
  249|  2.19M|  simdutf_really_inline uint64_t not_in_range(const T low, const T high) const {
  250|  2.19M|    const simd16<T> mask_low = simd16<T>::splat(static_cast<T>(low - 1));
  251|  2.19M|    const simd16<T> mask_high = simd16<T>::splat(static_cast<T>(high + 1));
  252|  2.19M|    return simd16x32<bool>(
  253|  2.19M|               (this->chunks[0] >= mask_high) | (this->chunks[0] <= mask_low),
  254|  2.19M|               (this->chunks[1] >= mask_high) | (this->chunks[1] <= mask_low))
  255|  2.19M|        .to_bitmask();
  256|  2.19M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd16ItEgeES4_:
  121|  4.38M|  operator>=(const simd16<uint16_t> other) const {
  122|  4.38M|    return other.min_val(*this) == other;
  123|  4.38M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd16ItE7min_valES4_:
  112|  4.38M|  min_val(const simd16<uint16_t> other) const {
  113|  4.38M|    return _mm256_min_epu16(*this, other);
  114|  4.38M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd14base16_numericItE4zeroEv:
   62|  1.53k|  static simdutf_really_inline simd16<T> zero() {
   63|  1.53k|    return _mm256_setzero_si256();
   64|  1.53k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd3minENS2_6simd16ItEES4_:
  259|  4.00M|simd16<uint16_t> min(const simd16<uint16_t> a, simd16<uint16_t> b) {
  260|  4.00M|  return _mm256_min_epu16(a.value, b.value);
  261|  4.00M|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd14base16_numericItEpLENS2_6simd16ItEE:
   87|  6.01M|  simdutf_really_inline simd16<T> &operator+=(const simd16<T> other) {
   88|  6.01M|    *this = *this + other;
   89|  6.01M|    return *static_cast<simd16<T> *>(this);
   90|  6.01M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd14base16_numericItEplENS2_6simd16ItEE:
   84|  6.01M|  simdutf_really_inline simd16<T> operator+(const simd16<T> other) const {
   85|  6.01M|    return _mm256_add_epi16(*this, other);
   86|  6.01M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd16ItE3sumEv:
  170|  1.53k|  simdutf_really_inline uint64_t sum() const {
  171|  1.53k|    const auto lo_u16 = _mm256_and_si256(value, _mm256_set1_epi32(0x0000ffff));
  172|  1.53k|    const auto hi_u16 = _mm256_srli_epi32(value, 16);
  173|  1.53k|    const auto sum_u32 = _mm256_add_epi32(lo_u16, hi_u16);
  174|       |
  175|  1.53k|    const auto lo_u32 =
  176|  1.53k|        _mm256_and_si256(sum_u32, _mm256_set1_epi64x(0xffffffff));
  177|  1.53k|    const auto hi_u32 = _mm256_srli_epi64(sum_u32, 32);
  178|  1.53k|    const auto sum_u64 = _mm256_add_epi64(lo_u32, hi_u32);
  179|       |
  180|  1.53k|    return uint64_t(_mm256_extract_epi64(sum_u64, 0)) +
  181|  1.53k|           uint64_t(_mm256_extract_epi64(sum_u64, 1)) +
  182|  1.53k|           uint64_t(_mm256_extract_epi64(sum_u64, 2)) +
  183|       |           uint64_t(_mm256_extract_epi64(sum_u64, 3));
  184|  1.53k|  }

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

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

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

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

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEC2Ev:
  183|  20.9k|  simdutf_really_inline simd8() : base8_numeric<uint8_t>() {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhEC2Ev:
  118|  20.9k|  simdutf_really_inline base8_numeric() : base8<T>() {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEEC2Ev:
   68|  20.9k|  simdutf_really_inline base8() : base<simd8<T>>() {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEC2Ev:
   13|  20.9k|  simdutf_really_inline base() : value{__m128i()} {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IhE9reduce_orEv:
  290|  4.87M|  simdutf_really_inline simd8<T> reduce_or() const {
  291|  4.87M|    return (this->chunks[0] | this->chunks[1]) |
  292|  4.87M|           (this->chunks[2] | this->chunks[3]);
  293|  4.87M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEorES5_:
   42|  30.9M|  simdutf_really_inline Child operator|(const Child other) const {
   43|  30.9M|    return _mm_or_si128(*this, other);
   44|  30.9M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEC2EDv2_x:
  185|   304M|      : base8_numeric<uint8_t>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhEC2EDv2_x:
  120|   304M|      : base8<T>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEEC2EDv2_x:
   69|   304M|  simdutf_really_inline base8(const __m128i _value) : base<simd8<T>>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEC2EDv2_x:
   16|   304M|  simdutf_really_inline base(const __m128i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE8is_asciiEv:
  228|  4.87M|  simdutf_really_inline bool is_ascii() const {
  229|  4.87M|    return _mm_movemask_epi8(*this) == 0;
  230|  4.87M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEoRES5_:
   51|  10.2M|  simdutf_really_inline Child &operator|=(const Child other) {
   52|  10.2M|    auto this_cast = static_cast<Child *>(this);
   53|  10.2M|    *this_cast = *this_cast | other;
   54|  10.2M|    return *this_cast;
   55|  10.2M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEE4prevILi1EEENS4_IhEES8_:
   79|  6.27M|  simdutf_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
   80|       |    return _mm_alignr_epi8(*this, prev_chunk, 16 - N);
   81|  6.27M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE3shrILi4EEES4_v:
  238|  12.5M|  template <int N> simdutf_really_inline simd8<uint8_t> shr() const {
  239|  12.5M|    return simd8<uint8_t>(_mm_srli_epi16(*this, N)) & uint8_t(0xFFu >> N);
  240|  12.5M|  }
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|  18.8M|            L replace15) const {
  152|  18.8M|    return lookup_16(simd8<L>::repeat_16(
  153|  18.8M|        replace0, replace1, replace2, replace3, replace4, replace5, replace6,
  154|  18.8M|        replace7, replace8, replace9, replace10, replace11, replace12,
  155|  18.8M|        replace13, replace14, replace15));
  156|  18.8M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE9lookup_16IhEENS2_5simd8IT_EES8_:
  142|  18.8M|  simdutf_really_inline simd8<L> lookup_16(simd8<L> lookup_table) const {
  143|  18.8M|    return _mm_shuffle_epi8(lookup_table, *this);
  144|  18.8M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE9repeat_16Ehhhhhhhhhhhhhhhh:
  113|  18.8M|                                                  T v14, T v15) {
  114|  18.8M|    return simd8<T>(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
  115|  18.8M|                    v14, v15);
  116|  18.8M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEC2Ehhhhhhhhhhhhhhhh:
  196|  18.8M|      : simd8(_mm_setr_epi8(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
  197|  18.8M|                            v12, v13, v14, v15)) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEC2Eh:
  188|  43.6M|  simdutf_really_inline simd8(uint8_t _value) : simd8(splat(_value)) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEE4prevILi2EEENS4_IhEES8_:
   79|  6.01M|  simdutf_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
   80|       |    return _mm_alignr_epi8(*this, prev_chunk, 16 - N);
   81|  6.01M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEE4prevILi3EEENS4_IhEES8_:
   79|  6.01M|  simdutf_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
   80|       |    return _mm_alignr_epi8(*this, prev_chunk, 16 - N);
   81|  6.01M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE14saturating_subES4_:
  201|  12.9M|  saturating_sub(const simd8<uint8_t> other) const {
  202|  12.9M|    return _mm_subs_epu8(*this, other);
  203|  12.9M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IbEC2EDv2_x:
   91|  44.1M|  simdutf_really_inline simd8(const __m128i _value) : base8<bool>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5base8IbNS2_5simd8IbEEEC2EDv2_x:
   69|  44.1M|  simdutf_really_inline base8(const __m128i _value) : base<simd8<T>>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IbEEEC2EDv2_x:
   16|  44.1M|  simdutf_really_inline base(const __m128i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IbEEEcvRKDv2_xEv:
   18|  44.1M|  simdutf_really_inline operator const __m128i &() const { return this->value; }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEeoES5_:
   48|  6.01M|  simdutf_really_inline Child operator^(const Child other) const {
   49|  6.01M|    return _mm_xor_si128(*this, other);
   50|  6.01M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEC2EPKh:
  190|   881k|  simdutf_really_inline simd8(const uint8_t *values) : simd8(load(values)) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE4loadEPKh:
  106|  20.3M|  static simdutf_really_inline simd8<T> load(const T values[16]) {
  107|  20.3M|    return _mm_loadu_si128(reinterpret_cast<const __m128i *>(values));
  108|  20.3M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE7gt_bitsES4_:
  212|   881k|  gt_bits(const simd8<uint8_t> other) const {
  213|   881k|    return this->saturating_sub(other);
  214|   881k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16ItEEEC2EDv2_x:
   16|   116M|  simdutf_really_inline base(const __m128i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16ItEEEcvRKDv2_xEv:
   18|   158M|  simdutf_really_inline operator const __m128i &() const { return this->value; }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IbE10to_bitmaskEv:
   95|  12.4M|  simdutf_really_inline int to_bitmask() const {
   96|  12.4M|    return _mm_movemask_epi8(*this);
   97|  12.4M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE21any_bits_set_anywhereEv:
  235|  2.30M|  simdutf_really_inline bool any_bits_set_anywhere() const {
  236|  2.30M|    return !bits_not_set_anywhere();
  237|  2.30M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE21bits_not_set_anywhereEv:
  232|  2.30M|  simdutf_really_inline bool bits_not_set_anywhere() const {
  233|  2.30M|    return _mm_testz_si128(*this, *this);
  234|  2.30M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaEC2EPKa:
  270|  6.04M|      : chunks{simd8<T>::load(ptr),
  271|  6.04M|               simd8<T>::load(ptr + sizeof(simd8<T>) / sizeof(T)),
  272|  6.04M|               simd8<T>::load(ptr + 2 * sizeof(simd8<T>) / sizeof(T)),
  273|  6.04M|               simd8<T>::load(ptr + 3 * sizeof(simd8<T>) / sizeof(T))} {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIaE4loadEPKa:
  106|  43.7M|  static simdutf_really_inline simd8<T> load(const T values[16]) {
  107|  43.7M|    return _mm_loadu_si128(reinterpret_cast<const __m128i *>(values));
  108|  43.7M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IaEC2EDv2_x:
  163|  81.0M|      : base8_numeric<int8_t>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIaEC2EDv2_x:
  120|  81.0M|      : base8<T>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5base8IaNS2_5simd8IbEEEC2EDv2_x:
   69|  81.0M|  simdutf_really_inline base8(const __m128i _value) : base<simd8<T>>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IaEEEC2EDv2_x:
   16|  81.0M|  simdutf_really_inline base(const __m128i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE8is_asciiEv:
  295|  5.29M|  simdutf_really_inline bool is_ascii() const {
  296|  5.29M|    return this->reduce_or().is_ascii();
  297|  5.29M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE9reduce_orEv:
  290|  5.29M|  simdutf_really_inline simd8<T> reduce_or() const {
  291|  5.29M|    return (this->chunks[0] | this->chunks[1]) |
  292|  5.29M|           (this->chunks[2] | this->chunks[3]);
  293|  5.29M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IaEEEorES5_:
   42|  15.8M|  simdutf_really_inline Child operator|(const Child other) const {
   43|  15.8M|    return _mm_or_si128(*this, other);
   44|  15.8M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IaEEEcvRKDv2_xEv:
   18|   130M|  simdutf_really_inline operator const __m128i &() const { return this->value; }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IaE8is_asciiEv:
  168|  5.29M|  simdutf_really_inline bool is_ascii() const {
  169|  5.29M|    return _mm_movemask_epi8(*this) == 0;
  170|  5.29M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE5storeEPa:
  275|   903k|  simdutf_really_inline void store(T *ptr) const {
  276|   903k|    this->chunks[0].store(ptr + sizeof(simd8<T>) * 0 / sizeof(T));
  277|   903k|    this->chunks[1].store(ptr + sizeof(simd8<T>) * 1 / sizeof(T));
  278|   903k|    this->chunks[2].store(ptr + sizeof(simd8<T>) * 2 / sizeof(T));
  279|   903k|    this->chunks[3].store(ptr + sizeof(simd8<T>) * 3 / sizeof(T));
  280|   903k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIaE5storeEPa:
  123|  3.61M|  simdutf_really_inline void store(T dst[16]) const {
  124|  3.61M|    return _mm_storeu_si128(reinterpret_cast<__m128i *>(dst), *this);
  125|  3.61M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IaEcvNS3_IhEEEv:
  251|  4.80M|simdutf_really_inline simd8<int8_t>::operator simd8<uint8_t>() const {
  252|  4.80M|  return this->value;
  253|  4.80M|}
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|  21.4M|  static simdutf_really_inline simd8<T> splat(T _value) {
  103|  21.4M|    return _mm_set1_epi8(_value);
  104|  21.4M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IaEltES4_:
  176|  4.22M|  simdutf_really_inline simd8<bool> operator<(const simd8<int8_t> other) const {
  177|  4.22M|    return _mm_cmpgt_epi8(other, *this);
  178|  4.22M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IbEC2ENS2_5simd8IbEES6_S6_S6_:
  268|  1.80M|      : chunks{chunk0, chunk1, chunk2, chunk3} {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IbE10to_bitmaskEv:
  318|  1.80M|  simdutf_really_inline uint64_t to_bitmask() const {
  319|  1.80M|    uint64_t r0 = uint32_t(this->chunks[0].to_bitmask());
  320|  1.80M|    uint64_t r1 = this->chunks[1].to_bitmask();
  321|  1.80M|    uint64_t r2 = this->chunks[2].to_bitmask();
  322|  1.80M|    uint64_t r3 = this->chunks[3].to_bitmask();
  323|  1.80M|    return r0 | (r1 << 16) | (r2 << 32) | (r3 << 48);
  324|  1.80M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE20store_ascii_as_utf32EPDi:
  311|  1.19M|  simdutf_really_inline void store_ascii_as_utf32(char32_t *ptr) const {
  312|  1.19M|    this->chunks[0].store_ascii_as_utf32(ptr + sizeof(simd8<T>) * 0);
  313|  1.19M|    this->chunks[1].store_ascii_as_utf32(ptr + sizeof(simd8<T>) * 1);
  314|  1.19M|    this->chunks[2].store_ascii_as_utf32(ptr + sizeof(simd8<T>) * 2);
  315|  1.19M|    this->chunks[3].store_ascii_as_utf32(ptr + sizeof(simd8<T>) * 3);
  316|  1.19M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IaEEE20store_ascii_as_utf32EPDi:
   32|  4.78M|  simdutf_really_inline void store_ascii_as_utf32(char32_t *p) const {
   33|  4.78M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p), _mm_cvtepu8_epi32(*this));
   34|  4.78M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p + 4),
   35|  4.78M|                     _mm_cvtepu8_epi32(_mm_srli_si128(*this, 4)));
   36|  4.78M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p + 8),
   37|  4.78M|                     _mm_cvtepu8_epi32(_mm_srli_si128(*this, 8)));
   38|  4.78M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p + 12),
   39|       |                     _mm_cvtepu8_epi32(_mm_srli_si128(*this, 12)));
   40|  4.78M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE4zeroEv:
  105|   208k|  static simdutf_really_inline simd8<T> zero() { return _mm_setzero_si128(); }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IaEgtES4_:
  173|  22.6M|  simdutf_really_inline simd8<bool> operator>(const simd8<int8_t> other) const {
  174|  22.6M|    return _mm_cmpgt_epi8(*this, other);
  175|  22.6M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IaEC2Ea:
  165|  19.6M|  simdutf_really_inline simd8(int8_t _value) : simd8(splat(_value)) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhEmIENS2_5simd8IhEE:
  134|  25.6M|  simdutf_really_inline simd8<T> &operator-=(const simd8<T> other) {
  135|  25.6M|    *this = *this - other;
  136|  25.6M|    return *static_cast<simd8<T> *>(this);
  137|  25.6M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhEmiENS2_5simd8IhEE:
  131|  25.6M|  simdutf_really_inline simd8<T> operator-(const simd8<T> other) const {
  132|  25.6M|    return _mm_sub_epi8(*this, other);
  133|  25.6M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd10sum_8bytesENS2_5simd8IhEE:
  366|   101k|simdutf_really_inline simd64<uint64_t> sum_8bytes(const simd8<uint8_t> v) {
  367|   101k|  return _mm_sad_epu8(v.value, simd8<uint8_t>::zero());
  368|   101k|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE9sum_bytesEv:
  245|  3.84k|  simdutf_really_inline uint64_t sum_bytes() const {
  246|  3.84k|    const auto tmp = _mm_sad_epu8(value, _mm_setzero_si128());
  247|  3.84k|    return _mm_extract_epi64(tmp, 0) + _mm_extract_epi64(tmp, 1);
  248|  3.84k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEgeES4_:
  217|  6.08M|  operator>=(const simd8<uint8_t> other) const {
  218|  6.08M|    return other.min_val(*this) == other;
  219|  6.08M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE7min_valES4_:
  207|  6.08M|  min_val(const simd8<uint8_t> other) const {
  208|  6.08M|    return _mm_min_epu8(*this, other);
  209|  6.08M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE2gtEa:
  333|   752k|  simdutf_really_inline uint64_t gt(const T m) const {
  334|   752k|    const simd8<T> mask = simd8<T>::splat(m);
  335|   752k|    return simd8x64<bool>(this->chunks[0] > mask, this->chunks[1] > mask,
  336|   752k|                          this->chunks[2] > mask, this->chunks[3] > mask)
  337|   752k|        .to_bitmask();
  338|   752k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16IbEEEC2EDv2_x:
   16|  30.3M|  simdutf_really_inline base(const __m128i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16IbEEEcvRKDv2_xEv:
   18|  30.3M|  simdutf_really_inline operator const __m128i &() const { return this->value; }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE5splatEh:
  102|  43.6M|  static simdutf_really_inline simd8<T> splat(T _value) {
  103|  43.6M|    return _mm_set1_epi8(_value);
  104|  43.6M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEcvRKDv2_xEv:
   18|   373M|  simdutf_really_inline operator const __m128i &() const { return this->value; }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdeqENS2_5simd8IhEES4_:
   72|  11.2M|                                               const simd8<T> rhs) {
   73|  11.2M|    return _mm_cmpeq_epi8(lhs, rhs);
   74|  11.2M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEanES5_:
   45|  42.5M|  simdutf_really_inline Child operator&(const Child other) const {
   46|  42.5M|    return _mm_and_si128(*this, other);
   47|  42.5M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IhEC2EPKh:
  270|  4.87M|      : chunks{simd8<T>::load(ptr),
  271|  4.87M|               simd8<T>::load(ptr + sizeof(simd8<T>) / sizeof(T)),
  272|  4.87M|               simd8<T>::load(ptr + 2 * sizeof(simd8<T>) / sizeof(T)),
  273|  4.87M|               simd8<T>::load(ptr + 3 * sizeof(simd8<T>) / sizeof(T))} {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16ItEEEanES5_:
   45|  17.2M|  simdutf_really_inline Child operator&(const Child other) const {
   46|  17.2M|    return _mm_and_si128(*this, other);
   47|  17.2M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE20store_ascii_as_utf16ILNS_10endiannessE0EEEvPDs:
  300|  1.00M|  simdutf_really_inline void store_ascii_as_utf16(char16_t *ptr) const {
  301|  1.00M|    this->chunks[0].template store_ascii_as_utf16<endian>(ptr +
  302|  1.00M|                                                          sizeof(simd8<T>) * 0);
  303|  1.00M|    this->chunks[1].template store_ascii_as_utf16<endian>(ptr +
  304|  1.00M|                                                          sizeof(simd8<T>) * 1);
  305|  1.00M|    this->chunks[2].template store_ascii_as_utf16<endian>(ptr +
  306|  1.00M|                                                          sizeof(simd8<T>) * 2);
  307|  1.00M|    this->chunks[3].template store_ascii_as_utf16<endian>(ptr +
  308|  1.00M|                                                          sizeof(simd8<T>) * 3);
  309|  1.00M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IaEEE20store_ascii_as_utf16ILNS_10endiannessE0EEEvPDs:
   20|  4.00M|  simdutf_really_inline void store_ascii_as_utf16(char16_t *p) const {
   21|  4.00M|    __m128i first = _mm_cvtepu8_epi16(*this);
   22|  4.00M|    __m128i second = _mm_cvtepu8_epi16(_mm_srli_si128(*this, 8));
   23|  4.00M|    if (big_endian) {
  ------------------
  |  Branch (23:9): [Folded, False: 4.00M]
  ------------------
   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|  4.00M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p), first);
   30|  4.00M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p + 8), second);
   31|  4.00M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE20store_ascii_as_utf16ILNS_10endiannessE1EEEvPDs:
  300|  1.13M|  simdutf_really_inline void store_ascii_as_utf16(char16_t *ptr) const {
  301|  1.13M|    this->chunks[0].template store_ascii_as_utf16<endian>(ptr +
  302|  1.13M|                                                          sizeof(simd8<T>) * 0);
  303|  1.13M|    this->chunks[1].template store_ascii_as_utf16<endian>(ptr +
  304|  1.13M|                                                          sizeof(simd8<T>) * 1);
  305|  1.13M|    this->chunks[2].template store_ascii_as_utf16<endian>(ptr +
  306|  1.13M|                                                          sizeof(simd8<T>) * 2);
  307|  1.13M|    this->chunks[3].template store_ascii_as_utf16<endian>(ptr +
  308|  1.13M|                                                          sizeof(simd8<T>) * 3);
  309|  1.13M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IaEEE20store_ascii_as_utf16ILNS_10endiannessE1EEEvPDs:
   20|  4.53M|  simdutf_really_inline void store_ascii_as_utf16(char16_t *p) const {
   21|  4.53M|    __m128i first = _mm_cvtepu8_epi16(*this);
   22|  4.53M|    __m128i second = _mm_cvtepu8_epi16(_mm_srli_si128(*this, 8));
   23|  4.53M|    if (big_endian) {
  ------------------
  |  Branch (23:9): [True: 4.53M, Folded]
  ------------------
   24|  4.53M|      const __m128i swap =
   25|  4.53M|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   26|  4.53M|      first = _mm_shuffle_epi8(first, swap);
   27|  4.53M|      second = _mm_shuffle_epi8(second, swap);
   28|  4.53M|    }
   29|  4.53M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p), first);
   30|  4.53M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p + 8), second);
   31|  4.53M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd12as_vector_u8ENS2_6simd32IjEE:
  370|  13.8k|simdutf_really_inline simd8<uint8_t> as_vector_u8(const simd32<uint32_t> v) {
  371|  13.8k|  return simd8<uint8_t>(v.value);
  372|  13.8k|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16IbEEEorES5_:
   42|  8.77M|  simdutf_really_inline Child operator|(const Child other) const {
   43|  8.77M|    return _mm_or_si128(*this, other);
   44|  8.77M|  }

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd16ItEC2EDv2_x:
   79|   116M|      : base16_numeric<uint16_t>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd14base16_numericItEC2EDv2_x:
   54|   116M|      : base16<T>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6base16ItNS2_6simd16IbEEEC2EDv2_x:
    8|   116M|      : base<simd16<T>>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd16ItE4packERKS4_S6_:
  130|  5.15M|                                                   const simd16<uint16_t> &v1) {
  131|  5.15M|    return _mm_packus_epi16(v0, v1);
  132|  5.15M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd9simd16x32ItEC2EPKt:
  164|  2.19M|      : chunks{simd16<T>::load(ptr),
  165|  2.19M|               simd16<T>::load(ptr + sizeof(simd16<T>) / sizeof(T)),
  166|  2.19M|               simd16<T>::load(ptr + 2 * sizeof(simd16<T>) / sizeof(T)),
  167|  2.19M|               simd16<T>::load(ptr + 3 * sizeof(simd16<T>) / sizeof(T))} {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd14base16_numericItE4loadEPKt:
   47|  23.1M|  static simdutf_really_inline simd16<T> load(const T values[8]) {
   48|  23.1M|    return _mm_loadu_si128(reinterpret_cast<const __m128i *>(values));
   49|  23.1M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd9simd16x32ItE10swap_bytesEv:
  200|  1.03M|  simdutf_really_inline void swap_bytes() {
  201|  1.03M|    this->chunks[0] = this->chunks[0].swap_bytes();
  202|  1.03M|    this->chunks[1] = this->chunks[1].swap_bytes();
  203|  1.03M|    this->chunks[2] = this->chunks[2].swap_bytes();
  204|  1.03M|    this->chunks[3] = this->chunks[3].swap_bytes();
  205|  1.03M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd16ItE10swap_bytesEv:
  121|  6.05M|  simdutf_really_inline simd16<uint16_t> swap_bytes() const {
  122|  6.05M|    const __m128i swap =
  123|  6.05M|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  124|  6.05M|    return _mm_shuffle_epi8(*this, swap);
  125|  6.05M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd14base16_numericItE5splatEt:
   41|  23.0M|  static simdutf_really_inline simd16<T> splat(T _value) {
   42|  23.0M|    return _mm_set1_epi16(_value);
   43|  23.0M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdeqENS2_6simd16ItEES4_:
   11|  21.5M|                                               const simd16<T> rhs) {
   12|  21.5M|    return _mm_cmpeq_epi16(lhs, rhs);
   13|  21.5M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd16IbEC2EDv2_x:
   28|  30.3M|  simdutf_really_inline simd16(const __m128i _value) : base16<bool>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6base16IbNS2_6simd16IbEEEC2EDv2_x:
    8|  30.3M|      : base<simd16<T>>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd9simd16x32IbEC2ENS2_6simd16IbEES6_S6_S6_:
  162|  2.19M|      : chunks{chunk0, chunk1, chunk2, chunk3} {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd9simd16x32IbE10to_bitmaskEv:
  192|  2.19M|  simdutf_really_inline uint64_t to_bitmask() const {
  193|  2.19M|    uint64_t r0 = uint32_t(this->chunks[0].to_bitmask());
  194|  2.19M|    uint64_t r1 = this->chunks[1].to_bitmask();
  195|  2.19M|    uint64_t r2 = this->chunks[2].to_bitmask();
  196|  2.19M|    uint64_t r3 = this->chunks[3].to_bitmask();
  197|  2.19M|    return r0 | (r1 << 16) | (r2 << 32) | (r3 << 48);
  198|  2.19M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd16IbE10to_bitmaskEv:
   33|  8.77M|  simdutf_really_inline int to_bitmask() const {
   34|  8.77M|    return _mm_movemask_epi8(*this);
   35|  8.77M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd16ItEgeES4_:
  104|  8.77M|  operator>=(const simd16<uint16_t> other) const {
  105|  8.77M|    return other.min_val(*this) == other;
  106|  8.77M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd16ItE7min_valES4_:
   95|  8.77M|  min_val(const simd16<uint16_t> other) const {
   96|  8.77M|    return _mm_min_epu16(*this, other);
   97|  8.77M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd16ItE3shrILi8EEES4_v:
  116|  5.08M|  template <int N> simdutf_really_inline simd16<uint16_t> shr() const {
  117|  5.08M|    return simd16<uint16_t>(_mm_srli_epi16(*this, N));
  118|  5.08M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd16ItEleES4_:
  100|  8.77M|  operator<=(const simd16<uint16_t> other) const {
  101|  8.77M|    return other.max_val(*this) == other;
  102|  8.77M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd16ItE7max_valES4_:
   90|  8.77M|  max_val(const simd16<uint16_t> other) const {
   91|  8.77M|    return _mm_max_epu16(*this, other);
   92|  8.77M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd16ItEC2EPKDs:
   86|  10.3M|      : simd16(load(reinterpret_cast<const uint16_t *>(values))) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd16ItEC2Et:
   82|  18.6M|  simdutf_really_inline simd16(uint16_t _value) : simd16(splat(_value)) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd9simd16x32ItE12not_in_rangeEtt:
  228|  2.19M|  simdutf_really_inline uint64_t not_in_range(const T low, const T high) const {
  229|  2.19M|    const simd16<T> mask_low = simd16<T>::splat(static_cast<T>(low - 1));
  230|  2.19M|    const simd16<T> mask_high = simd16<T>::splat(static_cast<T>(high + 1));
  231|  2.19M|    return simd16x32<bool>(
  232|  2.19M|               (this->chunks[0] >= mask_high) | (this->chunks[0] <= mask_low),
  233|  2.19M|               (this->chunks[1] >= mask_high) | (this->chunks[1] <= mask_low),
  234|  2.19M|               (this->chunks[2] >= mask_high) | (this->chunks[2] <= mask_low),
  235|  2.19M|               (this->chunks[3] >= mask_high) | (this->chunks[3] <= mask_low))
  236|  2.19M|        .to_bitmask();
  237|  2.19M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd14base16_numericItE4zeroEv:
   45|  1.59k|  static simdutf_really_inline simd16<T> zero() { return _mm_setzero_si128(); }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd3minENS2_6simd16ItEES4_:
  240|  8.02M|simd16<uint16_t> min(const simd16<uint16_t> a, simd16<uint16_t> b) {
  241|  8.02M|  return _mm_min_epu16(a.value, b.value);
  242|  8.02M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd14base16_numericItEpLENS2_6simd16ItEE:
   68|  12.0M|  simdutf_really_inline simd16<T> &operator+=(const simd16<T> other) {
   69|  12.0M|    *this = *this + other;
   70|  12.0M|    return *static_cast<simd16<T> *>(this);
   71|  12.0M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd14base16_numericItEplENS2_6simd16ItEE:
   65|  12.0M|  simdutf_really_inline simd16<T> operator+(const simd16<T> other) const {
   66|  12.0M|    return _mm_add_epi16(*this, other);
   67|  12.0M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd16ItE3sumEv:
  134|  1.59k|  simdutf_really_inline uint64_t sum() const {
  135|  1.59k|    const auto lo_u16 = _mm_and_si128(value, _mm_set1_epi32(0x0000ffff));
  136|  1.59k|    const auto hi_u16 = _mm_srli_epi32(value, 16);
  137|  1.59k|    const auto sum_u32 = _mm_add_epi32(lo_u16, hi_u16);
  138|       |
  139|  1.59k|    const auto lo_u32 = _mm_and_si128(sum_u32, _mm_set1_epi64x(0xffffffff));
  140|  1.59k|    const auto hi_u32 = _mm_srli_epi64(sum_u32, 32);
  141|  1.59k|    const auto sum_u64 = _mm_add_epi64(lo_u32, hi_u32);
  142|       |
  143|  1.59k|    return uint64_t(_mm_extract_epi64(sum_u64, 0)) +
  144|       |           uint64_t(_mm_extract_epi64(sum_u64, 1));
  145|  1.59k|  }

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

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

_ZNK7simdutf8westmere14implementation13validate_utf8EPKcm:
  299|  3.48k|implementation::validate_utf8(const char *buf, size_t len) const noexcept {
  300|  3.48k|  return westmere::utf8_validation::generic_validate_utf8(buf, len);
  301|  3.48k|}
_ZNK7simdutf8westmere14implementation25validate_utf8_with_errorsEPKcm:
  306|  3.48k|    const char *buf, size_t len) const noexcept {
  307|  3.48k|  return westmere::utf8_validation::generic_validate_utf8_with_errors(buf, len);
  308|  3.48k|}
_ZNK7simdutf8westmere14implementation16validate_utf16leEPKDsm:
  345|  1.35k|                                 size_t len) const noexcept {
  346|  1.35k|  if (simdutf_unlikely(len == 0)) {
  ------------------
  |  |   93|  1.35k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 17, False: 1.33k]
  |  |  ------------------
  ------------------
  347|       |    // empty input is valid UTF-16. protect the implementation from
  348|       |    // handling nullptr
  349|     17|    return true;
  350|     17|  }
  351|  1.33k|  const auto res =
  352|  1.33k|      westmere::utf16::validate_utf16_with_errors<endianness::LITTLE>(buf, len);
  353|  1.33k|  if (res.is_err()) {
  ------------------
  |  Branch (353:7): [True: 139, False: 1.19k]
  ------------------
  354|    139|    return false;
  355|    139|  }
  356|       |
  357|  1.19k|  if (res.count == len)
  ------------------
  |  Branch (357:7): [True: 0, False: 1.19k]
  ------------------
  358|      0|    return true;
  359|       |
  360|  1.19k|  return scalar::utf16::validate<endianness::LITTLE>(buf + res.count,
  361|  1.19k|                                                     len - res.count);
  362|  1.19k|}
_ZNK7simdutf8westmere14implementation16validate_utf16beEPKDsm:
  368|  1.33k|                                 size_t len) const noexcept {
  369|  1.33k|  if (simdutf_unlikely(len == 0)) {
  ------------------
  |  |   93|  1.33k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 16, False: 1.32k]
  |  |  ------------------
  ------------------
  370|       |    // empty input is valid UTF-16. protect the implementation from
  371|       |    // handling nullptr
  372|     16|    return true;
  373|     16|  }
  374|  1.32k|  const auto res =
  375|  1.32k|      westmere::utf16::validate_utf16_with_errors<endianness::BIG>(buf, len);
  376|  1.32k|  if (res.is_err()) {
  ------------------
  |  Branch (376:7): [True: 155, False: 1.16k]
  ------------------
  377|    155|    return false;
  378|    155|  }
  379|       |
  380|  1.16k|  if (res.count == len)
  ------------------
  |  Branch (380:7): [True: 0, False: 1.16k]
  ------------------
  381|      0|    return true;
  382|       |
  383|  1.16k|  return scalar::utf16::validate<endianness::BIG>(buf + res.count,
  384|  1.16k|                                                  len - res.count);
  385|  1.16k|}
_ZNK7simdutf8westmere14implementation28validate_utf16le_with_errorsEPKDsm:
  388|  1.35k|    const char16_t *buf, size_t len) const noexcept {
  389|  1.35k|  const result res =
  390|  1.35k|      westmere::utf16::validate_utf16_with_errors<endianness::LITTLE>(buf, len);
  391|  1.35k|  if (res.count != len) {
  ------------------
  |  Branch (391:7): [True: 1.33k, False: 17]
  ------------------
  392|  1.33k|    const result scalar_res =
  393|  1.33k|        scalar::utf16::validate_with_errors<endianness::LITTLE>(
  394|  1.33k|            buf + res.count, len - res.count);
  395|  1.33k|    return result(scalar_res.error, res.count + scalar_res.count);
  396|  1.33k|  } else {
  397|     17|    return res;
  398|     17|  }
  399|  1.35k|}
_ZNK7simdutf8westmere14implementation28validate_utf16be_with_errorsEPKDsm:
  402|  1.33k|    const char16_t *buf, size_t len) const noexcept {
  403|  1.33k|  const result res =
  404|  1.33k|      westmere::utf16::validate_utf16_with_errors<endianness::BIG>(buf, len);
  405|  1.33k|  if (res.count != len) {
  ------------------
  |  Branch (405:7): [True: 1.32k, False: 16]
  ------------------
  406|  1.32k|    result scalar_res = scalar::utf16::validate_with_errors<endianness::BIG>(
  407|  1.32k|        buf + res.count, len - res.count);
  408|  1.32k|    return result(scalar_res.error, res.count + scalar_res.count);
  409|  1.32k|  } else {
  410|     16|    return res;
  411|     16|  }
  412|  1.33k|}
_ZNK7simdutf8westmere14implementation14validate_utf32EPKDim:
  427|  2.63k|implementation::validate_utf32(const char32_t *buf, size_t len) const noexcept {
  428|  2.63k|  return utf32::validate(buf, len);
  429|  2.63k|}
_ZNK7simdutf8westmere14implementation26validate_utf32_with_errorsEPKDim:
  434|  2.63k|    const char32_t *buf, size_t len) const noexcept {
  435|  2.63k|  return utf32::validate_with_errors(buf, len);
  436|  2.63k|}
_ZNK7simdutf8westmere14implementation22convert_latin1_to_utf8EPKcmPc:
  441|    604|    const char *buf, size_t len, char *utf8_output) const noexcept {
  442|       |
  443|    604|  std::pair<const char *, char *> ret =
  444|    604|      sse_convert_latin1_to_utf8(buf, len, utf8_output);
  445|    604|  size_t converted_chars = ret.second - utf8_output;
  446|       |
  447|    604|  if (ret.first != buf + len) {
  ------------------
  |  Branch (447:7): [True: 512, False: 92]
  ------------------
  448|    512|    const size_t scalar_converted_chars = scalar::latin1_to_utf8::convert(
  449|    512|        ret.first, len - (ret.first - buf), ret.second);
  450|    512|    converted_chars += scalar_converted_chars;
  451|    512|  }
  452|       |
  453|    604|  return converted_chars;
  454|    604|}
_ZNK7simdutf8westmere14implementation25convert_latin1_to_utf16leEPKcmPDs:
  459|     76|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  460|     76|  std::pair<const char *, char16_t *> ret =
  461|     76|      sse_convert_latin1_to_utf16<endianness::LITTLE>(buf, len, utf16_output);
  462|     76|  if (ret.first == nullptr) {
  ------------------
  |  Branch (462:7): [True: 4, False: 72]
  ------------------
  463|      4|    return 0;
  464|      4|  }
  465|     72|  size_t converted_chars = ret.second - utf16_output;
  466|     72|  if (ret.first != buf + len) {
  ------------------
  |  Branch (466:7): [True: 58, False: 14]
  ------------------
  467|     58|    const size_t scalar_converted_chars =
  468|     58|        scalar::latin1_to_utf16::convert<endianness::LITTLE>(
  469|     58|            ret.first, len - (ret.first - buf), ret.second);
  470|     58|    if (scalar_converted_chars == 0) {
  ------------------
  |  Branch (470:9): [True: 0, False: 58]
  ------------------
  471|      0|      return 0;
  472|      0|    }
  473|     58|    converted_chars += scalar_converted_chars;
  474|     58|  }
  475|     72|  return converted_chars;
  476|     72|}
_ZNK7simdutf8westmere14implementation25convert_latin1_to_utf16beEPKcmPDs:
  479|     96|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  480|     96|  std::pair<const char *, char16_t *> ret =
  481|     96|      sse_convert_latin1_to_utf16<endianness::BIG>(buf, len, utf16_output);
  482|     96|  if (ret.first == nullptr) {
  ------------------
  |  Branch (482:7): [True: 4, False: 92]
  ------------------
  483|      4|    return 0;
  484|      4|  }
  485|     92|  size_t converted_chars = ret.second - utf16_output;
  486|     92|  if (ret.first != buf + len) {
  ------------------
  |  Branch (486:7): [True: 78, False: 14]
  ------------------
  487|     78|    const size_t scalar_converted_chars =
  488|     78|        scalar::latin1_to_utf16::convert<endianness::BIG>(
  489|     78|            ret.first, len - (ret.first - buf), ret.second);
  490|     78|    if (scalar_converted_chars == 0) {
  ------------------
  |  Branch (490:9): [True: 0, False: 78]
  ------------------
  491|      0|      return 0;
  492|      0|    }
  493|     78|    converted_chars += scalar_converted_chars;
  494|     78|  }
  495|     92|  return converted_chars;
  496|     92|}
_ZNK7simdutf8westmere14implementation23convert_latin1_to_utf32EPKcmPDi:
  501|    124|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  502|    124|  std::pair<const char *, char32_t *> ret =
  503|    124|      sse_convert_latin1_to_utf32(buf, len, utf32_output);
  504|    124|  if (ret.first == nullptr) {
  ------------------
  |  Branch (504:7): [True: 4, False: 120]
  ------------------
  505|      4|    return 0;
  506|      4|  }
  507|    120|  size_t converted_chars = ret.second - utf32_output;
  508|    120|  if (ret.first != buf + len) {
  ------------------
  |  Branch (508:7): [True: 106, False: 14]
  ------------------
  509|    106|    const size_t scalar_converted_chars = scalar::latin1_to_utf32::convert(
  510|    106|        ret.first, len - (ret.first - buf), ret.second);
  511|    106|    if (scalar_converted_chars == 0) {
  ------------------
  |  Branch (511:9): [True: 0, False: 106]
  ------------------
  512|      0|      return 0;
  513|      0|    }
  514|    106|    converted_chars += scalar_converted_chars;
  515|    106|  }
  516|    120|  return converted_chars;
  517|    120|}
_ZNK7simdutf8westmere14implementation22convert_utf8_to_latin1EPKcmPc:
  522|    586|    const char *buf, size_t len, char *latin1_output) const noexcept {
  523|    586|  utf8_to_latin1::validating_transcoder converter;
  524|    586|  return converter.convert(buf, len, latin1_output);
  525|    586|}
_ZNK7simdutf8westmere14implementation34convert_utf8_to_latin1_with_errorsEPKcmPc:
  528|    512|    const char *buf, size_t len, char *latin1_output) const noexcept {
  529|    512|  utf8_to_latin1::validating_transcoder converter;
  530|    512|  return converter.convert_with_errors(buf, len, latin1_output);
  531|    512|}
_ZNK7simdutf8westmere14implementation23convert_utf8_to_utf16leEPKcmPDs:
  541|    776|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  542|    776|  utf8_to_utf16::validating_transcoder converter;
  543|    776|  return converter.convert<endianness::LITTLE>(buf, len, utf16_output);
  544|    776|}
_ZNK7simdutf8westmere14implementation23convert_utf8_to_utf16beEPKcmPDs:
  547|    794|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  548|    794|  utf8_to_utf16::validating_transcoder converter;
  549|    794|  return converter.convert<endianness::BIG>(buf, len, utf16_output);
  550|    794|}
_ZNK7simdutf8westmere14implementation35convert_utf8_to_utf16le_with_errorsEPKcmPDs:
  553|    610|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  554|    610|  utf8_to_utf16::validating_transcoder converter;
  555|    610|  return converter.convert_with_errors<endianness::LITTLE>(buf, len,
  556|    610|                                                           utf16_output);
  557|    610|}
_ZNK7simdutf8westmere14implementation35convert_utf8_to_utf16be_with_errorsEPKcmPDs:
  560|    706|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  561|    706|  utf8_to_utf16::validating_transcoder converter;
  562|    706|  return converter.convert_with_errors<endianness::BIG>(buf, len, utf16_output);
  563|    706|}
_ZNK7simdutf8westmere14implementation29convert_valid_utf8_to_utf16leEPKcmPDs:
  566|    450|    const char *input, size_t size, char16_t *utf16_output) const noexcept {
  567|    450|  return utf8_to_utf16::convert_valid<endianness::LITTLE>(input, size,
  568|    450|                                                          utf16_output);
  569|    450|}
_ZNK7simdutf8westmere14implementation29convert_valid_utf8_to_utf16beEPKcmPDs:
  572|    510|    const char *input, size_t size, char16_t *utf16_output) const noexcept {
  573|    510|  return utf8_to_utf16::convert_valid<endianness::BIG>(input, size,
  574|    510|                                                       utf16_output);
  575|    510|}
_ZNK7simdutf8westmere14implementation21convert_utf8_to_utf32EPKcmPDi:
  580|    758|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  581|    758|  utf8_to_utf32::validating_transcoder converter;
  582|    758|  return converter.convert(buf, len, utf32_output);
  583|    758|}
_ZNK7simdutf8westmere14implementation33convert_utf8_to_utf32_with_errorsEPKcmPDi:
  586|    746|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  587|    746|  utf8_to_utf32::validating_transcoder converter;
  588|    746|  return converter.convert_with_errors(buf, len, utf32_output);
  589|    746|}
_ZNK7simdutf8westmere14implementation27convert_valid_utf8_to_utf32EPKcmPDi:
  592|    464|    const char *input, size_t size, char32_t *utf32_output) const noexcept {
  593|    464|  return utf8_to_utf32::convert_valid(input, size, utf32_output);
  594|    464|}
_ZNK7simdutf8westmere14implementation25convert_utf16le_to_latin1EPKDsmPc:
  599|    124|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  600|    124|  std::pair<const char16_t *, char *> ret =
  601|    124|      sse_convert_utf16_to_latin1<endianness::LITTLE>(buf, len, latin1_output);
  602|    124|  if (ret.first == nullptr) {
  ------------------
  |  Branch (602:7): [True: 42, False: 82]
  ------------------
  603|     42|    return 0;
  604|     42|  }
  605|     82|  size_t saved_bytes = ret.second - latin1_output;
  606|       |
  607|     82|  if (ret.first != buf + len) {
  ------------------
  |  Branch (607:7): [True: 64, False: 18]
  ------------------
  608|     64|    const size_t scalar_saved_bytes =
  609|     64|        scalar::utf16_to_latin1::convert<endianness::LITTLE>(
  610|     64|            ret.first, len - (ret.first - buf), ret.second);
  611|     64|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (611:9): [True: 40, False: 24]
  ------------------
  612|     40|      return 0;
  613|     40|    }
  614|     24|    saved_bytes += scalar_saved_bytes;
  615|     24|  }
  616|     42|  return saved_bytes;
  617|     82|}
_ZNK7simdutf8westmere14implementation25convert_utf16be_to_latin1EPKDsmPc:
  620|    114|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  621|    114|  std::pair<const char16_t *, char *> ret =
  622|    114|      sse_convert_utf16_to_latin1<endianness::BIG>(buf, len, latin1_output);
  623|    114|  if (ret.first == nullptr) {
  ------------------
  |  Branch (623:7): [True: 42, False: 72]
  ------------------
  624|     42|    return 0;
  625|     42|  }
  626|     72|  size_t saved_bytes = ret.second - latin1_output;
  627|       |
  628|     72|  if (ret.first != buf + len) {
  ------------------
  |  Branch (628:7): [True: 56, False: 16]
  ------------------
  629|     56|    const size_t scalar_saved_bytes =
  630|     56|        scalar::utf16_to_latin1::convert<endianness::BIG>(
  631|     56|            ret.first, len - (ret.first - buf), ret.second);
  632|     56|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (632:9): [True: 24, False: 32]
  ------------------
  633|     24|      return 0;
  634|     24|    }
  635|     32|    saved_bytes += scalar_saved_bytes;
  636|     32|  }
  637|     48|  return saved_bytes;
  638|     72|}
_ZNK7simdutf8westmere14implementation37convert_utf16le_to_latin1_with_errorsEPKDsmPc:
  642|    278|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  643|    278|  std::pair<result, char *> ret =
  644|    278|      sse_convert_utf16_to_latin1_with_errors<endianness::LITTLE>(
  645|    278|          buf, len, latin1_output);
  646|    278|  if (ret.first.error) {
  ------------------
  |  Branch (646:7): [True: 158, False: 120]
  ------------------
  647|    158|    return ret.first;
  648|    158|  } // Can return directly since scalar fallback already found correct
  649|       |    // ret.first.count
  650|    120|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (650:7): [True: 64, False: 56]
  ------------------
  651|     64|    result scalar_res =
  652|     64|        scalar::utf16_to_latin1::convert_with_errors<endianness::LITTLE>(
  653|     64|            buf + ret.first.count, len - ret.first.count, ret.second);
  654|     64|    if (scalar_res.error) {
  ------------------
  |  Branch (654:9): [True: 26, False: 38]
  ------------------
  655|     26|      scalar_res.count += ret.first.count;
  656|     26|      return scalar_res;
  657|     38|    } else {
  658|     38|      ret.second += scalar_res.count;
  659|     38|    }
  660|     64|  }
  661|     94|  ret.first.count =
  662|     94|      ret.second -
  663|     94|      latin1_output; // Set count to the number of 8-bit code units written
  664|     94|  return ret.first;
  665|    120|}
_ZNK7simdutf8westmere14implementation37convert_utf16be_to_latin1_with_errorsEPKDsmPc:
  669|    266|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  670|    266|  std::pair<result, char *> ret =
  671|    266|      sse_convert_utf16_to_latin1_with_errors<endianness::BIG>(buf, len,
  672|    266|                                                               latin1_output);
  673|    266|  if (ret.first.error) {
  ------------------
  |  Branch (673:7): [True: 142, False: 124]
  ------------------
  674|    142|    return ret.first;
  675|    142|  } // Can return directly since scalar fallback already found correct
  676|       |    // ret.first.count
  677|    124|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (677:7): [True: 80, False: 44]
  ------------------
  678|     80|    result scalar_res =
  679|     80|        scalar::utf16_to_latin1::convert_with_errors<endianness::BIG>(
  680|     80|            buf + ret.first.count, len - ret.first.count, ret.second);
  681|     80|    if (scalar_res.error) {
  ------------------
  |  Branch (681:9): [True: 32, False: 48]
  ------------------
  682|     32|      scalar_res.count += ret.first.count;
  683|     32|      return scalar_res;
  684|     48|    } else {
  685|     48|      ret.second += scalar_res.count;
  686|     48|    }
  687|     80|  }
  688|     92|  ret.first.count =
  689|     92|      ret.second -
  690|     92|      latin1_output; // Set count to the number of 8-bit code units written
  691|     92|  return ret.first;
  692|    124|}
_ZNK7simdutf8westmere14implementation23convert_utf16le_to_utf8EPKDsmPc:
  709|    842|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  710|    842|  std::pair<const char16_t *, char *> ret =
  711|    842|      sse_convert_utf16_to_utf8<endianness::LITTLE>(buf, len, utf8_output);
  712|    842|  if (ret.first == nullptr) {
  ------------------
  |  Branch (712:7): [True: 112, False: 730]
  ------------------
  713|    112|    return 0;
  714|    112|  }
  715|    730|  size_t saved_bytes = ret.second - utf8_output;
  716|    730|  if (ret.first != buf + len) {
  ------------------
  |  Branch (716:7): [True: 728, False: 2]
  ------------------
  717|    728|    const size_t scalar_saved_bytes =
  718|    728|        scalar::utf16_to_utf8::convert<endianness::LITTLE>(
  719|    728|            ret.first, len - (ret.first - buf), ret.second);
  720|    728|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (720:9): [True: 92, False: 636]
  ------------------
  721|     92|      return 0;
  722|     92|    }
  723|    636|    saved_bytes += scalar_saved_bytes;
  724|    636|  }
  725|    638|  return saved_bytes;
  726|    730|}
_ZNK7simdutf8westmere14implementation23convert_utf16be_to_utf8EPKDsmPc:
  729|    798|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  730|    798|  std::pair<const char16_t *, char *> ret =
  731|    798|      sse_convert_utf16_to_utf8<endianness::BIG>(buf, len, utf8_output);
  732|    798|  if (ret.first == nullptr) {
  ------------------
  |  Branch (732:7): [True: 94, False: 704]
  ------------------
  733|     94|    return 0;
  734|     94|  }
  735|    704|  size_t saved_bytes = ret.second - utf8_output;
  736|    704|  if (ret.first != buf + len) {
  ------------------
  |  Branch (736:7): [True: 702, False: 2]
  ------------------
  737|    702|    const size_t scalar_saved_bytes =
  738|    702|        scalar::utf16_to_utf8::convert<endianness::BIG>(
  739|    702|            ret.first, len - (ret.first - buf), ret.second);
  740|    702|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (740:9): [True: 70, False: 632]
  ------------------
  741|     70|      return 0;
  742|     70|    }
  743|    632|    saved_bytes += scalar_saved_bytes;
  744|    632|  }
  745|    634|  return saved_bytes;
  746|    704|}
_ZNK7simdutf8westmere14implementation35convert_utf16le_to_utf8_with_errorsEPKDsmPc:
  749|    642|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  750|       |  // ret.first.count is always the position in the buffer, not the number of
  751|       |  // code units written even if finished
  752|    642|  std::pair<result, char *> ret =
  753|    642|      westmere::sse_convert_utf16_to_utf8_with_errors<endianness::LITTLE>(
  754|    642|          buf, len, utf8_output);
  755|    642|  if (ret.first.error) {
  ------------------
  |  Branch (755:7): [True: 146, False: 496]
  ------------------
  756|    146|    return ret.first;
  757|    146|  } // Can return directly since scalar fallback already found correct
  758|       |    // ret.first.count
  759|    496|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (759:7): [True: 492, False: 4]
  ------------------
  760|    492|    result scalar_res =
  761|    492|        scalar::utf16_to_utf8::convert_with_errors<endianness::LITTLE>(
  762|    492|            buf + ret.first.count, len - ret.first.count, ret.second);
  763|    492|    if (scalar_res.error) {
  ------------------
  |  Branch (763:9): [True: 94, False: 398]
  ------------------
  764|     94|      scalar_res.count += ret.first.count;
  765|     94|      return scalar_res;
  766|    398|    } else {
  767|    398|      ret.second += scalar_res.count;
  768|    398|    }
  769|    492|  }
  770|    402|  ret.first.count =
  771|    402|      ret.second -
  772|    402|      utf8_output; // Set count to the number of 8-bit code units written
  773|    402|  return ret.first;
  774|    496|}
_ZNK7simdutf8westmere14implementation35convert_utf16be_to_utf8_with_errorsEPKDsmPc:
  777|    654|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  778|       |  // ret.first.count is always the position in the buffer, not the number of
  779|       |  // code units written even if finished
  780|    654|  std::pair<result, char *> ret =
  781|    654|      westmere::sse_convert_utf16_to_utf8_with_errors<endianness::BIG>(
  782|    654|          buf, len, utf8_output);
  783|    654|  if (ret.first.error) {
  ------------------
  |  Branch (783:7): [True: 158, False: 496]
  ------------------
  784|    158|    return ret.first;
  785|    158|  } // Can return directly since scalar fallback already found correct
  786|       |    // ret.first.count
  787|    496|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (787:7): [True: 492, False: 4]
  ------------------
  788|    492|    result scalar_res =
  789|    492|        scalar::utf16_to_utf8::convert_with_errors<endianness::BIG>(
  790|    492|            buf + ret.first.count, len - ret.first.count, ret.second);
  791|    492|    if (scalar_res.error) {
  ------------------
  |  Branch (791:9): [True: 114, False: 378]
  ------------------
  792|    114|      scalar_res.count += ret.first.count;
  793|    114|      return scalar_res;
  794|    378|    } else {
  795|    378|      ret.second += scalar_res.count;
  796|    378|    }
  797|    492|  }
  798|    382|  ret.first.count =
  799|    382|      ret.second -
  800|    382|      utf8_output; // Set count to the number of 8-bit code units written
  801|    382|  return ret.first;
  802|    496|}
_ZNK7simdutf8westmere14implementation29convert_valid_utf16le_to_utf8EPKDsmPc:
  805|    406|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  806|    406|  return convert_utf16le_to_utf8(buf, len, utf8_output);
  807|    406|}
_ZNK7simdutf8westmere14implementation29convert_valid_utf16be_to_utf8EPKDsmPc:
  810|    452|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  811|    452|  return convert_utf16be_to_utf8(buf, len, utf8_output);
  812|    452|}
_ZNK7simdutf8westmere14implementation23convert_utf32_to_latin1EPKDimPc:
  817|    228|    const char32_t *buf, size_t len, char *latin1_output) const noexcept {
  818|    228|  std::pair<const char32_t *, char *> ret =
  819|    228|      sse_convert_utf32_to_latin1(buf, len, latin1_output);
  820|    228|  if (ret.first == nullptr) {
  ------------------
  |  Branch (820:7): [True: 64, False: 164]
  ------------------
  821|     64|    return 0;
  822|     64|  }
  823|    164|  size_t saved_bytes = ret.second - latin1_output;
  824|       |  // if (ret.first != buf + len) {
  825|    164|  if (ret.first < buf + len) {
  ------------------
  |  Branch (825:7): [True: 150, False: 14]
  ------------------
  826|    150|    const size_t scalar_saved_bytes = scalar::utf32_to_latin1::convert(
  827|    150|        ret.first, len - (ret.first - buf), ret.second);
  828|    150|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (828:9): [True: 110, False: 40]
  ------------------
  829|    110|      return 0;
  830|    110|    }
  831|     40|    saved_bytes += scalar_saved_bytes;
  832|     40|  }
  833|     54|  return saved_bytes;
  834|    164|}
_ZNK7simdutf8westmere14implementation35convert_utf32_to_latin1_with_errorsEPKDimPc:
  837|    436|    const char32_t *buf, size_t len, char *latin1_output) const noexcept {
  838|       |  // ret.first.count is always the position in the buffer, not the number of
  839|       |  // code units written even if finished
  840|    436|  std::pair<result, char *> ret =
  841|    436|      westmere::sse_convert_utf32_to_latin1_with_errors(buf, len,
  842|    436|                                                        latin1_output);
  843|    436|  if (ret.first.count != len) {
  ------------------
  |  Branch (843:7): [True: 416, False: 20]
  ------------------
  844|    416|    result scalar_res = scalar::utf32_to_latin1::convert_with_errors(
  845|    416|        buf + ret.first.count, len - ret.first.count, ret.second);
  846|    416|    if (scalar_res.error) {
  ------------------
  |  Branch (846:9): [True: 394, False: 22]
  ------------------
  847|    394|      scalar_res.count += ret.first.count;
  848|    394|      return scalar_res;
  849|    394|    } else {
  850|     22|      ret.second += scalar_res.count;
  851|     22|    }
  852|    416|  }
  853|     42|  ret.first.count =
  854|     42|      ret.second -
  855|     42|      latin1_output; // Set count to the number of 8-bit code units written
  856|     42|  return ret.first;
  857|    436|}
_ZNK7simdutf8westmere14implementation21convert_utf32_to_utf8EPKDimPc:
  868|    864|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  869|    864|  std::pair<const char32_t *, char *> ret =
  870|    864|      sse_convert_utf32_to_utf8(buf, len, utf8_output);
  871|    864|  if (ret.first == nullptr) {
  ------------------
  |  Branch (871:7): [True: 262, False: 602]
  ------------------
  872|    262|    return 0;
  873|    262|  }
  874|    602|  size_t saved_bytes = ret.second - utf8_output;
  875|    602|  if (ret.first != buf + len) {
  ------------------
  |  Branch (875:7): [True: 600, False: 2]
  ------------------
  876|    600|    const size_t scalar_saved_bytes = scalar::utf32_to_utf8::convert(
  877|    600|        ret.first, len - (ret.first - buf), ret.second);
  878|    600|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (878:9): [True: 292, False: 308]
  ------------------
  879|    292|      return 0;
  880|    292|    }
  881|    308|    saved_bytes += scalar_saved_bytes;
  882|    308|  }
  883|    310|  return saved_bytes;
  884|    602|}
_ZNK7simdutf8westmere14implementation33convert_utf32_to_utf8_with_errorsEPKDimPc:
  887|    832|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  888|       |  // ret.first.count is always the position in the buffer, not the number of
  889|       |  // code units written even if finished
  890|    832|  std::pair<result, char *> ret =
  891|    832|      westmere::sse_convert_utf32_to_utf8_with_errors(buf, len, utf8_output);
  892|    832|  if (ret.first.count != len) {
  ------------------
  |  Branch (892:7): [True: 828, False: 4]
  ------------------
  893|    828|    result scalar_res = scalar::utf32_to_utf8::convert_with_errors(
  894|    828|        buf + ret.first.count, len - ret.first.count, ret.second);
  895|    828|    if (scalar_res.error) {
  ------------------
  |  Branch (895:9): [True: 618, False: 210]
  ------------------
  896|    618|      scalar_res.count += ret.first.count;
  897|    618|      return scalar_res;
  898|    618|    } else {
  899|    210|      ret.second += scalar_res.count;
  900|    210|    }
  901|    828|  }
  902|    214|  ret.first.count =
  903|    214|      ret.second -
  904|    214|      utf8_output; // Set count to the number of 8-bit code units written
  905|    214|  return ret.first;
  906|    832|}
_ZNK7simdutf8westmere14implementation24convert_utf16le_to_utf32EPKDsmPDi:
  911|    454|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  912|    454|  std::pair<const char16_t *, char32_t *> ret =
  913|    454|      sse_convert_utf16_to_utf32<endianness::LITTLE>(buf, len, utf32_output);
  914|    454|  if (ret.first == nullptr) {
  ------------------
  |  Branch (914:7): [True: 142, False: 312]
  ------------------
  915|    142|    return 0;
  916|    142|  }
  917|    312|  size_t saved_bytes = ret.second - utf32_output;
  918|    312|  if (ret.first != buf + len) {
  ------------------
  |  Branch (918:7): [True: 240, False: 72]
  ------------------
  919|    240|    const size_t scalar_saved_bytes =
  920|    240|        scalar::utf16_to_utf32::convert<endianness::LITTLE>(
  921|    240|            ret.first, len - (ret.first - buf), ret.second);
  922|    240|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (922:9): [True: 64, False: 176]
  ------------------
  923|     64|      return 0;
  924|     64|    }
  925|    176|    saved_bytes += scalar_saved_bytes;
  926|    176|  }
  927|    248|  return saved_bytes;
  928|    312|}
_ZNK7simdutf8westmere14implementation24convert_utf16be_to_utf32EPKDsmPDi:
  931|    422|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  932|    422|  std::pair<const char16_t *, char32_t *> ret =
  933|    422|      sse_convert_utf16_to_utf32<endianness::BIG>(buf, len, utf32_output);
  934|    422|  if (ret.first == nullptr) {
  ------------------
  |  Branch (934:7): [True: 114, False: 308]
  ------------------
  935|    114|    return 0;
  936|    114|  }
  937|    308|  size_t saved_bytes = ret.second - utf32_output;
  938|    308|  if (ret.first != buf + len) {
  ------------------
  |  Branch (938:7): [True: 250, False: 58]
  ------------------
  939|    250|    const size_t scalar_saved_bytes =
  940|    250|        scalar::utf16_to_utf32::convert<endianness::BIG>(
  941|    250|            ret.first, len - (ret.first - buf), ret.second);
  942|    250|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (942:9): [True: 62, False: 188]
  ------------------
  943|     62|      return 0;
  944|     62|    }
  945|    188|    saved_bytes += scalar_saved_bytes;
  946|    188|  }
  947|    246|  return saved_bytes;
  948|    308|}
_ZNK7simdutf8westmere14implementation36convert_utf16le_to_utf32_with_errorsEPKDsmPDi:
  951|    334|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  952|       |  // ret.first.count is always the position in the buffer, not the number of
  953|       |  // code units written even if finished
  954|    334|  std::pair<result, char32_t *> ret =
  955|    334|      westmere::sse_convert_utf16_to_utf32_with_errors<endianness::LITTLE>(
  956|    334|          buf, len, utf32_output);
  957|    334|  if (ret.first.error) {
  ------------------
  |  Branch (957:7): [True: 120, False: 214]
  ------------------
  958|    120|    return ret.first;
  959|    120|  } // Can return directly since scalar fallback already found correct
  960|       |    // ret.first.count
  961|    214|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (961:7): [True: 168, False: 46]
  ------------------
  962|    168|    result scalar_res =
  963|    168|        scalar::utf16_to_utf32::convert_with_errors<endianness::LITTLE>(
  964|    168|            buf + ret.first.count, len - ret.first.count, ret.second);
  965|    168|    if (scalar_res.error) {
  ------------------
  |  Branch (965:9): [True: 60, False: 108]
  ------------------
  966|     60|      scalar_res.count += ret.first.count;
  967|     60|      return scalar_res;
  968|    108|    } else {
  969|    108|      ret.second += scalar_res.count;
  970|    108|    }
  971|    168|  }
  972|    154|  ret.first.count =
  973|    154|      ret.second -
  974|    154|      utf32_output; // Set count to the number of 8-bit code units written
  975|    154|  return ret.first;
  976|    214|}
_ZNK7simdutf8westmere14implementation36convert_utf16be_to_utf32_with_errorsEPKDsmPDi:
  979|    346|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  980|       |  // ret.first.count is always the position in the buffer, not the number of
  981|       |  // code units written even if finished
  982|    346|  std::pair<result, char32_t *> ret =
  983|    346|      westmere::sse_convert_utf16_to_utf32_with_errors<endianness::BIG>(
  984|    346|          buf, len, utf32_output);
  985|    346|  if (ret.first.error) {
  ------------------
  |  Branch (985:7): [True: 116, False: 230]
  ------------------
  986|    116|    return ret.first;
  987|    116|  } // Can return directly since scalar fallback already found correct
  988|       |    // ret.first.count
  989|    230|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (989:7): [True: 184, False: 46]
  ------------------
  990|    184|    result scalar_res =
  991|    184|        scalar::utf16_to_utf32::convert_with_errors<endianness::BIG>(
  992|    184|            buf + ret.first.count, len - ret.first.count, ret.second);
  993|    184|    if (scalar_res.error) {
  ------------------
  |  Branch (993:9): [True: 68, False: 116]
  ------------------
  994|     68|      scalar_res.count += ret.first.count;
  995|     68|      return scalar_res;
  996|    116|    } else {
  997|    116|      ret.second += scalar_res.count;
  998|    116|    }
  999|    184|  }
 1000|    162|  ret.first.count =
 1001|    162|      ret.second -
 1002|    162|      utf32_output; // Set count to the number of 8-bit code units written
 1003|    162|  return ret.first;
 1004|    230|}
_ZNK7simdutf8westmere14implementation27convert_valid_utf32_to_utf8EPKDimPc:
 1009|    216|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
 1010|    216|  return convert_utf32_to_utf8(buf, len, utf8_output);
 1011|    216|}
_ZNK7simdutf8westmere14implementation24convert_utf32_to_utf16leEPKDimPDs:
 1016|    822|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1017|    822|  std::pair<const char32_t *, char16_t *> ret =
 1018|    822|      sse_convert_utf32_to_utf16<endianness::LITTLE>(buf, len, utf16_output);
 1019|    822|  if (ret.first == nullptr) {
  ------------------
  |  Branch (1019:7): [True: 60, False: 762]
  ------------------
 1020|     60|    return 0;
 1021|     60|  }
 1022|    762|  size_t saved_bytes = ret.second - utf16_output;
 1023|    762|  if (ret.first != buf + len) {
  ------------------
  |  Branch (1023:7): [True: 758, False: 4]
  ------------------
 1024|    758|    const size_t scalar_saved_bytes =
 1025|    758|        scalar::utf32_to_utf16::convert<endianness::LITTLE>(
 1026|    758|            ret.first, len - (ret.first - buf), ret.second);
 1027|    758|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (1027:9): [True: 334, False: 424]
  ------------------
 1028|    334|      return 0;
 1029|    334|    }
 1030|    424|    saved_bytes += scalar_saved_bytes;
 1031|    424|  }
 1032|    428|  return saved_bytes;
 1033|    762|}
_ZNK7simdutf8westmere14implementation24convert_utf32_to_utf16beEPKDimPDs:
 1036|    674|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1037|    674|  std::pair<const char32_t *, char16_t *> ret =
 1038|    674|      sse_convert_utf32_to_utf16<endianness::BIG>(buf, len, utf16_output);
 1039|    674|  if (ret.first == nullptr) {
  ------------------
  |  Branch (1039:7): [True: 94, False: 580]
  ------------------
 1040|     94|    return 0;
 1041|     94|  }
 1042|    580|  size_t saved_bytes = ret.second - utf16_output;
 1043|    580|  if (ret.first != buf + len) {
  ------------------
  |  Branch (1043:7): [True: 578, False: 2]
  ------------------
 1044|    578|    const size_t scalar_saved_bytes =
 1045|    578|        scalar::utf32_to_utf16::convert<endianness::BIG>(
 1046|    578|            ret.first, len - (ret.first - buf), ret.second);
 1047|    578|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (1047:9): [True: 326, False: 252]
  ------------------
 1048|    326|      return 0;
 1049|    326|    }
 1050|    252|    saved_bytes += scalar_saved_bytes;
 1051|    252|  }
 1052|    254|  return saved_bytes;
 1053|    580|}
_ZNK7simdutf8westmere14implementation36convert_utf32_to_utf16le_with_errorsEPKDimPDs:
 1056|    674|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1057|       |  // ret.first.count is always the position in the buffer, not the number of
 1058|       |  // code units written even if finished
 1059|    674|  std::pair<result, char16_t *> ret =
 1060|    674|      westmere::sse_convert_utf32_to_utf16_with_errors<endianness::LITTLE>(
 1061|    674|          buf, len, utf16_output);
 1062|    674|  if (ret.first.count != len) {
  ------------------
  |  Branch (1062:7): [True: 652, False: 22]
  ------------------
 1063|    652|    result scalar_res =
 1064|    652|        scalar::utf32_to_utf16::convert_with_errors<endianness::LITTLE>(
 1065|    652|            buf + ret.first.count, len - ret.first.count, ret.second);
 1066|    652|    if (scalar_res.error) {
  ------------------
  |  Branch (1066:9): [True: 504, False: 148]
  ------------------
 1067|    504|      scalar_res.count += ret.first.count;
 1068|    504|      return scalar_res;
 1069|    504|    } else {
 1070|    148|      ret.second += scalar_res.count;
 1071|    148|    }
 1072|    652|  }
 1073|    170|  ret.first.count =
 1074|    170|      ret.second -
 1075|    170|      utf16_output; // Set count to the number of 8-bit code units written
 1076|    170|  return ret.first;
 1077|    674|}
_ZNK7simdutf8westmere14implementation36convert_utf32_to_utf16be_with_errorsEPKDimPDs:
 1080|    694|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1081|       |  // ret.first.count is always the position in the buffer, not the number of
 1082|       |  // code units written even if finished
 1083|    694|  std::pair<result, char16_t *> ret =
 1084|    694|      westmere::sse_convert_utf32_to_utf16_with_errors<endianness::BIG>(
 1085|    694|          buf, len, utf16_output);
 1086|    694|  if (ret.first.count != len) {
  ------------------
  |  Branch (1086:7): [True: 670, False: 24]
  ------------------
 1087|    670|    result scalar_res =
 1088|    670|        scalar::utf32_to_utf16::convert_with_errors<endianness::BIG>(
 1089|    670|            buf + ret.first.count, len - ret.first.count, ret.second);
 1090|    670|    if (scalar_res.error) {
  ------------------
  |  Branch (1090:9): [True: 512, False: 158]
  ------------------
 1091|    512|      scalar_res.count += ret.first.count;
 1092|    512|      return scalar_res;
 1093|    512|    } else {
 1094|    158|      ret.second += scalar_res.count;
 1095|    158|    }
 1096|    670|  }
 1097|    182|  ret.first.count =
 1098|    182|      ret.second -
 1099|    182|      utf16_output; // Set count to the number of 8-bit code units written
 1100|    182|  return ret.first;
 1101|    694|}
_ZNK7simdutf8westmere14implementation30convert_valid_utf32_to_utf16leEPKDimPDs:
 1104|    280|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1105|    280|  return convert_utf32_to_utf16le(buf, len, utf16_output);
 1106|    280|}
_ZNK7simdutf8westmere14implementation30convert_valid_utf32_to_utf16beEPKDimPDs:
 1109|    134|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1110|    134|  return convert_utf32_to_utf16be(buf, len, utf16_output);
 1111|    134|}
_ZNK7simdutf8westmere14implementation30convert_valid_utf16le_to_utf32EPKDsmPDi:
 1114|    128|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
 1115|    128|  return convert_utf16le_to_utf32(buf, len, utf32_output);
 1116|    128|}
_ZNK7simdutf8westmere14implementation30convert_valid_utf16be_to_utf32EPKDsmPDi:
 1119|    142|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
 1120|    142|  return convert_utf16be_to_utf32(buf, len, utf32_output);
 1121|    142|}
_ZNK7simdutf8westmere14implementation13count_utf16leEPKDsm:
 1132|  1.35k|    const char16_t *input, size_t length) const noexcept {
 1133|  1.35k|  return utf16::count_code_points<endianness::LITTLE>(input, length);
 1134|  1.35k|}
_ZNK7simdutf8westmere14implementation13count_utf16beEPKDsm:
 1137|  1.33k|    const char16_t *input, size_t length) const noexcept {
 1138|  1.33k|  return utf16::count_code_points<endianness::BIG>(input, length);
 1139|  1.33k|}
_ZNK7simdutf8westmere14implementation10count_utf8EPKcm:
 1144|  4.03k|implementation::count_utf8(const char *input, size_t length) const noexcept {
 1145|  4.03k|  return utf8::count_code_points_bytemask(input, length);
 1146|  4.03k|}
_ZNK7simdutf8westmere14implementation23latin1_length_from_utf8EPKcm:
 1151|    549|    const char *buf, size_t len) const noexcept {
 1152|    549|  return count_utf8(buf, len);
 1153|    549|}
_ZNK7simdutf8westmere14implementation24utf8_length_from_utf16leEPKDsm:
 1158|    754|    const char16_t *input, size_t length) const noexcept {
 1159|    754|  return utf16::utf8_length_from_utf16_bytemask<endianness::LITTLE>(input,
 1160|    754|                                                                    length);
 1161|    754|}
_ZNK7simdutf8westmere14implementation24utf8_length_from_utf16beEPKDsm:
 1164|    748|    const char16_t *input, size_t length) const noexcept {
 1165|    748|  return utf16::utf8_length_from_utf16_bytemask<endianness::BIG>(input, length);
 1166|    748|}
_ZNK7simdutf8westmere14implementation23utf8_length_from_latin1EPKcm:
 1171|    302|    const char *input, size_t len) const noexcept {
 1172|    302|  const uint8_t *str = reinterpret_cast<const uint8_t *>(input);
 1173|    302|  size_t answer = len / sizeof(__m128i) * sizeof(__m128i);
 1174|    302|  size_t i = 0;
 1175|    302|  if (answer >= 2048) { // long strings optimization
  ------------------
  |  Branch (1175:7): [True: 139, False: 163]
  ------------------
 1176|    139|    __m128i two_64bits = _mm_setzero_si128();
 1177|  6.80k|    while (i + sizeof(__m128i) <= len) {
  ------------------
  |  Branch (1177:12): [True: 6.67k, False: 139]
  ------------------
 1178|  6.67k|      __m128i runner = _mm_setzero_si128();
 1179|  6.67k|      size_t iterations = (len - i) / sizeof(__m128i);
 1180|  6.67k|      if (iterations > 255) {
  ------------------
  |  Branch (1180:11): [True: 6.53k, False: 139]
  ------------------
 1181|  6.53k|        iterations = 255;
 1182|  6.53k|      }
 1183|  6.67k|      size_t max_i = i + iterations * sizeof(__m128i) - sizeof(__m128i);
 1184|   420k|      for (; i + 4 * sizeof(__m128i) <= max_i; i += 4 * sizeof(__m128i)) {
  ------------------
  |  Branch (1184:14): [True: 413k, False: 6.67k]
  ------------------
 1185|   413k|        __m128i input1 = _mm_loadu_si128((const __m128i *)(str + i));
 1186|   413k|        __m128i input2 =
 1187|   413k|            _mm_loadu_si128((const __m128i *)(str + i + sizeof(__m128i)));
 1188|   413k|        __m128i input3 =
 1189|   413k|            _mm_loadu_si128((const __m128i *)(str + i + 2 * sizeof(__m128i)));
 1190|   413k|        __m128i input4 =
 1191|   413k|            _mm_loadu_si128((const __m128i *)(str + i + 3 * sizeof(__m128i)));
 1192|   413k|        __m128i input12 =
 1193|   413k|            _mm_add_epi8(_mm_cmpgt_epi8(_mm_setzero_si128(), input1),
 1194|   413k|                         _mm_cmpgt_epi8(_mm_setzero_si128(), input2));
 1195|   413k|        __m128i input34 =
 1196|   413k|            _mm_add_epi8(_mm_cmpgt_epi8(_mm_setzero_si128(), input3),
 1197|   413k|                         _mm_cmpgt_epi8(_mm_setzero_si128(), input4));
 1198|   413k|        __m128i input1234 = _mm_add_epi8(input12, input34);
 1199|   413k|        runner = _mm_sub_epi8(runner, input1234);
 1200|   413k|      }
 1201|  26.5k|      for (; i <= max_i; i += sizeof(__m128i)) {
  ------------------
  |  Branch (1201:14): [True: 19.9k, False: 6.67k]
  ------------------
 1202|  19.9k|        __m128i more_input = _mm_loadu_si128((const __m128i *)(str + i));
 1203|  19.9k|        runner = _mm_sub_epi8(runner,
 1204|  19.9k|                              _mm_cmpgt_epi8(_mm_setzero_si128(), more_input));
 1205|  19.9k|      }
 1206|  6.67k|      two_64bits =
 1207|  6.67k|          _mm_add_epi64(two_64bits, _mm_sad_epu8(runner, _mm_setzero_si128()));
 1208|  6.67k|    }
 1209|    139|    answer +=
 1210|    139|        _mm_extract_epi64(two_64bits, 0) + _mm_extract_epi64(two_64bits, 1);
 1211|    163|  } else if (answer > 0) { // short string optimization
  ------------------
  |  Branch (1211:14): [True: 105, False: 58]
  ------------------
 1212|  1.43k|    for (; i + 2 * sizeof(__m128i) <= len; i += 2 * sizeof(__m128i)) {
  ------------------
  |  Branch (1212:12): [True: 1.32k, False: 105]
  ------------------
 1213|  1.32k|      __m128i latin = _mm_loadu_si128((const __m128i *)(input + i));
 1214|  1.32k|      uint16_t non_ascii = (uint16_t)_mm_movemask_epi8(latin);
 1215|  1.32k|      answer += count_ones(non_ascii);
 1216|  1.32k|      latin = _mm_loadu_si128((const __m128i *)(input + i) + 1);
 1217|  1.32k|      non_ascii = (uint16_t)_mm_movemask_epi8(latin);
 1218|  1.32k|      answer += count_ones(non_ascii);
 1219|  1.32k|    }
 1220|    156|    for (; i + sizeof(__m128i) <= len; i += sizeof(__m128i)) {
  ------------------
  |  Branch (1220:12): [True: 51, False: 105]
  ------------------
 1221|     51|      __m128i latin = _mm_loadu_si128((const __m128i *)(input + i));
 1222|     51|      uint16_t non_ascii = (uint16_t)_mm_movemask_epi8(latin);
 1223|     51|      answer += count_ones(non_ascii);
 1224|     51|    }
 1225|    105|  }
 1226|    302|  return answer + scalar::latin1::utf8_length_from_latin1(
 1227|    302|                      reinterpret_cast<const char *>(str + i), len - i);
 1228|    302|}
_ZNK7simdutf8westmere14implementation25utf32_length_from_utf16leEPKDsm:
 1233|    400|    const char16_t *input, size_t length) const noexcept {
 1234|    400|  return utf16::utf32_length_from_utf16<endianness::LITTLE>(input, length);
 1235|    400|}
_ZNK7simdutf8westmere14implementation25utf32_length_from_utf16beEPKDsm:
 1238|    400|    const char16_t *input, size_t length) const noexcept {
 1239|    400|  return utf16::utf32_length_from_utf16<endianness::BIG>(input, length);
 1240|    400|}
_ZNK7simdutf8westmere14implementation22utf16_length_from_utf8EPKcm:
 1245|  1.94k|    const char *input, size_t length) const noexcept {
 1246|  1.94k|  return utf8::utf16_length_from_utf8_bytemask(input, length);
 1247|  1.94k|}
_ZNK7simdutf8westmere14implementation22utf8_length_from_utf32EPKDim:
 1292|    860|    const char32_t *input, size_t length) const noexcept {
 1293|    860|  return utf32::utf8_length_from_utf32(input, length);
 1294|    860|}
_ZNK7simdutf8westmere14implementation23utf16_length_from_utf32EPKDim:
 1299|  1.44k|    const char32_t *input, size_t length) const noexcept {
 1300|  1.44k|  const __m128i v_00000000 = _mm_setzero_si128();
 1301|  1.44k|  const __m128i v_ffff0000 = _mm_set1_epi32((uint32_t)0xffff0000);
 1302|  1.44k|  size_t pos = 0;
 1303|  1.44k|  size_t count = 0;
 1304|  1.16M|  for (; pos + 4 <= length; pos += 4) {
  ------------------
  |  Branch (1304:10): [True: 1.16M, False: 1.44k]
  ------------------
 1305|  1.16M|    __m128i in = _mm_loadu_si128((__m128i *)(input + pos));
 1306|  1.16M|    const __m128i surrogate_bytemask =
 1307|  1.16M|        _mm_cmpeq_epi32(_mm_and_si128(in, v_ffff0000), v_00000000);
 1308|  1.16M|    const uint16_t surrogate_bitmask =
 1309|  1.16M|        static_cast<uint16_t>(_mm_movemask_epi8(surrogate_bytemask));
 1310|  1.16M|    size_t surrogate_count = (16 - count_ones(surrogate_bitmask)) / 4;
 1311|  1.16M|    count += 4 + surrogate_count;
 1312|  1.16M|  }
 1313|  1.44k|  return count +
 1314|  1.44k|         scalar::utf32::utf16_length_from_utf32(input + pos, length - pos);
 1315|  1.44k|}
_ZNK7simdutf8westmere14implementation22utf32_length_from_utf8EPKcm:
 1320|    994|    const char *input, size_t length) const noexcept {
 1321|    994|  return utf8::count_code_points(input, length);
 1322|    994|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_18is_asciiERKNS1_4simd8simd8x64IhEE:
   13|  4.87M|simdutf_really_inline bool is_ascii(const simd8x64<uint8_t> &input) {
   14|  4.87M|  return input.reduce_or().is_ascii();
   15|  4.87M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_124must_be_2_3_continuationENS1_4simd5simd8IhEES4_:
   22|  6.01M|                         const simd8<uint8_t> prev3) {
   23|  6.01M|  simd8<uint8_t> is_third_byte =
   24|  6.01M|      prev2.saturating_sub(0xe0u - 0x80); // Only 111_____ will be >= 0x80
   25|  6.01M|  simd8<uint8_t> is_fourth_byte =
   26|  6.01M|      prev3.saturating_sub(0xf0u - 0x80); // Only 1111____ will be >= 0x80
   27|  6.01M|  return simd8<bool>(is_third_byte | is_fourth_byte);
   28|  6.01M|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_18internal8westmere26write_v_u16_11bits_to_utf8EDv2_xRPcS4_S4_:
   57|   891k|                                       const __m128i v_ff80) {
   58|       |  // no bits set above 7th bit
   59|   891k|  const __m128i one_byte_bytemask =
   60|   891k|      _mm_cmpeq_epi16(_mm_and_si128(v_u16, v_ff80), v_0000);
   61|   891k|  const uint16_t one_byte_bitmask =
   62|   891k|      static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
   63|       |
   64|   891k|  write_v_u16_11bits_to_utf8(v_u16, utf8_output, one_byte_bytemask,
   65|   891k|                             one_byte_bitmask);
   66|   891k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_18internal8westmere26write_v_u16_11bits_to_utf8EDv2_xRPcS4_t:
   10|  1.32M|                                       const uint16_t one_byte_bitmask) {
   11|       |  // 0b1100_0000_1000_0000
   12|  1.32M|  const __m128i v_c080 = _mm_set1_epi16((int16_t)0xc080);
   13|       |  // 0b0001_1111_0000_0000
   14|  1.32M|  const __m128i v_1f00 = _mm_set1_epi16((int16_t)0x1f00);
   15|       |  // 0b0000_0000_0011_1111
   16|  1.32M|  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.32M|  const __m128i t0 = _mm_slli_epi16(v_u16, 2);
   24|       |  // t1 = [000a|aaaa|0000|0000]
   25|  1.32M|  const __m128i t1 = _mm_and_si128(t0, v_1f00);
   26|       |  // t2 = [0000|0000|00bb|bbbb]
   27|  1.32M|  const __m128i t2 = _mm_and_si128(v_u16, v_003f);
   28|       |  // t3 = [000a|aaaa|00bb|bbbb]
   29|  1.32M|  const __m128i t3 = _mm_or_si128(t1, t2);
   30|       |  // t4 = [110a|aaaa|10bb|bbbb]
   31|  1.32M|  const __m128i t4 = _mm_or_si128(t3, v_c080);
   32|       |
   33|       |  // 2. merge ASCII and 2-byte codewords
   34|  1.32M|  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.32M|  const uint16_t m0 = one_byte_bitmask & 0x5555;      // m0 = 0h0g0f0e0d0c0b0a
   40|  1.32M|  const uint16_t m1 = static_cast<uint16_t>(m0 >> 7); // m1 = 00000000h0g0f0e0
   41|  1.32M|  const uint8_t m2 = static_cast<uint8_t>((m0 | m1) & 0xff); // m2 = hdgcfbea
   42|       |  // 4. pack the bytes
   43|  1.32M|  const uint8_t *row =
   44|  1.32M|      &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0];
   45|  1.32M|  const __m128i shuffle = _mm_loadu_si128((__m128i *)(row + 1));
   46|  1.32M|  const __m128i utf8_packed = _mm_shuffle_epi8(utf8_unpacked, shuffle);
   47|       |
   48|       |  // 5. store bytes
   49|  1.32M|  _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   50|       |
   51|       |  // 6. adjust pointers
   52|  1.32M|  utf8_output += row[0];
   53|  1.32M|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_127sse_convert_latin1_to_utf16ILNS_10endiannessE0EEENSt3__14pairIPKcPDsEES7_mS8_:
    4|     76|                            char16_t *utf16_output) {
    5|     76|  size_t rounded_len = len & ~0xF; // Round down to nearest multiple of 16
    6|  93.4k|  for (size_t i = 0; i < rounded_len; i += 16) {
  ------------------
  |  Branch (6:22): [True: 93.3k, False: 76]
  ------------------
    7|       |    // Load 16 Latin1 characters into a 128-bit register
    8|  93.3k|    __m128i in =
    9|  93.3k|        _mm_loadu_si128(reinterpret_cast<const __m128i *>(&latin1_input[i]));
   10|  93.3k|    __m128i out1 = big_endian ? _mm_unpacklo_epi8(_mm_setzero_si128(), in)
  ------------------
  |  Branch (10:20): [Folded, False: 93.3k]
  ------------------
   11|  93.3k|                              : _mm_unpacklo_epi8(in, _mm_setzero_si128());
   12|  93.3k|    __m128i out2 = big_endian ? _mm_unpackhi_epi8(_mm_setzero_si128(), in)
  ------------------
  |  Branch (12:20): [Folded, False: 93.3k]
  ------------------
   13|  93.3k|                              : _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|  93.3k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(&utf16_output[i]), out1);
   17|  93.3k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(&utf16_output[i + 8]), out2);
   18|  93.3k|  }
   19|       |  // return pointers pointing to where we left off
   20|     76|  return std::make_pair(latin1_input + rounded_len, utf16_output + rounded_len);
   21|     76|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_127sse_convert_latin1_to_utf16ILNS_10endiannessE1EEENSt3__14pairIPKcPDsEES7_mS8_:
    4|     96|                            char16_t *utf16_output) {
    5|     96|  size_t rounded_len = len & ~0xF; // Round down to nearest multiple of 16
    6|   190k|  for (size_t i = 0; i < rounded_len; i += 16) {
  ------------------
  |  Branch (6:22): [True: 190k, False: 96]
  ------------------
    7|       |    // Load 16 Latin1 characters into a 128-bit register
    8|   190k|    __m128i in =
    9|   190k|        _mm_loadu_si128(reinterpret_cast<const __m128i *>(&latin1_input[i]));
   10|   190k|    __m128i out1 = big_endian ? _mm_unpacklo_epi8(_mm_setzero_si128(), in)
  ------------------
  |  Branch (10:20): [True: 190k, Folded]
  ------------------
   11|   190k|                              : _mm_unpacklo_epi8(in, _mm_setzero_si128());
   12|   190k|    __m128i out2 = big_endian ? _mm_unpackhi_epi8(_mm_setzero_si128(), in)
  ------------------
  |  Branch (12:20): [True: 190k, Folded]
  ------------------
   13|   190k|                              : _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|   190k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(&utf16_output[i]), out1);
   17|   190k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(&utf16_output[i + 8]), out2);
   18|   190k|  }
   19|       |  // return pointers pointing to where we left off
   20|     96|  return std::make_pair(latin1_input + rounded_len, utf16_output + rounded_len);
   21|     96|}

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

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_latin1_to_utf8EPKcmPc:
    3|    604|                           const size_t latin_input_length, char *utf8_output) {
    4|    604|  const char *end = latin_input + latin_input_length;
    5|       |
    6|    604|  const __m128i v_0000 = _mm_setzero_si128();
    7|       |  // 0b1000_0000
    8|    604|  const __m128i v_80 = _mm_set1_epi8((uint8_t)0x80);
    9|       |  // 0b1111_1111_1000_0000
   10|    604|  const __m128i v_ff80 = _mm_set1_epi16((uint16_t)0xff80);
   11|       |
   12|    604|  const __m128i latin_1_half_into_u16_byte_mask =
   13|    604|      _mm_setr_epi8(0, '\x80', 1, '\x80', 2, '\x80', 3, '\x80', 4, '\x80', 5,
   14|    604|                    '\x80', 6, '\x80', 7, '\x80');
   15|       |
   16|    604|  const __m128i latin_2_half_into_u16_byte_mask =
   17|    604|      _mm_setr_epi8(8, '\x80', 9, '\x80', 10, '\x80', 11, '\x80', 12, '\x80',
   18|    604|                    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-1 bytes by reserving 8 extra input bytes, we expect the output to have
   24|       |  // 8-16 bytes free
   25|  3.35M|  while (end - latin_input >= 16 + 8) {
  ------------------
  |  Branch (25:10): [True: 3.35M, False: 604]
  ------------------
   26|       |    // Load 16 Latin1 characters (16 bytes) into a 128-bit register
   27|  3.35M|    __m128i v_latin = _mm_loadu_si128((__m128i *)latin_input);
   28|       |
   29|  3.35M|    if (_mm_testz_si128(v_latin, v_80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (29:9): [True: 2.90M, False: 445k]
  ------------------
   30|  2.90M|      _mm_storeu_si128((__m128i *)utf8_output, v_latin);
   31|  2.90M|      latin_input += 16;
   32|  2.90M|      utf8_output += 16;
   33|  2.90M|      continue;
   34|  2.90M|    }
   35|       |
   36|       |    // assuming a/b are bytes and A/B are uint16 of the same value
   37|       |    // aaaa_aaaa_bbbb_bbbb -> AAAA_AAAA
   38|   445k|    __m128i v_u16_latin_1_half =
   39|   445k|        _mm_shuffle_epi8(v_latin, latin_1_half_into_u16_byte_mask);
   40|       |    // aaaa_aaaa_bbbb_bbbb -> BBBB_BBBB
   41|   445k|    __m128i v_u16_latin_2_half =
   42|   445k|        _mm_shuffle_epi8(v_latin, latin_2_half_into_u16_byte_mask);
   43|       |
   44|   445k|    internal::westmere::write_v_u16_11bits_to_utf8(v_u16_latin_1_half,
   45|   445k|                                                   utf8_output, v_0000, v_ff80);
   46|   445k|    internal::westmere::write_v_u16_11bits_to_utf8(v_u16_latin_2_half,
   47|   445k|                                                   utf8_output, v_0000, v_ff80);
   48|   445k|    latin_input += 16;
   49|   445k|  }
   50|       |
   51|    604|  if (end - latin_input >= 16) {
  ------------------
  |  Branch (51:7): [True: 312, False: 292]
  ------------------
   52|       |    // Load 16 Latin1 characters (16 bytes) into a 128-bit register
   53|    312|    __m128i v_latin = _mm_loadu_si128((__m128i *)latin_input);
   54|       |
   55|    312|    if (_mm_testz_si128(v_latin, v_80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (55:9): [True: 120, False: 192]
  ------------------
   56|    120|      _mm_storeu_si128((__m128i *)utf8_output, v_latin);
   57|    120|      latin_input += 16;
   58|    120|      utf8_output += 16;
   59|    192|    } else {
   60|       |      // assuming a/b are bytes and A/B are uint16 of the same value
   61|       |      // aaaa_aaaa_bbbb_bbbb -> AAAA_AAAA
   62|    192|      __m128i v_u16_latin_1_half =
   63|    192|          _mm_shuffle_epi8(v_latin, latin_1_half_into_u16_byte_mask);
   64|    192|      internal::westmere::write_v_u16_11bits_to_utf8(
   65|    192|          v_u16_latin_1_half, utf8_output, v_0000, v_ff80);
   66|    192|      latin_input += 8;
   67|    192|    }
   68|    312|  }
   69|       |
   70|    604|  return std::make_pair(latin_input, utf8_output);
   71|    604|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_127sse_convert_utf16_to_latin1ILNS_10endiannessE0EEENSt3__14pairIPKDsPcEES7_mS8_:
    4|    124|                            char *latin1_output) {
    5|    124|  const char16_t *end = buf + len;
    6|  1.12k|  while (end - buf >= 8) {
  ------------------
  |  Branch (6:10): [True: 1.03k, False: 86]
  ------------------
    7|       |    // Load 8 UTF-16 characters into 128-bit SSE register
    8|  1.03k|    __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|  1.03k|    __m128i high_byte_mask = _mm_set1_epi16((int16_t)0xFF00);
   17|  1.03k|    if (_mm_testz_si128(in, high_byte_mask)) {
  ------------------
  |  Branch (17:9): [True: 998, False: 38]
  ------------------
   18|       |      // Pack 16-bit characters into 8-bit and store in latin1_output
   19|    998|      __m128i latin1_packed = _mm_packus_epi16(in, in);
   20|    998|      _mm_storel_epi64(reinterpret_cast<__m128i *>(latin1_output),
   21|    998|                       latin1_packed);
   22|       |      // Adjust pointers for next iteration
   23|    998|      buf += 8;
   24|    998|      latin1_output += 8;
   25|    998|    } else {
   26|     38|      return std::make_pair(nullptr, reinterpret_cast<char *>(latin1_output));
   27|     38|    }
   28|  1.03k|  } // while
   29|     86|  return std::make_pair(buf, latin1_output);
   30|    124|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_127sse_convert_utf16_to_latin1ILNS_10endiannessE1EEENSt3__14pairIPKDsPcEES7_mS8_:
    4|    114|                            char *latin1_output) {
    5|    114|  const char16_t *end = buf + len;
    6|  3.12k|  while (end - buf >= 8) {
  ------------------
  |  Branch (6:10): [True: 3.04k, False: 76]
  ------------------
    7|       |    // Load 8 UTF-16 characters into 128-bit SSE register
    8|  3.04k|    __m128i in = _mm_loadu_si128(reinterpret_cast<const __m128i *>(buf));
    9|       |
   10|  3.04k|    if constexpr (!match_system(big_endian)) {
   11|  3.04k|      const __m128i swap =
   12|  3.04k|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   13|  3.04k|      in = _mm_shuffle_epi8(in, swap);
   14|  3.04k|    }
   15|       |
   16|  3.04k|    __m128i high_byte_mask = _mm_set1_epi16((int16_t)0xFF00);
   17|  3.04k|    if (_mm_testz_si128(in, high_byte_mask)) {
  ------------------
  |  Branch (17:9): [True: 3.01k, False: 38]
  ------------------
   18|       |      // Pack 16-bit characters into 8-bit and store in latin1_output
   19|  3.01k|      __m128i latin1_packed = _mm_packus_epi16(in, in);
   20|  3.01k|      _mm_storel_epi64(reinterpret_cast<__m128i *>(latin1_output),
   21|  3.01k|                       latin1_packed);
   22|       |      // Adjust pointers for next iteration
   23|  3.01k|      buf += 8;
   24|  3.01k|      latin1_output += 8;
   25|  3.01k|    } else {
   26|     38|      return std::make_pair(nullptr, reinterpret_cast<char *>(latin1_output));
   27|     38|    }
   28|  3.04k|  } // while
   29|     76|  return std::make_pair(buf, latin1_output);
   30|    114|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_139sse_convert_utf16_to_latin1_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
   35|    278|                                        char *latin1_output) {
   36|    278|  const char16_t *start = buf;
   37|    278|  const char16_t *end = buf + len;
   38|   820k|  while (end - buf >= 8) {
  ------------------
  |  Branch (38:10): [True: 820k, False: 120]
  ------------------
   39|   820k|    __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|   820k|    __m128i high_byte_mask = _mm_set1_epi16((int16_t)0xFF00);
   48|   820k|    if (_mm_testz_si128(in, high_byte_mask)) {
  ------------------
  |  Branch (48:9): [True: 820k, False: 158]
  ------------------
   49|   820k|      __m128i latin1_packed = _mm_packus_epi16(in, in);
   50|   820k|      _mm_storel_epi64(reinterpret_cast<__m128i *>(latin1_output),
   51|   820k|                       latin1_packed);
   52|   820k|      buf += 8;
   53|   820k|      latin1_output += 8;
   54|   820k|    } else {
   55|       |      // Fallback to scalar code for handling errors
   56|    514|      for (int k = 0; k < 8; k++) {
  ------------------
  |  Branch (56:23): [True: 514, False: 0]
  ------------------
   57|    514|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
   58|    514|        if (word <= 0xff) {
  ------------------
  |  Branch (58:13): [True: 356, False: 158]
  ------------------
   59|    356|          *latin1_output++ = char(word);
   60|    356|        } else {
   61|    158|          return std::make_pair(result(error_code::TOO_LARGE, buf - start + k),
   62|    158|                                latin1_output);
   63|    158|        }
   64|    514|      }
   65|      0|      buf += 8;
   66|      0|    }
   67|   820k|  } // while
   68|    120|  return std::make_pair(result(error_code::SUCCESS, buf - start),
   69|    120|                        latin1_output);
   70|    278|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_139sse_convert_utf16_to_latin1_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
   35|    266|                                        char *latin1_output) {
   36|    266|  const char16_t *start = buf;
   37|    266|  const char16_t *end = buf + len;
   38|  1.04M|  while (end - buf >= 8) {
  ------------------
  |  Branch (38:10): [True: 1.04M, False: 124]
  ------------------
   39|  1.04M|    __m128i in = _mm_loadu_si128(reinterpret_cast<const __m128i *>(buf));
   40|       |
   41|  1.04M|    if constexpr (!match_system(big_endian)) {
   42|  1.04M|      const __m128i swap =
   43|  1.04M|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   44|  1.04M|      in = _mm_shuffle_epi8(in, swap);
   45|  1.04M|    }
   46|       |
   47|  1.04M|    __m128i high_byte_mask = _mm_set1_epi16((int16_t)0xFF00);
   48|  1.04M|    if (_mm_testz_si128(in, high_byte_mask)) {
  ------------------
  |  Branch (48:9): [True: 1.04M, False: 142]
  ------------------
   49|  1.04M|      __m128i latin1_packed = _mm_packus_epi16(in, in);
   50|  1.04M|      _mm_storel_epi64(reinterpret_cast<__m128i *>(latin1_output),
   51|  1.04M|                       latin1_packed);
   52|  1.04M|      buf += 8;
   53|  1.04M|      latin1_output += 8;
   54|  1.04M|    } else {
   55|       |      // Fallback to scalar code for handling errors
   56|    454|      for (int k = 0; k < 8; k++) {
  ------------------
  |  Branch (56:23): [True: 454, False: 0]
  ------------------
   57|    454|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
   58|    454|        if (word <= 0xff) {
  ------------------
  |  Branch (58:13): [True: 312, False: 142]
  ------------------
   59|    312|          *latin1_output++ = char(word);
   60|    312|        } else {
   61|    142|          return std::make_pair(result(error_code::TOO_LARGE, buf - start + k),
   62|    142|                                latin1_output);
   63|    142|        }
   64|    454|      }
   65|      0|      buf += 8;
   66|      0|    }
   67|  1.04M|  } // while
   68|    124|  return std::make_pair(result(error_code::SUCCESS, buf - start),
   69|    124|                        latin1_output);
   70|    266|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_utf16_to_utf32ILNS_10endiannessE0EEENSt3__14pairIPKDsPDiEES7_mS8_:
   57|    454|                           char32_t *utf32_output) {
   58|    454|  const char16_t *end = buf + len;
   59|       |
   60|    454|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
   61|    454|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
   62|       |
   63|   542k|  while (end - buf >= 8) {
  ------------------
  |  Branch (63:10): [True: 542k, False: 318]
  ------------------
   64|   542k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   65|       |
   66|   542k|    if (big_endian) {
  ------------------
  |  Branch (66:9): [Folded, False: 542k]
  ------------------
   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|   542k|    const __m128i surrogates_bytemask =
   76|   542k|        _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|   542k|    const uint16_t surrogates_bitmask =
   81|   542k|        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|   542k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (84:9): [True: 536k, False: 5.51k]
  ------------------
   85|       |      // case: no surrogate pair, extend 16-bit code units to 32-bit code units
   86|   536k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
   87|   536k|                       _mm_cvtepu16_epi32(in));
   88|   536k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
   89|   536k|                       _mm_cvtepu16_epi32(_mm_srli_si128(in, 8)));
   90|   536k|      utf32_output += 8;
   91|   536k|      buf += 8;
   92|       |      // surrogate pair(s) in a register
   93|   536k|    } 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.51k|      size_t forward = 15;
   98|  5.51k|      size_t k = 0;
   99|  5.51k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (99:11): [True: 70, False: 5.44k]
  ------------------
  100|     70|        forward = size_t(end - buf - 1);
  101|     70|      }
  102|  80.1k|      for (; k < forward; k++) {
  ------------------
  |  Branch (102:14): [True: 74.7k, False: 5.38k]
  ------------------
  103|  74.7k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  104|  74.7k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (104:13): [True: 67.9k, False: 6.73k]
  ------------------
  105|  67.9k|          *utf32_output++ = char32_t(word);
  106|  67.9k|        } else {
  107|       |          // must be a surrogate pair
  108|  6.73k|          uint16_t diff = uint16_t(word - 0xD800);
  109|  6.73k|          uint16_t next_word =
  110|  6.73k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  111|  6.73k|          k++;
  112|  6.73k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  113|  6.73k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (113:15): [True: 136, False: 6.59k]
  ------------------
  114|    136|            return std::make_pair(nullptr, utf32_output);
  115|    136|          }
  116|  6.59k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  117|  6.59k|          *utf32_output++ = char32_t(value);
  118|  6.59k|        }
  119|  74.7k|      }
  120|  5.38k|      buf += k;
  121|  5.38k|    }
  122|   542k|  } // while
  123|    318|  return std::make_pair(buf, utf32_output);
  124|    454|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_utf16_to_utf32ILNS_10endiannessE1EEENSt3__14pairIPKDsPDiEES7_mS8_:
   57|    422|                           char32_t *utf32_output) {
   58|    422|  const char16_t *end = buf + len;
   59|       |
   60|    422|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
   61|    422|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
   62|       |
   63|   737k|  while (end - buf >= 8) {
  ------------------
  |  Branch (63:10): [True: 737k, False: 314]
  ------------------
   64|   737k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   65|       |
   66|   737k|    if (big_endian) {
  ------------------
  |  Branch (66:9): [True: 737k, Folded]
  ------------------
   67|   737k|      const __m128i swap =
   68|   737k|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   69|   737k|      in = _mm_shuffle_epi8(in, swap);
   70|   737k|    }
   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|   737k|    const __m128i surrogates_bytemask =
   76|   737k|        _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|   737k|    const uint16_t surrogates_bitmask =
   81|   737k|        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|   737k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (84:9): [True: 735k, False: 1.48k]
  ------------------
   85|       |      // case: no surrogate pair, extend 16-bit code units to 32-bit code units
   86|   735k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
   87|   735k|                       _mm_cvtepu16_epi32(in));
   88|   735k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
   89|   735k|                       _mm_cvtepu16_epi32(_mm_srli_si128(in, 8)));
   90|   735k|      utf32_output += 8;
   91|   735k|      buf += 8;
   92|       |      // surrogate pair(s) in a register
   93|   735k|    } 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|  1.48k|      size_t forward = 15;
   98|  1.48k|      size_t k = 0;
   99|  1.48k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (99:11): [True: 76, False: 1.41k]
  ------------------
  100|     76|        forward = size_t(end - buf - 1);
  101|     76|      }
  102|  20.1k|      for (; k < forward; k++) {
  ------------------
  |  Branch (102:14): [True: 18.7k, False: 1.38k]
  ------------------
  103|  18.7k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  104|  18.7k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (104:13): [True: 16.4k, False: 2.34k]
  ------------------
  105|  16.4k|          *utf32_output++ = char32_t(word);
  106|  16.4k|        } else {
  107|       |          // must be a surrogate pair
  108|  2.34k|          uint16_t diff = uint16_t(word - 0xD800);
  109|  2.34k|          uint16_t next_word =
  110|  2.34k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  111|  2.34k|          k++;
  112|  2.34k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  113|  2.34k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (113:15): [True: 108, False: 2.23k]
  ------------------
  114|    108|            return std::make_pair(nullptr, utf32_output);
  115|    108|          }
  116|  2.23k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  117|  2.23k|          *utf32_output++ = char32_t(value);
  118|  2.23k|        }
  119|  18.7k|      }
  120|  1.38k|      buf += k;
  121|  1.38k|    }
  122|   737k|  } // while
  123|    314|  return std::make_pair(buf, utf32_output);
  124|    422|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_138sse_convert_utf16_to_utf32_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPDiEEPKDsmS7_:
  136|    334|                                       char32_t *utf32_output) {
  137|    334|  const char16_t *start = buf;
  138|    334|  const char16_t *end = buf + len;
  139|       |
  140|    334|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
  141|    334|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
  142|       |
  143|   315k|  while (end - buf >= 8) {
  ------------------
  |  Branch (143:10): [True: 315k, False: 214]
  ------------------
  144|   315k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  145|       |
  146|   315k|    if (big_endian) {
  ------------------
  |  Branch (146:9): [Folded, False: 315k]
  ------------------
  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|   315k|    const __m128i surrogates_bytemask =
  156|   315k|        _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|   315k|    const uint16_t surrogates_bitmask =
  161|   315k|        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|   315k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (164:9): [True: 310k, False: 5.06k]
  ------------------
  165|       |      // case: no surrogate pair, extend 16-bit code units to 32-bit code units
  166|   310k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
  167|   310k|                       _mm_cvtepu16_epi32(in));
  168|   310k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
  169|   310k|                       _mm_cvtepu16_epi32(_mm_srli_si128(in, 8)));
  170|   310k|      utf32_output += 8;
  171|   310k|      buf += 8;
  172|       |      // surrogate pair(s) in a register
  173|   310k|    } 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.06k|      size_t forward = 15;
  178|  5.06k|      size_t k = 0;
  179|  5.06k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (179:11): [True: 58, False: 5.00k]
  ------------------
  180|     58|        forward = size_t(end - buf - 1);
  181|     58|      }
  182|  70.6k|      for (; k < forward; k++) {
  ------------------
  |  Branch (182:14): [True: 65.6k, False: 4.94k]
  ------------------
  183|  65.6k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  184|  65.6k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (184:13): [True: 56.1k, False: 9.50k]
  ------------------
  185|  56.1k|          *utf32_output++ = char32_t(word);
  186|  56.1k|        } else {
  187|       |          // must be a surrogate pair
  188|  9.50k|          uint16_t diff = uint16_t(word - 0xD800);
  189|  9.50k|          uint16_t next_word =
  190|  9.50k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  191|  9.50k|          k++;
  192|  9.50k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  193|  9.50k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (193:15): [True: 120, False: 9.38k]
  ------------------
  194|    120|            return std::make_pair(
  195|    120|                result(error_code::SURROGATE, buf - start + k - 1),
  196|    120|                utf32_output);
  197|    120|          }
  198|  9.38k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  199|  9.38k|          *utf32_output++ = char32_t(value);
  200|  9.38k|        }
  201|  65.6k|      }
  202|  4.94k|      buf += k;
  203|  4.94k|    }
  204|   315k|  } // while
  205|    214|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output);
  206|    334|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_138sse_convert_utf16_to_utf32_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPDiEEPKDsmS7_:
  136|    346|                                       char32_t *utf32_output) {
  137|    346|  const char16_t *start = buf;
  138|    346|  const char16_t *end = buf + len;
  139|       |
  140|    346|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
  141|    346|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
  142|       |
  143|   297k|  while (end - buf >= 8) {
  ------------------
  |  Branch (143:10): [True: 297k, False: 230]
  ------------------
  144|   297k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  145|       |
  146|   297k|    if (big_endian) {
  ------------------
  |  Branch (146:9): [True: 297k, Folded]
  ------------------
  147|   297k|      const __m128i swap =
  148|   297k|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  149|   297k|      in = _mm_shuffle_epi8(in, swap);
  150|   297k|    }
  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|   297k|    const __m128i surrogates_bytemask =
  156|   297k|        _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|   297k|    const uint16_t surrogates_bitmask =
  161|   297k|        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|   297k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (164:9): [True: 292k, False: 5.15k]
  ------------------
  165|       |      // case: no surrogate pair, extend 16-bit code units to 32-bit code units
  166|   292k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
  167|   292k|                       _mm_cvtepu16_epi32(in));
  168|   292k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
  169|   292k|                       _mm_cvtepu16_epi32(_mm_srli_si128(in, 8)));
  170|   292k|      utf32_output += 8;
  171|   292k|      buf += 8;
  172|       |      // surrogate pair(s) in a register
  173|   292k|    } 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.15k|      size_t forward = 15;
  178|  5.15k|      size_t k = 0;
  179|  5.15k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (179:11): [True: 82, False: 5.07k]
  ------------------
  180|     82|        forward = size_t(end - buf - 1);
  181|     82|      }
  182|  71.8k|      for (; k < forward; k++) {
  ------------------
  |  Branch (182:14): [True: 66.7k, False: 5.04k]
  ------------------
  183|  66.7k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  184|  66.7k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (184:13): [True: 56.8k, False: 9.90k]
  ------------------
  185|  56.8k|          *utf32_output++ = char32_t(word);
  186|  56.8k|        } else {
  187|       |          // must be a surrogate pair
  188|  9.90k|          uint16_t diff = uint16_t(word - 0xD800);
  189|  9.90k|          uint16_t next_word =
  190|  9.90k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  191|  9.90k|          k++;
  192|  9.90k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  193|  9.90k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (193:15): [True: 116, False: 9.78k]
  ------------------
  194|    116|            return std::make_pair(
  195|    116|                result(error_code::SURROGATE, buf - start + k - 1),
  196|    116|                utf32_output);
  197|    116|          }
  198|  9.78k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  199|  9.78k|          *utf32_output++ = char32_t(value);
  200|  9.78k|        }
  201|  66.7k|      }
  202|  5.04k|      buf += k;
  203|  5.04k|    }
  204|   297k|  } // while
  205|    230|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output);
  206|    346|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_125sse_convert_utf16_to_utf8ILNS_10endiannessE0EEENSt3__14pairIPKDsPcEES7_mS8_:
   56|    842|sse_convert_utf16_to_utf8(const char16_t *buf, size_t len, char *utf8_output) {
   57|       |
   58|    842|  const char16_t *end = buf + len;
   59|       |
   60|    842|  const __m128i v_0000 = _mm_setzero_si128();
   61|    842|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
   62|    842|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
   63|    842|  const size_t safety_margin =
   64|    842|      12; // to avoid overruns, see issue
   65|       |          // https://github.com/simdutf/simdutf/issues/92
   66|       |
   67|  1.07M|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (67:10): [True: 1.07M, False: 736]
  ------------------
   68|  1.07M|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   69|  1.07M|    if (big_endian) {
  ------------------
  |  Branch (69:9): [Folded, False: 1.07M]
  ------------------
   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.07M|    const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80);
   76|  1.07M|    if (_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (76:9): [True: 763k, False: 312k]
  ------------------
   77|   763k|      __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
   78|   763k|      if (big_endian) {
  ------------------
  |  Branch (78:11): [Folded, False: 763k]
  ------------------
   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|   763k|      if (!_mm_testz_si128(nextin, v_ff80)) {
  ------------------
  |  Branch (83:11): [True: 43.3k, False: 719k]
  ------------------
   84|       |        // 1. pack the bytes
   85|       |        // obviously suboptimal.
   86|  43.3k|        const __m128i utf8_packed = _mm_packus_epi16(in, in);
   87|       |        // 2. store (16 bytes)
   88|  43.3k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   89|       |        // 3. adjust pointers
   90|  43.3k|        buf += 8;
   91|  43.3k|        utf8_output += 8;
   92|  43.3k|        in = nextin;
   93|   719k|      } else {
   94|       |        // 1. pack the bytes
   95|       |        // obviously suboptimal.
   96|   719k|        const __m128i utf8_packed = _mm_packus_epi16(in, nextin);
   97|       |        // 2. store (16 bytes)
   98|   719k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   99|       |        // 3. adjust pointers
  100|   719k|        buf += 16;
  101|   719k|        utf8_output += 16;
  102|   719k|        continue; // we are done for this round!
  103|   719k|      }
  104|   763k|    }
  105|       |
  106|       |    // no bits set above 7th bit
  107|   355k|    const __m128i one_byte_bytemask =
  108|   355k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000);
  109|   355k|    const uint16_t one_byte_bitmask =
  110|   355k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  111|       |
  112|       |    // no bits set above 11th bit
  113|   355k|    const __m128i one_or_two_bytes_bytemask =
  114|   355k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000);
  115|   355k|    const uint16_t one_or_two_bytes_bitmask =
  116|   355k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  117|       |
  118|   355k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (118:9): [True: 235k, False: 119k]
  ------------------
  119|   235k|      internal::westmere::write_v_u16_11bits_to_utf8(
  120|   235k|          in, utf8_output, one_byte_bytemask, one_byte_bitmask);
  121|   235k|      buf += 8;
  122|   235k|      continue;
  123|   235k|    }
  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|   119k|    const __m128i surrogates_bytemask =
  129|   119k|        _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|   119k|    const uint16_t surrogates_bitmask =
  134|   119k|        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|   119k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (137:9): [True: 113k, False: 6.91k]
  ------------------
  138|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  139|   113k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  140|   113k|                                              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|   113k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  170|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  171|   113k|      const __m128i t0 = _mm_shuffle_epi8(in, dup_even);
  172|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  173|   113k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  169|   113k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  174|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  175|   113k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  169|   113k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  176|       |
  177|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  178|   113k|      const __m128i s0 = _mm_srli_epi16(in, 4);
  179|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  180|   113k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  169|   113k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  181|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  182|   113k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  169|   113k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  183|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  184|   113k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  169|   113k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  185|   113k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  186|   113k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  169|   113k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  187|   113k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  188|   113k|#undef simdutf_vec
  189|       |
  190|       |      // 4. expand code units 16-bit => 32-bit
  191|   113k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  192|   113k|      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|   113k|      const uint16_t mask =
  196|   113k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  197|   113k|      if (mask == 0) {
  ------------------
  |  Branch (197:11): [True: 20.3k, False: 92.6k]
  ------------------
  198|       |        // We only have three-byte code units. Use fast path.
  199|  20.3k|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  200|  20.3k|                                              15, 13, -1, -1, -1, -1);
  201|  20.3k|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  202|  20.3k|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  203|  20.3k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  204|  20.3k|        utf8_output += 12;
  205|  20.3k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  206|  20.3k|        utf8_output += 12;
  207|  20.3k|        buf += 8;
  208|  20.3k|        continue;
  209|  20.3k|      }
  210|  92.6k|      const uint8_t mask0 = uint8_t(mask);
  211|       |
  212|  92.6k|      const uint8_t *row0 =
  213|  92.6k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  214|  92.6k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  215|  92.6k|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  216|       |
  217|  92.6k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  218|       |
  219|  92.6k|      const uint8_t *row1 =
  220|  92.6k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  221|  92.6k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  222|  92.6k|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  223|       |
  224|  92.6k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  225|  92.6k|      utf8_output += row0[0];
  226|  92.6k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  227|  92.6k|      utf8_output += row1[0];
  228|       |
  229|  92.6k|      buf += 8;
  230|       |      // surrogate pair(s) in a register
  231|  92.6k|    } 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|  6.91k|      size_t forward = 15;
  236|  6.91k|      size_t k = 0;
  237|  6.91k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (237:11): [True: 0, False: 6.91k]
  ------------------
  238|      0|        forward = size_t(end - buf - 1);
  239|      0|      }
  240|   101k|      for (; k < forward; k++) {
  ------------------
  |  Branch (240:14): [True: 95.0k, False: 6.81k]
  ------------------
  241|  95.0k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  242|  95.0k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (242:13): [True: 13.3k, False: 81.6k]
  ------------------
  243|  13.3k|          *utf8_output++ = char(word);
  244|  81.6k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (244:20): [True: 3.92k, False: 77.7k]
  ------------------
  245|  3.92k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  246|  3.92k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  247|  77.7k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (247:20): [True: 69.8k, False: 7.92k]
  ------------------
  248|  69.8k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  249|  69.8k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  250|  69.8k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  251|  69.8k|        } else {
  252|       |          // must be a surrogate pair
  253|  7.92k|          uint16_t diff = uint16_t(word - 0xD800);
  254|  7.92k|          uint16_t next_word =
  255|  7.92k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  256|  7.92k|          k++;
  257|  7.92k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  258|  7.92k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (258:15): [True: 106, False: 7.81k]
  ------------------
  259|    106|            return std::make_pair(nullptr, utf8_output);
  260|    106|          }
  261|  7.81k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  262|  7.81k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  263|  7.81k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  264|  7.81k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  265|  7.81k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  266|  7.81k|        }
  267|  95.0k|      }
  268|  6.81k|      buf += k;
  269|  6.81k|    }
  270|   119k|  } // while
  271|       |
  272|    736|  return std::make_pair(buf, utf8_output);
  273|    842|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_125sse_convert_utf16_to_utf8ILNS_10endiannessE1EEENSt3__14pairIPKDsPcEES7_mS8_:
   56|    798|sse_convert_utf16_to_utf8(const char16_t *buf, size_t len, char *utf8_output) {
   57|       |
   58|    798|  const char16_t *end = buf + len;
   59|       |
   60|    798|  const __m128i v_0000 = _mm_setzero_si128();
   61|    798|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
   62|    798|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
   63|    798|  const size_t safety_margin =
   64|    798|      12; // to avoid overruns, see issue
   65|       |          // https://github.com/simdutf/simdutf/issues/92
   66|       |
   67|  1.16M|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (67:10): [True: 1.16M, False: 708]
  ------------------
   68|  1.16M|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   69|  1.16M|    if (big_endian) {
  ------------------
  |  Branch (69:9): [True: 1.16M, Folded]
  ------------------
   70|  1.16M|      const __m128i swap =
   71|  1.16M|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   72|  1.16M|      in = _mm_shuffle_epi8(in, swap);
   73|  1.16M|    }
   74|       |    // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes
   75|  1.16M|    const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80);
   76|  1.16M|    if (_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (76:9): [True: 741k, False: 425k]
  ------------------
   77|   741k|      __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
   78|   741k|      if (big_endian) {
  ------------------
  |  Branch (78:11): [True: 741k, Folded]
  ------------------
   79|   741k|        const __m128i swap =
   80|   741k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   81|   741k|        nextin = _mm_shuffle_epi8(nextin, swap);
   82|   741k|      }
   83|   741k|      if (!_mm_testz_si128(nextin, v_ff80)) {
  ------------------
  |  Branch (83:11): [True: 36.6k, False: 705k]
  ------------------
   84|       |        // 1. pack the bytes
   85|       |        // obviously suboptimal.
   86|  36.6k|        const __m128i utf8_packed = _mm_packus_epi16(in, in);
   87|       |        // 2. store (16 bytes)
   88|  36.6k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   89|       |        // 3. adjust pointers
   90|  36.6k|        buf += 8;
   91|  36.6k|        utf8_output += 8;
   92|  36.6k|        in = nextin;
   93|   705k|      } else {
   94|       |        // 1. pack the bytes
   95|       |        // obviously suboptimal.
   96|   705k|        const __m128i utf8_packed = _mm_packus_epi16(in, nextin);
   97|       |        // 2. store (16 bytes)
   98|   705k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   99|       |        // 3. adjust pointers
  100|   705k|        buf += 16;
  101|   705k|        utf8_output += 16;
  102|   705k|        continue; // we are done for this round!
  103|   705k|      }
  104|   741k|    }
  105|       |
  106|       |    // no bits set above 7th bit
  107|   462k|    const __m128i one_byte_bytemask =
  108|   462k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000);
  109|   462k|    const uint16_t one_byte_bitmask =
  110|   462k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  111|       |
  112|       |    // no bits set above 11th bit
  113|   462k|    const __m128i one_or_two_bytes_bytemask =
  114|   462k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000);
  115|   462k|    const uint16_t one_or_two_bytes_bitmask =
  116|   462k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  117|       |
  118|   462k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (118:9): [True: 29.0k, False: 433k]
  ------------------
  119|  29.0k|      internal::westmere::write_v_u16_11bits_to_utf8(
  120|  29.0k|          in, utf8_output, one_byte_bytemask, one_byte_bitmask);
  121|  29.0k|      buf += 8;
  122|  29.0k|      continue;
  123|  29.0k|    }
  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|   433k|    const __m128i surrogates_bytemask =
  129|   433k|        _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|   433k|    const uint16_t surrogates_bitmask =
  134|   433k|        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|   433k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (137:9): [True: 429k, False: 3.99k]
  ------------------
  138|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  139|   429k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  140|   429k|                                              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|   429k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  170|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  171|   429k|      const __m128i t0 = _mm_shuffle_epi8(in, dup_even);
  172|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  173|   429k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  169|   429k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  174|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  175|   429k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  169|   429k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  176|       |
  177|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  178|   429k|      const __m128i s0 = _mm_srli_epi16(in, 4);
  179|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  180|   429k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  169|   429k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  181|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  182|   429k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  169|   429k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  183|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  184|   429k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  169|   429k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  185|   429k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  186|   429k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  169|   429k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  187|   429k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  188|   429k|#undef simdutf_vec
  189|       |
  190|       |      // 4. expand code units 16-bit => 32-bit
  191|   429k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  192|   429k|      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|   429k|      const uint16_t mask =
  196|   429k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  197|   429k|      if (mask == 0) {
  ------------------
  |  Branch (197:11): [True: 257k, False: 171k]
  ------------------
  198|       |        // We only have three-byte code units. Use fast path.
  199|   257k|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  200|   257k|                                              15, 13, -1, -1, -1, -1);
  201|   257k|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  202|   257k|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  203|   257k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  204|   257k|        utf8_output += 12;
  205|   257k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  206|   257k|        utf8_output += 12;
  207|   257k|        buf += 8;
  208|   257k|        continue;
  209|   257k|      }
  210|   171k|      const uint8_t mask0 = uint8_t(mask);
  211|       |
  212|   171k|      const uint8_t *row0 =
  213|   171k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  214|   171k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  215|   171k|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  216|       |
  217|   171k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  218|       |
  219|   171k|      const uint8_t *row1 =
  220|   171k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  221|   171k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  222|   171k|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  223|       |
  224|   171k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  225|   171k|      utf8_output += row0[0];
  226|   171k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  227|   171k|      utf8_output += row1[0];
  228|       |
  229|   171k|      buf += 8;
  230|       |      // surrogate pair(s) in a register
  231|   171k|    } 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|  3.99k|      size_t forward = 15;
  236|  3.99k|      size_t k = 0;
  237|  3.99k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (237:11): [True: 0, False: 3.99k]
  ------------------
  238|      0|        forward = size_t(end - buf - 1);
  239|      0|      }
  240|  58.0k|      for (; k < forward; k++) {
  ------------------
  |  Branch (240:14): [True: 54.1k, False: 3.90k]
  ------------------
  241|  54.1k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  242|  54.1k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (242:13): [True: 7.65k, False: 46.5k]
  ------------------
  243|  7.65k|          *utf8_output++ = char(word);
  244|  46.5k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (244:20): [True: 2.08k, False: 44.4k]
  ------------------
  245|  2.08k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  246|  2.08k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  247|  44.4k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (247:20): [True: 39.5k, False: 4.92k]
  ------------------
  248|  39.5k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  249|  39.5k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  250|  39.5k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  251|  39.5k|        } else {
  252|       |          // must be a surrogate pair
  253|  4.92k|          uint16_t diff = uint16_t(word - 0xD800);
  254|  4.92k|          uint16_t next_word =
  255|  4.92k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  256|  4.92k|          k++;
  257|  4.92k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  258|  4.92k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (258:15): [True: 90, False: 4.83k]
  ------------------
  259|     90|            return std::make_pair(nullptr, utf8_output);
  260|     90|          }
  261|  4.83k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  262|  4.83k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  263|  4.83k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  264|  4.83k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  265|  4.83k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  266|  4.83k|        }
  267|  54.1k|      }
  268|  3.90k|      buf += k;
  269|  3.90k|    }
  270|   433k|  } // while
  271|       |
  272|    708|  return std::make_pair(buf, utf8_output);
  273|    798|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_137sse_convert_utf16_to_utf8_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
  285|    642|                                      char *utf8_output) {
  286|    642|  const char16_t *start = buf;
  287|    642|  const char16_t *end = buf + len;
  288|       |
  289|    642|  const __m128i v_0000 = _mm_setzero_si128();
  290|    642|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
  291|    642|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
  292|    642|  const size_t safety_margin =
  293|    642|      12; // to avoid overruns, see issue
  294|       |          // https://github.com/simdutf/simdutf/issues/92
  295|       |
  296|   965k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (296:10): [True: 964k, False: 496]
  ------------------
  297|   964k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  298|   964k|    if (big_endian) {
  ------------------
  |  Branch (298:9): [Folded, False: 964k]
  ------------------
  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|   964k|    const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80);
  305|   964k|    if (_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (305:9): [True: 325k, False: 639k]
  ------------------
  306|   325k|      __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  307|   325k|      if (big_endian) {
  ------------------
  |  Branch (307:11): [Folded, False: 325k]
  ------------------
  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|   325k|      if (!_mm_testz_si128(nextin, v_ff80)) {
  ------------------
  |  Branch (312:11): [True: 12.2k, False: 313k]
  ------------------
  313|       |        // 1. pack the bytes
  314|       |        // obviously suboptimal.
  315|  12.2k|        const __m128i utf8_packed = _mm_packus_epi16(in, in);
  316|       |        // 2. store (16 bytes)
  317|  12.2k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  318|       |        // 3. adjust pointers
  319|  12.2k|        buf += 8;
  320|  12.2k|        utf8_output += 8;
  321|  12.2k|        in = nextin;
  322|   313k|      } else {
  323|       |        // 1. pack the bytes
  324|       |        // obviously suboptimal.
  325|   313k|        const __m128i utf8_packed = _mm_packus_epi16(in, nextin);
  326|       |        // 2. store (16 bytes)
  327|   313k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  328|       |        // 3. adjust pointers
  329|   313k|        buf += 16;
  330|   313k|        utf8_output += 16;
  331|   313k|        continue; // we are done for this round!
  332|   313k|      }
  333|   325k|    }
  334|       |
  335|       |    // no bits set above 7th bit
  336|   651k|    const __m128i one_byte_bytemask =
  337|   651k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000);
  338|   651k|    const uint16_t one_byte_bitmask =
  339|   651k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  340|       |
  341|       |    // no bits set above 11th bit
  342|   651k|    const __m128i one_or_two_bytes_bytemask =
  343|   651k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000);
  344|   651k|    const uint16_t one_or_two_bytes_bitmask =
  345|   651k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  346|       |
  347|   651k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (347:9): [True: 123k, False: 528k]
  ------------------
  348|   123k|      internal::westmere::write_v_u16_11bits_to_utf8(
  349|   123k|          in, utf8_output, one_byte_bytemask, one_byte_bitmask);
  350|   123k|      buf += 8;
  351|   123k|      continue;
  352|   123k|    }
  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|   528k|    const __m128i surrogates_bytemask =
  358|   528k|        _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|   528k|    const uint16_t surrogates_bitmask =
  363|   528k|        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|   528k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (366:9): [True: 525k, False: 2.60k]
  ------------------
  367|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  368|   525k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  369|   525k|                                              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|   525k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  399|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  400|   525k|      const __m128i t0 = _mm_shuffle_epi8(in, dup_even);
  401|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  402|   525k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  398|   525k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  403|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  404|   525k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  398|   525k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  405|       |
  406|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  407|   525k|      const __m128i s0 = _mm_srli_epi16(in, 4);
  408|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  409|   525k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  398|   525k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  410|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  411|   525k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  398|   525k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  412|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  413|   525k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  398|   525k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  414|   525k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  415|   525k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  398|   525k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  416|   525k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  417|   525k|#undef simdutf_vec
  418|       |
  419|       |      // 4. expand code units 16-bit => 32-bit
  420|   525k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  421|   525k|      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|   525k|      const uint16_t mask =
  425|   525k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  426|   525k|      if (mask == 0) {
  ------------------
  |  Branch (426:11): [True: 446k, False: 79.1k]
  ------------------
  427|       |        // We only have three-byte code units. Use fast path.
  428|   446k|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  429|   446k|                                              15, 13, -1, -1, -1, -1);
  430|   446k|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  431|   446k|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  432|   446k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  433|   446k|        utf8_output += 12;
  434|   446k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  435|   446k|        utf8_output += 12;
  436|   446k|        buf += 8;
  437|   446k|        continue;
  438|   446k|      }
  439|  79.1k|      const uint8_t mask0 = uint8_t(mask);
  440|       |
  441|  79.1k|      const uint8_t *row0 =
  442|  79.1k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  443|  79.1k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  444|  79.1k|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  445|       |
  446|  79.1k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  447|       |
  448|  79.1k|      const uint8_t *row1 =
  449|  79.1k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  450|  79.1k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  451|  79.1k|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  452|       |
  453|  79.1k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  454|  79.1k|      utf8_output += row0[0];
  455|  79.1k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  456|  79.1k|      utf8_output += row1[0];
  457|       |
  458|  79.1k|      buf += 8;
  459|       |      // surrogate pair(s) in a register
  460|  79.1k|    } 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.60k|      size_t forward = 15;
  465|  2.60k|      size_t k = 0;
  466|  2.60k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (466:11): [True: 0, False: 2.60k]
  ------------------
  467|      0|        forward = size_t(end - buf - 1);
  468|      0|      }
  469|  37.1k|      for (; k < forward; k++) {
  ------------------
  |  Branch (469:14): [True: 34.6k, False: 2.46k]
  ------------------
  470|  34.6k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  471|  34.6k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (471:13): [True: 5.97k, False: 28.6k]
  ------------------
  472|  5.97k|          *utf8_output++ = char(word);
  473|  28.6k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (473:20): [True: 1.66k, False: 27.0k]
  ------------------
  474|  1.66k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  475|  1.66k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  476|  27.0k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (476:20): [True: 23.9k, False: 3.04k]
  ------------------
  477|  23.9k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  478|  23.9k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  479|  23.9k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  480|  23.9k|        } else {
  481|       |          // must be a surrogate pair
  482|  3.04k|          uint16_t diff = uint16_t(word - 0xD800);
  483|  3.04k|          uint16_t next_word =
  484|  3.04k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  485|  3.04k|          k++;
  486|  3.04k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  487|  3.04k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (487:15): [True: 146, False: 2.89k]
  ------------------
  488|    146|            return std::make_pair(
  489|    146|                result(error_code::SURROGATE, buf - start + k - 1),
  490|    146|                utf8_output);
  491|    146|          }
  492|  2.89k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  493|  2.89k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  494|  2.89k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  495|  2.89k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  496|  2.89k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  497|  2.89k|        }
  498|  34.6k|      }
  499|  2.46k|      buf += k;
  500|  2.46k|    }
  501|   528k|  } // while
  502|       |
  503|    496|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output);
  504|    642|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_137sse_convert_utf16_to_utf8_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
  285|    654|                                      char *utf8_output) {
  286|    654|  const char16_t *start = buf;
  287|    654|  const char16_t *end = buf + len;
  288|       |
  289|    654|  const __m128i v_0000 = _mm_setzero_si128();
  290|    654|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
  291|    654|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
  292|    654|  const size_t safety_margin =
  293|    654|      12; // to avoid overruns, see issue
  294|       |          // https://github.com/simdutf/simdutf/issues/92
  295|       |
  296|   559k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (296:10): [True: 559k, False: 496]
  ------------------
  297|   559k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  298|   559k|    if (big_endian) {
  ------------------
  |  Branch (298:9): [True: 559k, Folded]
  ------------------
  299|   559k|      const __m128i swap =
  300|   559k|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  301|   559k|      in = _mm_shuffle_epi8(in, swap);
  302|   559k|    }
  303|       |    // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes
  304|   559k|    const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80);
  305|   559k|    if (_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (305:9): [True: 406k, False: 153k]
  ------------------
  306|   406k|      __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  307|   406k|      if (big_endian) {
  ------------------
  |  Branch (307:11): [True: 406k, Folded]
  ------------------
  308|   406k|        const __m128i swap =
  309|   406k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  310|   406k|        nextin = _mm_shuffle_epi8(nextin, swap);
  311|   406k|      }
  312|   406k|      if (!_mm_testz_si128(nextin, v_ff80)) {
  ------------------
  |  Branch (312:11): [True: 33.2k, False: 372k]
  ------------------
  313|       |        // 1. pack the bytes
  314|       |        // obviously suboptimal.
  315|  33.2k|        const __m128i utf8_packed = _mm_packus_epi16(in, in);
  316|       |        // 2. store (16 bytes)
  317|  33.2k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  318|       |        // 3. adjust pointers
  319|  33.2k|        buf += 8;
  320|  33.2k|        utf8_output += 8;
  321|  33.2k|        in = nextin;
  322|   372k|      } else {
  323|       |        // 1. pack the bytes
  324|       |        // obviously suboptimal.
  325|   372k|        const __m128i utf8_packed = _mm_packus_epi16(in, nextin);
  326|       |        // 2. store (16 bytes)
  327|   372k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  328|       |        // 3. adjust pointers
  329|   372k|        buf += 16;
  330|   372k|        utf8_output += 16;
  331|   372k|        continue; // we are done for this round!
  332|   372k|      }
  333|   406k|    }
  334|       |
  335|       |    // no bits set above 7th bit
  336|   186k|    const __m128i one_byte_bytemask =
  337|   186k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000);
  338|   186k|    const uint16_t one_byte_bitmask =
  339|   186k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  340|       |
  341|       |    // no bits set above 11th bit
  342|   186k|    const __m128i one_or_two_bytes_bytemask =
  343|   186k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000);
  344|   186k|    const uint16_t one_or_two_bytes_bitmask =
  345|   186k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  346|       |
  347|   186k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (347:9): [True: 42.5k, False: 143k]
  ------------------
  348|  42.5k|      internal::westmere::write_v_u16_11bits_to_utf8(
  349|  42.5k|          in, utf8_output, one_byte_bytemask, one_byte_bitmask);
  350|  42.5k|      buf += 8;
  351|  42.5k|      continue;
  352|  42.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|   143k|    const __m128i surrogates_bytemask =
  358|   143k|        _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|   143k|    const uint16_t surrogates_bitmask =
  363|   143k|        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|   143k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (366:9): [True: 136k, False: 7.41k]
  ------------------
  367|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  368|   136k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  369|   136k|                                              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|   136k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  399|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  400|   136k|      const __m128i t0 = _mm_shuffle_epi8(in, dup_even);
  401|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  402|   136k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  398|   136k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  403|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  404|   136k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  398|   136k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  405|       |
  406|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  407|   136k|      const __m128i s0 = _mm_srli_epi16(in, 4);
  408|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  409|   136k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  398|   136k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  410|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  411|   136k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  398|   136k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  412|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  413|   136k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  398|   136k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  414|   136k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  415|   136k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  398|   136k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  416|   136k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  417|   136k|#undef simdutf_vec
  418|       |
  419|       |      // 4. expand code units 16-bit => 32-bit
  420|   136k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  421|   136k|      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|   136k|      const uint16_t mask =
  425|   136k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  426|   136k|      if (mask == 0) {
  ------------------
  |  Branch (426:11): [True: 49.5k, False: 86.9k]
  ------------------
  427|       |        // We only have three-byte code units. Use fast path.
  428|  49.5k|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  429|  49.5k|                                              15, 13, -1, -1, -1, -1);
  430|  49.5k|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  431|  49.5k|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  432|  49.5k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  433|  49.5k|        utf8_output += 12;
  434|  49.5k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  435|  49.5k|        utf8_output += 12;
  436|  49.5k|        buf += 8;
  437|  49.5k|        continue;
  438|  49.5k|      }
  439|  86.9k|      const uint8_t mask0 = uint8_t(mask);
  440|       |
  441|  86.9k|      const uint8_t *row0 =
  442|  86.9k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  443|  86.9k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  444|  86.9k|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  445|       |
  446|  86.9k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  447|       |
  448|  86.9k|      const uint8_t *row1 =
  449|  86.9k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  450|  86.9k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  451|  86.9k|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  452|       |
  453|  86.9k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  454|  86.9k|      utf8_output += row0[0];
  455|  86.9k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  456|  86.9k|      utf8_output += row1[0];
  457|       |
  458|  86.9k|      buf += 8;
  459|       |      // surrogate pair(s) in a register
  460|  86.9k|    } 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|  7.41k|      size_t forward = 15;
  465|  7.41k|      size_t k = 0;
  466|  7.41k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (466:11): [True: 0, False: 7.41k]
  ------------------
  467|      0|        forward = size_t(end - buf - 1);
  468|      0|      }
  469|   108k|      for (; k < forward; k++) {
  ------------------
  |  Branch (469:14): [True: 101k, False: 7.25k]
  ------------------
  470|   101k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  471|   101k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (471:13): [True: 34.4k, False: 66.7k]
  ------------------
  472|  34.4k|          *utf8_output++ = char(word);
  473|  66.7k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (473:20): [True: 4.94k, False: 61.7k]
  ------------------
  474|  4.94k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  475|  4.94k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  476|  61.7k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (476:20): [True: 53.1k, False: 8.69k]
  ------------------
  477|  53.1k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  478|  53.1k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  479|  53.1k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  480|  53.1k|        } else {
  481|       |          // must be a surrogate pair
  482|  8.69k|          uint16_t diff = uint16_t(word - 0xD800);
  483|  8.69k|          uint16_t next_word =
  484|  8.69k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  485|  8.69k|          k++;
  486|  8.69k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  487|  8.69k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (487:15): [True: 158, False: 8.54k]
  ------------------
  488|    158|            return std::make_pair(
  489|    158|                result(error_code::SURROGATE, buf - start + k - 1),
  490|    158|                utf8_output);
  491|    158|          }
  492|  8.54k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  493|  8.54k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  494|  8.54k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  495|  8.54k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  496|  8.54k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  497|  8.54k|        }
  498|   101k|      }
  499|  7.25k|      buf += k;
  500|  7.25k|    }
  501|   143k|  } // while
  502|       |
  503|    496|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output);
  504|    654|}

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

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_utf32_to_utf16ILNS_10endiannessE0EEENSt3__14pairIPKDiPDsEES7_mS8_:
   58|    822|                           char16_t *utf16_output) {
   59|       |
   60|    822|  const char32_t *end = buf + len;
   61|       |
   62|    822|  const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000);
   63|    822|  __m128i forbidden_bytemask = _mm_setzero_si128();
   64|       |
   65|  76.1k|  while (end - buf >= 16 + 8) {
  ------------------
  |  Branch (65:10): [True: 75.3k, False: 778]
  ------------------
   66|  75.3k|    const __m128i *ptr = reinterpret_cast<const __m128i *>(buf);
   67|  75.3k|    const __m128i in0 = _mm_loadu_si128(ptr + 0);
   68|  75.3k|    const __m128i in1 = _mm_loadu_si128(ptr + 1);
   69|  75.3k|    const __m128i in2 = _mm_loadu_si128(ptr + 2);
   70|  75.3k|    const __m128i in3 = _mm_loadu_si128(ptr + 3);
   71|       |
   72|  75.3k|    const __m128i combined =
   73|  75.3k|        _mm_or_si128(_mm_or_si128(in2, in3), _mm_or_si128(in0, in1));
   74|  75.3k|    if (simdutf_likely(_mm_testz_si128(combined, v_ffff0000))) {
  ------------------
  |  |   90|  75.3k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 73.3k, False: 2.03k]
  |  |  ------------------
  ------------------
   75|       |      // No bits set above 16th, directly pack UTF-32 to UTF-16
   76|  73.3k|      __m128i utf16_packed0 = _mm_packus_epi32(in0, in1);
   77|  73.3k|      __m128i utf16_packed1 = _mm_packus_epi32(in2, in3);
   78|       |
   79|  73.3k|      const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
   80|  73.3k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
   81|  73.3k|      forbidden_bytemask = _mm_or_si128(
   82|  73.3k|          forbidden_bytemask,
   83|  73.3k|          _mm_or_si128(
   84|  73.3k|              _mm_cmpeq_epi16(_mm_and_si128(utf16_packed0, v_f800), v_d800),
   85|  73.3k|              _mm_cmpeq_epi16(_mm_and_si128(utf16_packed1, v_f800), v_d800)));
   86|       |
   87|  73.3k|      if (big_endian) {
  ------------------
  |  Branch (87:11): [Folded, False: 73.3k]
  ------------------
   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|  73.3k|      _mm_storeu_si128((__m128i *)utf16_output + 0, utf16_packed0);
   95|  73.3k|      _mm_storeu_si128((__m128i *)utf16_output + 1, utf16_packed1);
   96|  73.3k|      utf16_output += 16;
   97|  73.3k|      buf += 16;
   98|  73.3k|    } else {
   99|  2.03k|      if (!validate_utf32(in0, in1) || !validate_utf32(in2, in3)) {
  ------------------
  |  Branch (99:11): [True: 26, False: 2.01k]
  |  Branch (99:40): [True: 18, False: 1.99k]
  ------------------
  100|     44|        return std::make_pair(nullptr, utf16_output);
  101|     44|      }
  102|       |
  103|  1.99k|      const auto ret0 = sse_expand_surrogate<big_endian>(in0);
  104|  1.99k|      _mm_storeu_si128((__m128i *)utf16_output, ret0.compressed);
  105|  1.99k|      utf16_output += ret0.u16count;
  106|       |
  107|  1.99k|      const auto ret1 = sse_expand_surrogate<big_endian>(in1);
  108|  1.99k|      _mm_storeu_si128((__m128i *)utf16_output, ret1.compressed);
  109|  1.99k|      utf16_output += ret1.u16count;
  110|       |
  111|  1.99k|      const auto ret2 = sse_expand_surrogate<big_endian>(in2);
  112|  1.99k|      _mm_storeu_si128((__m128i *)utf16_output, ret2.compressed);
  113|  1.99k|      utf16_output += ret2.u16count;
  114|       |
  115|  1.99k|      const auto ret3 = sse_expand_surrogate<big_endian>(in3);
  116|  1.99k|      _mm_storeu_si128((__m128i *)utf16_output, ret3.compressed);
  117|  1.99k|      utf16_output += ret3.u16count;
  118|       |
  119|  1.99k|      buf += 16;
  120|  1.99k|    }
  121|  75.3k|  }
  122|       |
  123|       |  // check for invalid input
  124|    778|  if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (124:7): [True: 12, False: 766]
  ------------------
  125|     12|    return std::make_pair(nullptr, utf16_output);
  126|     12|  }
  127|       |
  128|    766|  return std::make_pair(buf, utf16_output);
  129|    778|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114validate_utf32EDv2_xS2_:
   37|  7.10k|simdutf_really_inline bool validate_utf32(const __m128i a, const __m128i b) {
   38|  7.10k|  using vector_u32 = simd32<uint32_t>;
   39|       |
   40|  7.10k|  const auto in0 = vector_u32(a);
   41|  7.10k|  const auto in1 = vector_u32(b);
   42|       |
   43|  7.10k|  const auto standardmax = vector_u32::splat(0x10ffff);
   44|  7.10k|  const auto offset = vector_u32::splat(0xffff2000);
   45|  7.10k|  const auto standardoffsetmax = vector_u32::splat(0xfffff7ff);
   46|       |
   47|  7.10k|  const auto too_large = max(in0, in1) > standardmax;
   48|  7.10k|  const auto surrogate0 = (in0 + offset) > standardoffsetmax;
   49|  7.10k|  const auto surrogate1 = (in1 + offset) > standardoffsetmax;
   50|       |
   51|  7.10k|  const auto combined = too_large | surrogate0 | surrogate1;
   52|  7.10k|  return !combined.any();
   53|  7.10k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_120sse_expand_surrogateILNS_10endiannessE0EEENS1_18expansion_result_tEDv2_x:
    9|  7.97k|expansion_result_t sse_expand_surrogate(const __m128i x) {
   10|  7.97k|  using vector_u32 = simd32<uint32_t>;
   11|  7.97k|  using vector_u8 = simd8<uint8_t>;
   12|       |
   13|  7.97k|  const auto in = vector_u32(x);
   14|       |
   15|  7.97k|  const auto non_surrogate_mask = (in & uint32_t(0xffff0000)) == uint32_t(0);
   16|  7.97k|  const auto mask = (~non_surrogate_mask.to_4bit_bitmask()) & 0xf;
   17|       |
   18|  7.97k|  const auto t0 = in - uint32_t(0x00010000);
   19|  7.97k|  const auto hi = t0.shr<10>() & uint32_t(0x000003ff);
   20|  7.97k|  const auto lo = t0.shl<16>() & uint32_t(0x03ff0000);
   21|  7.97k|  const auto surrogates = (lo | hi) | uint32_t(0xdc00d800);
   22|       |
   23|  7.97k|  const auto merged = as_vector_u8(select(non_surrogate_mask, in, surrogates));
   24|       |
   25|  7.97k|  const auto shuffle = vector_u8::load(
   26|  7.97k|      (byte_order == endianness::LITTLE)
  ------------------
  |  Branch (26:7): [True: 7.97k, Folded]
  ------------------
   27|  7.97k|          ? tables::utf32_to_utf16::pack_utf32_to_utf16le[mask]
   28|  7.97k|          : tables::utf32_to_utf16::pack_utf32_to_utf16be[mask]);
   29|       |
   30|  7.97k|  const size_t u16count = (4 + count_ones(mask));
   31|  7.97k|  const auto compressed = shuffle.lookup_16(merged);
   32|       |
   33|  7.97k|  return {u16count, compressed};
   34|  7.97k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_utf32_to_utf16ILNS_10endiannessE1EEENSt3__14pairIPKDiPDsEES7_mS8_:
   58|    674|                           char16_t *utf16_output) {
   59|       |
   60|    674|  const char32_t *end = buf + len;
   61|       |
   62|    674|  const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000);
   63|    674|  __m128i forbidden_bytemask = _mm_setzero_si128();
   64|       |
   65|  9.12k|  while (end - buf >= 16 + 8) {
  ------------------
  |  Branch (65:10): [True: 8.53k, False: 596]
  ------------------
   66|  8.53k|    const __m128i *ptr = reinterpret_cast<const __m128i *>(buf);
   67|  8.53k|    const __m128i in0 = _mm_loadu_si128(ptr + 0);
   68|  8.53k|    const __m128i in1 = _mm_loadu_si128(ptr + 1);
   69|  8.53k|    const __m128i in2 = _mm_loadu_si128(ptr + 2);
   70|  8.53k|    const __m128i in3 = _mm_loadu_si128(ptr + 3);
   71|       |
   72|  8.53k|    const __m128i combined =
   73|  8.53k|        _mm_or_si128(_mm_or_si128(in2, in3), _mm_or_si128(in0, in1));
   74|  8.53k|    if (simdutf_likely(_mm_testz_si128(combined, v_ffff0000))) {
  ------------------
  |  |   90|  8.53k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 6.98k, False: 1.55k]
  |  |  ------------------
  ------------------
   75|       |      // No bits set above 16th, directly pack UTF-32 to UTF-16
   76|  6.98k|      __m128i utf16_packed0 = _mm_packus_epi32(in0, in1);
   77|  6.98k|      __m128i utf16_packed1 = _mm_packus_epi32(in2, in3);
   78|       |
   79|  6.98k|      const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
   80|  6.98k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
   81|  6.98k|      forbidden_bytemask = _mm_or_si128(
   82|  6.98k|          forbidden_bytemask,
   83|  6.98k|          _mm_or_si128(
   84|  6.98k|              _mm_cmpeq_epi16(_mm_and_si128(utf16_packed0, v_f800), v_d800),
   85|  6.98k|              _mm_cmpeq_epi16(_mm_and_si128(utf16_packed1, v_f800), v_d800)));
   86|       |
   87|  6.98k|      if (big_endian) {
  ------------------
  |  Branch (87:11): [True: 6.98k, Folded]
  ------------------
   88|  6.98k|        const __m128i swap =
   89|  6.98k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   90|  6.98k|        utf16_packed0 = _mm_shuffle_epi8(utf16_packed0, swap);
   91|  6.98k|        utf16_packed1 = _mm_shuffle_epi8(utf16_packed1, swap);
   92|  6.98k|      }
   93|       |
   94|  6.98k|      _mm_storeu_si128((__m128i *)utf16_output + 0, utf16_packed0);
   95|  6.98k|      _mm_storeu_si128((__m128i *)utf16_output + 1, utf16_packed1);
   96|  6.98k|      utf16_output += 16;
   97|  6.98k|      buf += 16;
   98|  6.98k|    } else {
   99|  1.55k|      if (!validate_utf32(in0, in1) || !validate_utf32(in2, in3)) {
  ------------------
  |  Branch (99:11): [True: 54, False: 1.49k]
  |  Branch (99:40): [True: 24, False: 1.47k]
  ------------------
  100|     78|        return std::make_pair(nullptr, utf16_output);
  101|     78|      }
  102|       |
  103|  1.47k|      const auto ret0 = sse_expand_surrogate<big_endian>(in0);
  104|  1.47k|      _mm_storeu_si128((__m128i *)utf16_output, ret0.compressed);
  105|  1.47k|      utf16_output += ret0.u16count;
  106|       |
  107|  1.47k|      const auto ret1 = sse_expand_surrogate<big_endian>(in1);
  108|  1.47k|      _mm_storeu_si128((__m128i *)utf16_output, ret1.compressed);
  109|  1.47k|      utf16_output += ret1.u16count;
  110|       |
  111|  1.47k|      const auto ret2 = sse_expand_surrogate<big_endian>(in2);
  112|  1.47k|      _mm_storeu_si128((__m128i *)utf16_output, ret2.compressed);
  113|  1.47k|      utf16_output += ret2.u16count;
  114|       |
  115|  1.47k|      const auto ret3 = sse_expand_surrogate<big_endian>(in3);
  116|  1.47k|      _mm_storeu_si128((__m128i *)utf16_output, ret3.compressed);
  117|  1.47k|      utf16_output += ret3.u16count;
  118|       |
  119|  1.47k|      buf += 16;
  120|  1.47k|    }
  121|  8.53k|  }
  122|       |
  123|       |  // check for invalid input
  124|    596|  if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (124:7): [True: 12, False: 584]
  ------------------
  125|     12|    return std::make_pair(nullptr, utf16_output);
  126|     12|  }
  127|       |
  128|    584|  return std::make_pair(buf, utf16_output);
  129|    596|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_120sse_expand_surrogateILNS_10endiannessE1EEENS1_18expansion_result_tEDv2_x:
    9|  5.89k|expansion_result_t sse_expand_surrogate(const __m128i x) {
   10|  5.89k|  using vector_u32 = simd32<uint32_t>;
   11|  5.89k|  using vector_u8 = simd8<uint8_t>;
   12|       |
   13|  5.89k|  const auto in = vector_u32(x);
   14|       |
   15|  5.89k|  const auto non_surrogate_mask = (in & uint32_t(0xffff0000)) == uint32_t(0);
   16|  5.89k|  const auto mask = (~non_surrogate_mask.to_4bit_bitmask()) & 0xf;
   17|       |
   18|  5.89k|  const auto t0 = in - uint32_t(0x00010000);
   19|  5.89k|  const auto hi = t0.shr<10>() & uint32_t(0x000003ff);
   20|  5.89k|  const auto lo = t0.shl<16>() & uint32_t(0x03ff0000);
   21|  5.89k|  const auto surrogates = (lo | hi) | uint32_t(0xdc00d800);
   22|       |
   23|  5.89k|  const auto merged = as_vector_u8(select(non_surrogate_mask, in, surrogates));
   24|       |
   25|  5.89k|  const auto shuffle = vector_u8::load(
   26|  5.89k|      (byte_order == endianness::LITTLE)
  ------------------
  |  Branch (26:7): [Folded, False: 5.89k]
  ------------------
   27|  5.89k|          ? tables::utf32_to_utf16::pack_utf32_to_utf16le[mask]
   28|  5.89k|          : tables::utf32_to_utf16::pack_utf32_to_utf16be[mask]);
   29|       |
   30|  5.89k|  const size_t u16count = (4 + count_ones(mask));
   31|  5.89k|  const auto compressed = shuffle.lookup_16(merged);
   32|       |
   33|  5.89k|  return {u16count, compressed};
   34|  5.89k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_138sse_convert_utf32_to_utf16_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPDsEEPKDimS7_:
  134|    674|                                       char16_t *utf16_output) {
  135|    674|  const char32_t *start = buf;
  136|    674|  const char32_t *end = buf + len;
  137|       |
  138|    674|  const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000);
  139|       |
  140|  68.6k|  while (end - buf >= 8) {
  ------------------
  |  Branch (140:10): [True: 68.3k, False: 316]
  ------------------
  141|  68.3k|    const __m128i in = _mm_loadu_si128((__m128i *)buf);
  142|  68.3k|    const __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  143|       |
  144|  68.3k|    const __m128i combined = _mm_or_si128(in, nextin);
  145|  68.3k|    if (simdutf_likely(_mm_testz_si128(combined, v_ffff0000))) {
  ------------------
  |  |   90|  68.3k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 66.6k, False: 1.68k]
  |  |  ------------------
  ------------------
  146|       |      // No bits set above 16th, directly pack UTF-32 to UTF-16
  147|  66.6k|      __m128i utf16_packed = _mm_packus_epi32(in, nextin);
  148|       |
  149|  66.6k|      const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
  150|  66.6k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
  151|  66.6k|      const __m128i forbidden_bytemask =
  152|  66.6k|          _mm_cmpeq_epi16(_mm_and_si128(utf16_packed, v_f800), v_d800);
  153|  66.6k|      if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (153:11): [True: 46, False: 66.5k]
  ------------------
  154|     46|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  155|     46|                              utf16_output);
  156|     46|      }
  157|       |
  158|  66.5k|      if (big_endian) {
  ------------------
  |  Branch (158:11): [Folded, False: 66.5k]
  ------------------
  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|  66.5k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
  165|  66.5k|      utf16_output += 8;
  166|  66.5k|      buf += 8;
  167|  66.5k|    } else {
  168|  1.68k|      size_t forward = 7;
  169|  1.68k|      size_t k = 0;
  170|  1.68k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (170:11): [True: 0, False: 1.68k]
  ------------------
  171|      0|        forward = size_t(end - buf - 1);
  172|      0|      }
  173|  11.8k|      for (; k < forward; k++) {
  ------------------
  |  Branch (173:14): [True: 10.5k, False: 1.36k]
  ------------------
  174|  10.5k|        uint32_t word = buf[k];
  175|  10.5k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (175:13): [True: 4.93k, False: 5.56k]
  ------------------
  176|       |          // will not generate a surrogate pair
  177|  4.93k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (177:15): [True: 720, False: 4.21k]
  |  Branch (177:33): [True: 14, False: 706]
  ------------------
  178|     14|            return std::make_pair(
  179|     14|                result(error_code::SURROGATE, buf - start + k), utf16_output);
  180|     14|          }
  181|  4.92k|          *utf16_output++ =
  182|  4.92k|              big_endian
  ------------------
  |  Branch (182:15): [Folded, False: 4.92k]
  ------------------
  183|  4.92k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
  184|  4.92k|                  : char16_t(word);
  185|  5.56k|        } else {
  186|       |          // will generate a surrogate pair
  187|  5.56k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (187:15): [True: 298, False: 5.27k]
  ------------------
  188|    298|            return std::make_pair(
  189|    298|                result(error_code::TOO_LARGE, buf - start + k), utf16_output);
  190|    298|          }
  191|  5.27k|          word -= 0x10000;
  192|  5.27k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
  193|  5.27k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
  194|  5.27k|          if (big_endian) {
  ------------------
  |  Branch (194:15): [Folded, False: 5.27k]
  ------------------
  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|  5.27k|          *utf16_output++ = char16_t(high_surrogate);
  201|  5.27k|          *utf16_output++ = char16_t(low_surrogate);
  202|  5.27k|        }
  203|  10.5k|      }
  204|  1.36k|      buf += k;
  205|  1.36k|    }
  206|  68.3k|  }
  207|       |
  208|    316|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output);
  209|    674|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_138sse_convert_utf32_to_utf16_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPDsEEPKDimS7_:
  134|    694|                                       char16_t *utf16_output) {
  135|    694|  const char32_t *start = buf;
  136|    694|  const char32_t *end = buf + len;
  137|       |
  138|    694|  const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000);
  139|       |
  140|  4.82k|  while (end - buf >= 8) {
  ------------------
  |  Branch (140:10): [True: 4.50k, False: 316]
  ------------------
  141|  4.50k|    const __m128i in = _mm_loadu_si128((__m128i *)buf);
  142|  4.50k|    const __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  143|       |
  144|  4.50k|    const __m128i combined = _mm_or_si128(in, nextin);
  145|  4.50k|    if (simdutf_likely(_mm_testz_si128(combined, v_ffff0000))) {
  ------------------
  |  |   90|  4.50k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 3.35k, False: 1.15k]
  |  |  ------------------
  ------------------
  146|       |      // No bits set above 16th, directly pack UTF-32 to UTF-16
  147|  3.35k|      __m128i utf16_packed = _mm_packus_epi32(in, nextin);
  148|       |
  149|  3.35k|      const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
  150|  3.35k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
  151|  3.35k|      const __m128i forbidden_bytemask =
  152|  3.35k|          _mm_cmpeq_epi16(_mm_and_si128(utf16_packed, v_f800), v_d800);
  153|  3.35k|      if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (153:11): [True: 22, False: 3.33k]
  ------------------
  154|     22|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  155|     22|                              utf16_output);
  156|     22|      }
  157|       |
  158|  3.33k|      if (big_endian) {
  ------------------
  |  Branch (158:11): [True: 3.33k, Folded]
  ------------------
  159|  3.33k|        const __m128i swap =
  160|  3.33k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  161|  3.33k|        utf16_packed = _mm_shuffle_epi8(utf16_packed, swap);
  162|  3.33k|      }
  163|       |
  164|  3.33k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
  165|  3.33k|      utf16_output += 8;
  166|  3.33k|      buf += 8;
  167|  3.33k|    } else {
  168|  1.15k|      size_t forward = 7;
  169|  1.15k|      size_t k = 0;
  170|  1.15k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (170:11): [True: 0, False: 1.15k]
  ------------------
  171|      0|        forward = size_t(end - buf - 1);
  172|      0|      }
  173|  7.49k|      for (; k < forward; k++) {
  ------------------
  |  Branch (173:14): [True: 6.69k, False: 796]
  ------------------
  174|  6.69k|        uint32_t word = buf[k];
  175|  6.69k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (175:13): [True: 3.35k, False: 3.34k]
  ------------------
  176|       |          // will not generate a surrogate pair
  177|  3.35k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (177:15): [True: 850, False: 2.50k]
  |  Branch (177:33): [True: 40, False: 810]
  ------------------
  178|     40|            return std::make_pair(
  179|     40|                result(error_code::SURROGATE, buf - start + k), utf16_output);
  180|     40|          }
  181|  3.31k|          *utf16_output++ =
  182|  3.31k|              big_endian
  ------------------
  |  Branch (182:15): [True: 3.31k, Folded]
  ------------------
  183|  3.31k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
  184|  3.31k|                  : char16_t(word);
  185|  3.34k|        } else {
  186|       |          // will generate a surrogate pair
  187|  3.34k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (187:15): [True: 316, False: 3.02k]
  ------------------
  188|    316|            return std::make_pair(
  189|    316|                result(error_code::TOO_LARGE, buf - start + k), utf16_output);
  190|    316|          }
  191|  3.02k|          word -= 0x10000;
  192|  3.02k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
  193|  3.02k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
  194|  3.02k|          if (big_endian) {
  ------------------
  |  Branch (194:15): [True: 3.02k, Folded]
  ------------------
  195|  3.02k|            high_surrogate =
  196|  3.02k|                uint16_t((high_surrogate >> 8) | (high_surrogate << 8));
  197|  3.02k|            low_surrogate =
  198|  3.02k|                uint16_t((low_surrogate >> 8) | (low_surrogate << 8));
  199|  3.02k|          }
  200|  3.02k|          *utf16_output++ = char16_t(high_surrogate);
  201|  3.02k|          *utf16_output++ = char16_t(low_surrogate);
  202|  3.02k|        }
  203|  6.69k|      }
  204|    796|      buf += k;
  205|    796|    }
  206|  4.50k|  }
  207|       |
  208|    316|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output);
  209|    694|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_125sse_convert_utf32_to_utf8EPKDimPc:
    2|    864|sse_convert_utf32_to_utf8(const char32_t *buf, size_t len, char *utf8_output) {
    3|    864|  const char32_t *end = buf + len;
    4|       |
    5|    864|  const __m128i v_0000 = _mm_setzero_si128();              //__m128 = 128 bits
    6|    864|  const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800); // 1111 1000 0000
    7|       |                                                           // 0000
    8|    864|  const __m128i v_c080 = _mm_set1_epi16((uint16_t)0xc080); // 1100 0000 1000
    9|       |                                                           // 0000
   10|    864|  const __m128i v_ff80 = _mm_set1_epi16((uint16_t)0xff80); // 1111 1111 1000
   11|       |                                                           // 0000
   12|    864|  const __m128i v_ffff0000 = _mm_set1_epi32(
   13|    864|      (uint32_t)0xffff0000); // 1111 1111 1111 1111 0000 0000 0000 0000
   14|    864|  const __m128i v_7fffffff = _mm_set1_epi32(
   15|    864|      (uint32_t)0x7fffffff); // 0111 1111 1111 1111 1111 1111 1111 1111
   16|    864|  __m128i running_max = _mm_setzero_si128();
   17|    864|  __m128i forbidden_bytemask = _mm_setzero_si128();
   18|    864|  const size_t safety_margin =
   19|    864|      12; // to avoid overruns, see issue
   20|       |          // https://github.com/simdutf/simdutf/issues/92
   21|       |
   22|  40.7k|  while (end - buf >=
  ------------------
  |  Branch (22:10): [True: 40.0k, False: 672]
  ------------------
   23|  40.7k|         std::ptrdiff_t(
   24|  40.7k|             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|  40.0k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   29|  40.0k|    __m128i nextin = _mm_loadu_si128(
   30|  40.0k|        (__m128i *)buf + 1); // These two values can hold only 8 UTF32 chars
   31|  40.0k|    running_max = _mm_max_epu32(
   32|  40.0k|        _mm_max_epu32(in, running_max), // take element-wise max char32_t from
   33|       |                                        // in and running_max vector
   34|  40.0k|        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|  40.0k|    __m128i in_16 = _mm_packus_epi32(
   40|  40.0k|        _mm_and_si128(in, v_7fffffff),
   41|  40.0k|        _mm_and_si128(
   42|  40.0k|            nextin,
   43|  40.0k|            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|  40.0k|    if (_mm_testz_si128(in_16, v_ff80)) { // if the first two blocks are ASCII
  ------------------
  |  Branch (60:9): [True: 35.3k, False: 4.73k]
  ------------------
   61|  35.3k|      __m128i thirdin = _mm_loadu_si128((__m128i *)buf + 2);
   62|  35.3k|      __m128i fourthin = _mm_loadu_si128((__m128i *)buf + 3);
   63|  35.3k|      running_max = _mm_max_epu32(
   64|  35.3k|          _mm_max_epu32(thirdin, running_max),
   65|  35.3k|          fourthin); // take the running max of all 4 vectors thus far
   66|  35.3k|      __m128i nextin_16 = _mm_packus_epi32(
   67|  35.3k|          _mm_and_si128(thirdin, v_7fffffff),
   68|  35.3k|          _mm_and_si128(fourthin,
   69|  35.3k|                        v_7fffffff)); // pack into 1 vector, now you have two
   70|  35.3k|      if (!_mm_testz_si128(
  ------------------
  |  Branch (70:11): [True: 1.21k, False: 34.1k]
  ------------------
   71|  35.3k|              nextin_16,
   72|  35.3k|              v_ff80)) { // checks if the second packed vector is ASCII, if not:
   73|       |        // 1. pack the bytes
   74|       |        // obviously suboptimal.
   75|  1.21k|        const __m128i utf8_packed = _mm_packus_epi16(
   76|  1.21k|            in_16, in_16); // creates two copy of in_16 in 1 vector
   77|       |        // 2. store (16 bytes)
   78|  1.21k|        _mm_storeu_si128((__m128i *)utf8_output,
   79|  1.21k|                         utf8_packed); // put them into the output
   80|       |        // 3. adjust pointers
   81|  1.21k|        buf += 8; // the char32_t buffer pointer goes up 8 char32_t chars* 32
   82|       |                  // bits =  256 bits
   83|  1.21k|        utf8_output +=
   84|  1.21k|            8; // same with output, e.g. lift the first two blocks alone.
   85|       |        // Proceed with next input
   86|  1.21k|        in_16 = nextin_16;
   87|       |        // We need to update in and nextin because they are used later.
   88|  1.21k|        in = thirdin;
   89|  1.21k|        nextin = fourthin;
   90|  34.1k|      } else {
   91|       |        // 1. pack the bytes
   92|  34.1k|        const __m128i utf8_packed = _mm_packus_epi16(in_16, nextin_16);
   93|       |        // 2. store (16 bytes)
   94|  34.1k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   95|       |        // 3. adjust pointers
   96|  34.1k|        buf += 16;
   97|  34.1k|        utf8_output += 16;
   98|  34.1k|        continue; // we are done for this round!
   99|  34.1k|      }
  100|  35.3k|    }
  101|       |
  102|       |    // no bits set above 7th bit -- find out all the ASCII characters
  103|  5.94k|    const __m128i one_byte_bytemask =
  104|  5.94k|        _mm_cmpeq_epi16( // this takes four bytes at a time and compares:
  105|  5.94k|            _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.94k|            v_0000                        //
  108|  5.94k|        ); // 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.94k|    const uint16_t one_byte_bitmask = static_cast<uint16_t>(_mm_movemask_epi8(
  113|  5.94k|        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.94k|    const __m128i one_or_two_bytes_bytemask =
  118|  5.94k|        _mm_cmpeq_epi16(_mm_and_si128(in_16, v_f800), v_0000);
  119|  5.94k|    const uint16_t one_or_two_bytes_bitmask =
  120|  5.94k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  121|       |
  122|  5.94k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (122:9): [True: 2.75k, False: 3.19k]
  ------------------
  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.75k|      const __m128i v_1f00 =
  129|  2.75k|          _mm_set1_epi16((int16_t)0x1f00); // 0001 1111 0000 0000
  130|  2.75k|      const __m128i v_003f =
  131|  2.75k|          _mm_set1_epi16((int16_t)0x003f); // 0000 0000 0011 1111
  132|       |
  133|       |      // t0 = [000a|aaaa|bbbb|bb00]
  134|  2.75k|      const __m128i t0 = _mm_slli_epi16(in_16, 2); // shift packed vector by two
  135|       |      // t1 = [000a|aaaa|0000|0000]
  136|  2.75k|      const __m128i t1 = _mm_and_si128(t0, v_1f00); // potential first utf8 byte
  137|       |      // t2 = [0000|0000|00bb|bbbb]
  138|  2.75k|      const __m128i t2 =
  139|  2.75k|          _mm_and_si128(in_16, v_003f); // potential second utf8 byte
  140|       |      // t3 = [000a|aaaa|00bb|bbbb]
  141|  2.75k|      const __m128i t3 =
  142|  2.75k|          _mm_or_si128(t1, t2); // first and second potential utf8 byte together
  143|       |      // t4 = [110a|aaaa|10bb|bbbb]
  144|  2.75k|      const __m128i t4 = _mm_or_si128(
  145|  2.75k|          t3,
  146|  2.75k|          v_c080); // t3 | 1100 0000 1000 0000 = full potential 2-byte utf8 unit
  147|       |
  148|       |      // 2. merge ASCII and 2-byte codewords
  149|  2.75k|      const __m128i utf8_unpacked =
  150|  2.75k|          _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.75k|      const uint16_t m0 = one_byte_bitmask & 0x5555; // m0 = 0h0g0f0e0d0c0b0a
  156|  2.75k|      const uint16_t m1 =
  157|  2.75k|          static_cast<uint16_t>(m0 >> 7); // m1 = 00000000h0g0f0e0
  158|  2.75k|      const uint8_t m2 =
  159|  2.75k|          static_cast<uint8_t>((m0 | m1) & 0xff); // m2 =         hdgcfbea
  160|       |      // 4. pack the bytes
  161|  2.75k|      const uint8_t *row =
  162|  2.75k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0];
  163|  2.75k|      const __m128i shuffle = _mm_loadu_si128((__m128i *)(row + 1));
  164|  2.75k|      const __m128i utf8_packed = _mm_shuffle_epi8(utf8_unpacked, shuffle);
  165|       |
  166|       |      // 5. store bytes
  167|  2.75k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  168|       |
  169|       |      // 6. adjust pointers
  170|  2.75k|      buf += 8;
  171|  2.75k|      utf8_output += row[0];
  172|  2.75k|      continue;
  173|  2.75k|    }
  174|       |
  175|       |    // Check for overflow in packing
  176|       |
  177|  3.19k|    const __m128i saturation_bytemask = _mm_cmpeq_epi32(
  178|  3.19k|        _mm_and_si128(_mm_or_si128(in, nextin), v_ffff0000), v_0000);
  179|  3.19k|    const uint32_t saturation_bitmask =
  180|  3.19k|        static_cast<uint32_t>(_mm_movemask_epi8(saturation_bytemask));
  181|  3.19k|    if (saturation_bitmask == 0xffff) {
  ------------------
  |  Branch (181:9): [True: 1.54k, False: 1.64k]
  ------------------
  182|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  183|  1.54k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
  184|  1.54k|      forbidden_bytemask =
  185|  1.54k|          _mm_or_si128(forbidden_bytemask,
  186|  1.54k|                       _mm_cmpeq_epi16(_mm_and_si128(in_16, v_f800), v_d800));
  187|       |
  188|  1.54k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  189|  1.54k|                                              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.54k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  219|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  220|  1.54k|      const __m128i t0 = _mm_shuffle_epi8(in_16, dup_even);
  221|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  222|  1.54k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  218|  1.54k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  223|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  224|  1.54k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  218|  1.54k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  225|       |
  226|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  227|  1.54k|      const __m128i s0 = _mm_srli_epi16(in_16, 4);
  228|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  229|  1.54k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  218|  1.54k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  230|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  231|  1.54k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  218|  1.54k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  232|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  233|  1.54k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  218|  1.54k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  234|  1.54k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  235|  1.54k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  218|  1.54k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  236|  1.54k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  237|  1.54k|#undef simdutf_vec
  238|       |
  239|       |      // 4. expand code units 16-bit => 32-bit
  240|  1.54k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  241|  1.54k|      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.54k|      const uint16_t mask =
  245|  1.54k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  246|  1.54k|      if (mask == 0) {
  ------------------
  |  Branch (246:11): [True: 588, False: 960]
  ------------------
  247|       |        // We only have three-byte code units. Use fast path.
  248|    588|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  249|    588|                                              15, 13, -1, -1, -1, -1);
  250|    588|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  251|    588|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  252|    588|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  253|    588|        utf8_output += 12;
  254|    588|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  255|    588|        utf8_output += 12;
  256|    588|        buf += 8;
  257|    588|        continue;
  258|    588|      }
  259|    960|      const uint8_t mask0 = uint8_t(mask);
  260|       |
  261|    960|      const uint8_t *row0 =
  262|    960|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  263|    960|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  264|    960|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  265|       |
  266|    960|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  267|       |
  268|    960|      const uint8_t *row1 =
  269|    960|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  270|    960|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  271|    960|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  272|       |
  273|    960|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  274|    960|      utf8_output += row0[0];
  275|    960|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  276|    960|      utf8_output += row1[0];
  277|       |
  278|    960|      buf += 8;
  279|  1.64k|    } 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.64k|      size_t forward = 15;
  285|  1.64k|      size_t k = 0;
  286|  1.64k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (286:11): [True: 0, False: 1.64k]
  ------------------
  287|      0|        forward = size_t(end - buf - 1);
  288|      0|      }
  289|  24.0k|      for (; k < forward; k++) {
  ------------------
  |  Branch (289:14): [True: 22.5k, False: 1.45k]
  ------------------
  290|  22.5k|        uint32_t word = buf[k];
  291|  22.5k|        if ((word & 0xFFFFFF80) == 0) {
  ------------------
  |  Branch (291:13): [True: 14.8k, False: 7.77k]
  ------------------
  292|  14.8k|          *utf8_output++ = char(word);
  293|  14.8k|        } else if ((word & 0xFFFFF800) == 0) {
  ------------------
  |  Branch (293:20): [True: 1.13k, False: 6.64k]
  ------------------
  294|  1.13k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  295|  1.13k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  296|  6.64k|        } else if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (296:20): [True: 2.55k, False: 4.09k]
  ------------------
  297|  2.55k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (297:15): [True: 712, False: 1.84k]
  |  Branch (297:33): [True: 22, False: 690]
  ------------------
  298|     22|            return std::make_pair(nullptr, utf8_output);
  299|     22|          }
  300|  2.53k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  301|  2.53k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  302|  2.53k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  303|  4.09k|        } else {
  304|  4.09k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (304:15): [True: 170, False: 3.92k]
  ------------------
  305|    170|            return std::make_pair(nullptr, utf8_output);
  306|    170|          }
  307|  3.92k|          *utf8_output++ = char((word >> 18) | 0b11110000);
  308|  3.92k|          *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000);
  309|  3.92k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  310|  3.92k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  311|  3.92k|        }
  312|  22.5k|      }
  313|  1.45k|      buf += k;
  314|  1.45k|    }
  315|  3.19k|  } // while
  316|       |
  317|       |  // check for invalid input
  318|    672|  const __m128i v_10ffff = _mm_set1_epi32((uint32_t)0x10ffff);
  319|    672|  if (static_cast<uint16_t>(_mm_movemask_epi8(_mm_cmpeq_epi32(
  ------------------
  |  Branch (319:7): [True: 16, False: 656]
  ------------------
  320|    672|          _mm_max_epu32(running_max, v_10ffff), v_10ffff))) != 0xffff) {
  321|     16|    return std::make_pair(nullptr, utf8_output);
  322|     16|  }
  323|       |
  324|    656|  if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (324:7): [True: 48, False: 608]
  ------------------
  325|     48|    return std::make_pair(nullptr, utf8_output);
  326|     48|  }
  327|       |
  328|    608|  return std::make_pair(buf, utf8_output);
  329|    656|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_137sse_convert_utf32_to_utf8_with_errorsEPKDimPc:
  333|    832|                                      char *utf8_output) {
  334|    832|  const char32_t *end = buf + len;
  335|    832|  const char32_t *start = buf;
  336|       |
  337|    832|  const __m128i v_0000 = _mm_setzero_si128();
  338|    832|  const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
  339|    832|  const __m128i v_c080 = _mm_set1_epi16((uint16_t)0xc080);
  340|    832|  const __m128i v_ff80 = _mm_set1_epi16((uint16_t)0xff80);
  341|    832|  const __m128i v_ffff0000 = _mm_set1_epi32((uint32_t)0xffff0000);
  342|    832|  const __m128i v_7fffffff = _mm_set1_epi32((uint32_t)0x7fffffff);
  343|    832|  const __m128i v_10ffff = _mm_set1_epi32((uint32_t)0x10ffff);
  344|       |
  345|    832|  const size_t safety_margin =
  346|    832|      12; // to avoid overruns, see issue
  347|       |          // https://github.com/simdutf/simdutf/issues/92
  348|       |
  349|  46.7k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (349:10): [True: 46.0k, False: 658]
  ------------------
  350|       |    // We load two 16 bytes registers for a total of 32 bytes or 8 characters.
  351|  46.0k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  352|  46.0k|    __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  353|       |    // Check for too large input
  354|  46.0k|    __m128i max_input = _mm_max_epu32(_mm_max_epu32(in, nextin), v_10ffff);
  355|  46.0k|    if (static_cast<uint16_t>(_mm_movemask_epi8(
  ------------------
  |  Branch (355:9): [True: 50, False: 45.9k]
  ------------------
  356|  46.0k|            _mm_cmpeq_epi32(max_input, v_10ffff))) != 0xffff) {
  357|     50|      return std::make_pair(result(error_code::TOO_LARGE, buf - start),
  358|     50|                            utf8_output);
  359|     50|    }
  360|       |
  361|       |    // Pack 32-bit UTF-32 code units to 16-bit UTF-16 code units with unsigned
  362|       |    // saturation
  363|  45.9k|    __m128i in_16 = _mm_packus_epi32(_mm_and_si128(in, v_7fffffff),
  364|  45.9k|                                     _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|  45.9k|    if (_mm_testz_si128(in_16, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (369:9): [True: 41.1k, False: 4.88k]
  ------------------
  370|       |      // 1. pack the bytes
  371|       |      // obviously suboptimal.
  372|  41.1k|      const __m128i utf8_packed = _mm_packus_epi16(in_16, in_16);
  373|       |      // 2. store (16 bytes)
  374|  41.1k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  375|       |      // 3. adjust pointers
  376|  41.1k|      buf += 8;
  377|  41.1k|      utf8_output += 8;
  378|  41.1k|      continue;
  379|  41.1k|    }
  380|       |
  381|       |    // no bits set above 7th bit
  382|  4.88k|    const __m128i one_byte_bytemask =
  383|  4.88k|        _mm_cmpeq_epi16(_mm_and_si128(in_16, v_ff80), v_0000);
  384|  4.88k|    const uint16_t one_byte_bitmask =
  385|  4.88k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  386|       |
  387|       |    // no bits set above 11th bit
  388|  4.88k|    const __m128i one_or_two_bytes_bytemask =
  389|  4.88k|        _mm_cmpeq_epi16(_mm_and_si128(in_16, v_f800), v_0000);
  390|  4.88k|    const uint16_t one_or_two_bytes_bitmask =
  391|  4.88k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  392|       |
  393|  4.88k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (393:9): [True: 2.88k, False: 1.99k]
  ------------------
  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.88k|      const __m128i v_1f00 = _mm_set1_epi16((int16_t)0x1f00);
  400|  2.88k|      const __m128i v_003f = _mm_set1_epi16((int16_t)0x003f);
  401|       |
  402|       |      // t0 = [000a|aaaa|bbbb|bb00]
  403|  2.88k|      const __m128i t0 = _mm_slli_epi16(in_16, 2);
  404|       |      // t1 = [000a|aaaa|0000|0000]
  405|  2.88k|      const __m128i t1 = _mm_and_si128(t0, v_1f00);
  406|       |      // t2 = [0000|0000|00bb|bbbb]
  407|  2.88k|      const __m128i t2 = _mm_and_si128(in_16, v_003f);
  408|       |      // t3 = [000a|aaaa|00bb|bbbb]
  409|  2.88k|      const __m128i t3 = _mm_or_si128(t1, t2);
  410|       |      // t4 = [110a|aaaa|10bb|bbbb]
  411|  2.88k|      const __m128i t4 = _mm_or_si128(t3, v_c080);
  412|       |
  413|       |      // 2. merge ASCII and 2-byte codewords
  414|  2.88k|      const __m128i utf8_unpacked =
  415|  2.88k|          _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.88k|      const uint16_t m0 = one_byte_bitmask & 0x5555; // m0 = 0h0g0f0e0d0c0b0a
  421|  2.88k|      const uint16_t m1 =
  422|  2.88k|          static_cast<uint16_t>(m0 >> 7); // m1 = 00000000h0g0f0e0
  423|  2.88k|      const uint8_t m2 =
  424|  2.88k|          static_cast<uint8_t>((m0 | m1) & 0xff); // m2 =         hdgcfbea
  425|       |      // 4. pack the bytes
  426|  2.88k|      const uint8_t *row =
  427|  2.88k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0];
  428|  2.88k|      const __m128i shuffle = _mm_loadu_si128((__m128i *)(row + 1));
  429|  2.88k|      const __m128i utf8_packed = _mm_shuffle_epi8(utf8_unpacked, shuffle);
  430|       |
  431|       |      // 5. store bytes
  432|  2.88k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  433|       |
  434|       |      // 6. adjust pointers
  435|  2.88k|      buf += 8;
  436|  2.88k|      utf8_output += row[0];
  437|  2.88k|      continue;
  438|  2.88k|    }
  439|       |
  440|       |    // Check for overflow in packing
  441|  1.99k|    const __m128i saturation_bytemask = _mm_cmpeq_epi32(
  442|  1.99k|        _mm_and_si128(_mm_or_si128(in, nextin), v_ffff0000), v_0000);
  443|  1.99k|    const uint32_t saturation_bitmask =
  444|  1.99k|        static_cast<uint32_t>(_mm_movemask_epi8(saturation_bytemask));
  445|       |
  446|  1.99k|    if (saturation_bitmask == 0xffff) {
  ------------------
  |  Branch (446:9): [True: 1.15k, False: 844]
  ------------------
  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.15k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
  451|  1.15k|      const __m128i forbidden_bytemask =
  452|  1.15k|          _mm_cmpeq_epi16(_mm_and_si128(in_16, v_f800), v_d800);
  453|  1.15k|      if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (453:11): [True: 18, False: 1.13k]
  ------------------
  454|     18|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  455|     18|                              utf8_output);
  456|     18|      }
  457|       |
  458|  1.13k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  459|  1.13k|                                              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|  1.13k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  489|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  490|  1.13k|      const __m128i t0 = _mm_shuffle_epi8(in_16, dup_even);
  491|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  492|  1.13k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  488|  1.13k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  493|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  494|  1.13k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  488|  1.13k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  495|       |
  496|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  497|  1.13k|      const __m128i s0 = _mm_srli_epi16(in_16, 4);
  498|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  499|  1.13k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  488|  1.13k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  500|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  501|  1.13k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  488|  1.13k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  502|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  503|  1.13k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  488|  1.13k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  504|  1.13k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  505|  1.13k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  488|  1.13k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  506|  1.13k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  507|  1.13k|#undef simdutf_vec
  508|       |
  509|       |      // 4. expand code units 16-bit => 32-bit
  510|  1.13k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  511|  1.13k|      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|  1.13k|      const uint16_t mask =
  515|  1.13k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  516|  1.13k|      if (mask == 0) {
  ------------------
  |  Branch (516:11): [True: 576, False: 558]
  ------------------
  517|       |        // We only have three-byte code units. Use fast path.
  518|    576|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  519|    576|                                              15, 13, -1, -1, -1, -1);
  520|    576|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  521|    576|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  522|    576|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  523|    576|        utf8_output += 12;
  524|    576|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  525|    576|        utf8_output += 12;
  526|    576|        buf += 8;
  527|    576|        continue;
  528|    576|      }
  529|    558|      const uint8_t mask0 = uint8_t(mask);
  530|       |
  531|    558|      const uint8_t *row0 =
  532|    558|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  533|    558|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  534|    558|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  535|       |
  536|    558|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  537|       |
  538|    558|      const uint8_t *row1 =
  539|    558|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  540|    558|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  541|    558|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  542|       |
  543|    558|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  544|    558|      utf8_output += row0[0];
  545|    558|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  546|    558|      utf8_output += row1[0];
  547|       |
  548|    558|      buf += 8;
  549|    844|    } 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|    844|      size_t forward = 15;
  555|    844|      size_t k = 0;
  556|    844|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (556:11): [True: 0, False: 844]
  ------------------
  557|      0|        forward = size_t(end - buf - 1);
  558|      0|      }
  559|  12.8k|      for (; k < forward; k++) {
  ------------------
  |  Branch (559:14): [True: 12.0k, False: 738]
  ------------------
  560|  12.0k|        uint32_t word = buf[k];
  561|  12.0k|        if ((word & 0xFFFFFF80) == 0) {
  ------------------
  |  Branch (561:13): [True: 4.47k, False: 7.61k]
  ------------------
  562|  4.47k|          *utf8_output++ = char(word);
  563|  7.61k|        } else if ((word & 0xFFFFF800) == 0) {
  ------------------
  |  Branch (563:20): [True: 920, False: 6.69k]
  ------------------
  564|    920|          *utf8_output++ = char((word >> 6) | 0b11000000);
  565|    920|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  566|  6.69k|        } else if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (566:20): [True: 3.39k, False: 3.30k]
  ------------------
  567|  3.39k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (567:15): [True: 1.93k, False: 1.45k]
  |  Branch (567:33): [True: 38, False: 1.89k]
  ------------------
  568|     38|            return std::make_pair(
  569|     38|                result(error_code::SURROGATE, buf - start + k), utf8_output);
  570|     38|          }
  571|  3.35k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  572|  3.35k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  573|  3.35k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  574|  3.35k|        } else {
  575|  3.30k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (575:15): [True: 68, False: 3.23k]
  ------------------
  576|     68|            return std::make_pair(
  577|     68|                result(error_code::TOO_LARGE, buf - start + k), utf8_output);
  578|     68|          }
  579|  3.23k|          *utf8_output++ = char((word >> 18) | 0b11110000);
  580|  3.23k|          *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000);
  581|  3.23k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  582|  3.23k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  583|  3.23k|        }
  584|  12.0k|      }
  585|    738|      buf += k;
  586|    738|    }
  587|  1.99k|  } // while
  588|    658|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output);
  589|    832|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_129convert_masked_utf8_to_latin1EPKcmRPc:
    9|   588k|                                     char *&latin1_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|   588k|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   21|   588k|  const uint16_t input_utf8_end_of_code_point_mask =
   22|   588k|      utf8_end_of_code_point_mask &
   23|   588k|      0xfff; // we are only processing 12 bytes in case it is not all ASCII
   24|   588k|  if (utf8_end_of_code_point_mask == 0xfff) {
  ------------------
  |  Branch (24:7): [True: 3.61k, False: 585k]
  ------------------
   25|       |    // We process the data in chunks of 12 bytes.
   26|  3.61k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(latin1_output), in);
   27|  3.61k|    latin1_output += 12; // We wrote 12 characters.
   28|  3.61k|    return 12;           // We consumed 12 bytes.
   29|  3.61k|  }
   30|       |  /// We do not have a fast path available, so we fallback.
   31|   585k|  const uint8_t idx =
   32|   585k|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0];
   33|   585k|  const uint8_t consumed =
   34|   585k|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1];
   35|       |  // this indicates an invalid input:
   36|   585k|  if (idx >= 64) {
  ------------------
  |  Branch (36:7): [True: 30.3k, False: 554k]
  ------------------
   37|  30.3k|    return consumed;
   38|  30.3k|  }
   39|       |  // Here we should have (idx < 64), if not, there is a bug in the validation or
   40|       |  // elsewhere. SIX (6) input code-code units this is a relatively easy scenario
   41|       |  // we process SIX (6) input code-code units. The max length in bytes of six
   42|       |  // code code units spanning between 1 and 2 bytes each is 12 bytes. On
   43|       |  // processors where pdep/pext is fast, we might be able to use a small lookup
   44|       |  // table.
   45|   554k|  const __m128i sh =
   46|   554k|      _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
   47|   554k|  const __m128i perm = _mm_shuffle_epi8(in, sh);
   48|   554k|  const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   49|   554k|  const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   50|   554k|  __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   51|   554k|  const __m128i latin1_packed = _mm_packus_epi16(composed, composed);
   52|       |  // writing 8 bytes even though we only care about the first 6 bytes.
   53|       |  // performance note: it would be faster to use _mm_storeu_si128, we should
   54|       |  // investigate.
   55|   554k|  _mm_storel_epi64((__m128i *)latin1_output, latin1_packed);
   56|   554k|  latin1_output += 6; // We wrote 6 bytes.
   57|   554k|  return consumed;
   58|   585k|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_128convert_masked_utf8_to_utf16ILNS_10endiannessE0EEEmPKcmRPDs:
   10|  3.17M|                                    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|  3.17M|  const __m128i swap =
   23|  3.17M|      _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   24|  3.17M|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   25|  3.17M|  const uint16_t input_utf8_end_of_code_point_mask =
   26|  3.17M|      utf8_end_of_code_point_mask & 0xfff;
   27|  3.17M|  if (utf8_end_of_code_point_mask == 0xfff) {
  ------------------
  |  Branch (27:7): [True: 10.8k, False: 3.16M]
  ------------------
   28|       |    // We process the data in chunks of 12 bytes.
   29|       |    // Note: using 16 bytes is unsafe, see issue_ossfuzz_71218
   30|  10.8k|    __m128i ascii_first = _mm_cvtepu8_epi16(in);
   31|  10.8k|    __m128i ascii_second = _mm_cvtepu8_epi16(_mm_srli_si128(in, 8));
   32|  10.8k|    if (big_endian) {
  ------------------
  |  Branch (32:9): [Folded, False: 10.8k]
  ------------------
   33|      0|      ascii_first = _mm_shuffle_epi8(ascii_first, swap);
   34|      0|      ascii_second = _mm_shuffle_epi8(ascii_second, swap);
   35|      0|    }
   36|  10.8k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf16_output), ascii_first);
   37|  10.8k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf16_output + 8),
   38|  10.8k|                     ascii_second);
   39|  10.8k|    utf16_output += 12; // We wrote 12 16-bit characters.
   40|  10.8k|    return 12;          // We consumed 12 bytes.
   41|  10.8k|  }
   42|  3.16M|  if (((utf8_end_of_code_point_mask & 0xFFFF) == 0xaaaa)) {
  ------------------
  |  Branch (42:7): [True: 15.9k, False: 3.15M]
  ------------------
   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|  15.9k|    const __m128i sh =
   47|  15.9k|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   48|  15.9k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   49|  15.9k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   50|  15.9k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   51|  15.9k|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   52|  15.9k|    if (big_endian)
  ------------------
  |  Branch (52:9): [Folded, False: 15.9k]
  ------------------
   53|      0|      composed = _mm_shuffle_epi8(composed, swap);
   54|  15.9k|    _mm_storeu_si128((__m128i *)utf16_output, composed);
   55|  15.9k|    utf16_output += 8; // We wrote 16 bytes, 8 code points.
   56|  15.9k|    return 16;
   57|  15.9k|  }
   58|  3.15M|  if (input_utf8_end_of_code_point_mask == 0x924) {
  ------------------
  |  Branch (58:7): [True: 2.28k, False: 3.14M]
  ------------------
   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.28k|    const __m128i sh =
   63|  2.28k|        _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1);
   64|  2.28k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   65|  2.28k|    const __m128i ascii =
   66|  2.28k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   67|  2.28k|    const __m128i middlebyte =
   68|  2.28k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
   69|  2.28k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
   70|  2.28k|    const __m128i highbyte =
   71|  2.28k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
   72|  2.28k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
   73|  2.28k|    const __m128i composed =
   74|  2.28k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
   75|  2.28k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
   76|  2.28k|    if (big_endian)
  ------------------
  |  Branch (76:9): [Folded, False: 2.28k]
  ------------------
   77|      0|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
   78|  2.28k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
   79|  2.28k|    utf16_output += 4;
   80|  2.28k|    return 12;
   81|  2.28k|  }
   82|       |  /// We do not have a fast path available, so we fallback.
   83|       |
   84|  3.14M|  const uint8_t idx =
   85|  3.14M|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0];
   86|  3.14M|  const uint8_t consumed =
   87|  3.14M|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1];
   88|  3.14M|  if (idx < 64) {
  ------------------
  |  Branch (88:7): [True: 2.64M, 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|  2.64M|    const __m128i sh =
   96|  2.64M|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
   97|  2.64M|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   98|  2.64M|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   99|  2.64M|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
  100|  2.64M|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
  101|  2.64M|    if (big_endian)
  ------------------
  |  Branch (101:9): [Folded, False: 2.64M]
  ------------------
  102|      0|      composed = _mm_shuffle_epi8(composed, swap);
  103|  2.64M|    _mm_storeu_si128((__m128i *)utf16_output, composed);
  104|  2.64M|    utf16_output += 6; // We wrote 12 bytes, 6 code points.
  105|  2.64M|  } else if (idx < 145) {
  ------------------
  |  Branch (105:14): [True: 434k, False: 66.2k]
  ------------------
  106|       |    // FOUR (4) input code-code units
  107|   434k|    const __m128i sh =
  108|   434k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  109|   434k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  110|   434k|    const __m128i ascii =
  111|   434k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
  112|   434k|    const __m128i middlebyte =
  113|   434k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
  114|   434k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  115|   434k|    const __m128i highbyte =
  116|   434k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
  117|   434k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
  118|   434k|    const __m128i composed =
  119|   434k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
  120|   434k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
  121|   434k|    if (big_endian)
  ------------------
  |  Branch (121:9): [Folded, False: 434k]
  ------------------
  122|      0|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
  123|   434k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
  124|   434k|    utf16_output += 4;
  125|   434k|  } else if (idx < 209) {
  ------------------
  |  Branch (125:14): [True: 65.5k, False: 712]
  ------------------
  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|  65.5k|    const __m128i sh =
  137|  65.5k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  138|  65.5k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  139|  65.5k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f));
  140|  65.5k|    const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00));
  141|  65.5k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  142|  65.5k|    __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000));
  143|       |    // correct for spurious high bit
  144|  65.5k|    const __m128i correct =
  145|  65.5k|        _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1);
  146|  65.5k|    middlehighbyte = _mm_xor_si128(correct, middlehighbyte);
  147|  65.5k|    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|  65.5k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0xff000000));
  151|  65.5k|    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|  65.5k|    const __m128i composed =
  157|  65.5k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted),
  158|  65.5k|                     _mm_or_si128(highbyte_shifted, middlehighbyte_shifted));
  159|  65.5k|    const __m128i composedminus =
  160|  65.5k|        _mm_sub_epi32(composed, _mm_set1_epi32(0x10000));
  161|  65.5k|    const __m128i lowtenbits =
  162|  65.5k|        _mm_and_si128(composedminus, _mm_set1_epi32(0x3ff));
  163|       |    // Notice the 0x3ff mask:
  164|  65.5k|    const __m128i hightenbits =
  165|  65.5k|        _mm_and_si128(_mm_srli_epi32(composedminus, 10), _mm_set1_epi32(0x3ff));
  166|  65.5k|    const __m128i lowtenbitsadd =
  167|  65.5k|        _mm_add_epi32(lowtenbits, _mm_set1_epi32(0xDC00));
  168|  65.5k|    const __m128i hightenbitsadd =
  169|  65.5k|        _mm_add_epi32(hightenbits, _mm_set1_epi32(0xD800));
  170|  65.5k|    const __m128i lowtenbitsaddshifted = _mm_slli_epi32(lowtenbitsadd, 16);
  171|  65.5k|    __m128i surrogates = _mm_or_si128(hightenbitsadd, lowtenbitsaddshifted);
  172|  65.5k|    uint32_t basic_buffer[4];
  173|  65.5k|    uint32_t basic_buffer_swap[4];
  174|  65.5k|    if (big_endian) {
  ------------------
  |  Branch (174:9): [Folded, False: 65.5k]
  ------------------
  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|  65.5k|    _mm_storeu_si128((__m128i *)basic_buffer, composed);
  180|  65.5k|    uint32_t surrogate_buffer[4];
  181|  65.5k|    _mm_storeu_si128((__m128i *)surrogate_buffer, surrogates);
  182|   262k|    for (size_t i = 0; i < 3; i++) {
  ------------------
  |  Branch (182:24): [True: 196k, False: 65.5k]
  ------------------
  183|   196k|      if (basic_buffer[i] > 0x3c00000) {
  ------------------
  |  Branch (183:11): [True: 54.1k, False: 142k]
  ------------------
  184|  54.1k|        utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff);
  185|  54.1k|        utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16);
  186|  54.1k|        utf16_output += 2;
  187|   142k|      } else {
  188|   142k|        utf16_output[0] = big_endian ? uint16_t(basic_buffer_swap[i])
  ------------------
  |  Branch (188:27): [Folded, False: 142k]
  ------------------
  189|   142k|                                     : uint16_t(basic_buffer[i]);
  190|   142k|        utf16_output++;
  191|   142k|      }
  192|   196k|    }
  193|  65.5k|  } else {
  194|       |    // here we know that there is an error but we do not handle errors
  195|    712|  }
  196|  3.14M|  return consumed;
  197|  3.15M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_128convert_masked_utf8_to_utf16ILNS_10endiannessE1EEEmPKcmRPDs:
   10|  3.00M|                                    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|  3.00M|  const __m128i swap =
   23|  3.00M|      _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   24|  3.00M|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   25|  3.00M|  const uint16_t input_utf8_end_of_code_point_mask =
   26|  3.00M|      utf8_end_of_code_point_mask & 0xfff;
   27|  3.00M|  if (utf8_end_of_code_point_mask == 0xfff) {
  ------------------
  |  Branch (27:7): [True: 9.13k, False: 2.99M]
  ------------------
   28|       |    // We process the data in chunks of 12 bytes.
   29|       |    // Note: using 16 bytes is unsafe, see issue_ossfuzz_71218
   30|  9.13k|    __m128i ascii_first = _mm_cvtepu8_epi16(in);
   31|  9.13k|    __m128i ascii_second = _mm_cvtepu8_epi16(_mm_srli_si128(in, 8));
   32|  9.13k|    if (big_endian) {
  ------------------
  |  Branch (32:9): [True: 9.13k, Folded]
  ------------------
   33|  9.13k|      ascii_first = _mm_shuffle_epi8(ascii_first, swap);
   34|  9.13k|      ascii_second = _mm_shuffle_epi8(ascii_second, swap);
   35|  9.13k|    }
   36|  9.13k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf16_output), ascii_first);
   37|  9.13k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf16_output + 8),
   38|  9.13k|                     ascii_second);
   39|  9.13k|    utf16_output += 12; // We wrote 12 16-bit characters.
   40|  9.13k|    return 12;          // We consumed 12 bytes.
   41|  9.13k|  }
   42|  2.99M|  if (((utf8_end_of_code_point_mask & 0xFFFF) == 0xaaaa)) {
  ------------------
  |  Branch (42:7): [True: 23.5k, False: 2.96M]
  ------------------
   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|  23.5k|    const __m128i sh =
   47|  23.5k|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   48|  23.5k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   49|  23.5k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   50|  23.5k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   51|  23.5k|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   52|  23.5k|    if (big_endian)
  ------------------
  |  Branch (52:9): [True: 23.5k, Folded]
  ------------------
   53|  23.5k|      composed = _mm_shuffle_epi8(composed, swap);
   54|  23.5k|    _mm_storeu_si128((__m128i *)utf16_output, composed);
   55|  23.5k|    utf16_output += 8; // We wrote 16 bytes, 8 code points.
   56|  23.5k|    return 16;
   57|  23.5k|  }
   58|  2.96M|  if (input_utf8_end_of_code_point_mask == 0x924) {
  ------------------
  |  Branch (58:7): [True: 5.17k, False: 2.96M]
  ------------------
   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|  5.17k|    const __m128i sh =
   63|  5.17k|        _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1);
   64|  5.17k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   65|  5.17k|    const __m128i ascii =
   66|  5.17k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   67|  5.17k|    const __m128i middlebyte =
   68|  5.17k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
   69|  5.17k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
   70|  5.17k|    const __m128i highbyte =
   71|  5.17k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
   72|  5.17k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
   73|  5.17k|    const __m128i composed =
   74|  5.17k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
   75|  5.17k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
   76|  5.17k|    if (big_endian)
  ------------------
  |  Branch (76:9): [True: 5.17k, Folded]
  ------------------
   77|  5.17k|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
   78|  5.17k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
   79|  5.17k|    utf16_output += 4;
   80|  5.17k|    return 12;
   81|  5.17k|  }
   82|       |  /// We do not have a fast path available, so we fallback.
   83|       |
   84|  2.96M|  const uint8_t idx =
   85|  2.96M|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0];
   86|  2.96M|  const uint8_t consumed =
   87|  2.96M|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1];
   88|  2.96M|  if (idx < 64) {
  ------------------
  |  Branch (88:7): [True: 2.67M, False: 286k]
  ------------------
   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|  2.67M|    const __m128i sh =
   96|  2.67M|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
   97|  2.67M|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   98|  2.67M|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   99|  2.67M|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
  100|  2.67M|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
  101|  2.67M|    if (big_endian)
  ------------------
  |  Branch (101:9): [True: 2.67M, Folded]
  ------------------
  102|  2.67M|      composed = _mm_shuffle_epi8(composed, swap);
  103|  2.67M|    _mm_storeu_si128((__m128i *)utf16_output, composed);
  104|  2.67M|    utf16_output += 6; // We wrote 12 bytes, 6 code points.
  105|  2.67M|  } else if (idx < 145) {
  ------------------
  |  Branch (105:14): [True: 221k, False: 65.3k]
  ------------------
  106|       |    // FOUR (4) input code-code units
  107|   221k|    const __m128i sh =
  108|   221k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  109|   221k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  110|   221k|    const __m128i ascii =
  111|   221k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
  112|   221k|    const __m128i middlebyte =
  113|   221k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
  114|   221k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  115|   221k|    const __m128i highbyte =
  116|   221k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
  117|   221k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
  118|   221k|    const __m128i composed =
  119|   221k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
  120|   221k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
  121|   221k|    if (big_endian)
  ------------------
  |  Branch (121:9): [True: 221k, Folded]
  ------------------
  122|   221k|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
  123|   221k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
  124|   221k|    utf16_output += 4;
  125|   221k|  } else if (idx < 209) {
  ------------------
  |  Branch (125:14): [True: 64.0k, False: 1.31k]
  ------------------
  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|  64.0k|    const __m128i sh =
  137|  64.0k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  138|  64.0k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  139|  64.0k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f));
  140|  64.0k|    const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00));
  141|  64.0k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  142|  64.0k|    __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000));
  143|       |    // correct for spurious high bit
  144|  64.0k|    const __m128i correct =
  145|  64.0k|        _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1);
  146|  64.0k|    middlehighbyte = _mm_xor_si128(correct, middlehighbyte);
  147|  64.0k|    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|  64.0k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0xff000000));
  151|  64.0k|    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|  64.0k|    const __m128i composed =
  157|  64.0k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted),
  158|  64.0k|                     _mm_or_si128(highbyte_shifted, middlehighbyte_shifted));
  159|  64.0k|    const __m128i composedminus =
  160|  64.0k|        _mm_sub_epi32(composed, _mm_set1_epi32(0x10000));
  161|  64.0k|    const __m128i lowtenbits =
  162|  64.0k|        _mm_and_si128(composedminus, _mm_set1_epi32(0x3ff));
  163|       |    // Notice the 0x3ff mask:
  164|  64.0k|    const __m128i hightenbits =
  165|  64.0k|        _mm_and_si128(_mm_srli_epi32(composedminus, 10), _mm_set1_epi32(0x3ff));
  166|  64.0k|    const __m128i lowtenbitsadd =
  167|  64.0k|        _mm_add_epi32(lowtenbits, _mm_set1_epi32(0xDC00));
  168|  64.0k|    const __m128i hightenbitsadd =
  169|  64.0k|        _mm_add_epi32(hightenbits, _mm_set1_epi32(0xD800));
  170|  64.0k|    const __m128i lowtenbitsaddshifted = _mm_slli_epi32(lowtenbitsadd, 16);
  171|  64.0k|    __m128i surrogates = _mm_or_si128(hightenbitsadd, lowtenbitsaddshifted);
  172|  64.0k|    uint32_t basic_buffer[4];
  173|  64.0k|    uint32_t basic_buffer_swap[4];
  174|  64.0k|    if (big_endian) {
  ------------------
  |  Branch (174:9): [True: 64.0k, Folded]
  ------------------
  175|  64.0k|      _mm_storeu_si128((__m128i *)basic_buffer_swap,
  176|  64.0k|                       _mm_shuffle_epi8(composed, swap));
  177|  64.0k|      surrogates = _mm_shuffle_epi8(surrogates, swap);
  178|  64.0k|    }
  179|  64.0k|    _mm_storeu_si128((__m128i *)basic_buffer, composed);
  180|  64.0k|    uint32_t surrogate_buffer[4];
  181|  64.0k|    _mm_storeu_si128((__m128i *)surrogate_buffer, surrogates);
  182|   256k|    for (size_t i = 0; i < 3; i++) {
  ------------------
  |  Branch (182:24): [True: 192k, False: 64.0k]
  ------------------
  183|   192k|      if (basic_buffer[i] > 0x3c00000) {
  ------------------
  |  Branch (183:11): [True: 53.9k, False: 138k]
  ------------------
  184|  53.9k|        utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff);
  185|  53.9k|        utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16);
  186|  53.9k|        utf16_output += 2;
  187|   138k|      } else {
  188|   138k|        utf16_output[0] = big_endian ? uint16_t(basic_buffer_swap[i])
  ------------------
  |  Branch (188:27): [True: 138k, Folded]
  ------------------
  189|   138k|                                     : uint16_t(basic_buffer[i]);
  190|   138k|        utf16_output++;
  191|   138k|      }
  192|   192k|    }
  193|  64.0k|  } else {
  194|       |    // here we know that there is an error but we do not handle errors
  195|  1.31k|  }
  196|  2.96M|  return consumed;
  197|  2.96M|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_128convert_masked_utf8_to_utf32EPKcmRPDi:
    9|  2.58M|                                    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|  2.58M|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   22|  2.58M|  const uint16_t input_utf8_end_of_code_point_mask =
   23|  2.58M|      utf8_end_of_code_point_mask & 0xfff;
   24|  2.58M|  if (utf8_end_of_code_point_mask == 0xfff) {
  ------------------
  |  Branch (24:7): [True: 7.57k, False: 2.57M]
  ------------------
   25|       |    // We process the data in chunks of 12 bytes.
   26|  7.57k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
   27|  7.57k|                     _mm_cvtepu8_epi32(in));
   28|  7.57k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
   29|  7.57k|                     _mm_cvtepu8_epi32(_mm_srli_si128(in, 4)));
   30|  7.57k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 8),
   31|  7.57k|                     _mm_cvtepu8_epi32(_mm_srli_si128(in, 8)));
   32|  7.57k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 12),
   33|  7.57k|                     _mm_cvtepu8_epi32(_mm_srli_si128(in, 12)));
   34|  7.57k|    utf32_output += 12; // We wrote 12 32-bit characters.
   35|  7.57k|    return 12;          // We consumed 12 bytes.
   36|  7.57k|  }
   37|  2.57M|  if (((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa)) {
  ------------------
  |  Branch (37:7): [True: 17.0k, False: 2.56M]
  ------------------
   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|  17.0k|    const __m128i sh =
   42|  17.0k|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   43|  17.0k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   44|  17.0k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   45|  17.0k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   46|  17.0k|    const __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   47|  17.0k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
   48|  17.0k|                     _mm_cvtepu16_epi32(composed));
   49|  17.0k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
   50|  17.0k|                     _mm_cvtepu16_epi32(_mm_srli_si128(composed, 8)));
   51|  17.0k|    utf32_output += 8; // We wrote 32 bytes, 8 code points.
   52|  17.0k|    return 16;
   53|  17.0k|  }
   54|  2.56M|  if (input_utf8_end_of_code_point_mask == 0x924) {
  ------------------
  |  Branch (54:7): [True: 2.91k, False: 2.55M]
  ------------------
   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|  2.91k|    const __m128i sh =
   59|  2.91k|        _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1);
   60|  2.91k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   61|  2.91k|    const __m128i ascii =
   62|  2.91k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   63|  2.91k|    const __m128i middlebyte =
   64|  2.91k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
   65|  2.91k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
   66|  2.91k|    const __m128i highbyte =
   67|  2.91k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
   68|  2.91k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
   69|  2.91k|    const __m128i composed =
   70|  2.91k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
   71|  2.91k|    _mm_storeu_si128((__m128i *)utf32_output, composed);
   72|  2.91k|    utf32_output += 4;
   73|  2.91k|    return 12;
   74|  2.91k|  }
   75|       |  /// We do not have a fast path available, so we fallback.
   76|       |
   77|  2.55M|  const uint8_t idx =
   78|  2.55M|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0];
   79|  2.55M|  const uint8_t consumed =
   80|  2.55M|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1];
   81|  2.55M|  if (idx < 64) {
  ------------------
  |  Branch (81:7): [True: 2.25M, False: 304k]
  ------------------
   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|  2.25M|    const __m128i sh =
   89|  2.25M|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
   90|  2.25M|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   91|  2.25M|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   92|  2.25M|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   93|  2.25M|    const __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   94|  2.25M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
   95|  2.25M|                     _mm_cvtepu16_epi32(composed));
   96|  2.25M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
   97|  2.25M|                     _mm_cvtepu16_epi32(_mm_srli_si128(composed, 8)));
   98|  2.25M|    utf32_output += 6; // We wrote 12 bytes, 6 code points.
   99|  2.25M|  } else if (idx < 145) {
  ------------------
  |  Branch (99:14): [True: 253k, False: 51.8k]
  ------------------
  100|       |    // FOUR (4) input code-code units
  101|   253k|    const __m128i sh =
  102|   253k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  103|   253k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  104|   253k|    const __m128i ascii =
  105|   253k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
  106|   253k|    const __m128i middlebyte =
  107|   253k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
  108|   253k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  109|   253k|    const __m128i highbyte =
  110|   253k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
  111|   253k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
  112|   253k|    const __m128i composed =
  113|   253k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
  114|   253k|    _mm_storeu_si128((__m128i *)utf32_output, composed);
  115|   253k|    utf32_output += 4;
  116|   253k|  } else if (idx < 209) {
  ------------------
  |  Branch (116:14): [True: 51.1k, False: 668]
  ------------------
  117|       |    // TWO (2) input code-code units
  118|  51.1k|    const __m128i sh =
  119|  51.1k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  120|  51.1k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  121|  51.1k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f));
  122|  51.1k|    const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00));
  123|  51.1k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  124|  51.1k|    __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000));
  125|       |    // correct for spurious high bit
  126|  51.1k|    const __m128i correct =
  127|  51.1k|        _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1);
  128|  51.1k|    middlehighbyte = _mm_xor_si128(correct, middlehighbyte);
  129|  51.1k|    const __m128i middlehighbyte_shifted = _mm_srli_epi32(middlehighbyte, 4);
  130|  51.1k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0x07000000));
  131|  51.1k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 6);
  132|  51.1k|    const __m128i composed =
  133|  51.1k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted),
  134|  51.1k|                     _mm_or_si128(highbyte_shifted, middlehighbyte_shifted));
  135|  51.1k|    _mm_storeu_si128((__m128i *)utf32_output, composed);
  136|  51.1k|    utf32_output += 3;
  137|  51.1k|  } else {
  138|       |    // here we know that there is an error but we do not handle errors
  139|    668|  }
  140|  2.55M|  return consumed;
  141|  2.56M|}

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

