_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|  8.58k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  640|  8.58k|  static const auto fptrs = populate_functions();
  641|  8.58k|  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|  8.58k|  if (size < 4) {
  ------------------
  |  Branch (646:7): [True: 3, False: 8.57k]
  ------------------
  647|      3|    return 0;
  648|      3|  }
  649|       |
  650|  8.57k|  constexpr auto actionmask = std::bit_ceil(Ncases) - 1;
  651|  8.57k|  const auto action = data[0] & actionmask;
  652|  8.57k|  data += 4;
  653|  8.57k|  size -= 4;
  654|       |
  655|  8.57k|  if (action >= Ncases) {
  ------------------
  |  Branch (655:7): [True: 1, False: 8.57k]
  ------------------
  656|      1|    return 0;
  657|      1|  }
  658|       |
  659|  8.57k|  if constexpr (use_separate_allocation) {
  660|       |    // this is better at exercising null input and catch buffer underflows
  661|  8.57k|    const std::vector<char> separate{data, data + size};
  662|  8.57k|    fptrs[action](std::span(separate));
  663|       |  } else {
  664|       |    std::span<const char> chardata{(const char*)data, size};
  665|       |    fptrs[action](chardata);
  666|       |  }
  667|       |
  668|  8.57k|  return 0;
  669|  8.57k|}
conversion.cpp:_ZZ18populate_functionsvENK3$_0clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     88|    +[](std::span<const char> chardata) {                                      \
  555|     88|      const auto c =                                                           \
  556|     88|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     88|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     88|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     88|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     88|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     88|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     88|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     88|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     88|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     88|  constexpr auto _size = _name.size();                                \
  |  | 1183|     88|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     88|  return _nameof; }()
  ------------------
  561|     88|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     88|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     88|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     88|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     88|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     88|  constexpr auto _size = _name.size();                                \
  |  | 1183|     88|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     88|  return _nameof; }()
  ------------------
  562|     88|      c.fuzz(chardata);                                                        \
  563|     88|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    201|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    201|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    201|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    201|    static const bool do_print_testcase =
  181|    201|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    201|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 201]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    201|    do {
  189|       |      // step 0 - is the input valid?
  190|    201|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    201|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 201]
  |  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|    201|                    From == UtfEncodings::UTF8) {
  198|    201|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 201]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    201|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    201|      const auto [output_length, length_agree] =
  204|    201|          calculate_length(from, inputisvalid);
  205|    201|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 201]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    201|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 92, False: 109]
  |  Branch (208:28): [True: 18, False: 74]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     18|        return;
  211|     18|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    183|      const auto [written, outputs_agree] =
  215|    183|          do_conversion(from, output_length, inputisvalid);
  216|    183|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 183]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    183|      return;
  221|    183|    } 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|    201|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    201|  validation_result verify_valid_input(FromSpan src) const {
  231|    201|    validation_result ret{};
  232|       |
  233|    201|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    201|    const auto implementations = get_supported_implementations();
  235|    201|    std::vector<simdutf::result> results;
  236|    201|    results.reserve(implementations.size());
  237|       |
  238|    603|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 603, False: 201]
  ------------------
  239|    603|      results.push_back(
  240|    603|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    603|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    603|      const bool validation2 =
  245|    603|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    603|                      src.data(), src.size());
  247|    603|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 603]
  ------------------
  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|    603|    }
  258|       |
  259|    201|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    201|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 201]
  ------------------
  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|    201|    } else {
  273|    201|      ret.implementations_agree = true;
  274|    201|    }
  275|    201|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    201|      return r.error == simdutf::SUCCESS;
  277|    201|    });
  278|    201|    return ret;
  279|    201|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    402|    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|    419|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    419|      return r.error == simdutf::SUCCESS;
  277|    419|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    201|  bool count_the_input(FromSpan src) const {
  290|    201|    const auto implementations = get_supported_implementations();
  291|    201|    std::vector<std::size_t> results;
  292|    201|    results.reserve(implementations.size());
  293|       |
  294|    603|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 603, False: 201]
  ------------------
  295|    603|      std::size_t ret;
  296|    603|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    603|        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|    603|      results.push_back(ret);
  304|    603|    }
  305|    201|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    201|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 201]
  ------------------
  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|    201|    return true;
  321|    201|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    402|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    201|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    201|    length_result ret{};
  344|       |
  345|    201|    const auto implementations = get_supported_implementations();
  346|    201|    std::vector<std::size_t> results;
  347|    201|    results.reserve(implementations.size());
  348|       |
  349|    603|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 603, False: 201]
  ------------------
  350|    603|      const auto len = invoke_lengthcalc(impl, src);
  351|    603|      results.push_back(len);
  352|    603|      ret.length.push_back(len);
  353|    603|    }
  354|       |
  355|    201|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    201|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 201]
  ------------------
  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|    201|    } else {
  375|    201|      ret.implementations_agree = true;
  376|    201|    }
  377|    201|    return ret;
  378|    201|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    603|                                FromSpan src) const {
  331|    603|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    603|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    402|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    183|                                  const bool inputisvalid) const {
  383|    183|    conversion_result ret{};
  384|       |
  385|    183|    const auto implementations = get_supported_implementations();
  386|       |
  387|    183|    std::vector<result<ConversionResult>> results;
  388|    183|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    183|    std::vector<std::vector<ToType>> outputbuffers;
  393|    183|    outputbuffers.reserve(implementations.size());
  394|    732|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 549, False: 183]
  ------------------
  395|    549|      auto impl = implementations[i];
  396|    549|      const ToType canary1{42};
  397|    549|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    549|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    549|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    549|      const auto success = [](const ConversionResult& r) -> bool {
  402|    549|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    549|          return r != 0;
  404|    549|        } else {
  405|    549|          return r.error == simdutf::error_code::SUCCESS;
  406|    549|        }
  407|    549|      }(implret1);
  408|    549|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    549|      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|    549|        const ToType canary2{25};
  414|    549|        const auto outputbuffer_first_run = outputbuffer;
  415|    549|        std::ranges::fill(outputbuffer, canary2);
  416|    549|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    549|                                          src.size(), outputbuffer.data());
  418|       |
  419|    549|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 549]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    549|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 327, False: 222]
  |  Branch (423:29): [True: 318, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    318|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    318|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 318]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    318|        }
  440|    549|      }
  441|    549|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 318, False: 231]
  ------------------
  442|    549|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    183|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 74, False: 109]
  ------------------
  447|    222|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 222, False: 74]
  ------------------
  448|    222|        e.outputhash.clear();
  449|    222|      }
  450|     74|    }
  451|       |
  452|    183|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    183|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 183]
  ------------------
  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|    183|    } else {
  474|    183|      ret.implementations_agree = true;
  475|    183|    }
  476|    183|    return ret;
  477|    183|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    549|      const auto success = [](const ConversionResult& r) -> bool {
  402|    549|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    549|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    549|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    366|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_1clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    240|    +[](std::span<const char> chardata) {                                      \
  555|    240|      const auto c =                                                           \
  556|    240|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    240|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    240|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    240|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    240|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    240|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    240|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    240|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    240|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    240|  constexpr auto _size = _name.size();                                \
  |  | 1183|    240|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    240|  return _nameof; }()
  ------------------
  561|    240|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    240|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    240|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    240|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    240|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    240|  constexpr auto _size = _name.size();                                \
  |  | 1183|    240|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    240|  return _nameof; }()
  ------------------
  562|    240|      c.fuzz(chardata);                                                        \
  563|    240|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    403|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    403|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    403|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    403|    static const bool do_print_testcase =
  181|    403|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    403|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 403]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    403|    do {
  189|       |      // step 0 - is the input valid?
  190|    403|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    403|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 403]
  |  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|    403|                    From == UtfEncodings::UTF8) {
  198|    403|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 403]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    403|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    403|      const auto [output_length, length_agree] =
  204|    403|          calculate_length(from, inputisvalid);
  205|    403|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 403]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    403|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 85, False: 318]
  |  Branch (208:28): [True: 19, False: 66]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     19|        return;
  211|     19|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    384|      const auto [written, outputs_agree] =
  215|    384|          do_conversion(from, output_length, inputisvalid);
  216|    384|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 384]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    384|      return;
  221|    384|    } 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|    403|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    403|  validation_result verify_valid_input(FromSpan src) const {
  231|    403|    validation_result ret{};
  232|       |
  233|    403|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    403|    const auto implementations = get_supported_implementations();
  235|    403|    std::vector<simdutf::result> results;
  236|    403|    results.reserve(implementations.size());
  237|       |
  238|  1.20k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.20k, False: 403]
  ------------------
  239|  1.20k|      results.push_back(
  240|  1.20k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.20k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.20k|      const bool validation2 =
  245|  1.20k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.20k|                      src.data(), src.size());
  247|  1.20k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.20k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  1.20k|    }
  258|       |
  259|    403|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    403|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 403]
  ------------------
  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|    403|    } else {
  273|    403|      ret.implementations_agree = true;
  274|    403|    }
  275|    403|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    403|      return r.error == simdutf::SUCCESS;
  277|    403|    });
  278|    403|    return ret;
  279|    403|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    806|    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.03k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.03k|      return r.error == simdutf::SUCCESS;
  277|  1.03k|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    403|  bool count_the_input(FromSpan src) const {
  290|    403|    const auto implementations = get_supported_implementations();
  291|    403|    std::vector<std::size_t> results;
  292|    403|    results.reserve(implementations.size());
  293|       |
  294|  1.20k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.20k, False: 403]
  ------------------
  295|  1.20k|      std::size_t ret;
  296|  1.20k|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|  1.20k|        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.20k|      results.push_back(ret);
  304|  1.20k|    }
  305|    403|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    403|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 403]
  ------------------
  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|    403|    return true;
  321|    403|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    806|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    403|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    403|    length_result ret{};
  344|       |
  345|    403|    const auto implementations = get_supported_implementations();
  346|    403|    std::vector<std::size_t> results;
  347|    403|    results.reserve(implementations.size());
  348|       |
  349|  1.20k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.20k, False: 403]
  ------------------
  350|  1.20k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.20k|      results.push_back(len);
  352|  1.20k|      ret.length.push_back(len);
  353|  1.20k|    }
  354|       |
  355|    403|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    403|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 403]
  ------------------
  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|    403|    } else {
  375|    403|      ret.implementations_agree = true;
  376|    403|    }
  377|    403|    return ret;
  378|    403|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.20k|                                FromSpan src) const {
  331|  1.20k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.20k|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    806|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    384|                                  const bool inputisvalid) const {
  383|    384|    conversion_result ret{};
  384|       |
  385|    384|    const auto implementations = get_supported_implementations();
  386|       |
  387|    384|    std::vector<result<ConversionResult>> results;
  388|    384|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    384|    std::vector<std::vector<ToType>> outputbuffers;
  393|    384|    outputbuffers.reserve(implementations.size());
  394|  1.53k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.15k, False: 384]
  ------------------
  395|  1.15k|      auto impl = implementations[i];
  396|  1.15k|      const ToType canary1{42};
  397|  1.15k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.15k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.15k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.15k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.15k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.15k|          return r != 0;
  404|  1.15k|        } else {
  405|  1.15k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.15k|        }
  407|  1.15k|      }(implret1);
  408|  1.15k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.15k|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|  1.15k|        const ToType canary2{25};
  414|  1.15k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.15k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.15k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.15k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.15k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.15k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.15k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 954, False: 198]
  |  Branch (423:29): [True: 945, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    945|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    945|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 945]
  ------------------
  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|    945|        }
  440|  1.15k|      }
  441|  1.15k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 945, False: 207]
  ------------------
  442|  1.15k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    384|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 66, False: 318]
  ------------------
  447|    198|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 198, False: 66]
  ------------------
  448|    198|        e.outputhash.clear();
  449|    198|      }
  450|     66|    }
  451|       |
  452|    384|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    384|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 384]
  ------------------
  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|    384|    } else {
  474|    384|      ret.implementations_agree = true;
  475|    384|    }
  476|    384|    return ret;
  477|    384|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.15k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.15k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.15k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.15k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    768|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_2clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     61|    +[](std::span<const char> chardata) {                                      \
  555|     61|      const auto c =                                                           \
  556|     61|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     61|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     61|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     61|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     61|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     61|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     61|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     61|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     61|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     61|  constexpr auto _size = _name.size();                                \
  |  | 1183|     61|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     61|  return _nameof; }()
  ------------------
  561|     61|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     61|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     61|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     61|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     61|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     61|  constexpr auto _size = _name.size();                                \
  |  | 1183|     61|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     61|  return _nameof; }()
  ------------------
  562|     61|      c.fuzz(chardata);                                                        \
  563|     61|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    197|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    197|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    197|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    197|    static const bool do_print_testcase =
  181|    197|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    197|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 197]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    197|    do {
  189|       |      // step 0 - is the input valid?
  190|    197|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    197|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 197]
  |  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|    197|                    From == UtfEncodings::UTF8) {
  198|    197|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 197]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    197|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    197|      const auto [output_length, length_agree] =
  204|    197|          calculate_length(from, inputisvalid);
  205|    197|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 197]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    197|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 90, False: 107]
  |  Branch (208:28): [True: 5, False: 85]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      5|        return;
  211|      5|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    192|      const auto [written, outputs_agree] =
  215|    192|          do_conversion(from, output_length, inputisvalid);
  216|    192|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 192]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    192|      return;
  221|    192|    } 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|    197|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    197|  validation_result verify_valid_input(FromSpan src) const {
  231|    197|    validation_result ret{};
  232|       |
  233|    197|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    197|    const auto implementations = get_supported_implementations();
  235|    197|    std::vector<simdutf::result> results;
  236|    197|    results.reserve(implementations.size());
  237|       |
  238|    591|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 591, False: 197]
  ------------------
  239|    591|      results.push_back(
  240|    591|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    591|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    591|      const bool validation2 =
  245|    591|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    591|                      src.data(), src.size());
  247|    591|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 591]
  ------------------
  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|    591|    }
  258|       |
  259|    197|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    197|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 197]
  ------------------
  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|    197|    } else {
  273|    197|      ret.implementations_agree = true;
  274|    197|    }
  275|    197|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    197|      return r.error == simdutf::SUCCESS;
  277|    197|    });
  278|    197|    return ret;
  279|    197|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    394|    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|    411|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    411|      return r.error == simdutf::SUCCESS;
  277|    411|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    197|  bool count_the_input(FromSpan src) const {
  290|    197|    const auto implementations = get_supported_implementations();
  291|    197|    std::vector<std::size_t> results;
  292|    197|    results.reserve(implementations.size());
  293|       |
  294|    591|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 591, False: 197]
  ------------------
  295|    591|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    591|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    591|        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|    591|      results.push_back(ret);
  304|    591|    }
  305|    197|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    197|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 197]
  ------------------
  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|    197|    return true;
  321|    197|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    394|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    197|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    197|    length_result ret{};
  344|       |
  345|    197|    const auto implementations = get_supported_implementations();
  346|    197|    std::vector<std::size_t> results;
  347|    197|    results.reserve(implementations.size());
  348|       |
  349|    591|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 591, False: 197]
  ------------------
  350|    591|      const auto len = invoke_lengthcalc(impl, src);
  351|    591|      results.push_back(len);
  352|    591|      ret.length.push_back(len);
  353|    591|    }
  354|       |
  355|    197|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    197|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 197]
  ------------------
  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|    197|    } else {
  375|    197|      ret.implementations_agree = true;
  376|    197|    }
  377|    197|    return ret;
  378|    197|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    591|                                FromSpan src) const {
  331|    591|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    591|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    394|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    192|                                  const bool inputisvalid) const {
  383|    192|    conversion_result ret{};
  384|       |
  385|    192|    const auto implementations = get_supported_implementations();
  386|       |
  387|    192|    std::vector<result<ConversionResult>> results;
  388|    192|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    192|    std::vector<std::vector<ToType>> outputbuffers;
  393|    192|    outputbuffers.reserve(implementations.size());
  394|    768|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 576, False: 192]
  ------------------
  395|    576|      auto impl = implementations[i];
  396|    576|      const ToType canary1{42};
  397|    576|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    576|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    576|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    576|      const auto success = [](const ConversionResult& r) -> bool {
  402|    576|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    576|          return r != 0;
  404|    576|        } else {
  405|    576|          return r.error == simdutf::error_code::SUCCESS;
  406|    576|        }
  407|    576|      }(implret1);
  408|    576|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    576|      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|    576|        const ToType canary2{25};
  414|    576|        const auto outputbuffer_first_run = outputbuffer;
  415|    576|        std::ranges::fill(outputbuffer, canary2);
  416|    576|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    576|                                          src.size(), outputbuffer.data());
  418|       |
  419|    576|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 576]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    576|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 321, False: 255]
  |  Branch (423:29): [True: 309, False: 12]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    309|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    309|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 309]
  ------------------
  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|    309|        }
  440|    576|      }
  441|    576|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 309, False: 267]
  ------------------
  442|    576|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    192|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 85, False: 107]
  ------------------
  447|    255|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 255, False: 85]
  ------------------
  448|    255|        e.outputhash.clear();
  449|    255|      }
  450|     85|    }
  451|       |
  452|    192|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    192|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 192]
  ------------------
  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|    192|    } else {
  474|    192|      ret.implementations_agree = true;
  475|    192|    }
  476|    192|    return ret;
  477|    192|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    576|      const auto success = [](const ConversionResult& r) -> bool {
  402|    576|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    576|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    576|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    384|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_3clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    219|    +[](std::span<const char> chardata) {                                      \
  555|    219|      const auto c =                                                           \
  556|    219|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    219|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    219|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    219|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    219|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    219|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    219|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    219|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    219|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    219|  constexpr auto _size = _name.size();                                \
  |  | 1183|    219|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    219|  return _nameof; }()
  ------------------
  561|    219|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    219|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    219|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    219|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    219|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    219|  constexpr auto _size = _name.size();                                \
  |  | 1183|    219|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    219|  return _nameof; }()
  ------------------
  562|    219|      c.fuzz(chardata);                                                        \
  563|    219|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    412|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    412|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    412|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    412|    static const bool do_print_testcase =
  181|    412|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    412|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 412]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    412|    do {
  189|       |      // step 0 - is the input valid?
  190|    412|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    412|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 412]
  |  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|    412|                    From == UtfEncodings::UTF8) {
  198|    412|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 412]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    412|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    412|      const auto [output_length, length_agree] =
  204|    412|          calculate_length(from, inputisvalid);
  205|    412|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 412]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    412|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 91, False: 321]
  |  Branch (208:28): [True: 11, False: 80]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     11|        return;
  211|     11|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    401|      const auto [written, outputs_agree] =
  215|    401|          do_conversion(from, output_length, inputisvalid);
  216|    401|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 401]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    401|      return;
  221|    401|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    412|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    412|  validation_result verify_valid_input(FromSpan src) const {
  231|    412|    validation_result ret{};
  232|       |
  233|    412|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    412|    const auto implementations = get_supported_implementations();
  235|    412|    std::vector<simdutf::result> results;
  236|    412|    results.reserve(implementations.size());
  237|       |
  238|  1.23k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.23k, False: 412]
  ------------------
  239|  1.23k|      results.push_back(
  240|  1.23k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.23k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.23k|      const bool validation2 =
  245|  1.23k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.23k|                      src.data(), src.size());
  247|  1.23k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.23k]
  ------------------
  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.23k|    }
  258|       |
  259|    412|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    412|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 412]
  ------------------
  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|    412|    } else {
  273|    412|      ret.implementations_agree = true;
  274|    412|    }
  275|    412|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    412|      return r.error == simdutf::SUCCESS;
  277|    412|    });
  278|    412|    return ret;
  279|    412|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    824|    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.05k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.05k|      return r.error == simdutf::SUCCESS;
  277|  1.05k|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    412|  bool count_the_input(FromSpan src) const {
  290|    412|    const auto implementations = get_supported_implementations();
  291|    412|    std::vector<std::size_t> results;
  292|    412|    results.reserve(implementations.size());
  293|       |
  294|  1.23k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.23k, False: 412]
  ------------------
  295|  1.23k|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|  1.23k|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|  1.23k|        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.23k|      results.push_back(ret);
  304|  1.23k|    }
  305|    412|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    412|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 412]
  ------------------
  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|    412|    return true;
  321|    412|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    824|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    412|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    412|    length_result ret{};
  344|       |
  345|    412|    const auto implementations = get_supported_implementations();
  346|    412|    std::vector<std::size_t> results;
  347|    412|    results.reserve(implementations.size());
  348|       |
  349|  1.23k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.23k, False: 412]
  ------------------
  350|  1.23k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.23k|      results.push_back(len);
  352|  1.23k|      ret.length.push_back(len);
  353|  1.23k|    }
  354|       |
  355|    412|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    412|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 412]
  ------------------
  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|    412|    } else {
  375|    412|      ret.implementations_agree = true;
  376|    412|    }
  377|    412|    return ret;
  378|    412|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.23k|                                FromSpan src) const {
  331|  1.23k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.23k|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    824|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    401|                                  const bool inputisvalid) const {
  383|    401|    conversion_result ret{};
  384|       |
  385|    401|    const auto implementations = get_supported_implementations();
  386|       |
  387|    401|    std::vector<result<ConversionResult>> results;
  388|    401|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    401|    std::vector<std::vector<ToType>> outputbuffers;
  393|    401|    outputbuffers.reserve(implementations.size());
  394|  1.60k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.20k, False: 401]
  ------------------
  395|  1.20k|      auto impl = implementations[i];
  396|  1.20k|      const ToType canary1{42};
  397|  1.20k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.20k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.20k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.20k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.20k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.20k|          return r != 0;
  404|  1.20k|        } else {
  405|  1.20k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.20k|        }
  407|  1.20k|      }(implret1);
  408|  1.20k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.20k|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|  1.20k|        const ToType canary2{25};
  414|  1.20k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.20k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.20k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.20k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.20k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.20k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.20k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 963, False: 240]
  |  Branch (423:29): [True: 951, False: 12]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    951|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    951|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 951]
  ------------------
  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|    951|        }
  440|  1.20k|      }
  441|  1.20k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 951, False: 252]
  ------------------
  442|  1.20k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    401|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 80, False: 321]
  ------------------
  447|    240|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 240, False: 80]
  ------------------
  448|    240|        e.outputhash.clear();
  449|    240|      }
  450|     80|    }
  451|       |
  452|    401|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    401|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 401]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    401|    } else {
  474|    401|      ret.implementations_agree = true;
  475|    401|    }
  476|    401|    return ret;
  477|    401|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.20k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.20k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.20k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.20k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    802|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_4clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     47|    +[](std::span<const char> chardata) {                                      \
  555|     47|      const auto c =                                                           \
  556|     47|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     47|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     47|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     47|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     47|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     47|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     47|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     47|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     47|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     47|  constexpr auto _size = _name.size();                                \
  |  | 1183|     47|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     47|  return _nameof; }()
  ------------------
  561|     47|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     47|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     47|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     47|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     47|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     47|  constexpr auto _size = _name.size();                                \
  |  | 1183|     47|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     47|  return _nameof; }()
  ------------------
  562|     47|      c.fuzz(chardata);                                                        \
  563|     47|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    268|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    268|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    268|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    268|    static const bool do_print_testcase =
  181|    268|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    268|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 268]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    268|    do {
  189|       |      // step 0 - is the input valid?
  190|    268|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    268|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 268]
  |  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|    268|      const auto [output_length, length_agree] =
  204|    268|          calculate_length(from, inputisvalid);
  205|    268|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 268]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    268|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 168, False: 100]
  |  Branch (208:28): [True: 4, False: 164]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      4|        return;
  211|      4|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    264|      const auto [written, outputs_agree] =
  215|    264|          do_conversion(from, output_length, inputisvalid);
  216|    264|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 264]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    264|      return;
  221|    264|    } 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|    268|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    268|  validation_result verify_valid_input(FromSpan src) const {
  231|    268|    validation_result ret{};
  232|       |
  233|    268|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    268|    const auto implementations = get_supported_implementations();
  235|    268|    std::vector<simdutf::result> results;
  236|    268|    results.reserve(implementations.size());
  237|       |
  238|    804|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 804, False: 268]
  ------------------
  239|    804|      results.push_back(
  240|    804|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    804|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    804|      const bool validation2 =
  245|    804|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    804|                      src.data(), src.size());
  247|    804|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 804]
  ------------------
  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|    804|    }
  258|       |
  259|    268|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    268|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 268]
  ------------------
  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|    268|    } else {
  273|    268|      ret.implementations_agree = true;
  274|    268|    }
  275|    268|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    268|      return r.error == simdutf::SUCCESS;
  277|    268|    });
  278|    268|    return ret;
  279|    268|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    536|    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|    468|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    468|      return r.error == simdutf::SUCCESS;
  277|    468|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    268|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    268|    length_result ret{};
  344|       |
  345|    268|    const auto implementations = get_supported_implementations();
  346|    268|    std::vector<std::size_t> results;
  347|    268|    results.reserve(implementations.size());
  348|       |
  349|    804|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 804, False: 268]
  ------------------
  350|    804|      const auto len = invoke_lengthcalc(impl, src);
  351|    804|      results.push_back(len);
  352|    804|      ret.length.push_back(len);
  353|    804|    }
  354|       |
  355|    268|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    268|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 268]
  ------------------
  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|    268|    } else {
  375|    268|      ret.implementations_agree = true;
  376|    268|    }
  377|    268|    return ret;
  378|    268|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    804|                                FromSpan src) const {
  331|    804|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    804|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    536|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    264|                                  const bool inputisvalid) const {
  383|    264|    conversion_result ret{};
  384|       |
  385|    264|    const auto implementations = get_supported_implementations();
  386|       |
  387|    264|    std::vector<result<ConversionResult>> results;
  388|    264|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    264|    std::vector<std::vector<ToType>> outputbuffers;
  393|    264|    outputbuffers.reserve(implementations.size());
  394|  1.05k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 792, False: 264]
  ------------------
  395|    792|      auto impl = implementations[i];
  396|    792|      const ToType canary1{42};
  397|    792|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    792|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    792|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    792|      const auto success = [](const ConversionResult& r) -> bool {
  402|    792|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    792|          return r != 0;
  404|    792|        } else {
  405|    792|          return r.error == simdutf::error_code::SUCCESS;
  406|    792|        }
  407|    792|      }(implret1);
  408|    792|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    792|      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|    792|        const ToType canary2{25};
  414|    792|        const auto outputbuffer_first_run = outputbuffer;
  415|    792|        std::ranges::fill(outputbuffer, canary2);
  416|    792|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    792|                                          src.size(), outputbuffer.data());
  418|       |
  419|    792|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 792]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    792|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 300, False: 492]
  |  Branch (423:29): [True: 291, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    291|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    291|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 291]
  ------------------
  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|    291|        }
  440|    792|      }
  441|    792|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 291, False: 501]
  ------------------
  442|    792|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    264|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 164, False: 100]
  ------------------
  447|    492|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 492, False: 164]
  ------------------
  448|    492|        e.outputhash.clear();
  449|    492|      }
  450|    164|    }
  451|       |
  452|    264|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    264|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 264]
  ------------------
  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|    264|    } else {
  474|    264|      ret.implementations_agree = true;
  475|    264|    }
  476|    264|    return ret;
  477|    264|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    792|      const auto success = [](const ConversionResult& r) -> bool {
  402|    792|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    792|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    792|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    528|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_5clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    150|    +[](std::span<const char> chardata) {                                      \
  555|    150|      const auto c =                                                           \
  556|    150|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    150|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    150|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    150|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    150|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    150|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    150|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    150|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    150|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    150|  constexpr auto _size = _name.size();                                \
  |  | 1183|    150|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    150|  return _nameof; }()
  ------------------
  561|    150|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    150|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    150|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    150|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    150|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    150|  constexpr auto _size = _name.size();                                \
  |  | 1183|    150|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    150|  return _nameof; }()
  ------------------
  562|    150|      c.fuzz(chardata);                                                        \
  563|    150|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    366|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    366|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    366|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    366|    static const bool do_print_testcase =
  181|    366|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    366|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 366]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    366|    do {
  189|       |      // step 0 - is the input valid?
  190|    366|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    366|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 366]
  |  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|    366|      const auto [output_length, length_agree] =
  204|    366|          calculate_length(from, inputisvalid);
  205|    366|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 366]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    366|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 146, False: 220]
  |  Branch (208:28): [True: 5, False: 141]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      5|        return;
  211|      5|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    361|      const auto [written, outputs_agree] =
  215|    361|          do_conversion(from, output_length, inputisvalid);
  216|    361|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 361]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    361|      return;
  221|    361|    } 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|    366|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    366|  validation_result verify_valid_input(FromSpan src) const {
  231|    366|    validation_result ret{};
  232|       |
  233|    366|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    366|    const auto implementations = get_supported_implementations();
  235|    366|    std::vector<simdutf::result> results;
  236|    366|    results.reserve(implementations.size());
  237|       |
  238|  1.09k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.09k, False: 366]
  ------------------
  239|  1.09k|      results.push_back(
  240|  1.09k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.09k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.09k|      const bool validation2 =
  245|  1.09k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.09k|                      src.data(), src.size());
  247|  1.09k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.09k]
  ------------------
  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.09k|    }
  258|       |
  259|    366|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    366|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 366]
  ------------------
  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|    366|    } else {
  273|    366|      ret.implementations_agree = true;
  274|    366|    }
  275|    366|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    366|      return r.error == simdutf::SUCCESS;
  277|    366|    });
  278|    366|    return ret;
  279|    366|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    732|    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|    806|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    806|      return r.error == simdutf::SUCCESS;
  277|    806|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    366|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    366|    length_result ret{};
  344|       |
  345|    366|    const auto implementations = get_supported_implementations();
  346|    366|    std::vector<std::size_t> results;
  347|    366|    results.reserve(implementations.size());
  348|       |
  349|  1.09k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.09k, False: 366]
  ------------------
  350|  1.09k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.09k|      results.push_back(len);
  352|  1.09k|      ret.length.push_back(len);
  353|  1.09k|    }
  354|       |
  355|    366|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    366|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 366]
  ------------------
  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|    366|    } else {
  375|    366|      ret.implementations_agree = true;
  376|    366|    }
  377|    366|    return ret;
  378|    366|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.09k|                                FromSpan src) const {
  331|  1.09k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.09k|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    732|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    361|                                  const bool inputisvalid) const {
  383|    361|    conversion_result ret{};
  384|       |
  385|    361|    const auto implementations = get_supported_implementations();
  386|       |
  387|    361|    std::vector<result<ConversionResult>> results;
  388|    361|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    361|    std::vector<std::vector<ToType>> outputbuffers;
  393|    361|    outputbuffers.reserve(implementations.size());
  394|  1.44k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.08k, False: 361]
  ------------------
  395|  1.08k|      auto impl = implementations[i];
  396|  1.08k|      const ToType canary1{42};
  397|  1.08k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.08k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.08k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.08k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.08k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.08k|          return r != 0;
  404|  1.08k|        } else {
  405|  1.08k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.08k|        }
  407|  1.08k|      }(implret1);
  408|  1.08k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.08k|      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.08k|        const ToType canary2{25};
  414|  1.08k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.08k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.08k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.08k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.08k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.08k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.08k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 660, False: 423]
  |  Branch (423:29): [True: 648, False: 12]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    648|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    648|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 648]
  ------------------
  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|    648|        }
  440|  1.08k|      }
  441|  1.08k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 648, False: 435]
  ------------------
  442|  1.08k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    361|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 141, False: 220]
  ------------------
  447|    423|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 423, False: 141]
  ------------------
  448|    423|        e.outputhash.clear();
  449|    423|      }
  450|    141|    }
  451|       |
  452|    361|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    361|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 361]
  ------------------
  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|    361|    } else {
  474|    361|      ret.implementations_agree = true;
  475|    361|    }
  476|    361|    return ret;
  477|    361|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.08k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.08k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.08k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.08k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    722|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_6clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    102|    +[](std::span<const char> chardata) {                                      \
  555|    102|      const auto c =                                                           \
  556|    102|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    102|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    102|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    102|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    102|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    102|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    102|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    102|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    102|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    102|  constexpr auto _size = _name.size();                                \
  |  | 1183|    102|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    102|  return _nameof; }()
  ------------------
  561|    102|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    102|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    102|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    102|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    102|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    102|  constexpr auto _size = _name.size();                                \
  |  | 1183|    102|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    102|  return _nameof; }()
  ------------------
  562|    102|      c.fuzz(chardata);                                                        \
  563|    102|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    404|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    404|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    404|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    404|    static const bool do_print_testcase =
  181|    404|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    404|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 404]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    404|    do {
  189|       |      // step 0 - is the input valid?
  190|    404|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    404|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 404]
  |  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|    404|      const auto [output_length, length_agree] =
  204|    404|          calculate_length(from, inputisvalid);
  205|    404|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 404]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    404|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 256, False: 148]
  |  Branch (208:28): [True: 6, False: 250]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      6|        return;
  211|      6|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    398|      const auto [written, outputs_agree] =
  215|    398|          do_conversion(from, output_length, inputisvalid);
  216|    398|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 398]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    398|      return;
  221|    398|    } 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|    404|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    404|  validation_result verify_valid_input(FromSpan src) const {
  231|    404|    validation_result ret{};
  232|       |
  233|    404|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    404|    const auto implementations = get_supported_implementations();
  235|    404|    std::vector<simdutf::result> results;
  236|    404|    results.reserve(implementations.size());
  237|       |
  238|  1.21k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.21k, False: 404]
  ------------------
  239|  1.21k|      results.push_back(
  240|  1.21k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.21k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.21k|      const bool validation2 =
  245|  1.21k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.21k|                      src.data(), src.size());
  247|  1.21k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.21k]
  ------------------
  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.21k|    }
  258|       |
  259|    404|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    404|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 404]
  ------------------
  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|    404|    } else {
  273|    404|      ret.implementations_agree = true;
  274|    404|    }
  275|    404|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    404|      return r.error == simdutf::SUCCESS;
  277|    404|    });
  278|    404|    return ret;
  279|    404|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    808|    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|    700|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    700|      return r.error == simdutf::SUCCESS;
  277|    700|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    404|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    404|    length_result ret{};
  344|       |
  345|    404|    const auto implementations = get_supported_implementations();
  346|    404|    std::vector<std::size_t> results;
  347|    404|    results.reserve(implementations.size());
  348|       |
  349|  1.21k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.21k, False: 404]
  ------------------
  350|  1.21k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.21k|      results.push_back(len);
  352|  1.21k|      ret.length.push_back(len);
  353|  1.21k|    }
  354|       |
  355|    404|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    404|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 404]
  ------------------
  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|    404|    } else {
  375|    404|      ret.implementations_agree = true;
  376|    404|    }
  377|    404|    return ret;
  378|    404|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.21k|                                FromSpan src) const {
  331|  1.21k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.21k|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    808|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    398|                                  const bool inputisvalid) const {
  383|    398|    conversion_result ret{};
  384|       |
  385|    398|    const auto implementations = get_supported_implementations();
  386|       |
  387|    398|    std::vector<result<ConversionResult>> results;
  388|    398|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    398|    std::vector<std::vector<ToType>> outputbuffers;
  393|    398|    outputbuffers.reserve(implementations.size());
  394|  1.59k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.19k, False: 398]
  ------------------
  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: 444, False: 750]
  |  Branch (423:29): [True: 435, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    435|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    435|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 435]
  ------------------
  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|    435|        }
  440|  1.19k|      }
  441|  1.19k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 435, False: 759]
  ------------------
  442|  1.19k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    398|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 250, False: 148]
  ------------------
  447|    750|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 750, False: 250]
  ------------------
  448|    750|        e.outputhash.clear();
  449|    750|      }
  450|    250|    }
  451|       |
  452|    398|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    398|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 398]
  ------------------
  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|    398|    } else {
  474|    398|      ret.implementations_agree = true;
  475|    398|    }
  476|    398|    return ret;
  477|    398|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_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);
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    796|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_7clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    228|    +[](std::span<const char> chardata) {                                      \
  555|    228|      const auto c =                                                           \
  556|    228|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    228|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    228|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    228|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    228|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    228|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    228|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    228|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    228|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    228|  constexpr auto _size = _name.size();                                \
  |  | 1183|    228|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    228|  return _nameof; }()
  ------------------
  561|    228|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    228|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    228|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    228|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    228|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    228|  constexpr auto _size = _name.size();                                \
  |  | 1183|    228|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    228|  return _nameof; }()
  ------------------
  562|    228|      c.fuzz(chardata);                                                        \
  563|    228|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    584|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    584|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    584|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    584|    static const bool do_print_testcase =
  181|    584|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    584|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 584]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    584|    do {
  189|       |      // step 0 - is the input valid?
  190|    584|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    584|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 584]
  |  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|    584|                    From == UtfEncodings::UTF8) {
  198|    584|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 584]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    584|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    584|      const auto [output_length, length_agree] =
  204|    584|          calculate_length(from, inputisvalid);
  205|    584|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 584]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    584|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 268, False: 316]
  |  Branch (208:28): [True: 9, False: 259]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      9|        return;
  211|      9|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    575|      const auto [written, outputs_agree] =
  215|    575|          do_conversion(from, output_length, inputisvalid);
  216|    575|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 575]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    575|      return;
  221|    575|    } 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|    584|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    584|  validation_result verify_valid_input(FromSpan src) const {
  231|    584|    validation_result ret{};
  232|       |
  233|    584|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    584|    const auto implementations = get_supported_implementations();
  235|    584|    std::vector<simdutf::result> results;
  236|    584|    results.reserve(implementations.size());
  237|       |
  238|  1.75k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.75k, False: 584]
  ------------------
  239|  1.75k|      results.push_back(
  240|  1.75k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.75k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.75k|      const bool validation2 =
  245|  1.75k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.75k|                      src.data(), src.size());
  247|  1.75k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.75k]
  ------------------
  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.75k|    }
  258|       |
  259|    584|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    584|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 584]
  ------------------
  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|    584|    } else {
  273|    584|      ret.implementations_agree = true;
  274|    584|    }
  275|    584|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    584|      return r.error == simdutf::SUCCESS;
  277|    584|    });
  278|    584|    return ret;
  279|    584|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|  1.16k|    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.21k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.21k|      return r.error == simdutf::SUCCESS;
  277|  1.21k|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    584|  bool count_the_input(FromSpan src) const {
  290|    584|    const auto implementations = get_supported_implementations();
  291|    584|    std::vector<std::size_t> results;
  292|    584|    results.reserve(implementations.size());
  293|       |
  294|  1.75k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.75k, False: 584]
  ------------------
  295|  1.75k|      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.75k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.75k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.75k|      }
  303|  1.75k|      results.push_back(ret);
  304|  1.75k|    }
  305|    584|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    584|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 584]
  ------------------
  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|    584|    return true;
  321|    584|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|  1.16k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    584|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    584|    length_result ret{};
  344|       |
  345|    584|    const auto implementations = get_supported_implementations();
  346|    584|    std::vector<std::size_t> results;
  347|    584|    results.reserve(implementations.size());
  348|       |
  349|  1.75k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.75k, False: 584]
  ------------------
  350|  1.75k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.75k|      results.push_back(len);
  352|  1.75k|      ret.length.push_back(len);
  353|  1.75k|    }
  354|       |
  355|    584|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    584|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 584]
  ------------------
  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|    584|    } else {
  375|    584|      ret.implementations_agree = true;
  376|    584|    }
  377|    584|    return ret;
  378|    584|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.75k|                                FromSpan src) const {
  331|  1.75k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.75k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|  1.16k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    575|                                  const bool inputisvalid) const {
  383|    575|    conversion_result ret{};
  384|       |
  385|    575|    const auto implementations = get_supported_implementations();
  386|       |
  387|    575|    std::vector<result<ConversionResult>> results;
  388|    575|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    575|    std::vector<std::vector<ToType>> outputbuffers;
  393|    575|    outputbuffers.reserve(implementations.size());
  394|  2.30k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.72k, False: 575]
  ------------------
  395|  1.72k|      auto impl = implementations[i];
  396|  1.72k|      const ToType canary1{42};
  397|  1.72k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.72k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.72k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.72k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.72k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.72k|          return r != 0;
  404|  1.72k|        } else {
  405|  1.72k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.72k|        }
  407|  1.72k|      }(implret1);
  408|  1.72k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.72k|      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.72k|        const ToType canary2{25};
  414|  1.72k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.72k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.72k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.72k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.72k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.72k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.72k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 948, False: 777]
  |  Branch (423:29): [True: 939, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    939|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    939|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 939]
  ------------------
  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|    939|        }
  440|  1.72k|      }
  441|  1.72k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 939, False: 786]
  ------------------
  442|  1.72k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    575|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 259, False: 316]
  ------------------
  447|    777|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 777, False: 259]
  ------------------
  448|    777|        e.outputhash.clear();
  449|    777|      }
  450|    259|    }
  451|       |
  452|    575|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    575|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 575]
  ------------------
  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|    575|    } else {
  474|    575|      ret.implementations_agree = true;
  475|    575|    }
  476|    575|    return ret;
  477|    575|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.72k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.72k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.72k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.72k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|  1.15k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_8clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    197|    +[](std::span<const char> chardata) {                                      \
  555|    197|      const auto c =                                                           \
  556|    197|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    197|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    197|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    197|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    197|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    197|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    197|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    197|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    197|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    197|  constexpr auto _size = _name.size();                                \
  |  | 1183|    197|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    197|  return _nameof; }()
  ------------------
  561|    197|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    197|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    197|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    197|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    197|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    197|  constexpr auto _size = _name.size();                                \
  |  | 1183|    197|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    197|  return _nameof; }()
  ------------------
  562|    197|      c.fuzz(chardata);                                                        \
  563|    197|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    527|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    527|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    527|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    527|    static const bool do_print_testcase =
  181|    527|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    527|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 527]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    527|    do {
  189|       |      // step 0 - is the input valid?
  190|    527|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    527|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 527]
  |  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|    527|                    From == UtfEncodings::UTF8) {
  198|    527|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 527]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    527|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    527|      const auto [output_length, length_agree] =
  204|    527|          calculate_length(from, inputisvalid);
  205|    527|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 527]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    527|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 230, False: 297]
  |  Branch (208:28): [True: 13, False: 217]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     13|        return;
  211|     13|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    514|      const auto [written, outputs_agree] =
  215|    514|          do_conversion(from, output_length, inputisvalid);
  216|    514|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 514]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    514|      return;
  221|    514|    } 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|    527|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    527|  validation_result verify_valid_input(FromSpan src) const {
  231|    527|    validation_result ret{};
  232|       |
  233|    527|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    527|    const auto implementations = get_supported_implementations();
  235|    527|    std::vector<simdutf::result> results;
  236|    527|    results.reserve(implementations.size());
  237|       |
  238|  1.58k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.58k, False: 527]
  ------------------
  239|  1.58k|      results.push_back(
  240|  1.58k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.58k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.58k|      const bool validation2 =
  245|  1.58k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.58k|                      src.data(), src.size());
  247|  1.58k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.58k]
  ------------------
  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.58k|    }
  258|       |
  259|    527|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    527|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 527]
  ------------------
  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|    527|    } else {
  273|    527|      ret.implementations_agree = true;
  274|    527|    }
  275|    527|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    527|      return r.error == simdutf::SUCCESS;
  277|    527|    });
  278|    527|    return ret;
  279|    527|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|  1.05k|    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.12k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.12k|      return r.error == simdutf::SUCCESS;
  277|  1.12k|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    527|  bool count_the_input(FromSpan src) const {
  290|    527|    const auto implementations = get_supported_implementations();
  291|    527|    std::vector<std::size_t> results;
  292|    527|    results.reserve(implementations.size());
  293|       |
  294|  1.58k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.58k, False: 527]
  ------------------
  295|  1.58k|      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.58k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.58k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.58k|      }
  303|  1.58k|      results.push_back(ret);
  304|  1.58k|    }
  305|    527|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    527|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 527]
  ------------------
  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|    527|    return true;
  321|    527|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|  1.05k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    527|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    527|    length_result ret{};
  344|       |
  345|    527|    const auto implementations = get_supported_implementations();
  346|    527|    std::vector<std::size_t> results;
  347|    527|    results.reserve(implementations.size());
  348|       |
  349|  1.58k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.58k, False: 527]
  ------------------
  350|  1.58k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.58k|      results.push_back(len);
  352|  1.58k|      ret.length.push_back(len);
  353|  1.58k|    }
  354|       |
  355|    527|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    527|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 527]
  ------------------
  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|    527|    } else {
  375|    527|      ret.implementations_agree = true;
  376|    527|    }
  377|    527|    return ret;
  378|    527|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.58k|                                FromSpan src) const {
  331|  1.58k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.58k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|  1.05k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    514|                                  const bool inputisvalid) const {
  383|    514|    conversion_result ret{};
  384|       |
  385|    514|    const auto implementations = get_supported_implementations();
  386|       |
  387|    514|    std::vector<result<ConversionResult>> results;
  388|    514|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    514|    std::vector<std::vector<ToType>> outputbuffers;
  393|    514|    outputbuffers.reserve(implementations.size());
  394|  2.05k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.54k, False: 514]
  ------------------
  395|  1.54k|      auto impl = implementations[i];
  396|  1.54k|      const ToType canary1{42};
  397|  1.54k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.54k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.54k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.54k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.54k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.54k|          return r != 0;
  404|  1.54k|        } else {
  405|  1.54k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.54k|        }
  407|  1.54k|      }(implret1);
  408|  1.54k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.54k|      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.54k|        const ToType canary2{25};
  414|  1.54k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.54k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.54k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.54k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.54k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.54k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.54k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 891, False: 651]
  |  Branch (423:29): [True: 882, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    882|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    882|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 882]
  ------------------
  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|    882|        }
  440|  1.54k|      }
  441|  1.54k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 882, False: 660]
  ------------------
  442|  1.54k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    514|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 217, False: 297]
  ------------------
  447|    651|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 651, False: 217]
  ------------------
  448|    651|        e.outputhash.clear();
  449|    651|      }
  450|    217|    }
  451|       |
  452|    514|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    514|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 514]
  ------------------
  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|    514|    } else {
  474|    514|      ret.implementations_agree = true;
  475|    514|    }
  476|    514|    return ret;
  477|    514|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.54k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.54k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.54k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.54k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|  1.02k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_9clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    208|    +[](std::span<const char> chardata) {                                      \
  555|    208|      const auto c =                                                           \
  556|    208|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    208|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    208|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    208|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    208|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    208|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    208|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    208|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    208|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    208|  constexpr auto _size = _name.size();                                \
  |  | 1183|    208|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    208|  return _nameof; }()
  ------------------
  561|    208|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    208|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    208|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    208|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    208|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    208|  constexpr auto _size = _name.size();                                \
  |  | 1183|    208|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    208|  return _nameof; }()
  ------------------
  562|    208|      c.fuzz(chardata);                                                        \
  563|    208|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    564|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    564|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    564|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    564|    static const bool do_print_testcase =
  181|    564|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    564|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 564]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    564|    do {
  189|       |      // step 0 - is the input valid?
  190|    564|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    564|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 564]
  |  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|    564|                    From == UtfEncodings::UTF8) {
  198|    564|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 564]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    564|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    564|      const auto [output_length, length_agree] =
  204|    564|          calculate_length(from, inputisvalid);
  205|    564|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 564]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    564|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 229, False: 335]
  |  Branch (208:28): [True: 11, False: 218]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     11|        return;
  211|     11|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    553|      const auto [written, outputs_agree] =
  215|    553|          do_conversion(from, output_length, inputisvalid);
  216|    553|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 553]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    553|      return;
  221|    553|    } 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|    564|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    564|  validation_result verify_valid_input(FromSpan src) const {
  231|    564|    validation_result ret{};
  232|       |
  233|    564|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    564|    const auto implementations = get_supported_implementations();
  235|    564|    std::vector<simdutf::result> results;
  236|    564|    results.reserve(implementations.size());
  237|       |
  238|  1.69k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.69k, False: 564]
  ------------------
  239|  1.69k|      results.push_back(
  240|  1.69k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.69k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.69k|      const bool validation2 =
  245|  1.69k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.69k|                      src.data(), src.size());
  247|  1.69k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.69k]
  ------------------
  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.69k|    }
  258|       |
  259|    564|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    564|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 564]
  ------------------
  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|    564|    } else {
  273|    564|      ret.implementations_agree = true;
  274|    564|    }
  275|    564|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    564|      return r.error == simdutf::SUCCESS;
  277|    564|    });
  278|    564|    return ret;
  279|    564|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|  1.12k|    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.23k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.23k|      return r.error == simdutf::SUCCESS;
  277|  1.23k|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    564|  bool count_the_input(FromSpan src) const {
  290|    564|    const auto implementations = get_supported_implementations();
  291|    564|    std::vector<std::size_t> results;
  292|    564|    results.reserve(implementations.size());
  293|       |
  294|  1.69k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.69k, False: 564]
  ------------------
  295|  1.69k|      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.69k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.69k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.69k|      }
  303|  1.69k|      results.push_back(ret);
  304|  1.69k|    }
  305|    564|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    564|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 564]
  ------------------
  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|    564|    return true;
  321|    564|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|  1.12k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    564|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    564|    length_result ret{};
  344|       |
  345|    564|    const auto implementations = get_supported_implementations();
  346|    564|    std::vector<std::size_t> results;
  347|    564|    results.reserve(implementations.size());
  348|       |
  349|  1.69k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.69k, False: 564]
  ------------------
  350|  1.69k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.69k|      results.push_back(len);
  352|  1.69k|      ret.length.push_back(len);
  353|  1.69k|    }
  354|       |
  355|    564|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    564|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 564]
  ------------------
  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|    564|    } else {
  375|    564|      ret.implementations_agree = true;
  376|    564|    }
  377|    564|    return ret;
  378|    564|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.69k|                                FromSpan src) const {
  331|  1.69k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.69k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|  1.12k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    553|                                  const bool inputisvalid) const {
  383|    553|    conversion_result ret{};
  384|       |
  385|    553|    const auto implementations = get_supported_implementations();
  386|       |
  387|    553|    std::vector<result<ConversionResult>> results;
  388|    553|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    553|    std::vector<std::vector<ToType>> outputbuffers;
  393|    553|    outputbuffers.reserve(implementations.size());
  394|  2.21k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.65k, False: 553]
  ------------------
  395|  1.65k|      auto impl = implementations[i];
  396|  1.65k|      const ToType canary1{42};
  397|  1.65k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.65k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.65k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.65k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.65k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.65k|          return r != 0;
  404|  1.65k|        } else {
  405|  1.65k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.65k|        }
  407|  1.65k|      }(implret1);
  408|  1.65k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.65k|      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.65k|        const ToType canary2{25};
  414|  1.65k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.65k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.65k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.65k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.65k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.65k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.65k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 1.00k, False: 654]
  |  Branch (423:29): [True: 999, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    999|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    999|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 999]
  ------------------
  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|    999|        }
  440|  1.65k|      }
  441|  1.65k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 999, False: 660]
  ------------------
  442|  1.65k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    553|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 218, False: 335]
  ------------------
  447|    654|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 654, False: 218]
  ------------------
  448|    654|        e.outputhash.clear();
  449|    654|      }
  450|    218|    }
  451|       |
  452|    553|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    553|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 553]
  ------------------
  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|    553|    } else {
  474|    553|      ret.implementations_agree = true;
  475|    553|    }
  476|    553|    return ret;
  477|    553|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.65k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.65k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.65k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.65k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|  1.10k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_10clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     63|    +[](std::span<const char> chardata) {                                      \
  555|     63|      const auto c =                                                           \
  556|     63|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     63|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     63|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     63|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     63|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     63|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     63|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     63|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     63|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     63|  constexpr auto _size = _name.size();                                \
  |  | 1183|     63|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     63|  return _nameof; }()
  ------------------
  561|     63|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     63|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     63|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     63|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     63|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     63|  constexpr auto _size = _name.size();                                \
  |  | 1183|     63|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     63|  return _nameof; }()
  ------------------
  562|     63|      c.fuzz(chardata);                                                        \
  563|     63|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|     63|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     63|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     63|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     63|    static const bool do_print_testcase =
  181|     63|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     63|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 63]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     63|    do {
  189|       |      // step 0 - is the input valid?
  190|     63|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     63|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 63]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|     63|                    From == UtfEncodings::UTF8) {
  198|     63|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 63]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|     63|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|     63|      const auto [output_length, length_agree] =
  204|     63|          calculate_length(from, inputisvalid);
  205|     63|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 63]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     63|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 9, False: 54]
  |  Branch (208:28): [True: 0, False: 9]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|     63|      const auto [written, outputs_agree] =
  215|     63|          do_conversion(from, output_length, inputisvalid);
  216|     63|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 63]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     63|      return;
  221|     63|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|     63|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  230|     63|  validation_result verify_valid_input(FromSpan src) const {
  231|     63|    validation_result ret{};
  232|       |
  233|     63|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|     63|    const auto implementations = get_supported_implementations();
  235|     63|    std::vector<simdutf::result> results;
  236|     63|    results.reserve(implementations.size());
  237|       |
  238|    189|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 189, False: 63]
  ------------------
  239|    189|      results.push_back(
  240|    189|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    189|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    189|      const bool validation2 =
  245|    189|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    189|                      src.data(), src.size());
  247|    189|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 189]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    189|    }
  258|       |
  259|     63|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|     63|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 63]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|     63|    } else {
  273|     63|      ret.implementations_agree = true;
  274|     63|    }
  275|     63|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|     63|      return r.error == simdutf::SUCCESS;
  277|     63|    });
  278|     63|    return ret;
  279|     63|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    126|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKNS1_6resultEE_clESI_:
  275|    171|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    171|      return r.error == simdutf::SUCCESS;
  277|    171|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE15count_the_inputENSt3__14spanIS5_Lm18446744073709551615EEE:
  289|     63|  bool count_the_input(FromSpan src) const {
  290|     63|    const auto implementations = get_supported_implementations();
  291|     63|    std::vector<std::size_t> results;
  292|     63|    results.reserve(implementations.size());
  293|       |
  294|    189|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 189, False: 63]
  ------------------
  295|    189|      std::size_t ret;
  296|    189|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    189|        ret = impl->count_utf16be(src.data(), src.size());
  298|       |      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|       |        ret = impl->count_utf16le(src.data(), src.size());
  300|       |      } else if constexpr (From == UtfEncodings::UTF8) {
  301|       |        ret = impl->count_utf8(src.data(), src.size());
  302|       |      }
  303|    189|      results.push_back(ret);
  304|    189|    }
  305|     63|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|     63|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 63]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|     63|    return true;
  321|     63|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE15count_the_inputENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    126|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     63|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     63|    length_result ret{};
  344|       |
  345|     63|    const auto implementations = get_supported_implementations();
  346|     63|    std::vector<std::size_t> results;
  347|     63|    results.reserve(implementations.size());
  348|       |
  349|    189|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 189, False: 63]
  ------------------
  350|    189|      const auto len = invoke_lengthcalc(impl, src);
  351|    189|      results.push_back(len);
  352|    189|      ret.length.push_back(len);
  353|    189|    }
  354|       |
  355|     63|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     63|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 63]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|     63|    } else {
  375|     63|      ret.implementations_agree = true;
  376|     63|    }
  377|     63|    return ret;
  378|     63|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    189|                                FromSpan src) const {
  339|    189|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    189|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    126|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     63|                                  const bool inputisvalid) const {
  383|     63|    conversion_result ret{};
  384|       |
  385|     63|    const auto implementations = get_supported_implementations();
  386|       |
  387|     63|    std::vector<result<ConversionResult>> results;
  388|     63|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     63|    std::vector<std::vector<ToType>> outputbuffers;
  393|     63|    outputbuffers.reserve(implementations.size());
  394|    252|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 189, False: 63]
  ------------------
  395|    189|      auto impl = implementations[i];
  396|    189|      const ToType canary1{42};
  397|    189|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    189|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    189|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    189|      const auto success = [](const ConversionResult& r) -> bool {
  402|    189|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    189|          return r != 0;
  404|    189|        } else {
  405|    189|          return r.error == simdutf::error_code::SUCCESS;
  406|    189|        }
  407|    189|      }(implret1);
  408|    189|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    189|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    189|        const ToType canary2{25};
  414|    189|        const auto outputbuffer_first_run = outputbuffer;
  415|    189|        std::ranges::fill(outputbuffer, canary2);
  416|    189|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    189|                                          src.size(), outputbuffer.data());
  418|       |
  419|    189|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 189]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    189|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 162, False: 27]
  |  Branch (423:29): [True: 93, False: 69]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|     93|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|     93|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 93]
  ------------------
  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|     93|        }
  440|    189|      }
  441|    189|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 93, False: 96]
  ------------------
  442|    189|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     63|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 9, False: 54]
  ------------------
  447|     27|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 27, False: 9]
  ------------------
  448|     27|        e.outputhash.clear();
  449|     27|      }
  450|      9|    }
  451|       |
  452|     63|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     63|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 63]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|     63|    } else {
  474|     63|      ret.implementations_agree = true;
  475|     63|    }
  476|     63|    return ret;
  477|     63|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    189|      const auto success = [](const ConversionResult& r) -> bool {
  402|    189|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    189|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    189|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    126|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_11clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    113|    +[](std::span<const char> chardata) {                                      \
  555|    113|      const auto c =                                                           \
  556|    113|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    113|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    113|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    113|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    113|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    113|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    113|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    113|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    113|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    113|  constexpr auto _size = _name.size();                                \
  |  | 1183|    113|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    113|  return _nameof; }()
  ------------------
  561|    113|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    113|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    113|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    113|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    113|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    113|  constexpr auto _size = _name.size();                                \
  |  | 1183|    113|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    113|  return _nameof; }()
  ------------------
  562|    113|      c.fuzz(chardata);                                                        \
  563|    113|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_12clENSt3__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$_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: 57, False: 81]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|     57|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|     57|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 57]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|     57|        }
  440|    186|      }
  441|    186|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 57, False: 129]
  ------------------
  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|    136|    +[](std::span<const char> chardata) {                                      \
  555|    136|      const auto c =                                                           \
  556|    136|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    136|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    136|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    136|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    136|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    136|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    136|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    136|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    136|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    136|  constexpr auto _size = _name.size();                                \
  |  | 1183|    136|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    136|  return _nameof; }()
  ------------------
  561|    136|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    136|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    136|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    136|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    136|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    136|  constexpr auto _size = _name.size();                                \
  |  | 1183|    136|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    136|  return _nameof; }()
  ------------------
  562|    136|      c.fuzz(chardata);                                                        \
  563|    136|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_15clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    193|    +[](std::span<const char> chardata) {                                      \
  555|    193|      const auto c =                                                           \
  556|    193|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    193|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    193|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    193|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    193|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    193|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    193|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    193|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    193|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    193|  constexpr auto _size = _name.size();                                \
  |  | 1183|    193|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    193|  return _nameof; }()
  ------------------
  561|    193|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    193|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    193|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    193|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    193|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    193|  constexpr auto _size = _name.size();                                \
  |  | 1183|    193|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    193|  return _nameof; }()
  ------------------
  562|    193|      c.fuzz(chardata);                                                        \
  563|    193|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_16clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     94|    +[](std::span<const char> chardata) {                                      \
  555|     94|      const auto c =                                                           \
  556|     94|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     94|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     94|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     94|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     94|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     94|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     94|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     94|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     94|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     94|  constexpr auto _size = _name.size();                                \
  |  | 1183|     94|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     94|  return _nameof; }()
  ------------------
  561|     94|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     94|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     94|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     94|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     94|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     94|  constexpr auto _size = _name.size();                                \
  |  | 1183|     94|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     94|  return _nameof; }()
  ------------------
  562|     94|      c.fuzz(chardata);                                                        \
  563|     94|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|     94|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     94|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     94|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     94|    static const bool do_print_testcase =
  181|     94|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     94|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 94]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     94|    do {
  189|       |      // step 0 - is the input valid?
  190|     94|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     94|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 94]
  |  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|     94|      const auto [output_length, length_agree] =
  204|     94|          calculate_length(from, inputisvalid);
  205|     94|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 94]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     94|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 62, False: 32]
  |  Branch (208:28): [True: 0, False: 62]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|     94|      const auto [written, outputs_agree] =
  215|     94|          do_conversion(from, output_length, inputisvalid);
  216|     94|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 94]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     94|      return;
  221|     94|    } 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|     94|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  230|     94|  validation_result verify_valid_input(FromSpan src) const {
  231|     94|    validation_result ret{};
  232|       |
  233|     94|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|     94|    const auto implementations = get_supported_implementations();
  235|     94|    std::vector<simdutf::result> results;
  236|     94|    results.reserve(implementations.size());
  237|       |
  238|    282|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 282, False: 94]
  ------------------
  239|    282|      results.push_back(
  240|    282|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    282|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    282|      const bool validation2 =
  245|    282|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    282|                      src.data(), src.size());
  247|    282|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 282]
  ------------------
  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|    282|    }
  258|       |
  259|     94|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|     94|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 94]
  ------------------
  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|     94|    } else {
  273|     94|      ret.implementations_agree = true;
  274|     94|    }
  275|     94|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|     94|      return r.error == simdutf::SUCCESS;
  277|     94|    });
  278|     94|    return ret;
  279|     94|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    188|    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|    158|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    158|      return r.error == simdutf::SUCCESS;
  277|    158|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     94|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     94|    length_result ret{};
  344|       |
  345|     94|    const auto implementations = get_supported_implementations();
  346|     94|    std::vector<std::size_t> results;
  347|     94|    results.reserve(implementations.size());
  348|       |
  349|    282|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 282, False: 94]
  ------------------
  350|    282|      const auto len = invoke_lengthcalc(impl, src);
  351|    282|      results.push_back(len);
  352|    282|      ret.length.push_back(len);
  353|    282|    }
  354|       |
  355|     94|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     94|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 94]
  ------------------
  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|     94|    } else {
  375|     94|      ret.implementations_agree = true;
  376|     94|    }
  377|     94|    return ret;
  378|     94|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    282|                                FromSpan src) const {
  339|    282|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    282|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    188|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     94|                                  const bool inputisvalid) const {
  383|     94|    conversion_result ret{};
  384|       |
  385|     94|    const auto implementations = get_supported_implementations();
  386|       |
  387|     94|    std::vector<result<ConversionResult>> results;
  388|     94|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     94|    std::vector<std::vector<ToType>> outputbuffers;
  393|     94|    outputbuffers.reserve(implementations.size());
  394|    376|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 282, False: 94]
  ------------------
  395|    282|      auto impl = implementations[i];
  396|    282|      const ToType canary1{42};
  397|    282|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    282|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    282|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    282|      const auto success = [](const ConversionResult& r) -> bool {
  402|    282|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    282|          return r != 0;
  404|    282|        } else {
  405|    282|          return r.error == simdutf::error_code::SUCCESS;
  406|    282|        }
  407|    282|      }(implret1);
  408|    282|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    282|      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|    282|        const ToType canary2{25};
  414|    282|        const auto outputbuffer_first_run = outputbuffer;
  415|    282|        std::ranges::fill(outputbuffer, canary2);
  416|    282|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    282|                                          src.size(), outputbuffer.data());
  418|       |
  419|    282|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 282]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    282|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 96, False: 186]
  |  Branch (423:29): [True: 84, False: 12]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|     84|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|     84|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 84]
  ------------------
  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|     84|        }
  440|    282|      }
  441|    282|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 84, False: 198]
  ------------------
  442|    282|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     94|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 62, False: 32]
  ------------------
  447|    186|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 186, False: 62]
  ------------------
  448|    186|        e.outputhash.clear();
  449|    186|      }
  450|     62|    }
  451|       |
  452|     94|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     94|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 94]
  ------------------
  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|     94|    } else {
  474|     94|      ret.implementations_agree = true;
  475|     94|    }
  476|     94|    return ret;
  477|     94|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    282|      const auto success = [](const ConversionResult& r) -> bool {
  402|    282|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    282|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    282|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    188|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_17clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    221|    +[](std::span<const char> chardata) {                                      \
  555|    221|      const auto c =                                                           \
  556|    221|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    221|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    221|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    221|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    221|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    221|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    221|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    221|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    221|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    221|  constexpr auto _size = _name.size();                                \
  |  | 1183|    221|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    221|  return _nameof; }()
  ------------------
  561|    221|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    221|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    221|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    221|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    221|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    221|  constexpr auto _size = _name.size();                                \
  |  | 1183|    221|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    221|  return _nameof; }()
  ------------------
  562|    221|      c.fuzz(chardata);                                                        \
  563|    221|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_18clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    216|    +[](std::span<const char> chardata) {                                      \
  555|    216|      const auto c =                                                           \
  556|    216|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    216|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    216|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    216|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    216|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    216|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    216|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    216|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    216|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    216|  constexpr auto _size = _name.size();                                \
  |  | 1183|    216|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    216|  return _nameof; }()
  ------------------
  561|    216|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    216|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    216|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    216|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    216|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    216|  constexpr auto _size = _name.size();                                \
  |  | 1183|    216|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    216|  return _nameof; }()
  ------------------
  562|    216|      c.fuzz(chardata);                                                        \
  563|    216|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_19clENSt3__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|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_20clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    281|    +[](std::span<const char> chardata) {                                      \
  555|    281|      const auto c =                                                           \
  556|    281|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    281|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    281|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    281|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    281|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    281|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    281|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    281|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    281|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    281|  constexpr auto _size = _name.size();                                \
  |  | 1183|    281|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    281|  return _nameof; }()
  ------------------
  561|    281|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    281|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    281|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    281|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    281|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    281|  constexpr auto _size = _name.size();                                \
  |  | 1183|    281|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    281|  return _nameof; }()
  ------------------
  562|    281|      c.fuzz(chardata);                                                        \
  563|    281|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    281|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    281|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    281|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    281|    static const bool do_print_testcase =
  181|    281|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    281|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 281]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    281|    do {
  189|       |      // step 0 - is the input valid?
  190|    281|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    281|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 281]
  |  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|    281|                    From == UtfEncodings::UTF8) {
  198|    281|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 281]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    281|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    281|      const auto [output_length, length_agree] =
  204|    281|          calculate_length(from, inputisvalid);
  205|    281|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 281]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    281|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 186, False: 95]
  |  Branch (208:28): [True: 0, False: 186]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    281|      const auto [written, outputs_agree] =
  215|    281|          do_conversion(from, output_length, inputisvalid);
  216|    281|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 281]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    281|      return;
  221|    281|    } 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|    281|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    281|  validation_result verify_valid_input(FromSpan src) const {
  231|    281|    validation_result ret{};
  232|       |
  233|    281|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    281|    const auto implementations = get_supported_implementations();
  235|    281|    std::vector<simdutf::result> results;
  236|    281|    results.reserve(implementations.size());
  237|       |
  238|    843|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 843, False: 281]
  ------------------
  239|    843|      results.push_back(
  240|    843|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    843|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    843|      const bool validation2 =
  245|    843|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    843|                      src.data(), src.size());
  247|    843|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 843]
  ------------------
  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|    843|    }
  258|       |
  259|    281|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    281|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 281]
  ------------------
  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|    281|    } else {
  273|    281|      ret.implementations_agree = true;
  274|    281|    }
  275|    281|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    281|      return r.error == simdutf::SUCCESS;
  277|    281|    });
  278|    281|    return ret;
  279|    281|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    562|    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|    471|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    471|      return r.error == simdutf::SUCCESS;
  277|    471|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    281|  bool count_the_input(FromSpan src) const {
  290|    281|    const auto implementations = get_supported_implementations();
  291|    281|    std::vector<std::size_t> results;
  292|    281|    results.reserve(implementations.size());
  293|       |
  294|    843|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 843, False: 281]
  ------------------
  295|    843|      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|    843|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|    843|        ret = impl->count_utf8(src.data(), src.size());
  302|    843|      }
  303|    843|      results.push_back(ret);
  304|    843|    }
  305|    281|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    281|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 281]
  ------------------
  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|    281|    return true;
  321|    281|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    562|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    281|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    281|    length_result ret{};
  344|       |
  345|    281|    const auto implementations = get_supported_implementations();
  346|    281|    std::vector<std::size_t> results;
  347|    281|    results.reserve(implementations.size());
  348|       |
  349|    843|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 843, False: 281]
  ------------------
  350|    843|      const auto len = invoke_lengthcalc(impl, src);
  351|    843|      results.push_back(len);
  352|    843|      ret.length.push_back(len);
  353|    843|    }
  354|       |
  355|    281|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    281|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 281]
  ------------------
  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|    281|    } else {
  375|    281|      ret.implementations_agree = true;
  376|    281|    }
  377|    281|    return ret;
  378|    281|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    843|                                FromSpan src) const {
  331|    843|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    843|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    562|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    281|                                  const bool inputisvalid) const {
  383|    281|    conversion_result ret{};
  384|       |
  385|    281|    const auto implementations = get_supported_implementations();
  386|       |
  387|    281|    std::vector<result<ConversionResult>> results;
  388|    281|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    281|    std::vector<std::vector<ToType>> outputbuffers;
  393|    281|    outputbuffers.reserve(implementations.size());
  394|  1.12k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 843, False: 281]
  ------------------
  395|    843|      auto impl = implementations[i];
  396|    843|      const ToType canary1{42};
  397|    843|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    843|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    843|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    843|      const auto success = [](const ConversionResult& r) -> bool {
  402|    843|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    843|          return r != 0;
  404|    843|        } else {
  405|    843|          return r.error == simdutf::error_code::SUCCESS;
  406|    843|        }
  407|    843|      }(implret1);
  408|    843|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    843|      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|    843|        const ToType canary2{25};
  414|    843|        const auto outputbuffer_first_run = outputbuffer;
  415|    843|        std::ranges::fill(outputbuffer, canary2);
  416|    843|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    843|                                          src.size(), outputbuffer.data());
  418|       |
  419|    843|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 843]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    843|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 285, False: 558]
  |  Branch (423:29): [True: 258, False: 27]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    258|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    258|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 258]
  ------------------
  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|    258|        }
  440|    843|      }
  441|    843|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 258, False: 585]
  ------------------
  442|    843|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    281|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 186, False: 95]
  ------------------
  447|    558|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 558, False: 186]
  ------------------
  448|    558|        e.outputhash.clear();
  449|    558|      }
  450|    186|    }
  451|       |
  452|    281|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    281|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 281]
  ------------------
  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|    281|    } else {
  474|    281|      ret.implementations_agree = true;
  475|    281|    }
  476|    281|    return ret;
  477|    281|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    843|      const auto success = [](const ConversionResult& r) -> bool {
  402|    843|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    843|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    843|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    562|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_21clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    356|    +[](std::span<const char> chardata) {                                      \
  555|    356|      const auto c =                                                           \
  556|    356|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    356|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    356|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    356|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    356|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    356|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    356|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    356|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    356|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    356|  constexpr auto _size = _name.size();                                \
  |  | 1183|    356|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    356|  return _nameof; }()
  ------------------
  561|    356|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    356|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    356|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    356|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    356|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    356|  constexpr auto _size = _name.size();                                \
  |  | 1183|    356|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    356|  return _nameof; }()
  ------------------
  562|    356|      c.fuzz(chardata);                                                        \
  563|    356|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_22clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    330|    +[](std::span<const char> chardata) {                                      \
  555|    330|      const auto c =                                                           \
  556|    330|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    330|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    330|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    330|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    330|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    330|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    330|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    330|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    330|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    330|  constexpr auto _size = _name.size();                                \
  |  | 1183|    330|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    330|  return _nameof; }()
  ------------------
  561|    330|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    330|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    330|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    330|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    330|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    330|  constexpr auto _size = _name.size();                                \
  |  | 1183|    330|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    330|  return _nameof; }()
  ------------------
  562|    330|      c.fuzz(chardata);                                                        \
  563|    330|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_23clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    356|    +[](std::span<const char> chardata) {                                      \
  555|    356|      const auto c =                                                           \
  556|    356|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    356|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    356|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    356|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    356|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    356|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    356|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    356|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    356|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    356|  constexpr auto _size = _name.size();                                \
  |  | 1183|    356|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    356|  return _nameof; }()
  ------------------
  561|    356|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    356|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    356|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    356|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    356|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    356|  constexpr auto _size = _name.size();                                \
  |  | 1183|    356|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    356|  return _nameof; }()
  ------------------
  562|    356|      c.fuzz(chardata);                                                        \
  563|    356|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_24clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    126|    +[](std::span<const char> chardata) {                                      \
  555|    126|      const auto c =                                                           \
  556|    126|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    126|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    126|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    126|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    126|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    126|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    126|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    126|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    126|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    126|  constexpr auto _size = _name.size();                                \
  |  | 1183|    126|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    126|  return _nameof; }()
  ------------------
  561|    126|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    126|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    126|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    126|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    126|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    126|  constexpr auto _size = _name.size();                                \
  |  | 1183|    126|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    126|  return _nameof; }()
  ------------------
  562|    126|      c.fuzz(chardata);                                                        \
  563|    126|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    126|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    126|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    126|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    126|    static const bool do_print_testcase =
  181|    126|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    126|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 126]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    126|    do {
  189|       |      // step 0 - is the input valid?
  190|    126|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    126|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 126]
  |  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|    126|                    From == UtfEncodings::UTF8) {
  198|    126|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 126]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    126|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    126|      const auto [output_length, length_agree] =
  204|    126|          calculate_length(from, inputisvalid);
  205|    126|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 126]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    126|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 21, False: 105]
  |  Branch (208:28): [True: 0, False: 21]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    126|      const auto [written, outputs_agree] =
  215|    126|          do_conversion(from, output_length, inputisvalid);
  216|    126|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 126]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    126|      return;
  221|    126|    } 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|    126|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEE:
  230|    126|  validation_result verify_valid_input(FromSpan src) const {
  231|    126|    validation_result ret{};
  232|       |
  233|    126|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    126|    const auto implementations = get_supported_implementations();
  235|    126|    std::vector<simdutf::result> results;
  236|    126|    results.reserve(implementations.size());
  237|       |
  238|    378|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 378, False: 126]
  ------------------
  239|    378|      results.push_back(
  240|    378|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    378|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    378|      const bool validation2 =
  245|    378|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    378|                      src.data(), src.size());
  247|    378|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 378]
  ------------------
  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|    378|    }
  258|       |
  259|    126|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    126|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 126]
  ------------------
  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|    126|    } else {
  273|    126|      ret.implementations_agree = true;
  274|    126|    }
  275|    126|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    126|      return r.error == simdutf::SUCCESS;
  277|    126|    });
  278|    126|    return ret;
  279|    126|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS5_S5_EEDaSJ_SM_:
  259|    252|    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|    336|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    336|      return r.error == simdutf::SUCCESS;
  277|    336|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE15count_the_inputENSt3__14spanIS6_Lm18446744073709551615EEE:
  289|    126|  bool count_the_input(FromSpan src) const {
  290|    126|    const auto implementations = get_supported_implementations();
  291|    126|    std::vector<std::size_t> results;
  292|    126|    results.reserve(implementations.size());
  293|       |
  294|    378|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 378, False: 126]
  ------------------
  295|    378|      std::size_t ret;
  296|    378|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    378|        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|    378|      results.push_back(ret);
  304|    378|    }
  305|    126|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    126|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 126]
  ------------------
  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|    126|    return true;
  321|    126|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE15count_the_inputENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    252|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEb:
  342|    126|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    126|    length_result ret{};
  344|       |
  345|    126|    const auto implementations = get_supported_implementations();
  346|    126|    std::vector<std::size_t> results;
  347|    126|    results.reserve(implementations.size());
  348|       |
  349|    378|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 378, False: 126]
  ------------------
  350|    378|      const auto len = invoke_lengthcalc(impl, src);
  351|    378|      results.push_back(len);
  352|    378|      ret.length.push_back(len);
  353|    378|    }
  354|       |
  355|    126|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    126|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 126]
  ------------------
  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|    126|    } else {
  375|    126|      ret.implementations_agree = true;
  376|    126|    }
  377|    126|    return ret;
  378|    126|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSF_NSt3__14spanIS6_Lm18446744073709551615EEE:
  338|    378|                                FromSpan src) const {
  339|    378|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    378|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    252|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    126|                                  const bool inputisvalid) const {
  383|    126|    conversion_result ret{};
  384|       |
  385|    126|    const auto implementations = get_supported_implementations();
  386|       |
  387|    126|    std::vector<result<ConversionResult>> results;
  388|    126|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    126|    std::vector<std::vector<ToType>> outputbuffers;
  393|    126|    outputbuffers.reserve(implementations.size());
  394|    504|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 378, False: 126]
  ------------------
  395|    378|      auto impl = implementations[i];
  396|    378|      const ToType canary1{42};
  397|    378|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    378|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    378|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    378|      const auto success = [](const ConversionResult& r) -> bool {
  402|    378|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    378|          return r != 0;
  404|    378|        } else {
  405|    378|          return r.error == simdutf::error_code::SUCCESS;
  406|    378|        }
  407|    378|      }(implret1);
  408|    378|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    378|      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|    378|        const ToType canary2{25};
  414|    378|        const auto outputbuffer_first_run = outputbuffer;
  415|    378|        std::ranges::fill(outputbuffer, canary2);
  416|    378|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    378|                                          src.size(), outputbuffer.data());
  418|       |
  419|    378|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 378]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    378|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 315, False: 63]
  |  Branch (423:29): [True: 144, False: 171]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    144|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    144|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 144]
  ------------------
  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|    144|        }
  440|    378|      }
  441|    378|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 144, False: 234]
  ------------------
  442|    378|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    126|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 21, False: 105]
  ------------------
  447|     63|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 63, False: 21]
  ------------------
  448|     63|        e.outputhash.clear();
  449|     63|      }
  450|     21|    }
  451|       |
  452|    126|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    126|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 126]
  ------------------
  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|    126|    } else {
  474|    126|      ret.implementations_agree = true;
  475|    126|    }
  476|    126|    return ret;
  477|    126|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS5_E_clESM_:
  401|    378|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    378|        } else {
  405|    378|          return r.error == simdutf::error_code::SUCCESS;
  406|    378|        }
  407|    378|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS5_ESU_EEDaSN_SQ_:
  452|    252|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_25clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    150|    +[](std::span<const char> chardata) {                                      \
  555|    150|      const auto c =                                                           \
  556|    150|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    150|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    150|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    150|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    150|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    150|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    150|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    150|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    150|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    150|  constexpr auto _size = _name.size();                                \
  |  | 1183|    150|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    150|  return _nameof; }()
  ------------------
  561|    150|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    150|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    150|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    150|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    150|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    150|  constexpr auto _size = _name.size();                                \
  |  | 1183|    150|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    150|  return _nameof; }()
  ------------------
  562|    150|      c.fuzz(chardata);                                                        \
  563|    150|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    150|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    150|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    150|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    150|    static const bool do_print_testcase =
  181|    150|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    150|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 150]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    150|    do {
  189|       |      // step 0 - is the input valid?
  190|    150|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    150|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 150]
  |  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|    150|                    From == UtfEncodings::UTF8) {
  198|    150|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 150]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    150|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    150|      const auto [output_length, length_agree] =
  204|    150|          calculate_length(from, inputisvalid);
  205|    150|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 150]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    150|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 70, False: 80]
  |  Branch (208:28): [True: 0, False: 70]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    150|      const auto [written, outputs_agree] =
  215|    150|          do_conversion(from, output_length, inputisvalid);
  216|    150|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 150]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    150|      return;
  221|    150|    } 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|    150|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    150|  validation_result verify_valid_input(FromSpan src) const {
  231|    150|    validation_result ret{};
  232|       |
  233|    150|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    150|    const auto implementations = get_supported_implementations();
  235|    150|    std::vector<simdutf::result> results;
  236|    150|    results.reserve(implementations.size());
  237|       |
  238|    450|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 450, False: 150]
  ------------------
  239|    450|      results.push_back(
  240|    450|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    450|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    450|      const bool validation2 =
  245|    450|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    450|                      src.data(), src.size());
  247|    450|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 450]
  ------------------
  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|    450|    }
  258|       |
  259|    150|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    150|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 150]
  ------------------
  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|    150|    } else {
  273|    150|      ret.implementations_agree = true;
  274|    150|    }
  275|    150|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    150|      return r.error == simdutf::SUCCESS;
  277|    150|    });
  278|    150|    return ret;
  279|    150|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    300|    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|    310|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    310|      return r.error == simdutf::SUCCESS;
  277|    310|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    150|  bool count_the_input(FromSpan src) const {
  290|    150|    const auto implementations = get_supported_implementations();
  291|    150|    std::vector<std::size_t> results;
  292|    150|    results.reserve(implementations.size());
  293|       |
  294|    450|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 450, False: 150]
  ------------------
  295|    450|      std::size_t ret;
  296|    450|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    450|        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|    450|      results.push_back(ret);
  304|    450|    }
  305|    150|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    150|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 150]
  ------------------
  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|    150|    return true;
  321|    150|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    300|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    150|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    150|    length_result ret{};
  344|       |
  345|    150|    const auto implementations = get_supported_implementations();
  346|    150|    std::vector<std::size_t> results;
  347|    150|    results.reserve(implementations.size());
  348|       |
  349|    450|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 450, False: 150]
  ------------------
  350|    450|      const auto len = invoke_lengthcalc(impl, src);
  351|    450|      results.push_back(len);
  352|    450|      ret.length.push_back(len);
  353|    450|    }
  354|       |
  355|    150|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    150|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 150]
  ------------------
  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|    150|    } else {
  375|    150|      ret.implementations_agree = true;
  376|    150|    }
  377|    150|    return ret;
  378|    150|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    450|                                FromSpan src) const {
  331|    450|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    450|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    300|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    150|                                  const bool inputisvalid) const {
  383|    150|    conversion_result ret{};
  384|       |
  385|    150|    const auto implementations = get_supported_implementations();
  386|       |
  387|    150|    std::vector<result<ConversionResult>> results;
  388|    150|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    150|    std::vector<std::vector<ToType>> outputbuffers;
  393|    150|    outputbuffers.reserve(implementations.size());
  394|    600|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 450, False: 150]
  ------------------
  395|    450|      auto impl = implementations[i];
  396|    450|      const ToType canary1{42};
  397|    450|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    450|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    450|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    450|      const auto success = [](const ConversionResult& r) -> bool {
  402|    450|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    450|          return r != 0;
  404|    450|        } else {
  405|    450|          return r.error == simdutf::error_code::SUCCESS;
  406|    450|        }
  407|    450|      }(implret1);
  408|    450|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    450|      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|    450|        const ToType canary2{25};
  414|    450|        const auto outputbuffer_first_run = outputbuffer;
  415|    450|        std::ranges::fill(outputbuffer, canary2);
  416|    450|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    450|                                          src.size(), outputbuffer.data());
  418|       |
  419|    450|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 450]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    450|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 240, False: 210]
  |  Branch (423:29): [True: 240, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    240|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    240|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 240]
  ------------------
  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|    240|        }
  440|    450|      }
  441|    450|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 240, False: 210]
  ------------------
  442|    450|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    150|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 70, False: 80]
  ------------------
  447|    210|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 210, False: 70]
  ------------------
  448|    210|        e.outputhash.clear();
  449|    210|      }
  450|     70|    }
  451|       |
  452|    150|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    150|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 150]
  ------------------
  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|    150|    } else {
  474|    150|      ret.implementations_agree = true;
  475|    150|    }
  476|    150|    return ret;
  477|    150|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    450|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    450|        } else {
  405|    450|          return r.error == simdutf::error_code::SUCCESS;
  406|    450|        }
  407|    450|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    300|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_26clENSt3__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|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  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: 125, False: 168]
  |  Branch (208:28): [True: 0, False: 125]
  ------------------
  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|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_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|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    586|    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|    629|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    629|      return r.error == simdutf::SUCCESS;
  277|    629|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_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|    879|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    879|        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|    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|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    586|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_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|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    879|                                FromSpan src) const {
  331|    879|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    879|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    586|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_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: 504, False: 375]
  |  Branch (423:29): [True: 504, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    504|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    504|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 504]
  ------------------
  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|    504|        }
  440|    879|      }
  441|    879|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 504, False: 375]
  ------------------
  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: 125, False: 168]
  ------------------
  447|    375|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 375, False: 125]
  ------------------
  448|    375|        e.outputhash.clear();
  449|    375|      }
  450|    125|    }
  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|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    879|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    879|        } else {
  405|    879|          return r.error == simdutf::error_code::SUCCESS;
  406|    879|        }
  407|    879|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    586|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_27clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    115|    +[](std::span<const char> chardata) {                                      \
  555|    115|      const auto c =                                                           \
  556|    115|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    115|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    115|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    115|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    115|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    115|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    115|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    115|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    115|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    115|  constexpr auto _size = _name.size();                                \
  |  | 1183|    115|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    115|  return _nameof; }()
  ------------------
  561|    115|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    115|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    115|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    115|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    115|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    115|  constexpr auto _size = _name.size();                                \
  |  | 1183|    115|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    115|  return _nameof; }()
  ------------------
  562|    115|      c.fuzz(chardata);                                                        \
  563|    115|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    115|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    115|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    115|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    115|    static const bool do_print_testcase =
  181|    115|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    115|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 115]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    115|    do {
  189|       |      // step 0 - is the input valid?
  190|    115|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    115|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 115]
  |  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|    115|                    From == UtfEncodings::UTF8) {
  198|    115|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 115]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    115|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    115|      const auto [output_length, length_agree] =
  204|    115|          calculate_length(from, inputisvalid);
  205|    115|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 115]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    115|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 21, False: 94]
  |  Branch (208:28): [True: 0, False: 21]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    115|      const auto [written, outputs_agree] =
  215|    115|          do_conversion(from, output_length, inputisvalid);
  216|    115|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 115]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    115|      return;
  221|    115|    } 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|    115|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEE:
  230|    115|  validation_result verify_valid_input(FromSpan src) const {
  231|    115|    validation_result ret{};
  232|       |
  233|    115|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    115|    const auto implementations = get_supported_implementations();
  235|    115|    std::vector<simdutf::result> results;
  236|    115|    results.reserve(implementations.size());
  237|       |
  238|    345|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 345, False: 115]
  ------------------
  239|    345|      results.push_back(
  240|    345|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    345|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    345|      const bool validation2 =
  245|    345|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    345|                      src.data(), src.size());
  247|    345|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 345]
  ------------------
  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|    345|    }
  258|       |
  259|    115|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    115|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 115]
  ------------------
  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|    115|    } else {
  273|    115|      ret.implementations_agree = true;
  274|    115|    }
  275|    115|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    115|      return r.error == simdutf::SUCCESS;
  277|    115|    });
  278|    115|    return ret;
  279|    115|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS5_S5_EEDaSJ_SM_:
  259|    230|    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|    303|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    303|      return r.error == simdutf::SUCCESS;
  277|    303|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE15count_the_inputENSt3__14spanIS6_Lm18446744073709551615EEE:
  289|    115|  bool count_the_input(FromSpan src) const {
  290|    115|    const auto implementations = get_supported_implementations();
  291|    115|    std::vector<std::size_t> results;
  292|    115|    results.reserve(implementations.size());
  293|       |
  294|    345|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 345, False: 115]
  ------------------
  295|    345|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    345|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    345|        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|    345|      results.push_back(ret);
  304|    345|    }
  305|    115|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    115|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 115]
  ------------------
  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|    115|    return true;
  321|    115|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE15count_the_inputENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    230|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEb:
  342|    115|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    115|    length_result ret{};
  344|       |
  345|    115|    const auto implementations = get_supported_implementations();
  346|    115|    std::vector<std::size_t> results;
  347|    115|    results.reserve(implementations.size());
  348|       |
  349|    345|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 345, False: 115]
  ------------------
  350|    345|      const auto len = invoke_lengthcalc(impl, src);
  351|    345|      results.push_back(len);
  352|    345|      ret.length.push_back(len);
  353|    345|    }
  354|       |
  355|    115|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    115|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 115]
  ------------------
  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|    115|    } else {
  375|    115|      ret.implementations_agree = true;
  376|    115|    }
  377|    115|    return ret;
  378|    115|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSF_NSt3__14spanIS6_Lm18446744073709551615EEE:
  338|    345|                                FromSpan src) const {
  339|    345|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    345|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    230|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    115|                                  const bool inputisvalid) const {
  383|    115|    conversion_result ret{};
  384|       |
  385|    115|    const auto implementations = get_supported_implementations();
  386|       |
  387|    115|    std::vector<result<ConversionResult>> results;
  388|    115|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    115|    std::vector<std::vector<ToType>> outputbuffers;
  393|    115|    outputbuffers.reserve(implementations.size());
  394|    460|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 345, False: 115]
  ------------------
  395|    345|      auto impl = implementations[i];
  396|    345|      const ToType canary1{42};
  397|    345|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    345|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    345|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    345|      const auto success = [](const ConversionResult& r) -> bool {
  402|    345|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    345|          return r != 0;
  404|    345|        } else {
  405|    345|          return r.error == simdutf::error_code::SUCCESS;
  406|    345|        }
  407|    345|      }(implret1);
  408|    345|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    345|      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|    345|        const ToType canary2{25};
  414|    345|        const auto outputbuffer_first_run = outputbuffer;
  415|    345|        std::ranges::fill(outputbuffer, canary2);
  416|    345|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    345|                                          src.size(), outputbuffer.data());
  418|       |
  419|    345|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 345]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    345|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 282, False: 63]
  |  Branch (423:29): [True: 123, False: 159]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    123|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    123|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 123]
  ------------------
  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|    123|        }
  440|    345|      }
  441|    345|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 123, False: 222]
  ------------------
  442|    345|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    115|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 21, False: 94]
  ------------------
  447|     63|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 63, False: 21]
  ------------------
  448|     63|        e.outputhash.clear();
  449|     63|      }
  450|     21|    }
  451|       |
  452|    115|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    115|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 115]
  ------------------
  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|    115|    } else {
  474|    115|      ret.implementations_agree = true;
  475|    115|    }
  476|    115|    return ret;
  477|    115|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS5_E_clESM_:
  401|    345|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    345|        } else {
  405|    345|          return r.error == simdutf::error_code::SUCCESS;
  406|    345|        }
  407|    345|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS5_ESU_EEDaSN_SQ_:
  452|    230|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_28clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    207|    +[](std::span<const char> chardata) {                                      \
  555|    207|      const auto c =                                                           \
  556|    207|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    207|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    207|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    207|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    207|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    207|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    207|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    207|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    207|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    207|  constexpr auto _size = _name.size();                                \
  |  | 1183|    207|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    207|  return _nameof; }()
  ------------------
  561|    207|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    207|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    207|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    207|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    207|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    207|  constexpr auto _size = _name.size();                                \
  |  | 1183|    207|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    207|  return _nameof; }()
  ------------------
  562|    207|      c.fuzz(chardata);                                                        \
  563|    207|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    207|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    207|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    207|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    207|    static const bool do_print_testcase =
  181|    207|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    207|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 207]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    207|    do {
  189|       |      // step 0 - is the input valid?
  190|    207|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    207|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 207]
  |  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|    207|                    From == UtfEncodings::UTF8) {
  198|    207|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 207]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    207|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    207|      const auto [output_length, length_agree] =
  204|    207|          calculate_length(from, inputisvalid);
  205|    207|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 207]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    207|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 112, False: 95]
  |  Branch (208:28): [True: 0, False: 112]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    207|      const auto [written, outputs_agree] =
  215|    207|          do_conversion(from, output_length, inputisvalid);
  216|    207|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 207]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    207|      return;
  221|    207|    } 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|    207|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    207|  validation_result verify_valid_input(FromSpan src) const {
  231|    207|    validation_result ret{};
  232|       |
  233|    207|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    207|    const auto implementations = get_supported_implementations();
  235|    207|    std::vector<simdutf::result> results;
  236|    207|    results.reserve(implementations.size());
  237|       |
  238|    621|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 621, False: 207]
  ------------------
  239|    621|      results.push_back(
  240|    621|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    621|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    621|      const bool validation2 =
  245|    621|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    621|                      src.data(), src.size());
  247|    621|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 621]
  ------------------
  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|    621|    }
  258|       |
  259|    207|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    207|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 207]
  ------------------
  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|    207|    } else {
  273|    207|      ret.implementations_agree = true;
  274|    207|    }
  275|    207|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    207|      return r.error == simdutf::SUCCESS;
  277|    207|    });
  278|    207|    return ret;
  279|    207|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    414|    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|    397|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    397|      return r.error == simdutf::SUCCESS;
  277|    397|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    207|  bool count_the_input(FromSpan src) const {
  290|    207|    const auto implementations = get_supported_implementations();
  291|    207|    std::vector<std::size_t> results;
  292|    207|    results.reserve(implementations.size());
  293|       |
  294|    621|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 621, False: 207]
  ------------------
  295|    621|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    621|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    621|        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|    621|      results.push_back(ret);
  304|    621|    }
  305|    207|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    207|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 207]
  ------------------
  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|    207|    return true;
  321|    207|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    414|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    207|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    207|    length_result ret{};
  344|       |
  345|    207|    const auto implementations = get_supported_implementations();
  346|    207|    std::vector<std::size_t> results;
  347|    207|    results.reserve(implementations.size());
  348|       |
  349|    621|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 621, False: 207]
  ------------------
  350|    621|      const auto len = invoke_lengthcalc(impl, src);
  351|    621|      results.push_back(len);
  352|    621|      ret.length.push_back(len);
  353|    621|    }
  354|       |
  355|    207|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    207|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 207]
  ------------------
  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|    207|    } else {
  375|    207|      ret.implementations_agree = true;
  376|    207|    }
  377|    207|    return ret;
  378|    207|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    621|                                FromSpan src) const {
  331|    621|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    621|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    414|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    207|                                  const bool inputisvalid) const {
  383|    207|    conversion_result ret{};
  384|       |
  385|    207|    const auto implementations = get_supported_implementations();
  386|       |
  387|    207|    std::vector<result<ConversionResult>> results;
  388|    207|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    207|    std::vector<std::vector<ToType>> outputbuffers;
  393|    207|    outputbuffers.reserve(implementations.size());
  394|    828|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 621, False: 207]
  ------------------
  395|    621|      auto impl = implementations[i];
  396|    621|      const ToType canary1{42};
  397|    621|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    621|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    621|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    621|      const auto success = [](const ConversionResult& r) -> bool {
  402|    621|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    621|          return r != 0;
  404|    621|        } else {
  405|    621|          return r.error == simdutf::error_code::SUCCESS;
  406|    621|        }
  407|    621|      }(implret1);
  408|    621|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    621|      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|    621|        const ToType canary2{25};
  414|    621|        const auto outputbuffer_first_run = outputbuffer;
  415|    621|        std::ranges::fill(outputbuffer, canary2);
  416|    621|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    621|                                          src.size(), outputbuffer.data());
  418|       |
  419|    621|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 621]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    621|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 285, False: 336]
  |  Branch (423:29): [True: 285, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    285|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    285|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 285]
  ------------------
  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|    285|        }
  440|    621|      }
  441|    621|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 285, False: 336]
  ------------------
  442|    621|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    207|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 112, False: 95]
  ------------------
  447|    336|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 336, False: 112]
  ------------------
  448|    336|        e.outputhash.clear();
  449|    336|      }
  450|    112|    }
  451|       |
  452|    207|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    207|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 207]
  ------------------
  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|    207|    } else {
  474|    207|      ret.implementations_agree = true;
  475|    207|    }
  476|    207|    return ret;
  477|    207|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    621|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    621|        } else {
  405|    621|          return r.error == simdutf::error_code::SUCCESS;
  406|    621|        }
  407|    621|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    414|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_29clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    315|    +[](std::span<const char> chardata) {                                      \
  555|    315|      const auto c =                                                           \
  556|    315|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    315|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    315|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    315|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    315|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    315|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    315|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    315|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    315|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    315|  constexpr auto _size = _name.size();                                \
  |  | 1183|    315|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    315|  return _nameof; }()
  ------------------
  561|    315|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    315|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    315|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    315|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    315|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    315|  constexpr auto _size = _name.size();                                \
  |  | 1183|    315|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    315|  return _nameof; }()
  ------------------
  562|    315|      c.fuzz(chardata);                                                        \
  563|    315|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    315|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    315|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    315|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    315|    static const bool do_print_testcase =
  181|    315|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    315|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 315]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    315|    do {
  189|       |      // step 0 - is the input valid?
  190|    315|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    315|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 315]
  |  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|    315|                    From == UtfEncodings::UTF8) {
  198|    315|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 315]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    315|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    315|      const auto [output_length, length_agree] =
  204|    315|          calculate_length(from, inputisvalid);
  205|    315|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 315]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    315|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 108, False: 207]
  |  Branch (208:28): [True: 0, False: 108]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    315|      const auto [written, outputs_agree] =
  215|    315|          do_conversion(from, output_length, inputisvalid);
  216|    315|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 315]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    315|      return;
  221|    315|    } 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|    315|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    315|  validation_result verify_valid_input(FromSpan src) const {
  231|    315|    validation_result ret{};
  232|       |
  233|    315|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    315|    const auto implementations = get_supported_implementations();
  235|    315|    std::vector<simdutf::result> results;
  236|    315|    results.reserve(implementations.size());
  237|       |
  238|    945|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 945, False: 315]
  ------------------
  239|    945|      results.push_back(
  240|    945|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    945|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    945|      const bool validation2 =
  245|    945|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    945|                      src.data(), src.size());
  247|    945|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 945]
  ------------------
  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|    945|    }
  258|       |
  259|    315|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    315|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 315]
  ------------------
  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|    315|    } else {
  273|    315|      ret.implementations_agree = true;
  274|    315|    }
  275|    315|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    315|      return r.error == simdutf::SUCCESS;
  277|    315|    });
  278|    315|    return ret;
  279|    315|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    630|    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|    729|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    729|      return r.error == simdutf::SUCCESS;
  277|    729|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    315|  bool count_the_input(FromSpan src) const {
  290|    315|    const auto implementations = get_supported_implementations();
  291|    315|    std::vector<std::size_t> results;
  292|    315|    results.reserve(implementations.size());
  293|       |
  294|    945|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 945, False: 315]
  ------------------
  295|    945|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    945|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    945|        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|    945|      results.push_back(ret);
  304|    945|    }
  305|    315|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    315|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 315]
  ------------------
  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|    315|    return true;
  321|    315|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    630|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    315|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    315|    length_result ret{};
  344|       |
  345|    315|    const auto implementations = get_supported_implementations();
  346|    315|    std::vector<std::size_t> results;
  347|    315|    results.reserve(implementations.size());
  348|       |
  349|    945|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 945, False: 315]
  ------------------
  350|    945|      const auto len = invoke_lengthcalc(impl, src);
  351|    945|      results.push_back(len);
  352|    945|      ret.length.push_back(len);
  353|    945|    }
  354|       |
  355|    315|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    315|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 315]
  ------------------
  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|    315|    } else {
  375|    315|      ret.implementations_agree = true;
  376|    315|    }
  377|    315|    return ret;
  378|    315|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    945|                                FromSpan src) const {
  331|    945|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    945|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    630|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    315|                                  const bool inputisvalid) const {
  383|    315|    conversion_result ret{};
  384|       |
  385|    315|    const auto implementations = get_supported_implementations();
  386|       |
  387|    315|    std::vector<result<ConversionResult>> results;
  388|    315|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    315|    std::vector<std::vector<ToType>> outputbuffers;
  393|    315|    outputbuffers.reserve(implementations.size());
  394|  1.26k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 945, False: 315]
  ------------------
  395|    945|      auto impl = implementations[i];
  396|    945|      const ToType canary1{42};
  397|    945|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    945|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    945|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    945|      const auto success = [](const ConversionResult& r) -> bool {
  402|    945|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    945|          return r != 0;
  404|    945|        } else {
  405|    945|          return r.error == simdutf::error_code::SUCCESS;
  406|    945|        }
  407|    945|      }(implret1);
  408|    945|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    945|      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|    945|        const ToType canary2{25};
  414|    945|        const auto outputbuffer_first_run = outputbuffer;
  415|    945|        std::ranges::fill(outputbuffer, canary2);
  416|    945|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    945|                                          src.size(), outputbuffer.data());
  418|       |
  419|    945|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 945]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    945|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 621, False: 324]
  |  Branch (423:29): [True: 621, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    621|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    621|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 621]
  ------------------
  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|    621|        }
  440|    945|      }
  441|    945|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 621, False: 324]
  ------------------
  442|    945|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    315|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 108, False: 207]
  ------------------
  447|    324|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 324, False: 108]
  ------------------
  448|    324|        e.outputhash.clear();
  449|    324|      }
  450|    108|    }
  451|       |
  452|    315|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    315|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 315]
  ------------------
  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|    315|    } else {
  474|    315|      ret.implementations_agree = true;
  475|    315|    }
  476|    315|    return ret;
  477|    315|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    945|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    945|        } else {
  405|    945|          return r.error == simdutf::error_code::SUCCESS;
  406|    945|        }
  407|    945|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    630|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_30clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    210|    +[](std::span<const char> chardata) {                                      \
  555|    210|      const auto c =                                                           \
  556|    210|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    210|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    210|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    210|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    210|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    210|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    210|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    210|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    210|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    210|  constexpr auto _size = _name.size();                                \
  |  | 1183|    210|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    210|  return _nameof; }()
  ------------------
  561|    210|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    210|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    210|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    210|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    210|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    210|  constexpr auto _size = _name.size();                                \
  |  | 1183|    210|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    210|  return _nameof; }()
  ------------------
  562|    210|      c.fuzz(chardata);                                                        \
  563|    210|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    210|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    210|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    210|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    210|    static const bool do_print_testcase =
  181|    210|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    210|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 210]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    210|    do {
  189|       |      // step 0 - is the input valid?
  190|    210|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    210|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 210]
  |  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|    210|      const auto [output_length, length_agree] =
  204|    210|          calculate_length(from, inputisvalid);
  205|    210|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 210]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    210|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 176, False: 34]
  |  Branch (208:28): [True: 0, False: 176]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    210|      const auto [written, outputs_agree] =
  215|    210|          do_conversion(from, output_length, inputisvalid);
  216|    210|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 210]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    210|      return;
  221|    210|    } 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|    210|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEE:
  230|    210|  validation_result verify_valid_input(FromSpan src) const {
  231|    210|    validation_result ret{};
  232|       |
  233|    210|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    210|    const auto implementations = get_supported_implementations();
  235|    210|    std::vector<simdutf::result> results;
  236|    210|    results.reserve(implementations.size());
  237|       |
  238|    630|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 630, False: 210]
  ------------------
  239|    630|      results.push_back(
  240|    630|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    630|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    630|      const bool validation2 =
  245|    630|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    630|                      src.data(), src.size());
  247|    630|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 630]
  ------------------
  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|    630|    }
  258|       |
  259|    210|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    210|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 210]
  ------------------
  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|    210|    } else {
  273|    210|      ret.implementations_agree = true;
  274|    210|    }
  275|    210|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    210|      return r.error == simdutf::SUCCESS;
  277|    210|    });
  278|    210|    return ret;
  279|    210|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS5_S5_EEDaSJ_SM_:
  259|    420|    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|    278|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    278|      return r.error == simdutf::SUCCESS;
  277|    278|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEb:
  342|    210|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    210|    length_result ret{};
  344|       |
  345|    210|    const auto implementations = get_supported_implementations();
  346|    210|    std::vector<std::size_t> results;
  347|    210|    results.reserve(implementations.size());
  348|       |
  349|    630|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 630, False: 210]
  ------------------
  350|    630|      const auto len = invoke_lengthcalc(impl, src);
  351|    630|      results.push_back(len);
  352|    630|      ret.length.push_back(len);
  353|    630|    }
  354|       |
  355|    210|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    210|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 210]
  ------------------
  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|    210|    } else {
  375|    210|      ret.implementations_agree = true;
  376|    210|    }
  377|    210|    return ret;
  378|    210|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSF_NSt3__14spanIS6_Lm18446744073709551615EEE:
  338|    630|                                FromSpan src) const {
  339|    630|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    630|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    420|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    210|                                  const bool inputisvalid) const {
  383|    210|    conversion_result ret{};
  384|       |
  385|    210|    const auto implementations = get_supported_implementations();
  386|       |
  387|    210|    std::vector<result<ConversionResult>> results;
  388|    210|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    210|    std::vector<std::vector<ToType>> outputbuffers;
  393|    210|    outputbuffers.reserve(implementations.size());
  394|    840|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 630, False: 210]
  ------------------
  395|    630|      auto impl = implementations[i];
  396|    630|      const ToType canary1{42};
  397|    630|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    630|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    630|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    630|      const auto success = [](const ConversionResult& r) -> bool {
  402|    630|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    630|          return r != 0;
  404|    630|        } else {
  405|    630|          return r.error == simdutf::error_code::SUCCESS;
  406|    630|        }
  407|    630|      }(implret1);
  408|    630|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    630|      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|    630|        const ToType canary2{25};
  414|    630|        const auto outputbuffer_first_run = outputbuffer;
  415|    630|        std::ranges::fill(outputbuffer, canary2);
  416|    630|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    630|                                          src.size(), outputbuffer.data());
  418|       |
  419|    630|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 630]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    630|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 102, False: 528]
  |  Branch (423:29): [True: 75, False: 27]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|     75|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|     75|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 75]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|     75|        }
  440|    630|      }
  441|    630|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 75, False: 555]
  ------------------
  442|    630|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    210|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 176, False: 34]
  ------------------
  447|    528|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 528, False: 176]
  ------------------
  448|    528|        e.outputhash.clear();
  449|    528|      }
  450|    176|    }
  451|       |
  452|    210|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    210|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 210]
  ------------------
  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|    210|    } else {
  474|    210|      ret.implementations_agree = true;
  475|    210|    }
  476|    210|    return ret;
  477|    210|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS5_E_clESM_:
  401|    630|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    630|        } else {
  405|    630|          return r.error == simdutf::error_code::SUCCESS;
  406|    630|        }
  407|    630|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS5_ESU_EEDaSN_SQ_:
  452|    420|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_31clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    303|    +[](std::span<const char> chardata) {                                      \
  555|    303|      const auto c =                                                           \
  556|    303|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    303|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    303|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    303|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    303|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    303|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    303|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    303|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    303|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    303|  constexpr auto _size = _name.size();                                \
  |  | 1183|    303|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    303|  return _nameof; }()
  ------------------
  561|    303|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    303|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    303|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    303|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    303|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    303|  constexpr auto _size = _name.size();                                \
  |  | 1183|    303|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    303|  return _nameof; }()
  ------------------
  562|    303|      c.fuzz(chardata);                                                        \
  563|    303|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    303|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    303|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    303|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    303|    static const bool do_print_testcase =
  181|    303|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    303|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 303]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    303|    do {
  189|       |      // step 0 - is the input valid?
  190|    303|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    303|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 303]
  |  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|    303|      const auto [output_length, length_agree] =
  204|    303|          calculate_length(from, inputisvalid);
  205|    303|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 303]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    303|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 217, False: 86]
  |  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|    303|      const auto [written, outputs_agree] =
  215|    303|          do_conversion(from, output_length, inputisvalid);
  216|    303|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 303]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    303|      return;
  221|    303|    } 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|    303|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    303|  validation_result verify_valid_input(FromSpan src) const {
  231|    303|    validation_result ret{};
  232|       |
  233|    303|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    303|    const auto implementations = get_supported_implementations();
  235|    303|    std::vector<simdutf::result> results;
  236|    303|    results.reserve(implementations.size());
  237|       |
  238|    909|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 909, False: 303]
  ------------------
  239|    909|      results.push_back(
  240|    909|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    909|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    909|      const bool validation2 =
  245|    909|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    909|                      src.data(), src.size());
  247|    909|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 909]
  ------------------
  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|    909|    }
  258|       |
  259|    303|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    303|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 303]
  ------------------
  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|    303|    } else {
  273|    303|      ret.implementations_agree = true;
  274|    303|    }
  275|    303|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    303|      return r.error == simdutf::SUCCESS;
  277|    303|    });
  278|    303|    return ret;
  279|    303|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    606|    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|    475|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    475|      return r.error == simdutf::SUCCESS;
  277|    475|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    303|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    303|    length_result ret{};
  344|       |
  345|    303|    const auto implementations = get_supported_implementations();
  346|    303|    std::vector<std::size_t> results;
  347|    303|    results.reserve(implementations.size());
  348|       |
  349|    909|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 909, False: 303]
  ------------------
  350|    909|      const auto len = invoke_lengthcalc(impl, src);
  351|    909|      results.push_back(len);
  352|    909|      ret.length.push_back(len);
  353|    909|    }
  354|       |
  355|    303|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    303|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 303]
  ------------------
  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|    303|    } else {
  375|    303|      ret.implementations_agree = true;
  376|    303|    }
  377|    303|    return ret;
  378|    303|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    909|                                FromSpan src) const {
  331|    909|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    909|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    606|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    303|                                  const bool inputisvalid) const {
  383|    303|    conversion_result ret{};
  384|       |
  385|    303|    const auto implementations = get_supported_implementations();
  386|       |
  387|    303|    std::vector<result<ConversionResult>> results;
  388|    303|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    303|    std::vector<std::vector<ToType>> outputbuffers;
  393|    303|    outputbuffers.reserve(implementations.size());
  394|  1.21k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 909, False: 303]
  ------------------
  395|    909|      auto impl = implementations[i];
  396|    909|      const ToType canary1{42};
  397|    909|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    909|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    909|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    909|      const auto success = [](const ConversionResult& r) -> bool {
  402|    909|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    909|          return r != 0;
  404|    909|        } else {
  405|    909|          return r.error == simdutf::error_code::SUCCESS;
  406|    909|        }
  407|    909|      }(implret1);
  408|    909|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    909|      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|    909|        const ToType canary2{25};
  414|    909|        const auto outputbuffer_first_run = outputbuffer;
  415|    909|        std::ranges::fill(outputbuffer, canary2);
  416|    909|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    909|                                          src.size(), outputbuffer.data());
  418|       |
  419|    909|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 909]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    909|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 258, False: 651]
  |  Branch (423:29): [True: 258, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    258|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    258|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 258]
  ------------------
  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|    258|        }
  440|    909|      }
  441|    909|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 258, False: 651]
  ------------------
  442|    909|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    303|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 217, False: 86]
  ------------------
  447|    651|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 651, False: 217]
  ------------------
  448|    651|        e.outputhash.clear();
  449|    651|      }
  450|    217|    }
  451|       |
  452|    303|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    303|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 303]
  ------------------
  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|    303|    } else {
  474|    303|      ret.implementations_agree = true;
  475|    303|    }
  476|    303|    return ret;
  477|    303|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    909|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    909|        } else {
  405|    909|          return r.error == simdutf::error_code::SUCCESS;
  406|    909|        }
  407|    909|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    606|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_32clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    358|    +[](std::span<const char> chardata) {                                      \
  555|    358|      const auto c =                                                           \
  556|    358|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    358|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    358|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    358|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    358|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    358|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    358|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    358|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    358|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    358|  constexpr auto _size = _name.size();                                \
  |  | 1183|    358|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    358|  return _nameof; }()
  ------------------
  561|    358|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    358|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    358|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    358|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    358|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    358|  constexpr auto _size = _name.size();                                \
  |  | 1183|    358|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    358|  return _nameof; }()
  ------------------
  562|    358|      c.fuzz(chardata);                                                        \
  563|    358|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    358|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    358|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    358|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    358|    static const bool do_print_testcase =
  181|    358|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    358|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 358]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    358|    do {
  189|       |      // step 0 - is the input valid?
  190|    358|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    358|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 358]
  |  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|    358|      const auto [output_length, length_agree] =
  204|    358|          calculate_length(from, inputisvalid);
  205|    358|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 358]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    358|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 265, False: 93]
  |  Branch (208:28): [True: 0, False: 265]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    358|      const auto [written, outputs_agree] =
  215|    358|          do_conversion(from, output_length, inputisvalid);
  216|    358|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 358]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    358|      return;
  221|    358|    } 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|    358|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    358|  validation_result verify_valid_input(FromSpan src) const {
  231|    358|    validation_result ret{};
  232|       |
  233|    358|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    358|    const auto implementations = get_supported_implementations();
  235|    358|    std::vector<simdutf::result> results;
  236|    358|    results.reserve(implementations.size());
  237|       |
  238|  1.07k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.07k, False: 358]
  ------------------
  239|  1.07k|      results.push_back(
  240|  1.07k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.07k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.07k|      const bool validation2 =
  245|  1.07k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.07k|                      src.data(), src.size());
  247|  1.07k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.07k]
  ------------------
  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.07k|    }
  258|       |
  259|    358|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    358|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 358]
  ------------------
  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|    358|    } else {
  273|    358|      ret.implementations_agree = true;
  274|    358|    }
  275|    358|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    358|      return r.error == simdutf::SUCCESS;
  277|    358|    });
  278|    358|    return ret;
  279|    358|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    716|    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|    544|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    544|      return r.error == simdutf::SUCCESS;
  277|    544|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    358|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    358|    length_result ret{};
  344|       |
  345|    358|    const auto implementations = get_supported_implementations();
  346|    358|    std::vector<std::size_t> results;
  347|    358|    results.reserve(implementations.size());
  348|       |
  349|  1.07k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.07k, False: 358]
  ------------------
  350|  1.07k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.07k|      results.push_back(len);
  352|  1.07k|      ret.length.push_back(len);
  353|  1.07k|    }
  354|       |
  355|    358|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    358|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 358]
  ------------------
  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|    358|    } else {
  375|    358|      ret.implementations_agree = true;
  376|    358|    }
  377|    358|    return ret;
  378|    358|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.07k|                                FromSpan src) const {
  331|  1.07k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.07k|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    716|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    358|                                  const bool inputisvalid) const {
  383|    358|    conversion_result ret{};
  384|       |
  385|    358|    const auto implementations = get_supported_implementations();
  386|       |
  387|    358|    std::vector<result<ConversionResult>> results;
  388|    358|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    358|    std::vector<std::vector<ToType>> outputbuffers;
  393|    358|    outputbuffers.reserve(implementations.size());
  394|  1.43k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.07k, False: 358]
  ------------------
  395|  1.07k|      auto impl = implementations[i];
  396|  1.07k|      const ToType canary1{42};
  397|  1.07k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.07k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.07k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.07k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.07k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.07k|          return r != 0;
  404|  1.07k|        } else {
  405|  1.07k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.07k|        }
  407|  1.07k|      }(implret1);
  408|  1.07k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.07k|      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.07k|        const ToType canary2{25};
  414|  1.07k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.07k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.07k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.07k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.07k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.07k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.07k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 279, False: 795]
  |  Branch (423:29): [True: 279, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    279|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    279|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 279]
  ------------------
  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|    279|        }
  440|  1.07k|      }
  441|  1.07k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 279, False: 795]
  ------------------
  442|  1.07k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    358|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 265, False: 93]
  ------------------
  447|    795|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 795, False: 265]
  ------------------
  448|    795|        e.outputhash.clear();
  449|    795|      }
  450|    265|    }
  451|       |
  452|    358|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    358|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 358]
  ------------------
  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|    358|    } else {
  474|    358|      ret.implementations_agree = true;
  475|    358|    }
  476|    358|    return ret;
  477|    358|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|  1.07k|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|  1.07k|        } else {
  405|  1.07k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.07k|        }
  407|  1.07k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    716|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_33clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    415|    +[](std::span<const char> chardata) {                                      \
  555|    415|      const auto c =                                                           \
  556|    415|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    415|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    415|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    415|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    415|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    415|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    415|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    415|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    415|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    415|  constexpr auto _size = _name.size();                                \
  |  | 1183|    415|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    415|  return _nameof; }()
  ------------------
  561|    415|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    415|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    415|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    415|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    415|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    415|  constexpr auto _size = _name.size();                                \
  |  | 1183|    415|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    415|  return _nameof; }()
  ------------------
  562|    415|      c.fuzz(chardata);                                                        \
  563|    415|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    415|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    415|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    415|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    415|    static const bool do_print_testcase =
  181|    415|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    415|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 415]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    415|    do {
  189|       |      // step 0 - is the input valid?
  190|    415|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    415|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 415]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|       |                    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|    415|      const auto [output_length, length_agree] =
  204|    415|          calculate_length(from, inputisvalid);
  205|    415|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 415]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    415|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 316, False: 99]
  |  Branch (208:28): [True: 0, False: 316]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    415|      const auto [written, outputs_agree] =
  215|    415|          do_conversion(from, output_length, inputisvalid);
  216|    415|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 415]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    415|      return;
  221|    415|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    415|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    415|  validation_result verify_valid_input(FromSpan src) const {
  231|    415|    validation_result ret{};
  232|       |
  233|    415|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    415|    const auto implementations = get_supported_implementations();
  235|    415|    std::vector<simdutf::result> results;
  236|    415|    results.reserve(implementations.size());
  237|       |
  238|  1.24k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.24k, False: 415]
  ------------------
  239|  1.24k|      results.push_back(
  240|  1.24k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.24k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.24k|      const bool validation2 =
  245|  1.24k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.24k|                      src.data(), src.size());
  247|  1.24k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.24k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  1.24k|    }
  258|       |
  259|    415|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    415|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 415]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    415|    } else {
  273|    415|      ret.implementations_agree = true;
  274|    415|    }
  275|    415|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    415|      return r.error == simdutf::SUCCESS;
  277|    415|    });
  278|    415|    return ret;
  279|    415|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    830|    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|    613|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    613|      return r.error == simdutf::SUCCESS;
  277|    613|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    415|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    415|    length_result ret{};
  344|       |
  345|    415|    const auto implementations = get_supported_implementations();
  346|    415|    std::vector<std::size_t> results;
  347|    415|    results.reserve(implementations.size());
  348|       |
  349|  1.24k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.24k, False: 415]
  ------------------
  350|  1.24k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.24k|      results.push_back(len);
  352|  1.24k|      ret.length.push_back(len);
  353|  1.24k|    }
  354|       |
  355|    415|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    415|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 415]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    415|    } else {
  375|    415|      ret.implementations_agree = true;
  376|    415|    }
  377|    415|    return ret;
  378|    415|  }
_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|    830|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    415|                                  const bool inputisvalid) const {
  383|    415|    conversion_result ret{};
  384|       |
  385|    415|    const auto implementations = get_supported_implementations();
  386|       |
  387|    415|    std::vector<result<ConversionResult>> results;
  388|    415|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    415|    std::vector<std::vector<ToType>> outputbuffers;
  393|    415|    outputbuffers.reserve(implementations.size());
  394|  1.66k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.24k, False: 415]
  ------------------
  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: 297, False: 948]
  |  Branch (423:29): [True: 297, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    297|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    297|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 297]
  ------------------
  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|    297|        }
  440|  1.24k|      }
  441|  1.24k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 297, False: 948]
  ------------------
  442|  1.24k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    415|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 316, False: 99]
  ------------------
  447|    948|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 948, False: 316]
  ------------------
  448|    948|        e.outputhash.clear();
  449|    948|      }
  450|    316|    }
  451|       |
  452|    415|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    415|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 415]
  ------------------
  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|    415|    } else {
  474|    415|      ret.implementations_agree = true;
  475|    415|    }
  476|    415|    return ret;
  477|    415|  }
_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|    830|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_34clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    258|    +[](std::span<const char> chardata) {                                      \
  555|    258|      const auto c =                                                           \
  556|    258|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    258|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    258|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    258|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    258|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    258|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    258|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    258|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    258|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    258|  constexpr auto _size = _name.size();                                \
  |  | 1183|    258|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    258|  return _nameof; }()
  ------------------
  561|    258|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    258|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    258|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    258|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    258|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    258|  constexpr auto _size = _name.size();                                \
  |  | 1183|    258|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    258|  return _nameof; }()
  ------------------
  562|    258|      c.fuzz(chardata);                                                        \
  563|    258|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    258|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    258|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    258|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    258|    static const bool do_print_testcase =
  181|    258|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    258|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 258]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    258|    do {
  189|       |      // step 0 - is the input valid?
  190|    258|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    258|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 258]
  |  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|    258|                    From == UtfEncodings::UTF8) {
  198|    258|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 258]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    258|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    258|      const auto [output_length, length_agree] =
  204|    258|          calculate_length(from, inputisvalid);
  205|    258|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 258]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    258|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 135, False: 123]
  |  Branch (208:28): [True: 0, False: 135]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    258|      const auto [written, outputs_agree] =
  215|    258|          do_conversion(from, output_length, inputisvalid);
  216|    258|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 258]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    258|      return;
  221|    258|    } 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|    258|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    258|  validation_result verify_valid_input(FromSpan src) const {
  231|    258|    validation_result ret{};
  232|       |
  233|    258|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    258|    const auto implementations = get_supported_implementations();
  235|    258|    std::vector<simdutf::result> results;
  236|    258|    results.reserve(implementations.size());
  237|       |
  238|    774|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 774, False: 258]
  ------------------
  239|    774|      results.push_back(
  240|    774|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    774|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    774|      const bool validation2 =
  245|    774|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    774|                      src.data(), src.size());
  247|    774|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 774]
  ------------------
  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|    774|    }
  258|       |
  259|    258|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    258|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 258]
  ------------------
  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|    258|    } else {
  273|    258|      ret.implementations_agree = true;
  274|    258|    }
  275|    258|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    258|      return r.error == simdutf::SUCCESS;
  277|    258|    });
  278|    258|    return ret;
  279|    258|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    516|    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|    504|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    504|      return r.error == simdutf::SUCCESS;
  277|    504|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    258|  bool count_the_input(FromSpan src) const {
  290|    258|    const auto implementations = get_supported_implementations();
  291|    258|    std::vector<std::size_t> results;
  292|    258|    results.reserve(implementations.size());
  293|       |
  294|    774|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 774, False: 258]
  ------------------
  295|    774|      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|    774|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|    774|        ret = impl->count_utf8(src.data(), src.size());
  302|    774|      }
  303|    774|      results.push_back(ret);
  304|    774|    }
  305|    258|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    258|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 258]
  ------------------
  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|    258|    return true;
  321|    258|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    516|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    258|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    258|    length_result ret{};
  344|       |
  345|    258|    const auto implementations = get_supported_implementations();
  346|    258|    std::vector<std::size_t> results;
  347|    258|    results.reserve(implementations.size());
  348|       |
  349|    774|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 774, False: 258]
  ------------------
  350|    774|      const auto len = invoke_lengthcalc(impl, src);
  351|    774|      results.push_back(len);
  352|    774|      ret.length.push_back(len);
  353|    774|    }
  354|       |
  355|    258|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    258|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 258]
  ------------------
  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|    258|    } else {
  375|    258|      ret.implementations_agree = true;
  376|    258|    }
  377|    258|    return ret;
  378|    258|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    774|                                FromSpan src) const {
  331|    774|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    774|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    516|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    258|                                  const bool inputisvalid) const {
  383|    258|    conversion_result ret{};
  384|       |
  385|    258|    const auto implementations = get_supported_implementations();
  386|       |
  387|    258|    std::vector<result<ConversionResult>> results;
  388|    258|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    258|    std::vector<std::vector<ToType>> outputbuffers;
  393|    258|    outputbuffers.reserve(implementations.size());
  394|  1.03k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 774, False: 258]
  ------------------
  395|    774|      auto impl = implementations[i];
  396|    774|      const ToType canary1{42};
  397|    774|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    774|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    774|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    774|      const auto success = [](const ConversionResult& r) -> bool {
  402|    774|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    774|          return r != 0;
  404|    774|        } else {
  405|    774|          return r.error == simdutf::error_code::SUCCESS;
  406|    774|        }
  407|    774|      }(implret1);
  408|    774|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    774|      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|    774|        const ToType canary2{25};
  414|    774|        const auto outputbuffer_first_run = outputbuffer;
  415|    774|        std::ranges::fill(outputbuffer, canary2);
  416|    774|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    774|                                          src.size(), outputbuffer.data());
  418|       |
  419|    774|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 774]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    774|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 369, False: 405]
  |  Branch (423:29): [True: 345, False: 24]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    345|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    345|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 345]
  ------------------
  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|    345|        }
  440|    774|      }
  441|    774|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 345, False: 429]
  ------------------
  442|    774|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    258|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 135, False: 123]
  ------------------
  447|    405|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 405, False: 135]
  ------------------
  448|    405|        e.outputhash.clear();
  449|    405|      }
  450|    135|    }
  451|       |
  452|    258|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    258|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 258]
  ------------------
  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|    258|    } else {
  474|    258|      ret.implementations_agree = true;
  475|    258|    }
  476|    258|    return ret;
  477|    258|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    774|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    774|        } else {
  405|    774|          return r.error == simdutf::error_code::SUCCESS;
  406|    774|        }
  407|    774|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    516|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_35clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    351|    +[](std::span<const char> chardata) {                                      \
  555|    351|      const auto c =                                                           \
  556|    351|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    351|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    351|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    351|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    351|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    351|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    351|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    351|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    351|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    351|  constexpr auto _size = _name.size();                                \
  |  | 1183|    351|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    351|  return _nameof; }()
  ------------------
  561|    351|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    351|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    351|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    351|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    351|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    351|  constexpr auto _size = _name.size();                                \
  |  | 1183|    351|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    351|  return _nameof; }()
  ------------------
  562|    351|      c.fuzz(chardata);                                                        \
  563|    351|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    351|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    351|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    351|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    351|    static const bool do_print_testcase =
  181|    351|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    351|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 351]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    351|    do {
  189|       |      // step 0 - is the input valid?
  190|    351|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    351|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 351]
  |  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|    351|                    From == UtfEncodings::UTF8) {
  198|    351|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 351]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    351|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    351|      const auto [output_length, length_agree] =
  204|    351|          calculate_length(from, inputisvalid);
  205|    351|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 351]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    351|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 194, False: 157]
  |  Branch (208:28): [True: 0, False: 194]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    351|      const auto [written, outputs_agree] =
  215|    351|          do_conversion(from, output_length, inputisvalid);
  216|    351|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 351]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    351|      return;
  221|    351|    } 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|    351|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    351|  validation_result verify_valid_input(FromSpan src) const {
  231|    351|    validation_result ret{};
  232|       |
  233|    351|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    351|    const auto implementations = get_supported_implementations();
  235|    351|    std::vector<simdutf::result> results;
  236|    351|    results.reserve(implementations.size());
  237|       |
  238|  1.05k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.05k, False: 351]
  ------------------
  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|    351|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    351|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 351]
  ------------------
  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|    351|    } else {
  273|    351|      ret.implementations_agree = true;
  274|    351|    }
  275|    351|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    351|      return r.error == simdutf::SUCCESS;
  277|    351|    });
  278|    351|    return ret;
  279|    351|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    702|    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|    351|  bool count_the_input(FromSpan src) const {
  290|    351|    const auto implementations = get_supported_implementations();
  291|    351|    std::vector<std::size_t> results;
  292|    351|    results.reserve(implementations.size());
  293|       |
  294|  1.05k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.05k, False: 351]
  ------------------
  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|    351|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    351|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 351]
  ------------------
  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|    351|    return true;
  321|    351|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    702|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    351|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    351|    length_result ret{};
  344|       |
  345|    351|    const auto implementations = get_supported_implementations();
  346|    351|    std::vector<std::size_t> results;
  347|    351|    results.reserve(implementations.size());
  348|       |
  349|  1.05k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.05k, False: 351]
  ------------------
  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|    351|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    351|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 351]
  ------------------
  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|    351|    } else {
  375|    351|      ret.implementations_agree = true;
  376|    351|    }
  377|    351|    return ret;
  378|    351|  }
_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|    702|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    351|                                  const bool inputisvalid) const {
  383|    351|    conversion_result ret{};
  384|       |
  385|    351|    const auto implementations = get_supported_implementations();
  386|       |
  387|    351|    std::vector<result<ConversionResult>> results;
  388|    351|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    351|    std::vector<std::vector<ToType>> outputbuffers;
  393|    351|    outputbuffers.reserve(implementations.size());
  394|  1.40k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.05k, False: 351]
  ------------------
  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: 471, False: 582]
  |  Branch (423:29): [True: 471, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    471|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    471|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 471]
  ------------------
  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|    471|        }
  440|  1.05k|      }
  441|  1.05k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 471, False: 582]
  ------------------
  442|  1.05k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    351|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 194, False: 157]
  ------------------
  447|    582|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 582, False: 194]
  ------------------
  448|    582|        e.outputhash.clear();
  449|    582|      }
  450|    194|    }
  451|       |
  452|    351|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    351|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 351]
  ------------------
  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|    351|    } else {
  474|    351|      ret.implementations_agree = true;
  475|    351|    }
  476|    351|    return ret;
  477|    351|  }
_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|    702|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_36clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    287|    +[](std::span<const char> chardata) {                                      \
  555|    287|      const auto c =                                                           \
  556|    287|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    287|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    287|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    287|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    287|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    287|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    287|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    287|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    287|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    287|  constexpr auto _size = _name.size();                                \
  |  | 1183|    287|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    287|  return _nameof; }()
  ------------------
  561|    287|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    287|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    287|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    287|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    287|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    287|  constexpr auto _size = _name.size();                                \
  |  | 1183|    287|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    287|  return _nameof; }()
  ------------------
  562|    287|      c.fuzz(chardata);                                                        \
  563|    287|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    287|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    287|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    287|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    287|    static const bool do_print_testcase =
  181|    287|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    287|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 287]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    287|    do {
  189|       |      // step 0 - is the input valid?
  190|    287|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    287|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 287]
  |  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|    287|                    From == UtfEncodings::UTF8) {
  198|    287|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 287]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    287|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    287|      const auto [output_length, length_agree] =
  204|    287|          calculate_length(from, inputisvalid);
  205|    287|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 287]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    287|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 164, False: 123]
  |  Branch (208:28): [True: 0, False: 164]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    287|      const auto [written, outputs_agree] =
  215|    287|          do_conversion(from, output_length, inputisvalid);
  216|    287|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 287]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    287|      return;
  221|    287|    } 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|    287|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    287|  validation_result verify_valid_input(FromSpan src) const {
  231|    287|    validation_result ret{};
  232|       |
  233|    287|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    287|    const auto implementations = get_supported_implementations();
  235|    287|    std::vector<simdutf::result> results;
  236|    287|    results.reserve(implementations.size());
  237|       |
  238|    861|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 861, False: 287]
  ------------------
  239|    861|      results.push_back(
  240|    861|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    861|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    861|      const bool validation2 =
  245|    861|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    861|                      src.data(), src.size());
  247|    861|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 861]
  ------------------
  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|    861|    }
  258|       |
  259|    287|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    287|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 287]
  ------------------
  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|    287|    } else {
  273|    287|      ret.implementations_agree = true;
  274|    287|    }
  275|    287|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    287|      return r.error == simdutf::SUCCESS;
  277|    287|    });
  278|    287|    return ret;
  279|    287|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    574|    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|    533|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    533|      return r.error == simdutf::SUCCESS;
  277|    533|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    287|  bool count_the_input(FromSpan src) const {
  290|    287|    const auto implementations = get_supported_implementations();
  291|    287|    std::vector<std::size_t> results;
  292|    287|    results.reserve(implementations.size());
  293|       |
  294|    861|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 861, False: 287]
  ------------------
  295|    861|      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|    861|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|    861|        ret = impl->count_utf8(src.data(), src.size());
  302|    861|      }
  303|    861|      results.push_back(ret);
  304|    861|    }
  305|    287|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    287|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 287]
  ------------------
  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|    287|    return true;
  321|    287|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    574|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    287|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    287|    length_result ret{};
  344|       |
  345|    287|    const auto implementations = get_supported_implementations();
  346|    287|    std::vector<std::size_t> results;
  347|    287|    results.reserve(implementations.size());
  348|       |
  349|    861|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 861, False: 287]
  ------------------
  350|    861|      const auto len = invoke_lengthcalc(impl, src);
  351|    861|      results.push_back(len);
  352|    861|      ret.length.push_back(len);
  353|    861|    }
  354|       |
  355|    287|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    287|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 287]
  ------------------
  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|    287|    } else {
  375|    287|      ret.implementations_agree = true;
  376|    287|    }
  377|    287|    return ret;
  378|    287|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    861|                                FromSpan src) const {
  331|    861|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    861|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    574|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    287|                                  const bool inputisvalid) const {
  383|    287|    conversion_result ret{};
  384|       |
  385|    287|    const auto implementations = get_supported_implementations();
  386|       |
  387|    287|    std::vector<result<ConversionResult>> results;
  388|    287|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    287|    std::vector<std::vector<ToType>> outputbuffers;
  393|    287|    outputbuffers.reserve(implementations.size());
  394|  1.14k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 861, False: 287]
  ------------------
  395|    861|      auto impl = implementations[i];
  396|    861|      const ToType canary1{42};
  397|    861|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    861|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    861|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    861|      const auto success = [](const ConversionResult& r) -> bool {
  402|    861|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    861|          return r != 0;
  404|    861|        } else {
  405|    861|          return r.error == simdutf::error_code::SUCCESS;
  406|    861|        }
  407|    861|      }(implret1);
  408|    861|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    861|      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|    861|        const ToType canary2{25};
  414|    861|        const auto outputbuffer_first_run = outputbuffer;
  415|    861|        std::ranges::fill(outputbuffer, canary2);
  416|    861|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    861|                                          src.size(), outputbuffer.data());
  418|       |
  419|    861|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 861]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    861|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 369, False: 492]
  |  Branch (423:29): [True: 369, False: 0]
  ------------------
  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|    861|      }
  441|    861|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 369, False: 492]
  ------------------
  442|    861|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    287|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 164, False: 123]
  ------------------
  447|    492|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 492, False: 164]
  ------------------
  448|    492|        e.outputhash.clear();
  449|    492|      }
  450|    164|    }
  451|       |
  452|    287|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    287|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 287]
  ------------------
  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|    287|    } else {
  474|    287|      ret.implementations_agree = true;
  475|    287|    }
  476|    287|    return ret;
  477|    287|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    861|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    861|        } else {
  405|    861|          return r.error == simdutf::error_code::SUCCESS;
  406|    861|        }
  407|    861|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    574|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_37clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    369|    +[](std::span<const char> chardata) {                                      \
  555|    369|      const auto c =                                                           \
  556|    369|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    369|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    369|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    369|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    369|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    369|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    369|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    369|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    369|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    369|  constexpr auto _size = _name.size();                                \
  |  | 1183|    369|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    369|  return _nameof; }()
  ------------------
  561|    369|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    369|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    369|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    369|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    369|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    369|  constexpr auto _size = _name.size();                                \
  |  | 1183|    369|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    369|  return _nameof; }()
  ------------------
  562|    369|      c.fuzz(chardata);                                                        \
  563|    369|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    369|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    369|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    369|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    369|    static const bool do_print_testcase =
  181|    369|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    369|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 369]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    369|    do {
  189|       |      // step 0 - is the input valid?
  190|    369|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    369|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 369]
  |  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|    369|                    From == UtfEncodings::UTF8) {
  198|    369|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 369]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    369|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    369|      const auto [output_length, length_agree] =
  204|    369|          calculate_length(from, inputisvalid);
  205|    369|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 369]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    369|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 199, False: 170]
  |  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|    369|      const auto [written, outputs_agree] =
  215|    369|          do_conversion(from, output_length, inputisvalid);
  216|    369|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 369]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    369|      return;
  221|    369|    } 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|    369|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    369|  validation_result verify_valid_input(FromSpan src) const {
  231|    369|    validation_result ret{};
  232|       |
  233|    369|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    369|    const auto implementations = get_supported_implementations();
  235|    369|    std::vector<simdutf::result> results;
  236|    369|    results.reserve(implementations.size());
  237|       |
  238|  1.10k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.10k, False: 369]
  ------------------
  239|  1.10k|      results.push_back(
  240|  1.10k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.10k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.10k|      const bool validation2 =
  245|  1.10k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.10k|                      src.data(), src.size());
  247|  1.10k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.10k]
  ------------------
  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.10k|    }
  258|       |
  259|    369|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    369|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 369]
  ------------------
  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|    369|    } else {
  273|    369|      ret.implementations_agree = true;
  274|    369|    }
  275|    369|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    369|      return r.error == simdutf::SUCCESS;
  277|    369|    });
  278|    369|    return ret;
  279|    369|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    738|    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|    709|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    709|      return r.error == simdutf::SUCCESS;
  277|    709|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    369|  bool count_the_input(FromSpan src) const {
  290|    369|    const auto implementations = get_supported_implementations();
  291|    369|    std::vector<std::size_t> results;
  292|    369|    results.reserve(implementations.size());
  293|       |
  294|  1.10k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.10k, False: 369]
  ------------------
  295|  1.10k|      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.10k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.10k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.10k|      }
  303|  1.10k|      results.push_back(ret);
  304|  1.10k|    }
  305|    369|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    369|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 369]
  ------------------
  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|    369|    return true;
  321|    369|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    738|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    369|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    369|    length_result ret{};
  344|       |
  345|    369|    const auto implementations = get_supported_implementations();
  346|    369|    std::vector<std::size_t> results;
  347|    369|    results.reserve(implementations.size());
  348|       |
  349|  1.10k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.10k, False: 369]
  ------------------
  350|  1.10k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.10k|      results.push_back(len);
  352|  1.10k|      ret.length.push_back(len);
  353|  1.10k|    }
  354|       |
  355|    369|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    369|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 369]
  ------------------
  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|    369|    } else {
  375|    369|      ret.implementations_agree = true;
  376|    369|    }
  377|    369|    return ret;
  378|    369|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.10k|                                FromSpan src) const {
  331|  1.10k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.10k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    738|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    369|                                  const bool inputisvalid) const {
  383|    369|    conversion_result ret{};
  384|       |
  385|    369|    const auto implementations = get_supported_implementations();
  386|       |
  387|    369|    std::vector<result<ConversionResult>> results;
  388|    369|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    369|    std::vector<std::vector<ToType>> outputbuffers;
  393|    369|    outputbuffers.reserve(implementations.size());
  394|  1.47k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.10k, False: 369]
  ------------------
  395|  1.10k|      auto impl = implementations[i];
  396|  1.10k|      const ToType canary1{42};
  397|  1.10k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.10k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.10k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.10k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.10k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.10k|          return r != 0;
  404|  1.10k|        } else {
  405|  1.10k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.10k|        }
  407|  1.10k|      }(implret1);
  408|  1.10k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.10k|      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.10k|        const ToType canary2{25};
  414|  1.10k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.10k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.10k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.10k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.10k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.10k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.10k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 510, False: 597]
  |  Branch (423:29): [True: 510, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    510|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    510|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 510]
  ------------------
  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|    510|        }
  440|  1.10k|      }
  441|  1.10k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 510, False: 597]
  ------------------
  442|  1.10k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    369|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 199, False: 170]
  ------------------
  447|    597|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 597, False: 199]
  ------------------
  448|    597|        e.outputhash.clear();
  449|    597|      }
  450|    199|    }
  451|       |
  452|    369|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    369|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 369]
  ------------------
  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|    369|    } else {
  474|    369|      ret.implementations_agree = true;
  475|    369|    }
  476|    369|    return ret;
  477|    369|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|  1.10k|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|  1.10k|        } else {
  405|  1.10k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.10k|        }
  407|  1.10k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    738|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_38clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     45|    +[](std::span<const char> chardata) {                                      \
  555|     45|      const auto c =                                                           \
  556|     45|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     45|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     45|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     45|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     45|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     45|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     45|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     45|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     45|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     45|  constexpr auto _size = _name.size();                                \
  |  | 1183|     45|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     45|  return _nameof; }()
  ------------------
  561|     45|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     45|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     45|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     45|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     45|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     45|  constexpr auto _size = _name.size();                                \
  |  | 1183|     45|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     45|  return _nameof; }()
  ------------------
  562|     45|      c.fuzz(chardata);                                                        \
  563|     45|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE4fuzzENSt3__14spanIS5_Lm18446744073709551615EEE:
  175|     45|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     45|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     45|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     45|    static const bool do_print_testcase =
  181|     45|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     45|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 45]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     45|    do {
  189|       |      // step 0 - is the input valid?
  190|     45|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     45|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 45]
  |  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|     45|      const auto [output_length, length_agree] =
  204|     45|          calculate_length(from, inputisvalid);
  205|     45|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 45]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     45|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 0, False: 45]
  |  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|     45|      const auto [written, outputs_agree] =
  215|     45|          do_conversion(from, output_length, inputisvalid);
  216|     45|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 45]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     45|      return;
  221|     45|    } 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|     45|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE18verify_valid_inputIvQeqT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  283|     45|  validation_result verify_valid_input(FromSpan) const {
  284|       |    // all latin1 input is valid. there is no simdutf validation function for
  285|       |    // it.
  286|     45|    return validation_result{.valid = true, .implementations_agree = true};
  287|     45|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     45|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     45|    length_result ret{};
  344|       |
  345|     45|    const auto implementations = get_supported_implementations();
  346|     45|    std::vector<std::size_t> results;
  347|     45|    results.reserve(implementations.size());
  348|       |
  349|    135|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 135, False: 45]
  ------------------
  350|    135|      const auto len = invoke_lengthcalc(impl, src);
  351|    135|      results.push_back(len);
  352|    135|      ret.length.push_back(len);
  353|    135|    }
  354|       |
  355|     45|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     45|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 45]
  ------------------
  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|     45|    } else {
  375|     45|      ret.implementations_agree = true;
  376|     45|    }
  377|     45|    return ret;
  378|     45|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    135|                                FromSpan src) const {
  339|    135|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    135|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|     90|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     45|                                  const bool inputisvalid) const {
  383|     45|    conversion_result ret{};
  384|       |
  385|     45|    const auto implementations = get_supported_implementations();
  386|       |
  387|     45|    std::vector<result<ConversionResult>> results;
  388|     45|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     45|    std::vector<std::vector<ToType>> outputbuffers;
  393|     45|    outputbuffers.reserve(implementations.size());
  394|    180|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 135, False: 45]
  ------------------
  395|    135|      auto impl = implementations[i];
  396|    135|      const ToType canary1{42};
  397|    135|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    135|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    135|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    135|      const auto success = [](const ConversionResult& r) -> bool {
  402|    135|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    135|          return r != 0;
  404|    135|        } else {
  405|    135|          return r.error == simdutf::error_code::SUCCESS;
  406|    135|        }
  407|    135|      }(implret1);
  408|    135|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    135|      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|    135|        const ToType canary2{25};
  414|    135|        const auto outputbuffer_first_run = outputbuffer;
  415|    135|        std::ranges::fill(outputbuffer, canary2);
  416|    135|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    135|                                          src.size(), outputbuffer.data());
  418|       |
  419|    135|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 135]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    135|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 135, False: 0]
  |  Branch (423:29): [True: 129, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    129|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    129|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 129]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    129|        }
  440|    135|      }
  441|    135|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 129, False: 6]
  ------------------
  442|    135|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     45|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 0, False: 45]
  ------------------
  447|      0|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 0, False: 0]
  ------------------
  448|      0|        e.outputhash.clear();
  449|      0|      }
  450|      0|    }
  451|       |
  452|     45|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     45|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 45]
  ------------------
  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|     45|    } else {
  474|     45|      ret.implementations_agree = true;
  475|     45|    }
  476|     45|    return ret;
  477|     45|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    135|      const auto success = [](const ConversionResult& r) -> bool {
  402|    135|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    135|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    135|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|     90|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_39clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     40|    +[](std::span<const char> chardata) {                                      \
  555|     40|      const auto c =                                                           \
  556|     40|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     40|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     40|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     40|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     40|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     40|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     40|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     40|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     40|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     40|  constexpr auto _size = _name.size();                                \
  |  | 1183|     40|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     40|  return _nameof; }()
  ------------------
  561|     40|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     40|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     40|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     40|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     40|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     40|  constexpr auto _size = _name.size();                                \
  |  | 1183|     40|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     40|  return _nameof; }()
  ------------------
  562|     40|      c.fuzz(chardata);                                                        \
  563|     40|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE4fuzzENSt3__14spanIS5_Lm18446744073709551615EEE:
  175|     40|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     40|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     40|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     40|    static const bool do_print_testcase =
  181|     40|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     40|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 40]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     40|    do {
  189|       |      // step 0 - is the input valid?
  190|     40|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     40|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 40]
  |  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|     40|      const auto [output_length, length_agree] =
  204|     40|          calculate_length(from, inputisvalid);
  205|     40|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 40]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     40|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 0, False: 40]
  |  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|     40|      const auto [written, outputs_agree] =
  215|     40|          do_conversion(from, output_length, inputisvalid);
  216|     40|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 40]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     40|      return;
  221|     40|    } 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|     40|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE18verify_valid_inputIvQeqT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  283|     40|  validation_result verify_valid_input(FromSpan) const {
  284|       |    // all latin1 input is valid. there is no simdutf validation function for
  285|       |    // it.
  286|     40|    return validation_result{.valid = true, .implementations_agree = true};
  287|     40|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     40|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     40|    length_result ret{};
  344|       |
  345|     40|    const auto implementations = get_supported_implementations();
  346|     40|    std::vector<std::size_t> results;
  347|     40|    results.reserve(implementations.size());
  348|       |
  349|    120|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 120, False: 40]
  ------------------
  350|    120|      const auto len = invoke_lengthcalc(impl, src);
  351|    120|      results.push_back(len);
  352|    120|      ret.length.push_back(len);
  353|    120|    }
  354|       |
  355|     40|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     40|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 40]
  ------------------
  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|     40|    } else {
  375|     40|      ret.implementations_agree = true;
  376|     40|    }
  377|     40|    return ret;
  378|     40|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    120|                                FromSpan src) const {
  339|    120|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    120|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|     80|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     40|                                  const bool inputisvalid) const {
  383|     40|    conversion_result ret{};
  384|       |
  385|     40|    const auto implementations = get_supported_implementations();
  386|       |
  387|     40|    std::vector<result<ConversionResult>> results;
  388|     40|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     40|    std::vector<std::vector<ToType>> outputbuffers;
  393|     40|    outputbuffers.reserve(implementations.size());
  394|    160|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 120, False: 40]
  ------------------
  395|    120|      auto impl = implementations[i];
  396|    120|      const ToType canary1{42};
  397|    120|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    120|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    120|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    120|      const auto success = [](const ConversionResult& r) -> bool {
  402|    120|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    120|          return r != 0;
  404|    120|        } else {
  405|    120|          return r.error == simdutf::error_code::SUCCESS;
  406|    120|        }
  407|    120|      }(implret1);
  408|    120|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    120|      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|    120|        const ToType canary2{25};
  414|    120|        const auto outputbuffer_first_run = outputbuffer;
  415|    120|        std::ranges::fill(outputbuffer, canary2);
  416|    120|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    120|                                          src.size(), outputbuffer.data());
  418|       |
  419|    120|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 120]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    120|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 120, False: 0]
  |  Branch (423:29): [True: 114, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    114|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    114|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 114]
  ------------------
  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|    114|        }
  440|    120|      }
  441|    120|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 114, False: 6]
  ------------------
  442|    120|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     40|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 0, False: 40]
  ------------------
  447|      0|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 0, False: 0]
  ------------------
  448|      0|        e.outputhash.clear();
  449|      0|      }
  450|      0|    }
  451|       |
  452|     40|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     40|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 40]
  ------------------
  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|     40|    } else {
  474|     40|      ret.implementations_agree = true;
  475|     40|    }
  476|     40|    return ret;
  477|     40|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    120|      const auto success = [](const ConversionResult& r) -> bool {
  402|    120|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    120|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    120|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|     80|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_40clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     40|    +[](std::span<const char> chardata) {                                      \
  555|     40|      const auto c =                                                           \
  556|     40|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     40|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     40|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     40|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     40|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     40|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     40|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     40|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     40|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     40|  constexpr auto _size = _name.size();                                \
  |  | 1183|     40|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     40|  return _nameof; }()
  ------------------
  561|     40|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     40|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     40|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     40|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     40|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     40|  constexpr auto _size = _name.size();                                \
  |  | 1183|     40|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     40|  return _nameof; }()
  ------------------
  562|     40|      c.fuzz(chardata);                                                        \
  563|     40|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE4fuzzENSt3__14spanIS5_Lm18446744073709551615EEE:
  175|     40|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     40|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     40|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     40|    static const bool do_print_testcase =
  181|     40|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     40|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 40]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     40|    do {
  189|       |      // step 0 - is the input valid?
  190|     40|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     40|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 40]
  |  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|     40|      const auto [output_length, length_agree] =
  204|     40|          calculate_length(from, inputisvalid);
  205|     40|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 40]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     40|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 0, False: 40]
  |  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|     40|      const auto [written, outputs_agree] =
  215|     40|          do_conversion(from, output_length, inputisvalid);
  216|     40|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 40]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     40|      return;
  221|     40|    } 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|     40|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE18verify_valid_inputIvQeqT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  283|     40|  validation_result verify_valid_input(FromSpan) const {
  284|       |    // all latin1 input is valid. there is no simdutf validation function for
  285|       |    // it.
  286|     40|    return validation_result{.valid = true, .implementations_agree = true};
  287|     40|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     40|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     40|    length_result ret{};
  344|       |
  345|     40|    const auto implementations = get_supported_implementations();
  346|     40|    std::vector<std::size_t> results;
  347|     40|    results.reserve(implementations.size());
  348|       |
  349|    120|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 120, False: 40]
  ------------------
  350|    120|      const auto len = invoke_lengthcalc(impl, src);
  351|    120|      results.push_back(len);
  352|    120|      ret.length.push_back(len);
  353|    120|    }
  354|       |
  355|     40|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     40|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 40]
  ------------------
  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|     40|    } else {
  375|     40|      ret.implementations_agree = true;
  376|     40|    }
  377|     40|    return ret;
  378|     40|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    120|                                FromSpan src) const {
  339|    120|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    120|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|     80|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     40|                                  const bool inputisvalid) const {
  383|     40|    conversion_result ret{};
  384|       |
  385|     40|    const auto implementations = get_supported_implementations();
  386|       |
  387|     40|    std::vector<result<ConversionResult>> results;
  388|     40|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     40|    std::vector<std::vector<ToType>> outputbuffers;
  393|     40|    outputbuffers.reserve(implementations.size());
  394|    160|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 120, False: 40]
  ------------------
  395|    120|      auto impl = implementations[i];
  396|    120|      const ToType canary1{42};
  397|    120|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    120|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    120|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    120|      const auto success = [](const ConversionResult& r) -> bool {
  402|    120|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    120|          return r != 0;
  404|    120|        } else {
  405|    120|          return r.error == simdutf::error_code::SUCCESS;
  406|    120|        }
  407|    120|      }(implret1);
  408|    120|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    120|      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|    120|        const ToType canary2{25};
  414|    120|        const auto outputbuffer_first_run = outputbuffer;
  415|    120|        std::ranges::fill(outputbuffer, canary2);
  416|    120|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    120|                                          src.size(), outputbuffer.data());
  418|       |
  419|    120|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 120]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    120|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 120, False: 0]
  |  Branch (423:29): [True: 114, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    114|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    114|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 114]
  ------------------
  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|    114|        }
  440|    120|      }
  441|    120|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 114, False: 6]
  ------------------
  442|    120|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     40|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 0, False: 40]
  ------------------
  447|      0|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 0, False: 0]
  ------------------
  448|      0|        e.outputhash.clear();
  449|      0|      }
  450|      0|    }
  451|       |
  452|     40|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     40|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 40]
  ------------------
  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|     40|    } else {
  474|     40|      ret.implementations_agree = true;
  475|     40|    }
  476|     40|    return ret;
  477|     40|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    120|      const auto success = [](const ConversionResult& r) -> bool {
  402|    120|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    120|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    120|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|     80|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_41clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    269|    +[](std::span<const char> chardata) {                                      \
  555|    269|      const auto c =                                                           \
  556|    269|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    269|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    269|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    269|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    269|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    269|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    269|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    269|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    269|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    269|  constexpr auto _size = _name.size();                                \
  |  | 1183|    269|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    269|  return _nameof; }()
  ------------------
  561|    269|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    269|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    269|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    269|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    269|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    269|  constexpr auto _size = _name.size();                                \
  |  | 1183|    269|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    269|  return _nameof; }()
  ------------------
  562|    269|      c.fuzz(chardata);                                                        \
  563|    269|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    269|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    269|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    269|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    269|    static const bool do_print_testcase =
  181|    269|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    269|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 269]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    269|    do {
  189|       |      // step 0 - is the input valid?
  190|    269|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    269|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 269]
  |  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|    269|      const auto [output_length, length_agree] =
  204|    269|          calculate_length(from, inputisvalid);
  205|    269|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 269]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    269|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 0, False: 269]
  |  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|    269|      const auto [written, outputs_agree] =
  215|    269|          do_conversion(from, output_length, inputisvalid);
  216|    269|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 269]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    269|      return;
  221|    269|    } 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|    269|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQeqT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  283|    269|  validation_result verify_valid_input(FromSpan) const {
  284|       |    // all latin1 input is valid. there is no simdutf validation function for
  285|       |    // it.
  286|    269|    return validation_result{.valid = true, .implementations_agree = true};
  287|    269|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    269|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    269|    length_result ret{};
  344|       |
  345|    269|    const auto implementations = get_supported_implementations();
  346|    269|    std::vector<std::size_t> results;
  347|    269|    results.reserve(implementations.size());
  348|       |
  349|    807|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 807, False: 269]
  ------------------
  350|    807|      const auto len = invoke_lengthcalc(impl, src);
  351|    807|      results.push_back(len);
  352|    807|      ret.length.push_back(len);
  353|    807|    }
  354|       |
  355|    269|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    269|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 269]
  ------------------
  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|    269|    } else {
  375|    269|      ret.implementations_agree = true;
  376|    269|    }
  377|    269|    return ret;
  378|    269|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    807|                                FromSpan src) const {
  331|    807|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    807|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    538|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    269|                                  const bool inputisvalid) const {
  383|    269|    conversion_result ret{};
  384|       |
  385|    269|    const auto implementations = get_supported_implementations();
  386|       |
  387|    269|    std::vector<result<ConversionResult>> results;
  388|    269|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    269|    std::vector<std::vector<ToType>> outputbuffers;
  393|    269|    outputbuffers.reserve(implementations.size());
  394|  1.07k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 807, False: 269]
  ------------------
  395|    807|      auto impl = implementations[i];
  396|    807|      const ToType canary1{42};
  397|    807|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    807|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    807|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    807|      const auto success = [](const ConversionResult& r) -> bool {
  402|    807|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    807|          return r != 0;
  404|    807|        } else {
  405|    807|          return r.error == simdutf::error_code::SUCCESS;
  406|    807|        }
  407|    807|      }(implret1);
  408|    807|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    807|      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|    807|        const ToType canary2{25};
  414|    807|        const auto outputbuffer_first_run = outputbuffer;
  415|    807|        std::ranges::fill(outputbuffer, canary2);
  416|    807|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    807|                                          src.size(), outputbuffer.data());
  418|       |
  419|    807|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 807]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    807|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 807, False: 0]
  |  Branch (423:29): [True: 801, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    801|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    801|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 801]
  ------------------
  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|    801|        }
  440|    807|      }
  441|    807|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 801, False: 6]
  ------------------
  442|    807|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    269|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 0, False: 269]
  ------------------
  447|      0|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 0, False: 0]
  ------------------
  448|      0|        e.outputhash.clear();
  449|      0|      }
  450|      0|    }
  451|       |
  452|    269|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    269|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 269]
  ------------------
  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|    269|    } else {
  474|    269|      ret.implementations_agree = true;
  475|    269|    }
  476|    269|    return ret;
  477|    269|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    807|      const auto success = [](const ConversionResult& r) -> bool {
  402|    807|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    807|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    807|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    538|    auto neq = [](const auto& a, const auto& b) { return a != b; };

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

_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|    962|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt25EE4dataEv:
  233|    962|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt25EE4sizeEv:
  235|    962|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_0clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     88|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     88|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     88|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     88|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     88|  constexpr auto _size = _name.size();                                \
 1183|     88|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     88|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_0clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     88|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     88|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     88|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     88|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     88|  constexpr auto _size = _name.size();                                \
 1183|     88|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     88|  return _nameof; }()
_ZNK6nameof7cstringILt30EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    346|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt30EE4dataEv:
  233|    346|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt30EE4sizeEv:
  235|    346|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_1clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    240|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    240|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    240|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    240|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    240|  constexpr auto _size = _name.size();                                \
 1183|    240|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    240|  return _nameof; }()
_ZNK6nameof7cstringILt24EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  2.90k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt24EE4dataEv:
  233|  2.90k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt24EE4sizeEv:
  235|  2.90k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_1clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    240|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    240|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    240|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    240|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    240|  constexpr auto _size = _name.size();                                \
 1183|    240|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    240|  return _nameof; }()
_ZNK6nameof7cstringILt29EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    884|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt29EE4dataEv:
  233|    884|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt29EE4sizeEv:
  235|    884|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_2clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     61|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     61|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     61|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     61|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     61|  constexpr auto _size = _name.size();                                \
 1183|     61|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     61|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_2clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     61|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     61|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     61|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     61|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     61|  constexpr auto _size = _name.size();                                \
 1183|     61|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     61|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_3clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    219|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    219|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    219|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    219|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    219|  constexpr auto _size = _name.size();                                \
 1183|    219|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    219|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_3clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    219|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    219|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    219|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    219|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    219|  constexpr auto _size = _name.size();                                \
 1183|    219|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    219|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_4clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     47|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     47|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     47|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     47|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     47|  constexpr auto _size = _name.size();                                \
 1183|     47|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     47|  return _nameof; }()
_ZNK6nameof7cstringILt23EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  3.28k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt23EE4dataEv:
  233|  3.28k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt23EE4sizeEv:
  235|  3.28k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_4clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     47|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     47|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     47|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     47|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     47|  constexpr auto _size = _name.size();                                \
 1183|     47|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     47|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_5clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    150|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    150|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    150|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    150|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    150|  constexpr auto _size = _name.size();                                \
 1183|    150|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    150|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_5clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    150|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    150|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    150|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    150|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    150|  constexpr auto _size = _name.size();                                \
 1183|    150|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    150|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_6clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    102|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    102|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    102|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    102|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    102|  constexpr auto _size = _name.size();                                \
 1183|    102|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    102|  return _nameof; }()
_ZNK6nameof7cstringILt22EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  4.05k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt22EE4dataEv:
  233|  4.05k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt22EE4sizeEv:
  235|  4.05k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_6clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    102|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    102|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    102|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    102|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    102|  constexpr auto _size = _name.size();                                \
 1183|    102|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    102|  return _nameof; }()
_ZNK6nameof7cstringILt27EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    310|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt27EE4dataEv:
  233|    310|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt27EE4sizeEv:
  235|    310|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_7clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    228|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    228|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    228|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    228|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    228|  constexpr auto _size = _name.size();                                \
 1183|    228|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    228|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_7clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    228|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    228|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    228|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    228|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    228|  constexpr auto _size = _name.size();                                \
 1183|    228|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    228|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_8clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    197|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    197|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    197|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    197|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    197|  constexpr auto _size = _name.size();                                \
 1183|    197|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    197|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_8clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    197|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    197|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    197|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    197|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    197|  constexpr auto _size = _name.size();                                \
 1183|    197|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    197|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_9clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    208|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    208|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    208|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    208|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    208|  constexpr auto _size = _name.size();                                \
 1183|    208|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    208|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_9clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    208|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    208|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    208|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    208|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    208|  constexpr auto _size = _name.size();                                \
 1183|    208|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    208|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_10clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     63|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     63|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     63|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     63|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     63|  constexpr auto _size = _name.size();                                \
 1183|     63|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     63|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_10clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     63|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     63|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     63|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     63|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     63|  constexpr auto _size = _name.size();                                \
 1183|     63|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     63|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_11clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    113|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    113|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    113|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    113|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    113|  constexpr auto _size = _name.size();                                \
 1183|    113|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    113|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_11clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    113|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    113|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    113|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    113|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    113|  constexpr auto _size = _name.size();                                \
 1183|    113|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    113|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_12clENSt3__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$_12clENSt3__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$_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|    136|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    136|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    136|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    136|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    136|  constexpr auto _size = _name.size();                                \
 1183|    136|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    136|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_14clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    136|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    136|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    136|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    136|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    136|  constexpr auto _size = _name.size();                                \
 1183|    136|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    136|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_15clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    193|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    193|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    193|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    193|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    193|  constexpr auto _size = _name.size();                                \
 1183|    193|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    193|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_15clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    193|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    193|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    193|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    193|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    193|  constexpr auto _size = _name.size();                                \
 1183|    193|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    193|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_16clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     94|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     94|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     94|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     94|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     94|  constexpr auto _size = _name.size();                                \
 1183|     94|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     94|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_16clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     94|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     94|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     94|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     94|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     94|  constexpr auto _size = _name.size();                                \
 1183|     94|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     94|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_17clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    221|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    221|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    221|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    221|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    221|  constexpr auto _size = _name.size();                                \
 1183|    221|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    221|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_17clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    221|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    221|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    221|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    221|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    221|  constexpr auto _size = _name.size();                                \
 1183|    221|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    221|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_18clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    216|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    216|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    216|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    216|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    216|  constexpr auto _size = _name.size();                                \
 1183|    216|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    216|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_18clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    216|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    216|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    216|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    216|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    216|  constexpr auto _size = _name.size();                                \
 1183|    216|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    216|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_19clENSt3__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$_19clENSt3__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; }()
_ZNK6nameof7cstringILt21EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    658|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt21EE4dataEv:
  233|    658|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt21EE4sizeEv:
  235|    658|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_20clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    281|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    281|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    281|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    281|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    281|  constexpr auto _size = _name.size();                                \
 1183|    281|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    281|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_20clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    281|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    281|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    281|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    281|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    281|  constexpr auto _size = _name.size();                                \
 1183|    281|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    281|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_21clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    356|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    356|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    356|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    356|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    356|  constexpr auto _size = _name.size();                                \
 1183|    356|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    356|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_21clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    356|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    356|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    356|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    356|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    356|  constexpr auto _size = _name.size();                                \
 1183|    356|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    356|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_22clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    330|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    330|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    330|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    330|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    330|  constexpr auto _size = _name.size();                                \
 1183|    330|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    330|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_22clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    330|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    330|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    330|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    330|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    330|  constexpr auto _size = _name.size();                                \
 1183|    330|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    330|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_23clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    356|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    356|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    356|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    356|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    356|  constexpr auto _size = _name.size();                                \
 1183|    356|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    356|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_23clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    356|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    356|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    356|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    356|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    356|  constexpr auto _size = _name.size();                                \
 1183|    356|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    356|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_24clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    126|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    126|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    126|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    126|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    126|  constexpr auto _size = _name.size();                                \
 1183|    126|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    126|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_24clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    126|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    126|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    126|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    126|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    126|  constexpr auto _size = _name.size();                                \
 1183|    126|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    126|  return _nameof; }()
_ZNK6nameof7cstringILt37EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    241|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt37EE4dataEv:
  233|    241|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt37EE4sizeEv:
  235|    241|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_25clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    150|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    150|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    150|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    150|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    150|  constexpr auto _size = _name.size();                                \
 1183|    150|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    150|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_25clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    150|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    150|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    150|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    150|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    150|  constexpr auto _size = _name.size();                                \
 1183|    150|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    150|  return _nameof; }()
_ZNK6nameof7cstringILt36EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  1.01k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt36EE4dataEv:
  233|  1.01k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt36EE4sizeEv:
  235|  1.01k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_26clENSt3__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$_26clENSt3__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; }()
_ZNK6nameof7cstringILt35EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  1.45k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt35EE4dataEv:
  233|  1.45k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt35EE4sizeEv:
  235|  1.45k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_27clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    115|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    115|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    115|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    115|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    115|  constexpr auto _size = _name.size();                                \
 1183|    115|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    115|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_27clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    115|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    115|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    115|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    115|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    115|  constexpr auto _size = _name.size();                                \
 1183|    115|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    115|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_28clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    207|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    207|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    207|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    207|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    207|  constexpr auto _size = _name.size();                                \
 1183|    207|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    207|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_28clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    207|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    207|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    207|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    207|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    207|  constexpr auto _size = _name.size();                                \
 1183|    207|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    207|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_29clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    315|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    315|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    315|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    315|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    315|  constexpr auto _size = _name.size();                                \
 1183|    315|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    315|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_29clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    315|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    315|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    315|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    315|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    315|  constexpr auto _size = _name.size();                                \
 1183|    315|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    315|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_30clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    210|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    210|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    210|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    210|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    210|  constexpr auto _size = _name.size();                                \
 1183|    210|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    210|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_30clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    210|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    210|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    210|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    210|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    210|  constexpr auto _size = _name.size();                                \
 1183|    210|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    210|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_31clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    303|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    303|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    303|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    303|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    303|  constexpr auto _size = _name.size();                                \
 1183|    303|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    303|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_31clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    303|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    303|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    303|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    303|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    303|  constexpr auto _size = _name.size();                                \
 1183|    303|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    303|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_32clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    358|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    358|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    358|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    358|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    358|  constexpr auto _size = _name.size();                                \
 1183|    358|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    358|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_32clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    358|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    358|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    358|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    358|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    358|  constexpr auto _size = _name.size();                                \
 1183|    358|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    358|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_33clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    415|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    415|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    415|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    415|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    415|  constexpr auto _size = _name.size();                                \
 1183|    415|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    415|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_33clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    415|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    415|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    415|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    415|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    415|  constexpr auto _size = _name.size();                                \
 1183|    415|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    415|  return _nameof; }()
_ZNK6nameof7cstringILt33EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    784|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt33EE4dataEv:
  233|    784|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt33EE4sizeEv:
  235|    784|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_34clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    258|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    258|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    258|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    258|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    258|  constexpr auto _size = _name.size();                                \
 1183|    258|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    258|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_34clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    258|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    258|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    258|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    258|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    258|  constexpr auto _size = _name.size();                                \
 1183|    258|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    258|  return _nameof; }()
_ZNK6nameof7cstringILt34EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    258|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt34EE4dataEv:
  233|    258|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt34EE4sizeEv:
  235|    258|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_35clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    351|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    351|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    351|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    351|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    351|  constexpr auto _size = _name.size();                                \
 1183|    351|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    351|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_35clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    351|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    351|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    351|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    351|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    351|  constexpr auto _size = _name.size();                                \
 1183|    351|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    351|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_36clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    287|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    287|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    287|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    287|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    287|  constexpr auto _size = _name.size();                                \
 1183|    287|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    287|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_36clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    287|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    287|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    287|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    287|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    287|  constexpr auto _size = _name.size();                                \
 1183|    287|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    287|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_37clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    369|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    369|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    369|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    369|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    369|  constexpr auto _size = _name.size();                                \
 1183|    369|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    369|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_37clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    369|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    369|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    369|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    369|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    369|  constexpr auto _size = _name.size();                                \
 1183|    369|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    369|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_38clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     45|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     45|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     45|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     45|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     45|  constexpr auto _size = _name.size();                                \
 1183|     45|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     45|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_38clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     45|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     45|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     45|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     45|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     45|  constexpr auto _size = _name.size();                                \
 1183|     45|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     45|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_39clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     40|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     40|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     40|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     40|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     40|  constexpr auto _size = _name.size();                                \
 1183|     40|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     40|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_39clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     40|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     40|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     40|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     40|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     40|  constexpr auto _size = _name.size();                                \
 1183|     40|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     40|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_40clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     40|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     40|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     40|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     40|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     40|  constexpr auto _size = _name.size();                                \
 1183|     40|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     40|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_40clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     40|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     40|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     40|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     40|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     40|  constexpr auto _size = _name.size();                                \
 1183|     40|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     40|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_41clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    269|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    269|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    269|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    269|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    269|  constexpr auto _size = _name.size();                                \
 1183|    269|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    269|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_41clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    269|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    269|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    269|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    269|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    269|  constexpr auto _size = _name.size();                                \
 1183|    269|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    269|  return _nameof; }()

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

_ZNK7simdutf14implementation4nameEv:
 5121|      4|  virtual std::string_view name() const noexcept { return _name; }
_ZNK7simdutf14implementation25required_instruction_setsEv:
 5172|      8|  virtual uint32_t required_instruction_sets() const {
 5173|      8|    return _required_instruction_sets;
 5174|      8|  }
_ZNK7simdutf14implementation24utf16_length_from_latin1Em:
 6362|    240|  utf16_length_from_latin1(size_t length) const noexcept {
 6363|    240|    return length;
 6364|    240|  }
_ZNK7simdutf14implementation24latin1_length_from_utf32Em:
 6550|    912|  latin1_length_from_utf32(size_t length) const noexcept {
 6551|    912|    return length;
 6552|    912|  }
_ZNK7simdutf14implementation24latin1_length_from_utf16Em:
 6587|  1.09k|  latin1_length_from_utf16(size_t length) const noexcept {
 6588|  1.09k|    return length;
 6589|  1.09k|  }
_ZNK7simdutf14implementation24utf32_length_from_latin1Em:
 6620|    135|  utf32_length_from_latin1(size_t length) const noexcept {
 6621|    135|    return length;
 6622|    135|  }
_ZN7simdutf14implementationC2EPKcS2_j:
 7058|      4|      : _name(name), _description(description),
 7059|      4|        _required_instruction_sets(required_instruction_sets) {}
_ZN7simdutf8internal29available_implementation_listC2Ev:
 7090|      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|    538|                                                     size_t len) {
   11|    538|  const uint8_t *c = reinterpret_cast<const uint8_t *>(buf);
   12|    538|  size_t answer = 0;
   13|  4.23k|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (13:22): [True: 3.69k, False: 538]
  ------------------
   14|  3.69k|    if ((c[i] >> 7)) {
  ------------------
  |  Branch (14:9): [True: 1.04k, False: 2.64k]
  ------------------
   15|  1.04k|      answer++;
   16|  1.04k|    }
   17|  3.69k|  }
   18|    538|  return answer + len;
   19|    538|}

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

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

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

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

_ZN7simdutf6scalar5utf168validateILNS_10endiannessE0EEEbPKDsm:
   22|  3.68k|validate(const char16_t *data, size_t len) noexcept {
   23|  3.68k|  uint64_t pos = 0;
   24|  21.6M|  while (pos < len) {
  ------------------
  |  Branch (24:10): [True: 21.6M, False: 2.57k]
  ------------------
   25|  21.6M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   26|  21.6M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (26:9): [True: 17.6k, False: 21.6M]
  ------------------
   27|  17.6k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 234, False: 17.3k]
  ------------------
   28|    234|        return false;
   29|    234|      }
   30|  17.3k|      char16_t diff = char16_t(word - 0xD800);
   31|  17.3k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (31:11): [True: 304, False: 17.0k]
  ------------------
   32|    304|        return false;
   33|    304|      }
   34|  17.0k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (34:28): [Folded, False: 17.0k]
  ------------------
   35|  17.0k|                               ? u16_swap_bytes(data[pos + 1])
   36|  17.0k|                               : data[pos + 1];
   37|  17.0k|      char16_t diff2 = char16_t(next_word - 0xDC00);
   38|  17.0k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (38:11): [True: 572, False: 16.5k]
  ------------------
   39|    572|        return false;
   40|    572|      }
   41|  16.5k|      pos += 2;
   42|  21.6M|    } else {
   43|  21.6M|      pos++;
   44|  21.6M|    }
   45|  21.6M|  }
   46|  2.57k|  return true;
   47|  3.68k|}
_ZN7simdutf6scalar5utf168validateILNS_10endiannessE1EEEbPKDsm:
   22|  3.44k|validate(const char16_t *data, size_t len) noexcept {
   23|  3.44k|  uint64_t pos = 0;
   24|  22.4M|  while (pos < len) {
  ------------------
  |  Branch (24:10): [True: 22.4M, False: 2.47k]
  ------------------
   25|  22.4M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   26|  22.4M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (26:9): [True: 17.4k, False: 22.4M]
  ------------------
   27|  17.4k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 213, False: 17.2k]
  ------------------
   28|    213|        return false;
   29|    213|      }
   30|  17.2k|      char16_t diff = char16_t(word - 0xD800);
   31|  17.2k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (31:11): [True: 276, False: 17.0k]
  ------------------
   32|    276|        return false;
   33|    276|      }
   34|  17.0k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (34:28): [True: 17.0k, Folded]
  ------------------
   35|  17.0k|                               ? u16_swap_bytes(data[pos + 1])
   36|  17.0k|                               : data[pos + 1];
   37|  17.0k|      char16_t diff2 = char16_t(next_word - 0xDC00);
   38|  17.0k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (38:11): [True: 488, False: 16.5k]
  ------------------
   39|    488|        return false;
   40|    488|      }
   41|  16.5k|      pos += 2;
   42|  22.4M|    } else {
   43|  22.4M|      pos++;
   44|  22.4M|    }
   45|  22.4M|  }
   46|  2.47k|  return true;
   47|  3.44k|}
_ZN7simdutf6scalar5utf1620validate_with_errorsILNS_10endiannessE0EEENS_6resultEPKDsm:
   51|  3.89k|validate_with_errors(const char16_t *data, size_t len) noexcept {
   52|  3.89k|  size_t pos = 0;
   53|  21.6M|  while (pos < len) {
  ------------------
  |  Branch (53:10): [True: 21.6M, False: 2.57k]
  ------------------
   54|  21.6M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   55|  21.6M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (55:9): [True: 17.8k, False: 21.6M]
  ------------------
   56|  17.8k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (56:11): [True: 234, False: 17.6k]
  ------------------
   57|    234|        return result(error_code::SURROGATE, pos);
   58|    234|      }
   59|  17.6k|      char16_t diff = char16_t(word - 0xD800);
   60|  17.6k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (60:11): [True: 408, False: 17.2k]
  ------------------
   61|    408|        return result(error_code::SURROGATE, pos);
   62|    408|      }
   63|  17.2k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (63:28): [Folded, False: 17.2k]
  ------------------
   64|  17.2k|                               ? u16_swap_bytes(data[pos + 1])
   65|  17.2k|                               : data[pos + 1];
   66|  17.2k|      char16_t diff2 = uint16_t(next_word - 0xDC00);
   67|  17.2k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (67:11): [True: 672, False: 16.5k]
  ------------------
   68|    672|        return result(error_code::SURROGATE, pos);
   69|    672|      }
   70|  16.5k|      pos += 2;
   71|  21.6M|    } else {
   72|  21.6M|      pos++;
   73|  21.6M|    }
   74|  21.6M|  }
   75|  2.57k|  return result(error_code::SUCCESS, pos);
   76|  3.89k|}
_ZN7simdutf6scalar5utf1620validate_with_errorsILNS_10endiannessE1EEENS_6resultEPKDsm:
   51|  3.67k|validate_with_errors(const char16_t *data, size_t len) noexcept {
   52|  3.67k|  size_t pos = 0;
   53|  22.4M|  while (pos < len) {
  ------------------
  |  Branch (53:10): [True: 22.4M, False: 2.47k]
  ------------------
   54|  22.4M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   55|  22.4M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (55:9): [True: 17.7k, False: 22.4M]
  ------------------
   56|  17.7k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (56:11): [True: 213, False: 17.5k]
  ------------------
   57|    213|        return result(error_code::SURROGATE, pos);
   58|    213|      }
   59|  17.5k|      char16_t diff = char16_t(word - 0xD800);
   60|  17.5k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (60:11): [True: 381, False: 17.2k]
  ------------------
   61|    381|        return result(error_code::SURROGATE, pos);
   62|    381|      }
   63|  17.2k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (63:28): [True: 17.2k, Folded]
  ------------------
   64|  17.2k|                               ? u16_swap_bytes(data[pos + 1])
   65|  17.2k|                               : data[pos + 1];
   66|  17.2k|      char16_t diff2 = uint16_t(next_word - 0xDC00);
   67|  17.2k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (67:11): [True: 612, False: 16.5k]
  ------------------
   68|    612|        return result(error_code::SURROGATE, pos);
   69|    612|      }
   70|  16.5k|      pos += 2;
   71|  22.4M|    } else {
   72|  22.4M|      pos++;
   73|  22.4M|    }
   74|  22.4M|  }
   75|  2.47k|  return result(error_code::SUCCESS, pos);
   76|  3.67k|}
_ZN7simdutf6scalar5utf1617count_code_pointsILNS_10endiannessE0EEEmPKDsm:
   79|  4.73k|simdutf_constexpr23 size_t count_code_points(const char16_t *p, size_t len) {
   80|       |  // We are not BOM aware.
   81|  4.73k|  size_t counter{0};
   82|  29.5M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (82:22): [True: 29.5M, False: 4.73k]
  ------------------
   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.73k|  return counter;
   87|  4.73k|}
_ZN7simdutf6scalar5utf1617count_code_pointsILNS_10endiannessE1EEEmPKDsm:
   79|  4.41k|simdutf_constexpr23 size_t count_code_points(const char16_t *p, size_t len) {
   80|       |  // We are not BOM aware.
   81|  4.41k|  size_t counter{0};
   82|  31.5M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (82:22): [True: 31.5M, False: 4.41k]
  ------------------
   83|  31.5M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
   84|  31.5M|    counter += ((word & 0xFC00) != 0xDC00);
   85|  31.5M|  }
   86|  4.41k|  return counter;
   87|  4.41k|}
_ZN7simdutf6scalar5utf1622utf8_length_from_utf16ILNS_10endiannessE0EEEmPKDsm:
   91|  2.18k|                                                  size_t len) {
   92|       |  // We are not BOM aware.
   93|  2.18k|  size_t counter{0};
   94|  19.1M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (94:22): [True: 19.0M, False: 2.18k]
  ------------------
   95|  19.0M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
   96|  19.0M|    counter++; // ASCII
   97|  19.0M|    counter += static_cast<size_t>(
   98|  19.0M|        word >
   99|  19.0M|        0x7F); // non-ASCII is at least 2 bytes, surrogates are 2*2 == 4 bytes
  100|  19.0M|    counter += static_cast<size_t>((word > 0x7FF && word <= 0xD7FF) ||
  ------------------
  |  Branch (100:37): [True: 3.17M, False: 15.9M]
  |  Branch (100:53): [True: 2.90M, False: 273k]
  ------------------
  101|  16.1M|                                   (word >= 0xE000)); // three-byte
  ------------------
  |  Branch (101:36): [True: 216k, False: 15.9M]
  ------------------
  102|  19.0M|  }
  103|  2.18k|  return counter;
  104|  2.18k|}
_ZN7simdutf6scalar5utf1622utf8_length_from_utf16ILNS_10endiannessE1EEEmPKDsm:
   91|  2.08k|                                                  size_t len) {
   92|       |  // We are not BOM aware.
   93|  2.08k|  size_t counter{0};
   94|  17.8M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (94:22): [True: 17.8M, False: 2.08k]
  ------------------
   95|  17.8M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
   96|  17.8M|    counter++; // ASCII
   97|  17.8M|    counter += static_cast<size_t>(
   98|  17.8M|        word >
   99|  17.8M|        0x7F); // non-ASCII is at least 2 bytes, surrogates are 2*2 == 4 bytes
  100|  17.8M|    counter += static_cast<size_t>((word > 0x7FF && word <= 0xD7FF) ||
  ------------------
  |  Branch (100:37): [True: 3.81M, False: 14.0M]
  |  Branch (100:53): [True: 3.66M, False: 156k]
  ------------------
  101|  14.1M|                                   (word >= 0xE000)); // three-byte
  ------------------
  |  Branch (101:36): [True: 132k, False: 14.0M]
  ------------------
  102|  17.8M|  }
  103|  2.08k|  return counter;
  104|  2.08k|}
_ZN7simdutf6scalar5utf1623utf32_length_from_utf16ILNS_10endiannessE0EEEmPKDsm:
  108|    404|                                                   size_t len) {
  109|       |  // We are not BOM aware.
  110|    404|  size_t counter{0};
  111|  6.01M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (111:22): [True: 6.01M, False: 404]
  ------------------
  112|  6.01M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
  113|  6.01M|    counter += ((word & 0xFC00) != 0xDC00);
  114|  6.01M|  }
  115|    404|  return counter;
  116|    404|}
_ZN7simdutf6scalar5utf1623utf32_length_from_utf16ILNS_10endiannessE1EEEmPKDsm:
  108|    351|                                                   size_t len) {
  109|       |  // We are not BOM aware.
  110|    351|  size_t counter{0};
  111|  6.99M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (111:22): [True: 6.99M, False: 351]
  ------------------
  112|  6.99M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
  113|  6.99M|    counter += ((word & 0xFC00) != 0xDC00);
  114|  6.99M|  }
  115|    351|  return counter;
  116|    351|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf16_to_latin17convertILNS_10endiannessE0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEEmS8_mS9_:
   17|    252|                                   OutputPtr latin_output) {
   18|    252|  if (len == 0) {
  ------------------
  |  Branch (18:7): [True: 6, False: 246]
  ------------------
   19|      6|    return 0;
   20|      6|  }
   21|    246|  size_t pos = 0;
   22|    246|  const auto latin_output_start = latin_output;
   23|    246|  uint16_t word = 0;
   24|    246|  uint16_t too_large = 0;
   25|       |
   26|   589k|  while (pos < len) {
  ------------------
  |  Branch (26:10): [True: 589k, False: 246]
  ------------------
   27|   589k|    word = !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (27:12): [Folded, False: 589k]
  ------------------
   28|   589k|    too_large |= word;
   29|   589k|    *latin_output++ = char(word & 0xFF);
   30|   589k|    pos++;
   31|   589k|  }
   32|    246|  if ((too_large & 0xFF00) != 0) {
  ------------------
  |  Branch (32:7): [True: 160, False: 86]
  ------------------
   33|    160|    return 0;
   34|    160|  }
   35|       |
   36|     86|  return latin_output - latin_output_start;
   37|    246|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf16_to_latin17convertILNS_10endiannessE1EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEEmS8_mS9_:
   17|    282|                                   OutputPtr latin_output) {
   18|    282|  if (len == 0) {
  ------------------
  |  Branch (18:7): [True: 6, False: 276]
  ------------------
   19|      6|    return 0;
   20|      6|  }
   21|    276|  size_t pos = 0;
   22|    276|  const auto latin_output_start = latin_output;
   23|    276|  uint16_t word = 0;
   24|    276|  uint16_t too_large = 0;
   25|       |
   26|  2.36M|  while (pos < len) {
  ------------------
  |  Branch (26:10): [True: 2.36M, False: 276]
  ------------------
   27|  2.36M|    word = !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (27:12): [True: 2.36M, Folded]
  ------------------
   28|  2.36M|    too_large |= word;
   29|  2.36M|    *latin_output++ = char(word & 0xFF);
   30|  2.36M|    pos++;
   31|  2.36M|  }
   32|    276|  if ((too_large & 0xFF00) != 0) {
  ------------------
  |  Branch (32:7): [True: 118, False: 158]
  ------------------
   33|    118|    return 0;
   34|    118|  }
   35|       |
   36|    158|  return latin_output - latin_output_start;
   37|    276|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf16_to_latin119convert_with_errorsILNS_10endiannessE0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEENS_6resultES8_mS9_:
   45|    396|                                               OutputPtr latin_output) {
   46|    396|  if (len == 0) {
  ------------------
  |  Branch (46:7): [True: 4, False: 392]
  ------------------
   47|      4|    return result(error_code::SUCCESS, 0);
   48|      4|  }
   49|    392|  size_t pos = 0;
   50|    392|  auto start = latin_output;
   51|    392|  uint16_t word;
   52|       |
   53|   453k|  while (pos < len) {
  ------------------
  |  Branch (53:10): [True: 453k, False: 168]
  ------------------
   54|       |#if SIMDUTF_CPLUSPLUS23
   55|       |    if !consteval
   56|       |#endif
   57|   453k|    {
   58|   453k|      if (pos + 16 <= len) { // if it is safe to read 32 more bytes, check that
  ------------------
  |  Branch (58:11): [True: 451k, False: 1.29k]
  ------------------
   59|       |                             // they are Latin1
   60|   451k|        uint64_t v1, v2, v3, v4;
   61|   451k|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   62|   451k|        ::memcpy(&v2, data + pos + 4, sizeof(uint64_t));
   63|   451k|        ::memcpy(&v3, data + pos + 8, sizeof(uint64_t));
   64|   451k|        ::memcpy(&v4, data + pos + 12, sizeof(uint64_t));
   65|       |
   66|       |        if constexpr (!match_system(big_endian)) {
   67|       |          v1 = (v1 >> 8) | (v1 << (64 - 8));
   68|       |        }
   69|       |        if constexpr (!match_system(big_endian)) {
   70|       |          v2 = (v2 >> 8) | (v2 << (64 - 8));
   71|       |        }
   72|       |        if constexpr (!match_system(big_endian)) {
   73|       |          v3 = (v3 >> 8) | (v3 << (64 - 8));
   74|       |        }
   75|       |        if constexpr (!match_system(big_endian)) {
   76|       |          v4 = (v4 >> 8) | (v4 << (64 - 8));
   77|       |        }
   78|       |
   79|   451k|        if (((v1 | v2 | v3 | v4) & 0xFF00FF00FF00FF00) == 0) {
  ------------------
  |  Branch (79:13): [True: 451k, False: 238]
  ------------------
   80|   451k|          size_t final_pos = pos + 16;
   81|  7.67M|          while (pos < final_pos) {
  ------------------
  |  Branch (81:18): [True: 7.22M, False: 451k]
  ------------------
   82|  7.22M|            *latin_output++ = !match_system(big_endian)
  ------------------
  |  Branch (82:31): [Folded, False: 7.22M]
  ------------------
   83|  7.22M|                                  ? char(u16_swap_bytes(data[pos]))
   84|  7.22M|                                  : char(data[pos]);
   85|  7.22M|            pos++;
   86|  7.22M|          }
   87|   451k|          continue;
   88|   451k|        }
   89|   451k|      }
   90|   453k|    }
   91|       |
   92|  1.53k|    word = !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (92:12): [Folded, False: 1.53k]
  ------------------
   93|  1.53k|    if ((word & 0xFF00) == 0) {
  ------------------
  |  Branch (93:9): [True: 1.30k, False: 224]
  ------------------
   94|  1.30k|      *latin_output++ = char(word & 0xFF);
   95|  1.30k|      pos++;
   96|  1.30k|    } else {
   97|    224|      return result(error_code::TOO_LARGE, pos);
   98|    224|    }
   99|  1.53k|  }
  100|    168|  return result(error_code::SUCCESS, latin_output - start);
  101|    392|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf16_to_latin119convert_with_errorsILNS_10endiannessE1EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEENS_6resultES8_mS9_:
   45|    450|                                               OutputPtr latin_output) {
   46|    450|  if (len == 0) {
  ------------------
  |  Branch (46:7): [True: 4, False: 446]
  ------------------
   47|      4|    return result(error_code::SUCCESS, 0);
   48|      4|  }
   49|    446|  size_t pos = 0;
   50|    446|  auto start = latin_output;
   51|    446|  uint16_t word;
   52|       |
   53|   525k|  while (pos < len) {
  ------------------
  |  Branch (53:10): [True: 525k, False: 208]
  ------------------
   54|       |#if SIMDUTF_CPLUSPLUS23
   55|       |    if !consteval
   56|       |#endif
   57|   525k|    {
   58|   525k|      if (pos + 16 <= len) { // if it is safe to read 32 more bytes, check that
  ------------------
  |  Branch (58:11): [True: 523k, False: 1.75k]
  ------------------
   59|       |                             // they are Latin1
   60|   523k|        uint64_t v1, v2, v3, v4;
   61|   523k|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   62|   523k|        ::memcpy(&v2, data + pos + 4, sizeof(uint64_t));
   63|   523k|        ::memcpy(&v3, data + pos + 8, sizeof(uint64_t));
   64|   523k|        ::memcpy(&v4, data + pos + 12, sizeof(uint64_t));
   65|       |
   66|   523k|        if constexpr (!match_system(big_endian)) {
   67|   523k|          v1 = (v1 >> 8) | (v1 << (64 - 8));
   68|   523k|        }
   69|   523k|        if constexpr (!match_system(big_endian)) {
   70|   523k|          v2 = (v2 >> 8) | (v2 << (64 - 8));
   71|   523k|        }
   72|   523k|        if constexpr (!match_system(big_endian)) {
   73|   523k|          v3 = (v3 >> 8) | (v3 << (64 - 8));
   74|   523k|        }
   75|   523k|        if constexpr (!match_system(big_endian)) {
   76|   523k|          v4 = (v4 >> 8) | (v4 << (64 - 8));
   77|   523k|        }
   78|       |
   79|   523k|        if (((v1 | v2 | v3 | v4) & 0xFF00FF00FF00FF00) == 0) {
  ------------------
  |  Branch (79:13): [True: 523k, False: 406]
  ------------------
   80|   523k|          size_t final_pos = pos + 16;
   81|  8.89M|          while (pos < final_pos) {
  ------------------
  |  Branch (81:18): [True: 8.37M, False: 523k]
  ------------------
   82|  8.37M|            *latin_output++ = !match_system(big_endian)
  ------------------
  |  Branch (82:31): [True: 8.37M, Folded]
  ------------------
   83|  8.37M|                                  ? char(u16_swap_bytes(data[pos]))
   84|  8.37M|                                  : char(data[pos]);
   85|  8.37M|            pos++;
   86|  8.37M|          }
   87|   523k|          continue;
   88|   523k|        }
   89|   523k|      }
   90|   525k|    }
   91|       |
   92|  2.15k|    word = !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (92:12): [True: 2.15k, Folded]
  ------------------
   93|  2.15k|    if ((word & 0xFF00) == 0) {
  ------------------
  |  Branch (93:9): [True: 1.92k, False: 238]
  ------------------
   94|  1.92k|      *latin_output++ = char(word & 0xFF);
   95|  1.92k|      pos++;
   96|  1.92k|    } else {
   97|    238|      return result(error_code::TOO_LARGE, pos);
   98|    238|    }
   99|  2.15k|  }
  100|    208|  return result(error_code::SUCCESS, latin_output - start);
  101|    446|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf327convertILNS_10endiannessE0EEEmPKDsmPDi:
   11|    712|                                   char32_t *utf32_output) {
   12|    712|  size_t pos = 0;
   13|    712|  char32_t *start{utf32_output};
   14|  1.04M|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 1.04M, False: 410]
  ------------------
   15|  1.04M|    uint16_t word =
   16|  1.04M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (16:9): [Folded, False: 1.04M]
  ------------------
   17|  1.04M|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (17:9): [True: 1.04M, False: 2.76k]
  ------------------
   18|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   19|  1.04M|      *utf32_output++ = char32_t(word);
   20|  1.04M|      pos++;
   21|  1.04M|    } else {
   22|       |      // must be a surrogate pair
   23|  2.76k|      uint16_t diff = uint16_t(word - 0xD800);
   24|  2.76k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (24:11): [True: 104, False: 2.65k]
  ------------------
   25|    104|        return 0;
   26|    104|      }
   27|  2.65k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 78, False: 2.58k]
  ------------------
   28|     78|        return 0;
   29|     78|      } // minimal bound checking
   30|  2.58k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (30:28): [Folded, False: 2.58k]
  ------------------
   31|  2.58k|                               ? u16_swap_bytes(data[pos + 1])
   32|  2.58k|                               : data[pos + 1];
   33|  2.58k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   34|  2.58k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (34:11): [True: 120, False: 2.46k]
  ------------------
   35|    120|        return 0;
   36|    120|      }
   37|  2.46k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   38|  2.46k|      *utf32_output++ = char32_t(value);
   39|  2.46k|      pos += 2;
   40|  2.46k|    }
   41|  1.04M|  }
   42|    410|  return utf32_output - start;
   43|    712|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf327convertILNS_10endiannessE1EEEmPKDsmPDi:
   11|    708|                                   char32_t *utf32_output) {
   12|    708|  size_t pos = 0;
   13|    708|  char32_t *start{utf32_output};
   14|   925k|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 924k, False: 402]
  ------------------
   15|   924k|    uint16_t word =
   16|   924k|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (16:9): [True: 924k, Folded]
  ------------------
   17|   924k|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (17:9): [True: 923k, False: 1.00k]
  ------------------
   18|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   19|   923k|      *utf32_output++ = char32_t(word);
   20|   923k|      pos++;
   21|   923k|    } else {
   22|       |      // must be a surrogate pair
   23|  1.00k|      uint16_t diff = uint16_t(word - 0xD800);
   24|  1.00k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (24:11): [True: 88, False: 918]
  ------------------
   25|     88|        return 0;
   26|     88|      }
   27|    918|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 96, False: 822]
  ------------------
   28|     96|        return 0;
   29|     96|      } // minimal bound checking
   30|    822|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (30:28): [True: 822, Folded]
  ------------------
   31|    822|                               ? u16_swap_bytes(data[pos + 1])
   32|    822|                               : data[pos + 1];
   33|    822|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   34|    822|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (34:11): [True: 122, False: 700]
  ------------------
   35|    122|        return 0;
   36|    122|      }
   37|    700|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   38|    700|      *utf32_output++ = char32_t(value);
   39|    700|      pos += 2;
   40|    700|    }
   41|   924k|  }
   42|    402|  return utf32_output - start;
   43|    708|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf3219convert_with_errorsILNS_10endiannessE0EEENS_6resultEPKDsmPDi:
   47|    892|                                               char32_t *utf32_output) {
   48|    892|  size_t pos = 0;
   49|    892|  char32_t *start{utf32_output};
   50|  2.49M|  while (pos < len) {
  ------------------
  |  Branch (50:10): [True: 2.49M, False: 492]
  ------------------
   51|  2.49M|    uint16_t word =
   52|  2.49M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (52:9): [Folded, False: 2.49M]
  ------------------
   53|  2.49M|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (53:9): [True: 2.48M, False: 11.9k]
  ------------------
   54|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   55|  2.48M|      *utf32_output++ = char32_t(word);
   56|  2.48M|      pos++;
   57|  2.48M|    } else {
   58|       |      // must be a surrogate pair
   59|  11.9k|      uint16_t diff = uint16_t(word - 0xD800);
   60|  11.9k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (60:11): [True: 118, False: 11.8k]
  ------------------
   61|    118|        return result(error_code::SURROGATE, pos);
   62|    118|      }
   63|  11.8k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (63:11): [True: 96, False: 11.7k]
  ------------------
   64|     96|        return result(error_code::SURROGATE, pos);
   65|     96|      } // minimal bound checking
   66|  11.7k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (66:28): [Folded, False: 11.7k]
  ------------------
   67|  11.7k|                               ? u16_swap_bytes(data[pos + 1])
   68|  11.7k|                               : data[pos + 1];
   69|  11.7k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   70|  11.7k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (70:11): [True: 186, False: 11.5k]
  ------------------
   71|    186|        return result(error_code::SURROGATE, pos);
   72|    186|      }
   73|  11.5k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   74|  11.5k|      *utf32_output++ = char32_t(value);
   75|  11.5k|      pos += 2;
   76|  11.5k|    }
   77|  2.49M|  }
   78|    492|  return result(error_code::SUCCESS, utf32_output - start);
   79|    892|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf3219convert_with_errorsILNS_10endiannessE1EEENS_6resultEPKDsmPDi:
   47|    702|                                               char32_t *utf32_output) {
   48|    702|  size_t pos = 0;
   49|    702|  char32_t *start{utf32_output};
   50|  3.39M|  while (pos < len) {
  ------------------
  |  Branch (50:10): [True: 3.39M, False: 412]
  ------------------
   51|  3.39M|    uint16_t word =
   52|  3.39M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (52:9): [True: 3.39M, Folded]
  ------------------
   53|  3.39M|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (53:9): [True: 3.38M, False: 10.4k]
  ------------------
   54|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   55|  3.38M|      *utf32_output++ = char32_t(word);
   56|  3.38M|      pos++;
   57|  3.38M|    } else {
   58|       |      // must be a surrogate pair
   59|  10.4k|      uint16_t diff = uint16_t(word - 0xD800);
   60|  10.4k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (60:11): [True: 68, False: 10.4k]
  ------------------
   61|     68|        return result(error_code::SURROGATE, pos);
   62|     68|      }
   63|  10.4k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (63:11): [True: 102, False: 10.3k]
  ------------------
   64|    102|        return result(error_code::SURROGATE, pos);
   65|    102|      } // minimal bound checking
   66|  10.3k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (66:28): [True: 10.3k, Folded]
  ------------------
   67|  10.3k|                               ? u16_swap_bytes(data[pos + 1])
   68|  10.3k|                               : data[pos + 1];
   69|  10.3k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   70|  10.3k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (70:11): [True: 120, False: 10.1k]
  ------------------
   71|    120|        return result(error_code::SURROGATE, pos);
   72|    120|      }
   73|  10.1k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   74|  10.1k|      *utf32_output++ = char32_t(value);
   75|  10.1k|      pos += 2;
   76|  10.1k|    }
   77|  3.39M|  }
   78|    412|  return result(error_code::SUCCESS, utf32_output - start);
   79|    702|}

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

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf87convertILNS_10endiannessE0EPKDsPcQsr7simdutf6detailE18indexes_into_utf16IT0_EEEmS8_mT1_:
   17|  1.79k|                                   OutputPtr utf8_output) {
   18|  1.79k|  size_t pos = 0;
   19|  1.79k|  const auto start = utf8_output;
   20|  3.00M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 3.00M, False: 1.49k]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  3.00M|    {
   25|       |      // try to convert the next block of 8 bytes
   26|  3.00M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (26:11): [True: 2.99M, False: 3.18k]
  ------------------
   27|       |                            // they are ascii
   28|  2.99M|        uint64_t v;
   29|  2.99M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   30|       |        if constexpr (!match_system(big_endian)) {
   31|       |          v = (v >> 8) | (v << (64 - 8));
   32|       |        }
   33|  2.99M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (33:13): [True: 2.42M, False: 571k]
  ------------------
   34|  2.42M|          size_t final_pos = pos + 4;
   35|  12.1M|          while (pos < final_pos) {
  ------------------
  |  Branch (35:18): [True: 9.69M, False: 2.42M]
  ------------------
   36|  9.69M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (36:30): [Folded, False: 9.69M]
  ------------------
   37|  9.69M|                                 ? char(u16_swap_bytes(data[pos]))
   38|  9.69M|                                 : char(data[pos]);
   39|  9.69M|            pos++;
   40|  9.69M|          }
   41|  2.42M|          continue;
   42|  2.42M|        }
   43|  2.99M|      }
   44|  3.00M|    }
   45|   575k|    uint16_t word =
   46|   575k|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (46:9): [Folded, False: 575k]
  ------------------
   47|   575k|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (47:9): [True: 139k, False: 436k]
  ------------------
   48|       |      // will generate one UTF-8 bytes
   49|   139k|      *utf8_output++ = char(word);
   50|   139k|      pos++;
   51|   436k|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (51:16): [True: 91.6k, False: 344k]
  ------------------
   52|       |      // will generate two UTF-8 bytes
   53|       |      // we have 0b110XXXXX 0b10XXXXXX
   54|  91.6k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   55|  91.6k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   56|  91.6k|      pos++;
   57|   344k|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (57:16): [True: 339k, False: 4.42k]
  ------------------
   58|       |      // will generate three UTF-8 bytes
   59|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   60|   339k|      *utf8_output++ = char((word >> 12) | 0b11100000);
   61|   339k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   62|   339k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   63|   339k|      pos++;
   64|   339k|    } else {
   65|       |      // must be a surrogate pair
   66|  4.42k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (66:11): [True: 42, False: 4.37k]
  ------------------
   67|     42|        return 0;
   68|     42|      }
   69|  4.37k|      uint16_t diff = uint16_t(word - 0xD800);
   70|  4.37k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (70:11): [True: 102, False: 4.27k]
  ------------------
   71|    102|        return 0;
   72|    102|      }
   73|  4.27k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (73:28): [Folded, False: 4.27k]
  ------------------
   74|  4.27k|                               ? u16_swap_bytes(data[pos + 1])
   75|  4.27k|                               : data[pos + 1];
   76|  4.27k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   77|  4.27k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (77:11): [True: 152, False: 4.12k]
  ------------------
   78|    152|        return 0;
   79|    152|      }
   80|  4.12k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   81|       |      // will generate four UTF-8 bytes
   82|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   83|  4.12k|      *utf8_output++ = char((value >> 18) | 0b11110000);
   84|  4.12k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
   85|  4.12k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
   86|  4.12k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
   87|  4.12k|      pos += 2;
   88|  4.12k|    }
   89|   575k|  }
   90|  1.49k|  return utf8_output - start;
   91|  1.79k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf87convertILNS_10endiannessE1EPKDsPcQsr7simdutf6detailE18indexes_into_utf16IT0_EEEmS8_mT1_:
   17|  1.68k|                                   OutputPtr utf8_output) {
   18|  1.68k|  size_t pos = 0;
   19|  1.68k|  const auto start = utf8_output;
   20|  3.79M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 3.78M, False: 1.45k]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  3.78M|    {
   25|       |      // try to convert the next block of 8 bytes
   26|  3.78M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (26:11): [True: 3.78M, False: 3.06k]
  ------------------
   27|       |                            // they are ascii
   28|  3.78M|        uint64_t v;
   29|  3.78M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   30|  3.78M|        if constexpr (!match_system(big_endian)) {
   31|  3.78M|          v = (v >> 8) | (v << (64 - 8));
   32|  3.78M|        }
   33|  3.78M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (33:13): [True: 1.59M, False: 2.19M]
  ------------------
   34|  1.59M|          size_t final_pos = pos + 4;
   35|  7.96M|          while (pos < final_pos) {
  ------------------
  |  Branch (35:18): [True: 6.36M, False: 1.59M]
  ------------------
   36|  6.36M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (36:30): [True: 6.36M, Folded]
  ------------------
   37|  6.36M|                                 ? char(u16_swap_bytes(data[pos]))
   38|  6.36M|                                 : char(data[pos]);
   39|  6.36M|            pos++;
   40|  6.36M|          }
   41|  1.59M|          continue;
   42|  1.59M|        }
   43|  3.78M|      }
   44|  3.78M|    }
   45|  2.19M|    uint16_t word =
   46|  2.19M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (46:9): [True: 2.19M, Folded]
  ------------------
   47|  2.19M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (47:9): [True: 160k, False: 2.03M]
  ------------------
   48|       |      // will generate one UTF-8 bytes
   49|   160k|      *utf8_output++ = char(word);
   50|   160k|      pos++;
   51|  2.03M|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (51:16): [True: 57.5k, False: 1.97M]
  ------------------
   52|       |      // will generate two UTF-8 bytes
   53|       |      // we have 0b110XXXXX 0b10XXXXXX
   54|  57.5k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   55|  57.5k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   56|  57.5k|      pos++;
   57|  1.97M|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (57:16): [True: 1.97M, False: 6.51k]
  ------------------
   58|       |      // will generate three UTF-8 bytes
   59|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   60|  1.97M|      *utf8_output++ = char((word >> 12) | 0b11100000);
   61|  1.97M|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   62|  1.97M|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   63|  1.97M|      pos++;
   64|  1.97M|    } else {
   65|       |      // must be a surrogate pair
   66|  6.51k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (66:11): [True: 30, False: 6.48k]
  ------------------
   67|     30|        return 0;
   68|     30|      }
   69|  6.48k|      uint16_t diff = uint16_t(word - 0xD800);
   70|  6.48k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (70:11): [True: 80, False: 6.40k]
  ------------------
   71|     80|        return 0;
   72|     80|      }
   73|  6.40k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (73:28): [True: 6.40k, Folded]
  ------------------
   74|  6.40k|                               ? u16_swap_bytes(data[pos + 1])
   75|  6.40k|                               : data[pos + 1];
   76|  6.40k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   77|  6.40k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (77:11): [True: 122, False: 6.28k]
  ------------------
   78|    122|        return 0;
   79|    122|      }
   80|  6.28k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   81|       |      // will generate four UTF-8 bytes
   82|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   83|  6.28k|      *utf8_output++ = char((value >> 18) | 0b11110000);
   84|  6.28k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
   85|  6.28k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
   86|  6.28k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
   87|  6.28k|      pos += 2;
   88|  6.28k|    }
   89|  2.19M|  }
   90|  1.45k|  return utf8_output - start;
   91|  1.68k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf819convert_with_errorsILNS_10endiannessE0ELb0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT1_Esr7simdutf6detailE26index_assignable_from_charIT2_EEENS_11full_resultES8_mS9_m:
  101|  1.64k|                                                    size_t utf8_len = 0) {
  102|  1.64k|  if (check_output && utf8_len == 0) {
  ------------------
  |  Branch (102:7): [Folded, False: 1.64k]
  |  Branch (102:23): [True: 0, False: 0]
  ------------------
  103|      0|    return full_result(error_code::OUTPUT_BUFFER_TOO_SMALL, 0, 0);
  104|      0|  }
  105|       |
  106|  1.64k|  size_t pos = 0;
  107|  1.64k|  auto start = utf8_output;
  108|  1.64k|  auto end = utf8_output + utf8_len;
  109|       |
  110|  6.55M|  while (pos < len) {
  ------------------
  |  Branch (110:10): [True: 6.55M, False: 1.23k]
  ------------------
  111|       |#if SIMDUTF_CPLUSPLUS23
  112|       |    if !consteval
  113|       |#endif
  114|  6.55M|    {
  115|       |      // try to convert the next block of 8 bytes
  116|  6.55M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (116:11): [True: 6.54M, False: 2.83k]
  ------------------
  117|       |                            // they are ascii
  118|  6.54M|        uint64_t v;
  119|  6.54M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
  120|       |        if constexpr (!match_system(big_endian))
  121|       |          v = (v >> 8) | (v << (64 - 8));
  122|  6.54M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (122:13): [True: 1.95M, False: 4.59M]
  ------------------
  123|  1.95M|          size_t final_pos = pos + 4;
  124|  9.78M|          while (pos < final_pos) {
  ------------------
  |  Branch (124:18): [True: 7.82M, False: 1.95M]
  ------------------
  125|  7.82M|            if (check_output && size_t(end - utf8_output) < 1) {
  ------------------
  |  Branch (125:17): [Folded, False: 7.82M]
  |  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|  7.82M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (129:30): [Folded, False: 7.82M]
  ------------------
  130|  7.82M|                                 ? char(u16_swap_bytes(data[pos]))
  131|  7.82M|                                 : char(data[pos]);
  132|  7.82M|            pos++;
  133|  7.82M|          }
  134|  1.95M|          continue;
  135|  1.95M|        }
  136|  6.54M|      }
  137|  6.55M|    }
  138|       |
  139|  4.59M|    uint16_t word =
  140|  4.59M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (140:9): [Folded, False: 4.59M]
  ------------------
  141|  4.59M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (141:9): [True: 240k, False: 4.35M]
  ------------------
  142|       |      // will generate one UTF-8 bytes
  143|   240k|      if (check_output && size_t(end - utf8_output) < 1) {
  ------------------
  |  Branch (143:11): [Folded, False: 240k]
  |  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|   240k|      *utf8_output++ = char(word);
  148|   240k|      pos++;
  149|  4.35M|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (149:16): [True: 1.48M, False: 2.86M]
  ------------------
  150|       |      // will generate two UTF-8 bytes
  151|       |      // we have 0b110XXXXX 0b10XXXXXX
  152|  1.48M|      if (check_output && size_t(end - utf8_output) < 2) {
  ------------------
  |  Branch (152:11): [Folded, False: 1.48M]
  |  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|  1.48M|      *utf8_output++ = char((word >> 6) | 0b11000000);
  157|  1.48M|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  158|  1.48M|      pos++;
  159|       |
  160|  2.86M|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (160:16): [True: 2.85M, False: 4.84k]
  ------------------
  161|       |      // will generate three UTF-8 bytes
  162|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
  163|  2.85M|      if (check_output && size_t(end - utf8_output) < 3) {
  ------------------
  |  Branch (163:11): [Folded, False: 2.85M]
  |  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|  2.85M|      *utf8_output++ = char((word >> 12) | 0b11100000);
  168|  2.85M|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  169|  2.85M|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  170|  2.85M|      pos++;
  171|  2.85M|    } else {
  172|       |
  173|  4.84k|      if (check_output && size_t(end - utf8_output) < 4) {
  ------------------
  |  Branch (173:11): [Folded, False: 4.84k]
  |  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|  4.84k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (178:11): [True: 72, False: 4.77k]
  ------------------
  179|     72|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  180|     72|      }
  181|  4.77k|      uint16_t diff = uint16_t(word - 0xD800);
  182|  4.77k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (182:11): [True: 98, False: 4.67k]
  ------------------
  183|     98|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  184|     98|      }
  185|  4.67k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (185:28): [Folded, False: 4.67k]
  ------------------
  186|  4.67k|                               ? u16_swap_bytes(data[pos + 1])
  187|  4.67k|                               : data[pos + 1];
  188|  4.67k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
  189|  4.67k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (189:11): [True: 238, False: 4.43k]
  ------------------
  190|    238|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  191|    238|      }
  192|  4.43k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
  193|       |      // will generate four UTF-8 bytes
  194|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
  195|  4.43k|      *utf8_output++ = char((value >> 18) | 0b11110000);
  196|  4.43k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  197|  4.43k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  198|  4.43k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
  199|  4.43k|      pos += 2;
  200|  4.43k|    }
  201|  4.59M|  }
  202|  1.23k|  return full_result(error_code::SUCCESS, pos, utf8_output - start);
  203|  1.64k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf819convert_with_errorsILNS_10endiannessE1ELb0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT1_Esr7simdutf6detailE26index_assignable_from_charIT2_EEENS_11full_resultES8_mS9_m:
  101|  1.44k|                                                    size_t utf8_len = 0) {
  102|  1.44k|  if (check_output && utf8_len == 0) {
  ------------------
  |  Branch (102:7): [Folded, False: 1.44k]
  |  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.44k|  size_t pos = 0;
  107|  1.44k|  auto start = utf8_output;
  108|  1.44k|  auto end = utf8_output + utf8_len;
  109|       |
  110|  2.49M|  while (pos < len) {
  ------------------
  |  Branch (110:10): [True: 2.49M, False: 1.00k]
  ------------------
  111|       |#if SIMDUTF_CPLUSPLUS23
  112|       |    if !consteval
  113|       |#endif
  114|  2.49M|    {
  115|       |      // try to convert the next block of 8 bytes
  116|  2.49M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (116:11): [True: 2.49M, False: 2.25k]
  ------------------
  117|       |                            // they are ascii
  118|  2.49M|        uint64_t v;
  119|  2.49M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
  120|       |        if constexpr (!match_system(big_endian))
  121|  2.49M|          v = (v >> 8) | (v << (64 - 8));
  122|  2.49M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (122:13): [True: 1.66M, False: 829k]
  ------------------
  123|  1.66M|          size_t final_pos = pos + 4;
  124|  8.30M|          while (pos < final_pos) {
  ------------------
  |  Branch (124:18): [True: 6.64M, False: 1.66M]
  ------------------
  125|  6.64M|            if (check_output && size_t(end - utf8_output) < 1) {
  ------------------
  |  Branch (125:17): [Folded, False: 6.64M]
  |  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.64M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (129:30): [True: 6.64M, Folded]
  ------------------
  130|  6.64M|                                 ? char(u16_swap_bytes(data[pos]))
  131|  6.64M|                                 : char(data[pos]);
  132|  6.64M|            pos++;
  133|  6.64M|          }
  134|  1.66M|          continue;
  135|  1.66M|        }
  136|  2.49M|      }
  137|  2.49M|    }
  138|       |
  139|   832k|    uint16_t word =
  140|   832k|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (140:9): [True: 832k, Folded]
  ------------------
  141|   832k|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (141:9): [True: 255k, False: 576k]
  ------------------
  142|       |      // will generate one UTF-8 bytes
  143|   255k|      if (check_output && size_t(end - utf8_output) < 1) {
  ------------------
  |  Branch (143:11): [Folded, False: 255k]
  |  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|   255k|      *utf8_output++ = char(word);
  148|   255k|      pos++;
  149|   576k|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (149:16): [True: 110k, False: 465k]
  ------------------
  150|       |      // will generate two UTF-8 bytes
  151|       |      // we have 0b110XXXXX 0b10XXXXXX
  152|   110k|      if (check_output && size_t(end - utf8_output) < 2) {
  ------------------
  |  Branch (152:11): [Folded, False: 110k]
  |  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|   110k|      *utf8_output++ = char((word >> 6) | 0b11000000);
  157|   110k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  158|   110k|      pos++;
  159|       |
  160|   465k|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (160:16): [True: 457k, False: 8.40k]
  ------------------
  161|       |      // will generate three UTF-8 bytes
  162|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
  163|   457k|      if (check_output && size_t(end - utf8_output) < 3) {
  ------------------
  |  Branch (163:11): [Folded, False: 457k]
  |  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|   457k|      *utf8_output++ = char((word >> 12) | 0b11100000);
  168|   457k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  169|   457k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  170|   457k|      pos++;
  171|   457k|    } else {
  172|       |
  173|  8.40k|      if (check_output && size_t(end - utf8_output) < 4) {
  ------------------
  |  Branch (173:11): [Folded, False: 8.40k]
  |  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|  8.40k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (178:11): [True: 72, False: 8.33k]
  ------------------
  179|     72|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  180|     72|      }
  181|  8.33k|      uint16_t diff = uint16_t(word - 0xD800);
  182|  8.33k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (182:11): [True: 152, False: 8.18k]
  ------------------
  183|    152|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  184|    152|      }
  185|  8.18k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (185:28): [True: 8.18k, Folded]
  ------------------
  186|  8.18k|                               ? u16_swap_bytes(data[pos + 1])
  187|  8.18k|                               : data[pos + 1];
  188|  8.18k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
  189|  8.18k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (189:11): [True: 220, False: 7.96k]
  ------------------
  190|    220|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  191|    220|      }
  192|  7.96k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
  193|       |      // will generate four UTF-8 bytes
  194|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
  195|  7.96k|      *utf8_output++ = char((value >> 18) | 0b11110000);
  196|  7.96k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  197|  7.96k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  198|  7.96k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
  199|  7.96k|      pos += 2;
  200|  7.96k|    }
  201|   832k|  }
  202|  1.00k|  return full_result(error_code::SUCCESS, pos, utf8_output - start);
  203|  1.44k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf813convert_validILNS_10endiannessE0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEEmS8_mS9_:
   17|    416|                                         OutputPtr utf8_output) {
   18|    416|  size_t pos = 0;
   19|    416|  auto start = utf8_output;
   20|  2.15M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 2.15M, False: 416]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  2.15M|    {
   25|       |      // try to convert the next block of 4 ASCII characters
   26|  2.15M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (26:11): [True: 2.15M, False: 850]
  ------------------
   27|       |                            // they are ascii
   28|  2.15M|        uint64_t v;
   29|  2.15M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   30|       |        if constexpr (!match_system(big_endian)) {
   31|       |          v = (v >> 8) | (v << (64 - 8));
   32|       |        }
   33|  2.15M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (33:13): [True: 1.70M, False: 456k]
  ------------------
   34|  1.70M|          size_t final_pos = pos + 4;
   35|  8.50M|          while (pos < final_pos) {
  ------------------
  |  Branch (35:18): [True: 6.80M, False: 1.70M]
  ------------------
   36|  6.80M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (36:30): [Folded, False: 6.80M]
  ------------------
   37|  6.80M|                                 ? char(u16_swap_bytes(data[pos]))
   38|  6.80M|                                 : char(data[pos]);
   39|  6.80M|            pos++;
   40|  6.80M|          }
   41|  1.70M|          continue;
   42|  1.70M|        }
   43|  2.15M|      }
   44|  2.15M|    }
   45|       |
   46|   457k|    uint16_t word =
   47|   457k|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (47:9): [Folded, False: 457k]
  ------------------
   48|   457k|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (48:9): [True: 177k, False: 279k]
  ------------------
   49|       |      // will generate one UTF-8 bytes
   50|   177k|      *utf8_output++ = char(word);
   51|   177k|      pos++;
   52|   279k|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (52:16): [True: 74.6k, False: 205k]
  ------------------
   53|       |      // will generate two UTF-8 bytes
   54|       |      // we have 0b110XXXXX 0b10XXXXXX
   55|  74.6k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   56|  74.6k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   57|  74.6k|      pos++;
   58|   205k|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (58:16): [True: 200k, False: 4.60k]
  ------------------
   59|       |      // will generate three UTF-8 bytes
   60|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   61|   200k|      *utf8_output++ = char((word >> 12) | 0b11100000);
   62|   200k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   63|   200k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   64|   200k|      pos++;
   65|   200k|    } else {
   66|       |      // must be a surrogate pair
   67|  4.60k|      uint16_t diff = uint16_t(word - 0xD800);
   68|  4.60k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (68:11): [True: 0, False: 4.60k]
  ------------------
   69|      0|        return 0;
   70|      0|      } // minimal bound checking
   71|  4.60k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (71:28): [Folded, False: 4.60k]
  ------------------
   72|  4.60k|                               ? u16_swap_bytes(data[pos + 1])
   73|  4.60k|                               : data[pos + 1];
   74|  4.60k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   75|  4.60k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   76|       |      // will generate four UTF-8 bytes
   77|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   78|  4.60k|      *utf8_output++ = char((value >> 18) | 0b11110000);
   79|  4.60k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
   80|  4.60k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
   81|  4.60k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
   82|  4.60k|      pos += 2;
   83|  4.60k|    }
   84|   457k|  }
   85|    416|  return utf8_output - start;
   86|    416|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf813convert_validILNS_10endiannessE1EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEEmS8_mS9_:
   17|    442|                                         OutputPtr utf8_output) {
   18|    442|  size_t pos = 0;
   19|    442|  auto start = utf8_output;
   20|  3.33M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 3.33M, False: 442]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  3.33M|    {
   25|       |      // try to convert the next block of 4 ASCII characters
   26|  3.33M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (26:11): [True: 3.33M, False: 880]
  ------------------
   27|       |                            // they are ascii
   28|  3.33M|        uint64_t v;
   29|  3.33M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   30|  3.33M|        if constexpr (!match_system(big_endian)) {
   31|  3.33M|          v = (v >> 8) | (v << (64 - 8));
   32|  3.33M|        }
   33|  3.33M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (33:13): [True: 1.91M, False: 1.41M]
  ------------------
   34|  1.91M|          size_t final_pos = pos + 4;
   35|  9.59M|          while (pos < final_pos) {
  ------------------
  |  Branch (35:18): [True: 7.67M, False: 1.91M]
  ------------------
   36|  7.67M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (36:30): [True: 7.67M, Folded]
  ------------------
   37|  7.67M|                                 ? char(u16_swap_bytes(data[pos]))
   38|  7.67M|                                 : char(data[pos]);
   39|  7.67M|            pos++;
   40|  7.67M|          }
   41|  1.91M|          continue;
   42|  1.91M|        }
   43|  3.33M|      }
   44|  3.33M|    }
   45|       |
   46|  1.41M|    uint16_t word =
   47|  1.41M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (47:9): [True: 1.41M, Folded]
  ------------------
   48|  1.41M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (48:9): [True: 361k, False: 1.05M]
  ------------------
   49|       |      // will generate one UTF-8 bytes
   50|   361k|      *utf8_output++ = char(word);
   51|   361k|      pos++;
   52|  1.05M|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (52:16): [True: 105k, False: 952k]
  ------------------
   53|       |      // will generate two UTF-8 bytes
   54|       |      // we have 0b110XXXXX 0b10XXXXXX
   55|   105k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   56|   105k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   57|   105k|      pos++;
   58|   952k|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (58:16): [True: 949k, False: 2.44k]
  ------------------
   59|       |      // will generate three UTF-8 bytes
   60|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   61|   949k|      *utf8_output++ = char((word >> 12) | 0b11100000);
   62|   949k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   63|   949k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   64|   949k|      pos++;
   65|   949k|    } else {
   66|       |      // must be a surrogate pair
   67|  2.44k|      uint16_t diff = uint16_t(word - 0xD800);
   68|  2.44k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (68:11): [True: 0, False: 2.44k]
  ------------------
   69|      0|        return 0;
   70|      0|      } // minimal bound checking
   71|  2.44k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (71:28): [True: 2.44k, Folded]
  ------------------
   72|  2.44k|                               ? u16_swap_bytes(data[pos + 1])
   73|  2.44k|                               : data[pos + 1];
   74|  2.44k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   75|  2.44k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   76|       |      // will generate four UTF-8 bytes
   77|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   78|  2.44k|      *utf8_output++ = char((value >> 18) | 0b11110000);
   79|  2.44k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
   80|  2.44k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
   81|  2.44k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
   82|  2.44k|      pos += 2;
   83|  2.44k|    }
   84|  1.41M|  }
   85|    442|  return utf8_output - start;
   86|    442|}

_ZN7simdutf6scalar5utf328validateEPKDim:
   25|  5.29k|                                                        size_t len) noexcept {
   26|  5.29k|  return validate(reinterpret_cast<const uint32_t *>(buf), len);
   27|  5.29k|}
_ZN7simdutf6scalar5utf3220validate_with_errorsEPKDim:
   49|  7.21k|validate_with_errors(const char32_t *buf, size_t len) noexcept {
   50|  7.21k|  return validate_with_errors(reinterpret_cast<const uint32_t *>(buf), len);
   51|  7.21k|}
_ZN7simdutf6scalar5utf3222utf8_length_from_utf32EPKDim:
   54|  2.45k|                                                         size_t len) {
   55|       |  // We are not BOM aware.
   56|  2.45k|  size_t counter{0};
   57|  2.32M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (57:22): [True: 2.32M, False: 2.45k]
  ------------------
   58|       |    // credit: @ttsugriy  for the vectorizable approach
   59|  2.32M|    counter++;                                     // ASCII
   60|  2.32M|    counter += static_cast<size_t>(p[i] > 0x7F);   // two-byte
   61|  2.32M|    counter += static_cast<size_t>(p[i] > 0x7FF);  // three-byte
   62|  2.32M|    counter += static_cast<size_t>(p[i] > 0xFFFF); // four-bytes
   63|  2.32M|  }
   64|  2.45k|  return counter;
   65|  2.45k|}
_ZN7simdutf6scalar5utf3223utf16_length_from_utf32EPKDim:
   68|  3.88k|utf16_length_from_utf32(const char32_t *p, size_t len) {
   69|       |  // We are not BOM aware.
   70|  3.88k|  size_t counter{0};
   71|  5.38M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (71:22): [True: 5.37M, False: 3.88k]
  ------------------
   72|  5.37M|    counter++;                                     // non-surrogate word
   73|  5.37M|    counter += static_cast<size_t>(p[i] > 0xFFFF); // surrogate pair
   74|  5.37M|  }
   75|  3.88k|  return counter;
   76|  3.88k|}
_ZN7simdutf6scalar5utf328validateIPKjQsr7simdutf6detailE19indexes_into_uint32IT_EEEbS5_m:
   13|  5.29k|                                                      size_t len) noexcept {
   14|  5.29k|  uint64_t pos = 0;
   15|  1.02M|  for (; pos < len; pos++) {
  ------------------
  |  Branch (15:10): [True: 1.02M, False: 2.39k]
  ------------------
   16|  1.02M|    uint32_t word = data[pos];
   17|  1.02M|    if (word > 0x10FFFF || (word >= 0xD800 && word <= 0xDFFF)) {
  ------------------
  |  Branch (17:9): [True: 2.41k, False: 1.01M]
  |  Branch (17:29): [True: 31.7k, False: 986k]
  |  Branch (17:47): [True: 487, False: 31.2k]
  ------------------
   18|  2.90k|      return false;
   19|  2.90k|    }
   20|  1.02M|  }
   21|  2.39k|  return true;
   22|  5.29k|}
_ZN7simdutf6scalar5utf3220validate_with_errorsIPKjQsr7simdutf6detailE19indexes_into_uint32IT_EEENS_6resultES5_m:
   34|  7.21k|validate_with_errors(InputPtr data, size_t len) noexcept {
   35|  7.21k|  size_t pos = 0;
   36|  1.02M|  for (; pos < len; pos++) {
  ------------------
  |  Branch (36:10): [True: 1.02M, False: 2.39k]
  ------------------
   37|  1.02M|    uint32_t word = data[pos];
   38|  1.02M|    if (word > 0x10FFFF) {
  ------------------
  |  Branch (38:9): [True: 3.92k, False: 1.02M]
  ------------------
   39|  3.92k|      return result(error_code::TOO_LARGE, pos);
   40|  3.92k|    }
   41|  1.02M|    if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (41:9): [True: 33.0k, False: 988k]
  |  Branch (41:27): [True: 894, False: 32.1k]
  ------------------
   42|    894|      return result(error_code::SURROGATE, pos);
   43|    894|    }
   44|  1.02M|  }
   45|  2.39k|  return result(error_code::SUCCESS, pos);
   46|  7.21k|}

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

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf167convertILNS_10endiannessE0EEEmPKDimPDs:
   11|  1.69k|                                   char16_t *utf16_output) {
   12|  1.69k|  size_t pos = 0;
   13|  1.69k|  char16_t *start{utf16_output};
   14|  17.3k|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 16.3k, False: 1.01k]
  ------------------
   15|  16.3k|    uint32_t word = data[pos];
   16|  16.3k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (16:9): [True: 12.9k, False: 3.40k]
  ------------------
   17|  12.9k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (17:11): [True: 1.71k, False: 11.2k]
  |  Branch (17:29): [True: 176, False: 1.53k]
  ------------------
   18|    176|        return 0;
   19|    176|      }
   20|       |      // will not generate a surrogate pair
   21|  12.7k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (21:25): [Folded, False: 12.7k]
  ------------------
   22|  12.7k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   23|  12.7k|                            : char16_t(word);
   24|  12.7k|    } else {
   25|       |      // will generate a surrogate pair
   26|  3.40k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (26:11): [True: 506, False: 2.89k]
  ------------------
   27|    506|        return 0;
   28|    506|      }
   29|  2.89k|      word -= 0x10000;
   30|  2.89k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   31|  2.89k|      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|  2.89k|      *utf16_output++ = char16_t(high_surrogate);
   37|  2.89k|      *utf16_output++ = char16_t(low_surrogate);
   38|  2.89k|    }
   39|  15.6k|    pos++;
   40|  15.6k|  }
   41|  1.01k|  return utf16_output - start;
   42|  1.69k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf167convertILNS_10endiannessE1EEEmPKDimPDs:
   11|  1.28k|                                   char16_t *utf16_output) {
   12|  1.28k|  size_t pos = 0;
   13|  1.28k|  char16_t *start{utf16_output};
   14|  55.8k|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 55.3k, False: 502]
  ------------------
   15|  55.3k|    uint32_t word = data[pos];
   16|  55.3k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (16:9): [True: 53.1k, False: 2.24k]
  ------------------
   17|  53.1k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (17:11): [True: 1.05k, False: 52.0k]
  |  Branch (17:29): [True: 194, False: 860]
  ------------------
   18|    194|        return 0;
   19|    194|      }
   20|       |      // will not generate a surrogate pair
   21|  52.9k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (21:25): [True: 52.9k, Folded]
  ------------------
   22|  52.9k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   23|  52.9k|                            : char16_t(word);
   24|  52.9k|    } else {
   25|       |      // will generate a surrogate pair
   26|  2.24k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (26:11): [True: 586, False: 1.66k]
  ------------------
   27|    586|        return 0;
   28|    586|      }
   29|  1.66k|      word -= 0x10000;
   30|  1.66k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   31|  1.66k|      uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   32|  1.66k|      if constexpr (!match_system(big_endian)) {
   33|  1.66k|        high_surrogate = u16_swap_bytes(high_surrogate);
   34|  1.66k|        low_surrogate = u16_swap_bytes(low_surrogate);
   35|  1.66k|      }
   36|  1.66k|      *utf16_output++ = char16_t(high_surrogate);
   37|  1.66k|      *utf16_output++ = char16_t(low_surrogate);
   38|  1.66k|    }
   39|  54.5k|    pos++;
   40|  54.5k|  }
   41|    502|  return utf16_output - start;
   42|  1.28k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf1619convert_with_errorsILNS_10endiannessE0EEENS_6resultEPKDimPDs:
   46|  2.12k|                                               char16_t *utf16_output) {
   47|  2.12k|  size_t pos = 0;
   48|  2.12k|  char16_t *start{utf16_output};
   49|   707k|  while (pos < len) {
  ------------------
  |  Branch (49:10): [True: 707k, False: 530]
  ------------------
   50|   707k|    uint32_t word = data[pos];
   51|   707k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (51:9): [True: 695k, False: 11.6k]
  ------------------
   52|   695k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (52:11): [True: 2.06k, False: 693k]
  |  Branch (52:29): [True: 366, False: 1.69k]
  ------------------
   53|    366|        return result(error_code::SURROGATE, pos);
   54|    366|      }
   55|       |      // will not generate a surrogate pair
   56|   695k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (56:25): [Folded, False: 695k]
  ------------------
   57|   695k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   58|   695k|                            : char16_t(word);
   59|   695k|    } else {
   60|       |      // will generate a surrogate pair
   61|  11.6k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (61:11): [True: 1.22k, False: 10.4k]
  ------------------
   62|  1.22k|        return result(error_code::TOO_LARGE, pos);
   63|  1.22k|      }
   64|  10.4k|      word -= 0x10000;
   65|  10.4k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   66|  10.4k|      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|  10.4k|      *utf16_output++ = char16_t(high_surrogate);
   72|  10.4k|      *utf16_output++ = char16_t(low_surrogate);
   73|  10.4k|    }
   74|   705k|    pos++;
   75|   705k|  }
   76|    530|  return result(error_code::SUCCESS, utf16_output - start);
   77|  2.12k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf1619convert_with_errorsILNS_10endiannessE1EEENS_6resultEPKDimPDs:
   46|  1.79k|                                               char16_t *utf16_output) {
   47|  1.79k|  size_t pos = 0;
   48|  1.79k|  char16_t *start{utf16_output};
   49|   103k|  while (pos < len) {
  ------------------
  |  Branch (49:10): [True: 102k, False: 490]
  ------------------
   50|   102k|    uint32_t word = data[pos];
   51|   102k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (51:9): [True: 97.8k, False: 4.79k]
  ------------------
   52|  97.8k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (52:11): [True: 1.87k, False: 96.0k]
  |  Branch (52:29): [True: 210, False: 1.66k]
  ------------------
   53|    210|        return result(error_code::SURROGATE, pos);
   54|    210|      }
   55|       |      // will not generate a surrogate pair
   56|  97.6k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (56:25): [True: 97.6k, Folded]
  ------------------
   57|  97.6k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   58|  97.6k|                            : char16_t(word);
   59|  97.6k|    } else {
   60|       |      // will generate a surrogate pair
   61|  4.79k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (61:11): [True: 1.09k, False: 3.69k]
  ------------------
   62|  1.09k|        return result(error_code::TOO_LARGE, pos);
   63|  1.09k|      }
   64|  3.69k|      word -= 0x10000;
   65|  3.69k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   66|  3.69k|      uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   67|  3.69k|      if constexpr (!match_system(big_endian)) {
   68|  3.69k|        high_surrogate = u16_swap_bytes(high_surrogate);
   69|  3.69k|        low_surrogate = u16_swap_bytes(low_surrogate);
   70|  3.69k|      }
   71|  3.69k|      *utf16_output++ = char16_t(high_surrogate);
   72|  3.69k|      *utf16_output++ = char16_t(low_surrogate);
   73|  3.69k|    }
   74|   101k|    pos++;
   75|   101k|  }
   76|    490|  return result(error_code::SUCCESS, utf16_output - start);
   77|  1.79k|}

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

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf32_to_utf87convertIPKDiPcQaasr7simdutf6detailE18indexes_into_utf32IT_Esr7simdutf6detailE26index_assignable_from_charIT0_EEEmS7_mS8_:
   17|  1.67k|                                   OutputPtr utf8_output) {
   18|  1.67k|  size_t pos = 0;
   19|  1.67k|  auto start = utf8_output;
   20|  39.1k|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 38.4k, False: 684]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  38.4k|    { // try to convert the next block of 2 ASCII characters
   25|  38.4k|      if (pos + 2 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 37.4k, False: 948]
  ------------------
   26|       |                            // they are ascii
   27|  37.4k|        uint64_t v;
   28|  37.4k|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   29|  37.4k|        if ((v & 0xFFFFFF80FFFFFF80) == 0) {
  ------------------
  |  Branch (29:13): [True: 17.1k, False: 20.3k]
  ------------------
   30|  17.1k|          *utf8_output++ = char(data[pos]);
   31|  17.1k|          *utf8_output++ = char(data[pos + 1]);
   32|  17.1k|          pos += 2;
   33|  17.1k|          continue;
   34|  17.1k|        }
   35|  37.4k|      }
   36|  38.4k|    }
   37|       |
   38|  21.3k|    uint32_t word = data[pos];
   39|  21.3k|    if ((word & 0xFFFFFF80) == 0) {
  ------------------
  |  Branch (39:9): [True: 2.73k, False: 18.5k]
  ------------------
   40|       |      // will generate one UTF-8 bytes
   41|  2.73k|      *utf8_output++ = char(word);
   42|  2.73k|      pos++;
   43|  18.5k|    } else if ((word & 0xFFFFF800) == 0) {
  ------------------
  |  Branch (43:16): [True: 6.79k, False: 11.7k]
  ------------------
   44|       |      // will generate two UTF-8 bytes
   45|       |      // we have 0b110XXXXX 0b10XXXXXX
   46|  6.79k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   47|  6.79k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   48|  6.79k|      pos++;
   49|  11.7k|    } else if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (49:16): [True: 7.97k, False: 3.80k]
  ------------------
   50|       |      // will generate three UTF-8 bytes
   51|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   52|  7.97k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (52:11): [True: 5.98k, False: 1.98k]
  |  Branch (52:29): [True: 192, False: 5.79k]
  ------------------
   53|    192|        return 0;
   54|    192|      }
   55|  7.78k|      *utf8_output++ = char((word >> 12) | 0b11100000);
   56|  7.78k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   57|  7.78k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   58|  7.78k|      pos++;
   59|  7.78k|    } else {
   60|       |      // will generate four UTF-8 bytes
   61|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   62|  3.80k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (62:11): [True: 794, False: 3.01k]
  ------------------
   63|    794|        return 0;
   64|    794|      }
   65|  3.01k|      *utf8_output++ = char((word >> 18) | 0b11110000);
   66|  3.01k|      *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000);
   67|  3.01k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   68|  3.01k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   69|  3.01k|      pos++;
   70|  3.01k|    }
   71|  21.3k|  }
   72|    684|  return utf8_output - start;
   73|  1.67k|}
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|   284k|  while (pos < len) {
  ------------------
  |  Branch (84:10): [True: 283k, False: 586]
  ------------------
   85|       |#if SIMDUTF_CPLUSPLUS23
   86|       |    if !consteval
   87|       |#endif
   88|   283k|    { // try to convert the next block of 2 ASCII characters
   89|   283k|      if (pos + 2 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (89:11): [True: 282k, False: 934]
  ------------------
   90|       |                            // they are ascii
   91|   282k|        uint64_t v;
   92|   282k|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   93|   282k|        if ((v & 0xFFFFFF80FFFFFF80) == 0) {
  ------------------
  |  Branch (93:13): [True: 228k, False: 54.8k]
  ------------------
   94|   228k|          *utf8_output++ = char(data[pos]);
   95|   228k|          *utf8_output++ = char(data[pos + 1]);
   96|   228k|          pos += 2;
   97|   228k|          continue;
   98|   228k|        }
   99|   282k|      }
  100|   283k|    }
  101|       |
  102|  55.7k|    uint32_t word = data[pos];
  103|  55.7k|    if ((word & 0xFFFFFF80) == 0) {
  ------------------
  |  Branch (103:9): [True: 5.47k, False: 50.2k]
  ------------------
  104|       |      // will generate one UTF-8 bytes
  105|  5.47k|      *utf8_output++ = char(word);
  106|  5.47k|      pos++;
  107|  50.2k|    } else if ((word & 0xFFFFF800) == 0) {
  ------------------
  |  Branch (107:16): [True: 28.4k, False: 21.8k]
  ------------------
  108|       |      // will generate two UTF-8 bytes
  109|       |      // we have 0b110XXXXX 0b10XXXXXX
  110|  28.4k|      *utf8_output++ = char((word >> 6) | 0b11000000);
  111|  28.4k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  112|  28.4k|      pos++;
  113|  28.4k|    } else if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (113:16): [True: 9.28k, False: 12.5k]
  ------------------
  114|       |      // will generate three UTF-8 bytes
  115|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
  116|  9.28k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (116:11): [True: 5.94k, False: 3.34k]
  |  Branch (116:29): [True: 330, False: 5.61k]
  ------------------
  117|    330|        return result(error_code::SURROGATE, pos);
  118|    330|      }
  119|  8.95k|      *utf8_output++ = char((word >> 12) | 0b11100000);
  120|  8.95k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  121|  8.95k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  122|  8.95k|      pos++;
  123|  12.5k|    } else {
  124|       |      // will generate four UTF-8 bytes
  125|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
  126|  12.5k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (126:11): [True: 1.56k, False: 10.9k]
  ------------------
  127|  1.56k|        return result(error_code::TOO_LARGE, pos);
  128|  1.56k|      }
  129|  10.9k|      *utf8_output++ = char((word >> 18) | 0b11110000);
  130|  10.9k|      *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000);
  131|  10.9k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  132|  10.9k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  133|  10.9k|      pos++;
  134|  10.9k|    }
  135|  55.7k|  }
  136|    586|  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|    192|                                         OutputPtr utf8_output) {
   18|    192|  size_t pos = 0;
   19|    192|  auto start = utf8_output;
   20|  15.3k|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 15.1k, False: 192]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  15.1k|    { // try to convert the next block of 2 ASCII characters
   25|  15.1k|      if (pos + 2 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 14.9k, False: 174]
  ------------------
   26|       |                            // they are ascii
   27|  14.9k|        uint64_t v;
   28|  14.9k|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   29|  14.9k|        if ((v & 0xFFFFFF80FFFFFF80) == 0) {
  ------------------
  |  Branch (29:13): [True: 1.41k, False: 13.5k]
  ------------------
   30|  1.41k|          *utf8_output++ = char(data[pos]);
   31|  1.41k|          *utf8_output++ = char(data[pos + 1]);
   32|  1.41k|          pos += 2;
   33|  1.41k|          continue;
   34|  1.41k|        }
   35|  14.9k|      }
   36|  15.1k|    }
   37|       |
   38|  13.6k|    uint32_t word = data[pos];
   39|  13.6k|    if ((word & 0xFFFFFF80) == 0) {
  ------------------
  |  Branch (39:9): [True: 636, False: 13.0k]
  ------------------
   40|       |      // will generate one UTF-8 bytes
   41|    636|      *utf8_output++ = char(word);
   42|    636|      pos++;
   43|  13.0k|    } else if ((word & 0xFFFFF800) == 0) {
  ------------------
  |  Branch (43:16): [True: 7.83k, False: 5.22k]
  ------------------
   44|       |      // will generate two UTF-8 bytes
   45|       |      // we have 0b110XXXXX 0b10XXXXXX
   46|  7.83k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   47|  7.83k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   48|  7.83k|      pos++;
   49|  7.83k|    } else if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (49:16): [True: 1.52k, False: 3.69k]
  ------------------
   50|       |      // will generate three UTF-8 bytes
   51|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   52|  1.52k|      *utf8_output++ = char((word >> 12) | 0b11100000);
   53|  1.52k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   54|  1.52k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   55|  1.52k|      pos++;
   56|  3.69k|    } else {
   57|       |      // will generate four UTF-8 bytes
   58|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   59|  3.69k|      *utf8_output++ = char((word >> 18) | 0b11110000);
   60|  3.69k|      *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000);
   61|  3.69k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   62|  3.69k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   63|  3.69k|      pos++;
   64|  3.69k|    }
   65|  13.6k|  }
   66|    192|  return utf8_output - start;
   67|    192|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf88validateEPKcm:
  113|  3.22k|                                                        size_t len) noexcept {
  114|  3.22k|  return validate(reinterpret_cast<const uint8_t *>(buf), len);
  115|  3.22k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf88validateIPKhEEbT_m:
   14|  3.22k|                                                      size_t len) noexcept {
   15|  3.22k|  static_assert(
   16|  3.22k|      std::is_same<typename std::decay<decltype(*data)>::type, uint8_t>::value,
   17|  3.22k|      "dereferencing the data pointer must result in a uint8_t");
   18|  3.22k|  uint64_t pos = 0;
   19|  3.22k|  uint32_t code_point = 0;
   20|  8.18M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 8.18M, False: 616]
  ------------------
   21|  8.18M|    uint64_t next_pos;
   22|       |#if SIMDUTF_CPLUSPLUS23
   23|       |    if !consteval
   24|       |#endif
   25|  8.18M|    { // check if the next 16 bytes are ascii.
   26|  8.18M|      next_pos = pos + 16;
   27|  8.18M|      if (next_pos <= len) { // if it is safe to read 16 more bytes, check
  ------------------
  |  Branch (27:11): [True: 8.18M, False: 3.19k]
  ------------------
   28|       |                             // that they are ascii
   29|  8.18M|        uint64_t v1{};
   30|  8.18M|        std::memcpy(&v1, data + pos, sizeof(uint64_t));
   31|  8.18M|        uint64_t v2{};
   32|  8.18M|        std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   33|  8.18M|        uint64_t v{v1 | v2};
   34|  8.18M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (34:13): [True: 7.12M, False: 1.06M]
  ------------------
   35|  7.12M|          pos = next_pos;
   36|  7.12M|          continue;
   37|  7.12M|        }
   38|  8.18M|      }
   39|  8.18M|    }
   40|       |
   41|  1.06M|    unsigned char byte = data[pos];
   42|       |
   43|  5.48M|    while (byte < 0b10000000) {
  ------------------
  |  Branch (43:12): [True: 4.41M, False: 1.06M]
  ------------------
   44|  4.41M|      if (++pos == len) {
  ------------------
  |  Branch (44:11): [True: 1.00k, False: 4.41M]
  ------------------
   45|  1.00k|        return true;
   46|  1.00k|      }
   47|  4.41M|      byte = data[pos];
   48|  4.41M|    }
   49|       |
   50|  1.06M|    if ((byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (50:9): [True: 706k, False: 357k]
  ------------------
   51|   706k|      next_pos = pos + 2;
   52|   706k|      if (next_pos > len) {
  ------------------
  |  Branch (52:11): [True: 67, False: 706k]
  ------------------
   53|     67|        return false;
   54|     67|      }
   55|   706k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (55:11): [True: 252, False: 705k]
  ------------------
   56|    252|        return false;
   57|    252|      }
   58|       |      // range check
   59|   705k|      code_point = (byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
   60|   705k|      if (code_point < 0x80) {
  ------------------
  |  Branch (60:11): [True: 30, False: 705k]
  ------------------
   61|     30|        return false;
   62|     30|      }
   63|   705k|    } else if ((byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (63:16): [True: 303k, False: 54.1k]
  ------------------
   64|   303k|      next_pos = pos + 3;
   65|   303k|      if (next_pos > len) {
  ------------------
  |  Branch (65:11): [True: 39, False: 303k]
  ------------------
   66|     39|        return false;
   67|     39|      }
   68|   303k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (68:11): [True: 102, False: 303k]
  ------------------
   69|    102|        return false;
   70|    102|      }
   71|   303k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (71:11): [True: 48, False: 302k]
  ------------------
   72|     48|        return false;
   73|     48|      }
   74|       |      // range check
   75|   302k|      code_point = (byte & 0b00001111) << 12 |
   76|   302k|                   (data[pos + 1] & 0b00111111) << 6 |
   77|   302k|                   (data[pos + 2] & 0b00111111);
   78|   302k|      if ((code_point < 0x800) ||
  ------------------
  |  Branch (78:11): [True: 39, False: 302k]
  ------------------
   79|   302k|          (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (79:12): [True: 8.41k, False: 294k]
  |  Branch (79:35): [True: 18, False: 8.39k]
  ------------------
   80|     57|        return false;
   81|     57|      }
   82|   302k|    } else if ((byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (82:16): [True: 53.3k, False: 762]
  ------------------
   83|  53.3k|      next_pos = pos + 4;
   84|  53.3k|      if (next_pos > len) {
  ------------------
  |  Branch (84:11): [True: 28, False: 53.3k]
  ------------------
   85|     28|        return false;
   86|     28|      }
   87|  53.3k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (87:11): [True: 91, False: 53.2k]
  ------------------
   88|     91|        return false;
   89|     91|      }
   90|  53.2k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (90:11): [True: 36, False: 53.2k]
  ------------------
   91|     36|        return false;
   92|     36|      }
   93|  53.2k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (93:11): [True: 32, False: 53.1k]
  ------------------
   94|     32|        return false;
   95|     32|      }
   96|       |      // range check
   97|  53.1k|      code_point =
   98|  53.1k|          (byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 |
   99|  53.1k|          (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111);
  100|  53.1k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (100:11): [True: 27, False: 53.1k]
  |  Branch (100:35): [True: 34, False: 53.1k]
  ------------------
  101|     61|        return false;
  102|     61|      }
  103|  53.1k|    } else {
  104|       |      // we may have a continuation
  105|    762|      return false;
  106|    762|    }
  107|  1.06M|    pos = next_pos;
  108|  1.06M|  }
  109|    616|  return true;
  110|  3.22k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf820validate_with_errorsEPKcm:
  221|  6.18k|validate_with_errors(const char *buf, size_t len) noexcept {
  222|  6.18k|  return validate_with_errors(reinterpret_cast<const uint8_t *>(buf), len);
  223|  6.18k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf820validate_with_errorsIPKhEENS_6resultET_m:
  119|  6.18k|validate_with_errors(BytePtr data, size_t len) noexcept {
  120|  6.18k|  static_assert(
  121|  6.18k|      std::is_same<typename std::decay<decltype(*data)>::type, uint8_t>::value,
  122|  6.18k|      "dereferencing the data pointer must result in a uint8_t");
  123|  6.18k|  size_t pos = 0;
  124|  6.18k|  uint32_t code_point = 0;
  125|  8.19M|  while (pos < len) {
  ------------------
  |  Branch (125:10): [True: 8.19M, False: 616]
  ------------------
  126|       |    // check of the next 16 bytes are ascii.
  127|  8.19M|    size_t next_pos = pos + 16;
  128|  8.19M|    if (next_pos <=
  ------------------
  |  Branch (128:9): [True: 8.18M, False: 4.86k]
  ------------------
  129|  8.19M|        len) { // if it is safe to read 16 more bytes, check that they are ascii
  130|  8.18M|      uint64_t v1;
  131|  8.18M|      std::memcpy(&v1, data + pos, sizeof(uint64_t));
  132|  8.18M|      uint64_t v2;
  133|  8.18M|      std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  134|  8.18M|      uint64_t v{v1 | v2};
  135|  8.18M|      if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (135:11): [True: 7.12M, False: 1.06M]
  ------------------
  136|  7.12M|        pos = next_pos;
  137|  7.12M|        continue;
  138|  7.12M|      }
  139|  8.18M|    }
  140|  1.07M|    unsigned char byte = data[pos];
  141|       |
  142|  5.50M|    while (byte < 0b10000000) {
  ------------------
  |  Branch (142:12): [True: 4.43M, False: 1.06M]
  ------------------
  143|  4.43M|      if (++pos == len) {
  ------------------
  |  Branch (143:11): [True: 1.00k, False: 4.43M]
  ------------------
  144|  1.00k|        return result(error_code::SUCCESS, len);
  145|  1.00k|      }
  146|  4.43M|      byte = data[pos];
  147|  4.43M|    }
  148|       |
  149|  1.06M|    if ((byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (149:9): [True: 709k, False: 360k]
  ------------------
  150|   709k|      next_pos = pos + 2;
  151|   709k|      if (next_pos > len) {
  ------------------
  |  Branch (151:11): [True: 201, False: 708k]
  ------------------
  152|    201|        return result(error_code::TOO_SHORT, pos);
  153|    201|      }
  154|   708k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (154:11): [True: 756, False: 708k]
  ------------------
  155|    756|        return result(error_code::TOO_SHORT, pos);
  156|    756|      }
  157|       |      // range check
  158|   708k|      code_point = (byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
  159|   708k|      if (code_point < 0x80) {
  ------------------
  |  Branch (159:11): [True: 90, False: 708k]
  ------------------
  160|     90|        return result(error_code::OVERLONG, pos);
  161|     90|      }
  162|   708k|    } else if ((byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (162:16): [True: 304k, False: 56.2k]
  ------------------
  163|   304k|      next_pos = pos + 3;
  164|   304k|      if (next_pos > len) {
  ------------------
  |  Branch (164:11): [True: 117, False: 304k]
  ------------------
  165|    117|        return result(error_code::TOO_SHORT, pos);
  166|    117|      }
  167|   304k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (167:11): [True: 306, False: 304k]
  ------------------
  168|    306|        return result(error_code::TOO_SHORT, pos);
  169|    306|      }
  170|   304k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (170:11): [True: 144, False: 304k]
  ------------------
  171|    144|        return result(error_code::TOO_SHORT, pos);
  172|    144|      }
  173|       |      // range check
  174|   304k|      code_point = (byte & 0b00001111) << 12 |
  175|   304k|                   (data[pos + 1] & 0b00111111) << 6 |
  176|   304k|                   (data[pos + 2] & 0b00111111);
  177|   304k|      if (code_point < 0x800) {
  ------------------
  |  Branch (177:11): [True: 117, False: 303k]
  ------------------
  178|    117|        return result(error_code::OVERLONG, pos);
  179|    117|      }
  180|   303k|      if (0xd7ff < code_point && code_point < 0xe000) {
  ------------------
  |  Branch (180:11): [True: 9.03k, False: 294k]
  |  Branch (180:34): [True: 54, False: 8.98k]
  ------------------
  181|     54|        return result(error_code::SURROGATE, pos);
  182|     54|      }
  183|   303k|    } else if ((byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (183:16): [True: 54.1k, False: 2.04k]
  ------------------
  184|  54.1k|      next_pos = pos + 4;
  185|  54.1k|      if (next_pos > len) {
  ------------------
  |  Branch (185:11): [True: 84, False: 54.0k]
  ------------------
  186|     84|        return result(error_code::TOO_SHORT, pos);
  187|     84|      }
  188|  54.0k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (188:11): [True: 273, False: 53.8k]
  ------------------
  189|    273|        return result(error_code::TOO_SHORT, pos);
  190|    273|      }
  191|  53.8k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (191:11): [True: 108, False: 53.7k]
  ------------------
  192|    108|        return result(error_code::TOO_SHORT, pos);
  193|    108|      }
  194|  53.7k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (194:11): [True: 96, False: 53.6k]
  ------------------
  195|     96|        return result(error_code::TOO_SHORT, pos);
  196|     96|      }
  197|       |      // range check
  198|  53.6k|      code_point =
  199|  53.6k|          (byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 |
  200|  53.6k|          (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111);
  201|  53.6k|      if (code_point <= 0xffff) {
  ------------------
  |  Branch (201:11): [True: 81, False: 53.5k]
  ------------------
  202|     81|        return result(error_code::OVERLONG, pos);
  203|     81|      }
  204|  53.5k|      if (0x10ffff < code_point) {
  ------------------
  |  Branch (204:11): [True: 102, False: 53.4k]
  ------------------
  205|    102|        return result(error_code::TOO_LARGE, pos);
  206|    102|      }
  207|  53.5k|    } else {
  208|       |      // we either have too many continuation bytes or an invalid leading byte
  209|  2.04k|      if ((byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (209:11): [True: 995, False: 1.04k]
  ------------------
  210|    995|        return result(error_code::TOO_LONG, pos);
  211|  1.04k|      } else {
  212|  1.04k|        return result(error_code::HEADER_BITS, pos);
  213|  1.04k|      }
  214|  2.04k|    }
  215|  1.06M|    pos = next_pos;
  216|  1.06M|  }
  217|    616|  return result(error_code::SUCCESS, len);
  218|  6.18k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf831rewind_and_validate_with_errorsEPKcS4_m:
  232|  3.21k|    const char *start, const char *buf, size_t len) noexcept {
  233|       |  // First check that we start with a leading byte
  234|  3.21k|  if ((*start & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (234:7): [True: 244, False: 2.96k]
  ------------------
  235|    244|    return result(error_code::TOO_LONG, 0);
  236|    244|  }
  237|  2.96k|  size_t extra_len{0};
  238|       |  // A leading byte cannot be further than 4 bytes away
  239|  3.16k|  for (int i = 0; i < 5; i++) {
  ------------------
  |  Branch (239:19): [True: 3.16k, False: 0]
  ------------------
  240|  3.16k|    unsigned char byte = *buf;
  241|  3.16k|    if ((byte & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (241:9): [True: 2.96k, False: 194]
  ------------------
  242|  2.96k|      break;
  243|  2.96k|    } else {
  244|    194|      buf--;
  245|    194|      extra_len++;
  246|    194|    }
  247|  3.16k|  }
  248|       |
  249|  2.96k|  result res = validate_with_errors(buf, len + extra_len);
  250|  2.96k|  res.count -= extra_len; // Might underflow
  251|  2.96k|  return res;
  252|  3.21k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf817count_code_pointsIPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEEmS6_m:
  258|  14.0k|simdutf_constexpr23 size_t count_code_points(InputPtr data, size_t len) {
  259|  14.0k|  size_t counter{0};
  260|   256M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (260:22): [True: 256M, False: 14.0k]
  ------------------
  261|       |    // -65 is 0b10111111, anything larger in two-complement's should start a new
  262|       |    // code point.
  263|   256M|    if (int8_t(data[i]) > -65) {
  ------------------
  |  Branch (263:9): [True: 253M, False: 2.84M]
  ------------------
  264|   253M|      counter++;
  265|   253M|    }
  266|   256M|  }
  267|  14.0k|  return counter;
  268|  14.0k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf822utf16_length_from_utf8IPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEEmS6_m:
  274|  5.24k|simdutf_constexpr23 size_t utf16_length_from_utf8(InputPtr data, size_t len) {
  275|  5.24k|  size_t counter{0};
  276|  95.6M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (276:22): [True: 95.6M, False: 5.24k]
  ------------------
  277|  95.6M|    if (int8_t(data[i]) > -65) {
  ------------------
  |  Branch (277:9): [True: 94.1M, False: 1.47M]
  ------------------
  278|  94.1M|      counter++;
  279|  94.1M|    }
  280|  95.6M|    if (uint8_t(data[i]) >= 240) {
  ------------------
  |  Branch (280:9): [True: 130k, False: 95.4M]
  ------------------
  281|   130k|      counter++;
  282|   130k|    }
  283|  95.6M|  }
  284|  5.24k|  return counter;
  285|  5.24k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf8_to_latin130rewind_and_convert_with_errorsEmPKcmPc:
  176|  1.02k|                                             char *latin1_output) {
  177|  1.02k|  size_t extra_len{0};
  178|       |  // We potentially need to go back in time and find a leading byte.
  179|       |  // In theory '3' would be sufficient, but sometimes the error can go back
  180|       |  // quite far.
  181|  1.02k|  size_t how_far_back = prior_bytes;
  182|       |  // size_t how_far_back = 3; // 3 bytes in the past + current position
  183|       |  // if(how_far_back >= prior_bytes) { how_far_back = prior_bytes; }
  184|  1.02k|  bool found_leading_bytes{false};
  185|       |  // important: it is i <= how_far_back and not 'i < how_far_back'.
  186|  1.10k|  for (size_t i = 0; i <= how_far_back; i++) {
  ------------------
  |  Branch (186:22): [True: 1.02k, False: 72]
  ------------------
  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: 952, False: 76]
  ------------------
  190|    952|      if (i > 0 && byte < 128) {
  ------------------
  |  Branch (190:11): [True: 4, False: 948]
  |  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|    948|      buf -= i;
  196|    948|      extra_len = i;
  197|    948|      break;
  198|    952|    }
  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.02k|  if (!found_leading_bytes) {
  ------------------
  |  Branch (208:7): [True: 72, False: 948]
  ------------------
  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|     72|    return result(error_code::TOO_LONG, 0 - how_far_back);
  214|     72|  }
  215|    948|  result res = convert_with_errors(buf, len + extra_len, latin1_output);
  216|    948|  if (res.error) {
  ------------------
  |  Branch (216:7): [True: 496, False: 452]
  ------------------
  217|    496|    res.count -= extra_len;
  218|    496|  }
  219|    948|  return res;
  220|  1.02k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf8_to_latin119convert_with_errorsIPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEENS_6resultES6_mPc:
   92|  1.46k|                                               char *latin_output) {
   93|  1.46k|  size_t pos = 0;
   94|  1.46k|  char *start{latin_output};
   95|       |
   96|  1.78M|  while (pos < len) {
  ------------------
  |  Branch (96:10): [True: 1.77M, False: 682]
  ------------------
   97|       |#if SIMDUTF_CPLUSPLUS23
   98|       |    if !consteval
   99|       |#endif
  100|  1.77M|    {
  101|       |      // try to convert the next block of 16 ASCII bytes
  102|  1.77M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (102:11): [True: 1.77M, False: 7.01k]
  ------------------
  103|       |                             // they are ascii
  104|  1.77M|        uint64_t v1;
  105|  1.77M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
  106|  1.77M|        uint64_t v2;
  107|  1.77M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  108|  1.77M|        uint64_t v{v1 | v2}; // We are only interested in these bits: 1000 1000
  109|       |                             // 1000 1000...etc
  110|  1.77M|        if ((v & 0x8080808080808080) ==
  ------------------
  |  Branch (110:13): [True: 1.49M, False: 277k]
  ------------------
  111|  1.77M|            0) { // if NONE of these are set, e.g. all of them are zero, then
  112|       |                 // everything is ASCII
  113|  1.49M|          size_t final_pos = pos + 16;
  114|  25.4M|          while (pos < final_pos) {
  ------------------
  |  Branch (114:18): [True: 23.9M, False: 1.49M]
  ------------------
  115|  23.9M|            *latin_output++ = char(data[pos]);
  116|  23.9M|            pos++;
  117|  23.9M|          }
  118|  1.49M|          continue;
  119|  1.49M|        }
  120|  1.77M|      }
  121|  1.77M|    }
  122|       |    // suppose it is not an all ASCII byte sequence
  123|   284k|    uint8_t leading_byte = data[pos]; // leading byte
  124|   284k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (124:9): [True: 247k, False: 36.8k]
  ------------------
  125|       |      // converting one ASCII byte !!!
  126|   247k|      *latin_output++ = char(leading_byte);
  127|   247k|      pos++;
  128|   247k|    } else if ((leading_byte & 0b11100000) ==
  ------------------
  |  Branch (128:16): [True: 36.4k, False: 434]
  ------------------
  129|  36.8k|               0b11000000) { // the first three bits indicate:
  130|       |      // We have a two-byte UTF-8
  131|  36.4k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (131:11): [True: 42, False: 36.4k]
  ------------------
  132|     42|        return result(error_code::TOO_SHORT, pos);
  133|     42|      } // minimal bound checking
  134|  36.4k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (134:11): [True: 222, False: 36.1k]
  ------------------
  135|    222|        return result(error_code::TOO_SHORT, pos);
  136|    222|      } // 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|  36.1k|      uint32_t code_point =
  140|  36.1k|          (leading_byte & 0b00011111) << 6 |
  141|  36.1k|          (data[pos + 1] &
  142|  36.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|  36.1k|      if (code_point < 0x80) {
  ------------------
  |  Branch (147:11): [True: 18, False: 36.1k]
  ------------------
  148|     18|        return result(error_code::OVERLONG, pos);
  149|     18|      }
  150|  36.1k|      if (0xFF < code_point) {
  ------------------
  |  Branch (150:11): [True: 66, False: 36.0k]
  ------------------
  151|     66|        return result(error_code::TOO_LARGE, pos);
  152|     66|      } // We only care about the range 129-255 which is Non-ASCII latin1
  153|       |        // characters
  154|  36.0k|      *latin_output++ = char(code_point);
  155|  36.0k|      pos += 2;
  156|  36.0k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (156:16): [True: 102, False: 332]
  ------------------
  157|       |      // We have a three-byte UTF-8
  158|    102|      return result(error_code::TOO_LARGE, pos);
  159|    332|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (159:16): [True: 42, False: 290]
  ------------------
  160|       |      // we have a 4-byte UTF-8 word.
  161|     42|      return result(error_code::TOO_LARGE, pos);
  162|    290|    } else {
  163|       |      // we either have too many continuation bytes or an invalid leading byte
  164|    290|      if ((leading_byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (164:11): [True: 152, False: 138]
  ------------------
  165|    152|        return result(error_code::TOO_LONG, pos);
  166|    152|      }
  167|       |
  168|    138|      return result(error_code::HEADER_BITS, pos);
  169|    290|    }
  170|   284k|  }
  171|    682|  return result(error_code::SUCCESS, latin_output - start);
  172|  1.46k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf8_to_latin17convertIPKcPcQaasr7simdutf6detailE22indexes_into_byte_likeIT_Esr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mS8_:
   17|  1.16k|                                   OutputPtr latin_output) {
   18|  1.16k|  size_t pos = 0;
   19|  1.16k|  auto start = latin_output;
   20|       |
   21|  1.58M|  while (pos < len) {
  ------------------
  |  Branch (21:10): [True: 1.58M, False: 520]
  ------------------
   22|       |#if SIMDUTF_CPLUSPLUS23
   23|       |    if !consteval
   24|       |#endif
   25|  1.58M|    {
   26|       |      // try to convert the next block of 16 ASCII bytes
   27|  1.58M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (27:11): [True: 1.57M, False: 4.27k]
  ------------------
   28|       |                             // they are ascii
   29|  1.57M|        uint64_t v1;
   30|  1.57M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   31|  1.57M|        uint64_t v2;
   32|  1.57M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   33|  1.57M|        uint64_t v{v1 | v2}; // We are only interested in these bits: 1000 1000
   34|       |                             // 1000 1000 .... etc
   35|  1.57M|        if ((v & 0x8080808080808080) ==
  ------------------
  |  Branch (35:13): [True: 1.43M, False: 144k]
  ------------------
   36|  1.57M|            0) { // if NONE of these are set, e.g. all of them are zero, then
   37|       |                 // everything is ASCII
   38|  1.43M|          size_t final_pos = pos + 16;
   39|  24.3M|          while (pos < final_pos) {
  ------------------
  |  Branch (39:18): [True: 22.9M, False: 1.43M]
  ------------------
   40|  22.9M|            *latin_output++ = char(data[pos]);
   41|  22.9M|            pos++;
   42|  22.9M|          }
   43|  1.43M|          continue;
   44|  1.43M|        }
   45|  1.57M|      }
   46|  1.58M|    }
   47|       |
   48|       |    // suppose it is not an all ASCII byte sequence
   49|   149k|    uint8_t leading_byte = data[pos]; // leading byte
   50|   149k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (50:9): [True: 131k, False: 17.9k]
  ------------------
   51|       |      // converting one ASCII byte !!!
   52|   131k|      *latin_output++ = char(leading_byte);
   53|   131k|      pos++;
   54|   131k|    } else if ((leading_byte & 0b11100000) ==
  ------------------
  |  Branch (54:16): [True: 17.4k, False: 450]
  ------------------
   55|  17.9k|               0b11000000) { // the first three bits indicate:
   56|       |      // We have a two-byte UTF-8
   57|  17.4k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (57:11): [True: 24, False: 17.4k]
  ------------------
   58|     24|        return 0;
   59|     24|      } // minimal bound checking
   60|  17.4k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (60:11): [True: 108, False: 17.3k]
  ------------------
   61|    108|        return 0;
   62|    108|      } // 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|  17.3k|      uint32_t code_point =
   66|  17.3k|          (leading_byte & 0b00011111) << 6 |
   67|  17.3k|          (data[pos + 1] &
   68|  17.3k|           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|  17.3k|      if (code_point < 0x80 || 0xFF < code_point) {
  ------------------
  |  Branch (73:11): [True: 16, False: 17.3k]
  |  Branch (73:32): [True: 44, False: 17.2k]
  ------------------
   74|     60|        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|     60|      }
   78|  17.2k|      *latin_output++ = char(code_point);
   79|  17.2k|      pos += 2;
   80|  17.2k|    } else {
   81|    450|      return 0;
   82|    450|    }
   83|   149k|  }
   84|    520|  return latin_output - start;
   85|  1.16k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf167convertILNS_10endiannessE0EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mPDs:
   16|  1.42k|                                   char16_t *utf16_output) {
   17|  1.42k|  size_t pos = 0;
   18|  1.42k|  char16_t *start{utf16_output};
   19|  2.07M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 2.07M, False: 670]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|       |    // try to convert the next block of 16 ASCII bytes
   24|  2.07M|    {
   25|  2.07M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 2.06M, False: 4.16k]
  ------------------
   26|       |                             // they are ascii
   27|  2.06M|        uint64_t v1;
   28|  2.06M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   29|  2.06M|        uint64_t v2;
   30|  2.06M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   31|  2.06M|        uint64_t v{v1 | v2};
   32|  2.06M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (32:13): [True: 1.16M, False: 899k]
  ------------------
   33|  1.16M|          size_t final_pos = pos + 16;
   34|  19.8M|          while (pos < final_pos) {
  ------------------
  |  Branch (34:18): [True: 18.6M, False: 1.16M]
  ------------------
   35|  18.6M|            *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (35:31): [Folded, False: 18.6M]
  ------------------
   36|  18.6M|                                  ? char16_t(u16_swap_bytes(data[pos]))
   37|  18.6M|                                  : char16_t(data[pos]);
   38|  18.6M|            pos++;
   39|  18.6M|          }
   40|  1.16M|          continue;
   41|  1.16M|        }
   42|  2.06M|      }
   43|  2.07M|    }
   44|       |
   45|   904k|    uint8_t leading_byte = data[pos]; // leading byte
   46|   904k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (46:9): [True: 740k, False: 163k]
  ------------------
   47|       |      // converting one ASCII byte !!!
   48|   740k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (48:25): [Folded, False: 740k]
  ------------------
   49|   740k|                            ? char16_t(u16_swap_bytes(leading_byte))
   50|   740k|                            : char16_t(leading_byte);
   51|   740k|      pos++;
   52|   740k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (52:16): [True: 97.3k, False: 65.9k]
  ------------------
   53|       |      // We have a two-byte UTF-8, it should become
   54|       |      // a single UTF-16 word.
   55|  97.3k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (55:11): [True: 30, False: 97.3k]
  ------------------
   56|     30|        return 0;
   57|     30|      } // minimal bound checking
   58|  97.3k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (58:11): [True: 72, False: 97.2k]
  ------------------
   59|     72|        return 0;
   60|     72|      }
   61|       |      // range check
   62|  97.2k|      uint32_t code_point =
   63|  97.2k|          (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
   64|  97.2k|      if (code_point < 0x80) {
  ------------------
  |  Branch (64:11): [True: 18, False: 97.2k]
  ------------------
   65|     18|        return 0;
   66|     18|      }
   67|       |      if constexpr (!match_system(big_endian)) {
   68|       |        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
   69|       |      }
   70|  97.2k|      *utf16_output++ = char16_t(code_point);
   71|  97.2k|      pos += 2;
   72|  97.2k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (72:16): [True: 59.8k, False: 6.07k]
  ------------------
   73|       |      // We have a three-byte UTF-8, it should become
   74|       |      // a single UTF-16 word.
   75|  59.8k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (75:11): [True: 30, False: 59.8k]
  ------------------
   76|     30|        return 0;
   77|     30|      } // minimal bound checking
   78|       |
   79|  59.8k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (79:11): [True: 42, False: 59.8k]
  ------------------
   80|     42|        return 0;
   81|     42|      }
   82|  59.8k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (82:11): [True: 38, False: 59.7k]
  ------------------
   83|     38|        return 0;
   84|     38|      }
   85|       |      // range check
   86|  59.7k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
   87|  59.7k|                            (data[pos + 1] & 0b00111111) << 6 |
   88|  59.7k|                            (data[pos + 2] & 0b00111111);
   89|  59.7k|      if (code_point < 0x800 || (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (89:11): [True: 44, False: 59.7k]
  |  Branch (89:34): [True: 404, False: 59.3k]
  |  Branch (89:57): [True: 18, False: 386]
  ------------------
   90|     62|        return 0;
   91|     62|      }
   92|       |      if constexpr (!match_system(big_endian)) {
   93|       |        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
   94|       |      }
   95|  59.7k|      *utf16_output++ = char16_t(code_point);
   96|  59.7k|      pos += 3;
   97|  59.7k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (97:16): [True: 5.74k, False: 326]
  ------------------
   98|       |      // we have a 4-byte UTF-8 word.
   99|  5.74k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (99:11): [True: 12, False: 5.73k]
  ------------------
  100|     12|        return 0;
  101|     12|      } // minimal bound checking
  102|  5.73k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (102:11): [True: 40, False: 5.69k]
  ------------------
  103|     40|        return 0;
  104|     40|      }
  105|  5.69k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (105:11): [True: 22, False: 5.67k]
  ------------------
  106|     22|        return 0;
  107|     22|      }
  108|  5.67k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (108:11): [True: 28, False: 5.64k]
  ------------------
  109|     28|        return 0;
  110|     28|      }
  111|       |
  112|       |      // range check
  113|  5.64k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  114|  5.64k|                            (data[pos + 1] & 0b00111111) << 12 |
  115|  5.64k|                            (data[pos + 2] & 0b00111111) << 6 |
  116|  5.64k|                            (data[pos + 3] & 0b00111111);
  117|  5.64k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (117:11): [True: 10, False: 5.63k]
  |  Branch (117:35): [True: 28, False: 5.60k]
  ------------------
  118|     38|        return 0;
  119|     38|      }
  120|  5.60k|      code_point -= 0x10000;
  121|  5.60k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
  122|  5.60k|      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|  5.60k|      *utf16_output++ = char16_t(high_surrogate);
  128|  5.60k|      *utf16_output++ = char16_t(low_surrogate);
  129|  5.60k|      pos += 4;
  130|  5.60k|    } else {
  131|    326|      return 0;
  132|    326|    }
  133|   904k|  }
  134|    670|  return utf16_output - start;
  135|  1.42k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf167convertILNS_10endiannessE1EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mPDs:
   16|  1.46k|                                   char16_t *utf16_output) {
   17|  1.46k|  size_t pos = 0;
   18|  1.46k|  char16_t *start{utf16_output};
   19|  1.59M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 1.59M, False: 578]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|       |    // try to convert the next block of 16 ASCII bytes
   24|  1.59M|    {
   25|  1.59M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 1.59M, False: 3.67k]
  ------------------
   26|       |                             // they are ascii
   27|  1.59M|        uint64_t v1;
   28|  1.59M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   29|  1.59M|        uint64_t v2;
   30|  1.59M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   31|  1.59M|        uint64_t v{v1 | v2};
   32|  1.59M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (32:13): [True: 1.04M, False: 545k]
  ------------------
   33|  1.04M|          size_t final_pos = pos + 16;
   34|  17.8M|          while (pos < final_pos) {
  ------------------
  |  Branch (34:18): [True: 16.7M, False: 1.04M]
  ------------------
   35|  16.7M|            *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (35:31): [True: 16.7M, Folded]
  ------------------
   36|  16.7M|                                  ? char16_t(u16_swap_bytes(data[pos]))
   37|  16.7M|                                  : char16_t(data[pos]);
   38|  16.7M|            pos++;
   39|  16.7M|          }
   40|  1.04M|          continue;
   41|  1.04M|        }
   42|  1.59M|      }
   43|  1.59M|    }
   44|       |
   45|   549k|    uint8_t leading_byte = data[pos]; // leading byte
   46|   549k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (46:9): [True: 441k, False: 107k]
  ------------------
   47|       |      // converting one ASCII byte !!!
   48|   441k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (48:25): [True: 441k, Folded]
  ------------------
   49|   441k|                            ? char16_t(u16_swap_bytes(leading_byte))
   50|   441k|                            : char16_t(leading_byte);
   51|   441k|      pos++;
   52|   441k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (52:16): [True: 70.3k, False: 37.5k]
  ------------------
   53|       |      // We have a two-byte UTF-8, it should become
   54|       |      // a single UTF-16 word.
   55|  70.3k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (55:11): [True: 60, False: 70.3k]
  ------------------
   56|     60|        return 0;
   57|     60|      } // minimal bound checking
   58|  70.3k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (58:11): [True: 110, False: 70.2k]
  ------------------
   59|    110|        return 0;
   60|    110|      }
   61|       |      // range check
   62|  70.2k|      uint32_t code_point =
   63|  70.2k|          (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
   64|  70.2k|      if (code_point < 0x80) {
  ------------------
  |  Branch (64:11): [True: 16, False: 70.1k]
  ------------------
   65|     16|        return 0;
   66|     16|      }
   67|  70.1k|      if constexpr (!match_system(big_endian)) {
   68|  70.1k|        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
   69|  70.1k|      }
   70|  70.1k|      *utf16_output++ = char16_t(code_point);
   71|  70.1k|      pos += 2;
   72|  70.1k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (72:16): [True: 29.3k, False: 8.16k]
  ------------------
   73|       |      // We have a three-byte UTF-8, it should become
   74|       |      // a single UTF-16 word.
   75|  29.3k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (75:11): [True: 30, False: 29.3k]
  ------------------
   76|     30|        return 0;
   77|     30|      } // minimal bound checking
   78|       |
   79|  29.3k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (79:11): [True: 42, False: 29.3k]
  ------------------
   80|     42|        return 0;
   81|     42|      }
   82|  29.3k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (82:11): [True: 46, False: 29.2k]
  ------------------
   83|     46|        return 0;
   84|     46|      }
   85|       |      // range check
   86|  29.2k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
   87|  29.2k|                            (data[pos + 1] & 0b00111111) << 6 |
   88|  29.2k|                            (data[pos + 2] & 0b00111111);
   89|  29.2k|      if (code_point < 0x800 || (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (89:11): [True: 38, False: 29.2k]
  |  Branch (89:34): [True: 568, False: 28.6k]
  |  Branch (89:57): [True: 16, False: 552]
  ------------------
   90|     54|        return 0;
   91|     54|      }
   92|  29.2k|      if constexpr (!match_system(big_endian)) {
   93|  29.2k|        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
   94|  29.2k|      }
   95|  29.2k|      *utf16_output++ = char16_t(code_point);
   96|  29.2k|      pos += 3;
   97|  29.2k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (97:16): [True: 7.79k, False: 368]
  ------------------
   98|       |      // we have a 4-byte UTF-8 word.
   99|  7.79k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (99:11): [True: 42, False: 7.75k]
  ------------------
  100|     42|        return 0;
  101|     42|      } // minimal bound checking
  102|  7.75k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (102:11): [True: 44, False: 7.70k]
  ------------------
  103|     44|        return 0;
  104|     44|      }
  105|  7.70k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (105:11): [True: 16, False: 7.69k]
  ------------------
  106|     16|        return 0;
  107|     16|      }
  108|  7.69k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (108:11): [True: 24, False: 7.66k]
  ------------------
  109|     24|        return 0;
  110|     24|      }
  111|       |
  112|       |      // range check
  113|  7.66k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  114|  7.66k|                            (data[pos + 1] & 0b00111111) << 12 |
  115|  7.66k|                            (data[pos + 2] & 0b00111111) << 6 |
  116|  7.66k|                            (data[pos + 3] & 0b00111111);
  117|  7.66k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (117:11): [True: 12, False: 7.65k]
  |  Branch (117:35): [True: 22, False: 7.63k]
  ------------------
  118|     34|        return 0;
  119|     34|      }
  120|  7.63k|      code_point -= 0x10000;
  121|  7.63k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
  122|  7.63k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
  123|  7.63k|      if constexpr (!match_system(big_endian)) {
  124|  7.63k|        high_surrogate = u16_swap_bytes(high_surrogate);
  125|  7.63k|        low_surrogate = u16_swap_bytes(low_surrogate);
  126|  7.63k|      }
  127|  7.63k|      *utf16_output++ = char16_t(high_surrogate);
  128|  7.63k|      *utf16_output++ = char16_t(low_surrogate);
  129|  7.63k|      pos += 4;
  130|  7.63k|    } else {
  131|    368|      return 0;
  132|    368|    }
  133|   549k|  }
  134|    578|  return utf16_output - start;
  135|  1.46k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1619convert_with_errorsILNS_10endiannessE0EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEENS_6resultES7_mPDs:
  142|  1.64k|                                               char16_t *utf16_output) {
  143|  1.64k|  size_t pos = 0;
  144|  1.64k|  char16_t *start{utf16_output};
  145|  3.10M|  while (pos < len) {
  ------------------
  |  Branch (145:10): [True: 3.10M, False: 730]
  ------------------
  146|       |#if SIMDUTF_CPLUSPLUS23
  147|       |    if !consteval
  148|       |#endif
  149|  3.10M|    {
  150|       |      // try to convert the next block of 16 ASCII bytes
  151|  3.10M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (151:11): [True: 3.09M, False: 5.53k]
  ------------------
  152|       |                             // they are ascii
  153|  3.09M|        uint64_t v1;
  154|  3.09M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
  155|  3.09M|        uint64_t v2;
  156|  3.09M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  157|  3.09M|        uint64_t v{v1 | v2};
  158|  3.09M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (158:13): [True: 1.38M, False: 1.71M]
  ------------------
  159|  1.38M|          size_t final_pos = pos + 16;
  160|  23.5M|          while (pos < final_pos) {
  ------------------
  |  Branch (160:18): [True: 22.1M, False: 1.38M]
  ------------------
  161|  22.1M|            const char16_t byte = uint8_t(data[pos]);
  162|  22.1M|            *utf16_output++ =
  163|  22.1M|                !match_system(big_endian) ? u16_swap_bytes(byte) : byte;
  ------------------
  |  Branch (163:17): [Folded, False: 22.1M]
  ------------------
  164|  22.1M|            pos++;
  165|  22.1M|          }
  166|  1.38M|          continue;
  167|  1.38M|        }
  168|  3.09M|      }
  169|  3.10M|    }
  170|       |
  171|  1.71M|    auto leading_byte = uint8_t(data[pos]); // leading byte
  172|  1.71M|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (172:9): [True: 1.41M, False: 298k]
  ------------------
  173|       |      // converting one ASCII byte !!!
  174|  1.41M|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (174:25): [Folded, False: 1.41M]
  ------------------
  175|  1.41M|                            ? char16_t(u16_swap_bytes(leading_byte))
  176|  1.41M|                            : char16_t(leading_byte);
  177|  1.41M|      pos++;
  178|  1.41M|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (178:16): [True: 193k, False: 104k]
  ------------------
  179|       |      // We have a two-byte UTF-8, it should become
  180|       |      // a single UTF-16 word.
  181|   193k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (181:11): [True: 54, False: 193k]
  ------------------
  182|     54|        return result(error_code::TOO_SHORT, pos);
  183|     54|      } // minimal bound checking
  184|   193k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (184:11): [True: 102, False: 193k]
  ------------------
  185|    102|        return result(error_code::TOO_SHORT, pos);
  186|    102|      }
  187|       |      // range check
  188|   193k|      uint32_t code_point = (leading_byte & 0b00011111) << 6 |
  189|   193k|                            (uint8_t(data[pos + 1]) & 0b00111111);
  190|   193k|      if (code_point < 0x80) {
  ------------------
  |  Branch (190:11): [True: 30, False: 193k]
  ------------------
  191|     30|        return result(error_code::OVERLONG, pos);
  192|     30|      }
  193|       |      if constexpr (!match_system(big_endian)) {
  194|       |        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
  195|       |      }
  196|   193k|      *utf16_output++ = char16_t(code_point);
  197|   193k|      pos += 2;
  198|   193k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (198:16): [True: 87.0k, False: 17.5k]
  ------------------
  199|       |      // We have a three-byte UTF-8, it should become
  200|       |      // a single UTF-16 word.
  201|  87.0k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (201:11): [True: 36, False: 86.9k]
  ------------------
  202|     36|        return result(error_code::TOO_SHORT, pos);
  203|     36|      } // minimal bound checking
  204|       |
  205|  86.9k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (205:11): [True: 72, False: 86.9k]
  ------------------
  206|     72|        return result(error_code::TOO_SHORT, pos);
  207|     72|      }
  208|  86.9k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (208:11): [True: 30, False: 86.8k]
  ------------------
  209|     30|        return result(error_code::TOO_SHORT, pos);
  210|     30|      }
  211|       |      // range check
  212|  86.8k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
  213|  86.8k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 6 |
  214|  86.8k|                            (uint8_t(data[pos + 2]) & 0b00111111);
  215|  86.8k|      if (code_point < 0x800) {
  ------------------
  |  Branch (215:11): [True: 18, False: 86.8k]
  ------------------
  216|     18|        return result(error_code::OVERLONG, pos);
  217|     18|      }
  218|  86.8k|      if (0xd7ff < code_point && code_point < 0xe000) {
  ------------------
  |  Branch (218:11): [True: 2.04k, False: 84.8k]
  |  Branch (218:34): [True: 12, False: 2.03k]
  ------------------
  219|     12|        return result(error_code::SURROGATE, pos);
  220|     12|      }
  221|       |      if constexpr (!match_system(big_endian)) {
  222|       |        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
  223|       |      }
  224|  86.8k|      *utf16_output++ = char16_t(code_point);
  225|  86.8k|      pos += 3;
  226|  86.8k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (226:16): [True: 17.1k, False: 376]
  ------------------
  227|       |      // we have a 4-byte UTF-8 word.
  228|  17.1k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (228:11): [True: 18, False: 17.1k]
  ------------------
  229|     18|        return result(error_code::TOO_SHORT, pos);
  230|     18|      } // minimal bound checking
  231|  17.1k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (231:11): [True: 72, False: 17.1k]
  ------------------
  232|     72|        return result(error_code::TOO_SHORT, pos);
  233|     72|      }
  234|  17.1k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (234:11): [True: 18, False: 17.0k]
  ------------------
  235|     18|        return result(error_code::TOO_SHORT, pos);
  236|     18|      }
  237|  17.0k|      if ((uint8_t(data[pos + 3]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (237:11): [True: 24, False: 17.0k]
  ------------------
  238|     24|        return result(error_code::TOO_SHORT, pos);
  239|     24|      }
  240|       |
  241|       |      // range check
  242|  17.0k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  243|  17.0k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 12 |
  244|  17.0k|                            (uint8_t(data[pos + 2]) & 0b00111111) << 6 |
  245|  17.0k|                            (uint8_t(data[pos + 3]) & 0b00111111);
  246|  17.0k|      if (code_point <= 0xffff) {
  ------------------
  |  Branch (246:11): [True: 12, False: 17.0k]
  ------------------
  247|     12|        return result(error_code::OVERLONG, pos);
  248|     12|      }
  249|  17.0k|      if (0x10ffff < code_point) {
  ------------------
  |  Branch (249:11): [True: 42, False: 17.0k]
  ------------------
  250|     42|        return result(error_code::TOO_LARGE, pos);
  251|     42|      }
  252|  17.0k|      code_point -= 0x10000;
  253|  17.0k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
  254|  17.0k|      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|  17.0k|      *utf16_output++ = char16_t(high_surrogate);
  260|  17.0k|      *utf16_output++ = char16_t(low_surrogate);
  261|  17.0k|      pos += 4;
  262|  17.0k|    } else {
  263|       |      // we either have too many continuation bytes or an invalid leading byte
  264|    376|      if ((leading_byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (264:11): [True: 154, False: 222]
  ------------------
  265|    154|        return result(error_code::TOO_LONG, pos);
  266|    222|      } else {
  267|    222|        return result(error_code::HEADER_BITS, pos);
  268|    222|      }
  269|    376|    }
  270|  1.71M|  }
  271|    730|  return result(error_code::SUCCESS, utf16_output - start);
  272|  1.64k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1619convert_with_errorsILNS_10endiannessE1EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEENS_6resultES7_mPDs:
  142|  2.01k|                                               char16_t *utf16_output) {
  143|  2.01k|  size_t pos = 0;
  144|  2.01k|  char16_t *start{utf16_output};
  145|  3.62M|  while (pos < len) {
  ------------------
  |  Branch (145:10): [True: 3.62M, False: 934]
  ------------------
  146|       |#if SIMDUTF_CPLUSPLUS23
  147|       |    if !consteval
  148|       |#endif
  149|  3.62M|    {
  150|       |      // try to convert the next block of 16 ASCII bytes
  151|  3.62M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (151:11): [True: 3.61M, False: 8.21k]
  ------------------
  152|       |                             // they are ascii
  153|  3.61M|        uint64_t v1;
  154|  3.61M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
  155|  3.61M|        uint64_t v2;
  156|  3.61M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  157|  3.61M|        uint64_t v{v1 | v2};
  158|  3.61M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (158:13): [True: 1.52M, False: 2.08M]
  ------------------
  159|  1.52M|          size_t final_pos = pos + 16;
  160|  25.9M|          while (pos < final_pos) {
  ------------------
  |  Branch (160:18): [True: 24.4M, False: 1.52M]
  ------------------
  161|  24.4M|            const char16_t byte = uint8_t(data[pos]);
  162|  24.4M|            *utf16_output++ =
  163|  24.4M|                !match_system(big_endian) ? u16_swap_bytes(byte) : byte;
  ------------------
  |  Branch (163:17): [True: 24.4M, Folded]
  ------------------
  164|  24.4M|            pos++;
  165|  24.4M|          }
  166|  1.52M|          continue;
  167|  1.52M|        }
  168|  3.61M|      }
  169|  3.62M|    }
  170|       |
  171|  2.09M|    auto leading_byte = uint8_t(data[pos]); // leading byte
  172|  2.09M|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (172:9): [True: 1.72M, False: 369k]
  ------------------
  173|       |      // converting one ASCII byte !!!
  174|  1.72M|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (174:25): [True: 1.72M, Folded]
  ------------------
  175|  1.72M|                            ? char16_t(u16_swap_bytes(leading_byte))
  176|  1.72M|                            : char16_t(leading_byte);
  177|  1.72M|      pos++;
  178|  1.72M|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (178:16): [True: 227k, False: 141k]
  ------------------
  179|       |      // We have a two-byte UTF-8, it should become
  180|       |      // a single UTF-16 word.
  181|   227k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (181:11): [True: 60, False: 227k]
  ------------------
  182|     60|        return result(error_code::TOO_SHORT, pos);
  183|     60|      } // minimal bound checking
  184|   227k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (184:11): [True: 126, False: 227k]
  ------------------
  185|    126|        return result(error_code::TOO_SHORT, pos);
  186|    126|      }
  187|       |      // range check
  188|   227k|      uint32_t code_point = (leading_byte & 0b00011111) << 6 |
  189|   227k|                            (uint8_t(data[pos + 1]) & 0b00111111);
  190|   227k|      if (code_point < 0x80) {
  ------------------
  |  Branch (190:11): [True: 12, False: 227k]
  ------------------
  191|     12|        return result(error_code::OVERLONG, pos);
  192|     12|      }
  193|   227k|      if constexpr (!match_system(big_endian)) {
  194|   227k|        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
  195|   227k|      }
  196|   227k|      *utf16_output++ = char16_t(code_point);
  197|   227k|      pos += 2;
  198|   227k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (198:16): [True: 131k, False: 10.6k]
  ------------------
  199|       |      // We have a three-byte UTF-8, it should become
  200|       |      // a single UTF-16 word.
  201|   131k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (201:11): [True: 30, False: 131k]
  ------------------
  202|     30|        return result(error_code::TOO_SHORT, pos);
  203|     30|      } // minimal bound checking
  204|       |
  205|   131k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (205:11): [True: 90, False: 131k]
  ------------------
  206|     90|        return result(error_code::TOO_SHORT, pos);
  207|     90|      }
  208|   131k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (208:11): [True: 36, False: 131k]
  ------------------
  209|     36|        return result(error_code::TOO_SHORT, pos);
  210|     36|      }
  211|       |      // range check
  212|   131k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
  213|   131k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 6 |
  214|   131k|                            (uint8_t(data[pos + 2]) & 0b00111111);
  215|   131k|      if (code_point < 0x800) {
  ------------------
  |  Branch (215:11): [True: 30, False: 131k]
  ------------------
  216|     30|        return result(error_code::OVERLONG, pos);
  217|     30|      }
  218|   131k|      if (0xd7ff < code_point && code_point < 0xe000) {
  ------------------
  |  Branch (218:11): [True: 3.53k, False: 127k]
  |  Branch (218:34): [True: 18, False: 3.51k]
  ------------------
  219|     18|        return result(error_code::SURROGATE, pos);
  220|     18|      }
  221|   131k|      if constexpr (!match_system(big_endian)) {
  222|   131k|        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
  223|   131k|      }
  224|   131k|      *utf16_output++ = char16_t(code_point);
  225|   131k|      pos += 3;
  226|   131k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (226:16): [True: 10.1k, False: 472]
  ------------------
  227|       |      // we have a 4-byte UTF-8 word.
  228|  10.1k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (228:11): [True: 42, False: 10.1k]
  ------------------
  229|     42|        return result(error_code::TOO_SHORT, pos);
  230|     42|      } // minimal bound checking
  231|  10.1k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (231:11): [True: 24, False: 10.1k]
  ------------------
  232|     24|        return result(error_code::TOO_SHORT, pos);
  233|     24|      }
  234|  10.1k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (234:11): [True: 42, False: 10.0k]
  ------------------
  235|     42|        return result(error_code::TOO_SHORT, pos);
  236|     42|      }
  237|  10.0k|      if ((uint8_t(data[pos + 3]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (237:11): [True: 36, False: 10.0k]
  ------------------
  238|     36|        return result(error_code::TOO_SHORT, pos);
  239|     36|      }
  240|       |
  241|       |      // range check
  242|  10.0k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  243|  10.0k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 12 |
  244|  10.0k|                            (uint8_t(data[pos + 2]) & 0b00111111) << 6 |
  245|  10.0k|                            (uint8_t(data[pos + 3]) & 0b00111111);
  246|  10.0k|      if (code_point <= 0xffff) {
  ------------------
  |  Branch (246:11): [True: 36, False: 9.98k]
  ------------------
  247|     36|        return result(error_code::OVERLONG, pos);
  248|     36|      }
  249|  9.98k|      if (0x10ffff < code_point) {
  ------------------
  |  Branch (249:11): [True: 30, False: 9.95k]
  ------------------
  250|     30|        return result(error_code::TOO_LARGE, pos);
  251|     30|      }
  252|  9.95k|      code_point -= 0x10000;
  253|  9.95k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
  254|  9.95k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
  255|  9.95k|      if constexpr (!match_system(big_endian)) {
  256|  9.95k|        high_surrogate = u16_swap_bytes(high_surrogate);
  257|  9.95k|        low_surrogate = u16_swap_bytes(low_surrogate);
  258|  9.95k|      }
  259|  9.95k|      *utf16_output++ = char16_t(high_surrogate);
  260|  9.95k|      *utf16_output++ = char16_t(low_surrogate);
  261|  9.95k|      pos += 4;
  262|  9.95k|    } else {
  263|       |      // we either have too many continuation bytes or an invalid leading byte
  264|    472|      if ((leading_byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (264:11): [True: 208, False: 264]
  ------------------
  265|    208|        return result(error_code::TOO_LONG, pos);
  266|    264|      } else {
  267|    264|        return result(error_code::HEADER_BITS, pos);
  268|    264|      }
  269|    472|    }
  270|  2.09M|  }
  271|    934|  return result(error_code::SUCCESS, utf16_output - start);
  272|  2.01k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1630rewind_and_convert_with_errorsILNS_10endiannessE0EEENS_6resultEmPKcmPDs:
  292|  1.14k|                                             char16_t *utf16_output) {
  293|  1.14k|  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.14k|  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.14k|  bool found_leading_bytes{false};
  301|       |  // important: it is i <= how_far_back and not 'i < how_far_back'.
  302|  1.20k|  for (size_t i = 0; i <= how_far_back; i++) {
  ------------------
  |  Branch (302:22): [True: 1.15k, False: 56]
  ------------------
  303|  1.15k|    unsigned char byte = buf[-static_cast<std::ptrdiff_t>(i)];
  304|  1.15k|    found_leading_bytes = ((byte & 0b11000000) != 0b10000000);
  305|  1.15k|    if (found_leading_bytes) {
  ------------------
  |  Branch (305:9): [True: 1.08k, False: 68]
  ------------------
  306|  1.08k|      if (i > 0 && byte < 128) {
  ------------------
  |  Branch (306:11): [True: 12, False: 1.07k]
  |  Branch (306:20): [True: 12, False: 0]
  ------------------
  307|       |        // If we had to go back and the leading byte is ascii
  308|       |        // then we can stop right away.
  309|     12|        return result(error_code::TOO_LONG, 0 - i + 1);
  310|     12|      }
  311|  1.07k|      buf -= i;
  312|  1.07k|      extra_len = i;
  313|  1.07k|      break;
  314|  1.08k|    }
  315|  1.15k|  }
  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.12k|  if (!found_leading_bytes) {
  ------------------
  |  Branch (324:7): [True: 56, False: 1.07k]
  ------------------
  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|     56|    return result(error_code::TOO_LONG, 0 - how_far_back);
  330|     56|  }
  331|  1.07k|  result res = convert_with_errors<endian>(buf, len + extra_len, utf16_output);
  332|  1.07k|  if (res.error) {
  ------------------
  |  Branch (332:7): [True: 588, False: 484]
  ------------------
  333|    588|    res.count -= extra_len;
  334|    588|  }
  335|  1.07k|  return res;
  336|  1.12k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1630rewind_and_convert_with_errorsILNS_10endiannessE1EEENS_6resultEmPKcmPDs:
  292|  1.39k|                                             char16_t *utf16_output) {
  293|  1.39k|  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.39k|  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.39k|  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: 72]
  ------------------
  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.32k, False: 80]
  ------------------
  306|  1.32k|      if (i > 0 && byte < 128) {
  ------------------
  |  Branch (306:11): [True: 8, False: 1.31k]
  |  Branch (306:20): [True: 8, False: 0]
  ------------------
  307|       |        // If we had to go back and the leading byte is ascii
  308|       |        // then we can stop right away.
  309|      8|        return result(error_code::TOO_LONG, 0 - i + 1);
  310|      8|      }
  311|  1.31k|      buf -= i;
  312|  1.31k|      extra_len = i;
  313|  1.31k|      break;
  314|  1.32k|    }
  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.38k|  if (!found_leading_bytes) {
  ------------------
  |  Branch (324:7): [True: 72, False: 1.31k]
  ------------------
  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|     72|    return result(error_code::TOO_LONG, 0 - how_far_back);
  330|     72|  }
  331|  1.31k|  result res = convert_with_errors<endian>(buf, len + extra_len, utf16_output);
  332|  1.31k|  if (res.error) {
  ------------------
  |  Branch (332:7): [True: 696, False: 620]
  ------------------
  333|    696|    res.count -= extra_len;
  334|    696|  }
  335|  1.31k|  return res;
  336|  1.38k|}

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

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf3230rewind_and_convert_with_errorsEmPKcmPDi:
  249|  1.46k|                                             char32_t *utf32_output) {
  250|  1.46k|  size_t extra_len{0};
  251|       |  // We potentially need to go back in time and find a leading byte.
  252|  1.46k|  size_t how_far_back = 3; // 3 bytes in the past + current position
  253|  1.46k|  if (how_far_back > prior_bytes) {
  ------------------
  |  Branch (253:7): [True: 760, False: 708]
  ------------------
  254|    760|    how_far_back = prior_bytes;
  255|    760|  }
  256|  1.46k|  bool found_leading_bytes{false};
  257|       |  // important: it is i <= how_far_back and not 'i < how_far_back'.
  258|  1.54k|  for (size_t i = 0; i <= how_far_back; i++) {
  ------------------
  |  Branch (258:22): [True: 1.47k, False: 68]
  ------------------
  259|  1.47k|    unsigned char byte = buf[-static_cast<std::ptrdiff_t>(i)];
  260|  1.47k|    found_leading_bytes = ((byte & 0b11000000) != 0b10000000);
  261|  1.47k|    if (found_leading_bytes) {
  ------------------
  |  Branch (261:9): [True: 1.40k, False: 72]
  ------------------
  262|  1.40k|      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.40k|    }
  271|  1.47k|  }
  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.46k|  if (!found_leading_bytes) {
  ------------------
  |  Branch (280:7): [True: 68, 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|     68|    return result(error_code::TOO_LONG, 0 - how_far_back);
  286|     68|  }
  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: 724, False: 672]
  ------------------
  290|    724|    res.count -= extra_len;
  291|    724|  }
  292|  1.39k|  return res;
  293|  1.46k|}
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.35M|  while (pos < len) {
  ------------------
  |  Branch (124:10): [True: 2.35M, False: 1.01k]
  ------------------
  125|       |#if SIMDUTF_CPLUSPLUS23
  126|       |    if !consteval
  127|       |#endif
  128|  2.35M|    {
  129|       |      // try to convert the next block of 16 ASCII bytes
  130|  2.35M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (130:11): [True: 2.34M, False: 9.21k]
  ------------------
  131|       |                             // they are ascii
  132|  2.34M|        uint64_t v1;
  133|  2.34M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
  134|  2.34M|        uint64_t v2;
  135|  2.34M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  136|  2.34M|        uint64_t v{v1 | v2};
  137|  2.34M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (137:13): [True: 1.69M, False: 654k]
  ------------------
  138|  1.69M|          size_t final_pos = pos + 16;
  139|  28.7M|          while (pos < final_pos) {
  ------------------
  |  Branch (139:18): [True: 27.0M, False: 1.69M]
  ------------------
  140|  27.0M|            *utf32_output++ = uint8_t(data[pos]);
  141|  27.0M|            pos++;
  142|  27.0M|          }
  143|  1.69M|          continue;
  144|  1.69M|        }
  145|  2.34M|      }
  146|  2.35M|    }
  147|   663k|    auto leading_byte = uint8_t(data[pos]); // leading byte
  148|   663k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (148:9): [True: 505k, False: 158k]
  ------------------
  149|       |      // converting one ASCII byte !!!
  150|   505k|      *utf32_output++ = char32_t(leading_byte);
  151|   505k|      pos++;
  152|   505k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (152:16): [True: 112k, False: 46.2k]
  ------------------
  153|       |      // We have a two-byte UTF-8
  154|   112k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (154:11): [True: 72, False: 112k]
  ------------------
  155|     72|        return result(error_code::TOO_SHORT, pos);
  156|     72|      } // minimal bound checking
  157|   112k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (157:11): [True: 186, False: 111k]
  ------------------
  158|    186|        return result(error_code::TOO_SHORT, pos);
  159|    186|      }
  160|       |      // range check
  161|   111k|      uint32_t code_point = (leading_byte & 0b00011111) << 6 |
  162|   111k|                            (uint8_t(data[pos + 1]) & 0b00111111);
  163|   111k|      if (code_point < 0x80) {
  ------------------
  |  Branch (163:11): [True: 12, False: 111k]
  ------------------
  164|     12|        return result(error_code::OVERLONG, pos);
  165|     12|      }
  166|   111k|      *utf32_output++ = char32_t(code_point);
  167|   111k|      pos += 2;
  168|   111k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (168:16): [True: 37.5k, False: 8.63k]
  ------------------
  169|       |      // We have a three-byte UTF-8
  170|  37.5k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (170:11): [True: 42, False: 37.5k]
  ------------------
  171|     42|        return result(error_code::TOO_SHORT, pos);
  172|     42|      } // minimal bound checking
  173|       |
  174|  37.5k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (174:11): [True: 66, False: 37.4k]
  ------------------
  175|     66|        return result(error_code::TOO_SHORT, pos);
  176|     66|      }
  177|  37.4k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (177:11): [True: 48, False: 37.4k]
  ------------------
  178|     48|        return result(error_code::TOO_SHORT, pos);
  179|     48|      }
  180|       |      // range check
  181|  37.4k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
  182|  37.4k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 6 |
  183|  37.4k|                            (uint8_t(data[pos + 2]) & 0b00111111);
  184|  37.4k|      if (code_point < 0x800) {
  ------------------
  |  Branch (184:11): [True: 36, False: 37.3k]
  ------------------
  185|     36|        return result(error_code::OVERLONG, pos);
  186|     36|      }
  187|  37.3k|      if (0xd7ff < code_point && code_point < 0xe000) {
  ------------------
  |  Branch (187:11): [True: 3.81k, False: 33.5k]
  |  Branch (187:34): [True: 6, False: 3.80k]
  ------------------
  188|      6|        return result(error_code::SURROGATE, pos);
  189|      6|      }
  190|  37.3k|      *utf32_output++ = char32_t(code_point);
  191|  37.3k|      pos += 3;
  192|  37.3k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (192:16): [True: 8.17k, False: 462]
  ------------------
  193|       |      // we have a 4-byte UTF-8 word.
  194|  8.17k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (194:11): [True: 30, False: 8.14k]
  ------------------
  195|     30|        return result(error_code::TOO_SHORT, pos);
  196|     30|      } // minimal bound checking
  197|  8.14k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (197:11): [True: 72, False: 8.06k]
  ------------------
  198|     72|        return result(error_code::TOO_SHORT, pos);
  199|     72|      }
  200|  8.06k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (200:11): [True: 36, False: 8.03k]
  ------------------
  201|     36|        return result(error_code::TOO_SHORT, pos);
  202|     36|      }
  203|  8.03k|      if ((uint8_t(data[pos + 3]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (203:11): [True: 18, False: 8.01k]
  ------------------
  204|     18|        return result(error_code::TOO_SHORT, pos);
  205|     18|      }
  206|       |
  207|       |      // range check
  208|  8.01k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  209|  8.01k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 12 |
  210|  8.01k|                            (uint8_t(data[pos + 2]) & 0b00111111) << 6 |
  211|  8.01k|                            (uint8_t(data[pos + 3]) & 0b00111111);
  212|  8.01k|      if (code_point <= 0xffff) {
  ------------------
  |  Branch (212:11): [True: 12, False: 8.00k]
  ------------------
  213|     12|        return result(error_code::OVERLONG, pos);
  214|     12|      }
  215|  8.00k|      if (0x10ffff < code_point) {
  ------------------
  |  Branch (215:11): [True: 24, False: 7.97k]
  ------------------
  216|     24|        return result(error_code::TOO_LARGE, pos);
  217|     24|      }
  218|  7.97k|      *utf32_output++ = char32_t(code_point);
  219|  7.97k|      pos += 4;
  220|  7.97k|    } else {
  221|       |      // we either have too many continuation bytes or an invalid leading byte
  222|    462|      if ((leading_byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (222:11): [True: 228, False: 234]
  ------------------
  223|    228|        return result(error_code::TOO_LONG, pos);
  224|    234|      } else {
  225|    234|        return result(error_code::HEADER_BITS, pos);
  226|    234|      }
  227|    462|    }
  228|   663k|  }
  229|  1.01k|  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.60k|                                   char32_t *utf32_output) {
   17|  1.60k|  size_t pos = 0;
   18|  1.60k|  char32_t *start{utf32_output};
   19|  2.10M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 2.10M, False: 824]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|  2.10M|    {
   24|       |      // try to convert the next block of 16 ASCII bytes
   25|  2.10M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 2.09M, False: 5.39k]
  ------------------
   26|       |                             // they are ascii
   27|  2.09M|        uint64_t v1;
   28|  2.09M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   29|  2.09M|        uint64_t v2;
   30|  2.09M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   31|  2.09M|        uint64_t v{v1 | v2};
   32|  2.09M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (32:13): [True: 1.24M, False: 850k]
  ------------------
   33|  1.24M|          size_t final_pos = pos + 16;
   34|  21.1M|          while (pos < final_pos) {
  ------------------
  |  Branch (34:18): [True: 19.9M, False: 1.24M]
  ------------------
   35|  19.9M|            *utf32_output++ = uint8_t(data[pos]);
   36|  19.9M|            pos++;
   37|  19.9M|          }
   38|  1.24M|          continue;
   39|  1.24M|        }
   40|  2.09M|      }
   41|  2.10M|    }
   42|   855k|    auto leading_byte = uint8_t(data[pos]); // leading byte
   43|   855k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (43:9): [True: 697k, False: 158k]
  ------------------
   44|       |      // converting one ASCII byte !!!
   45|   697k|      *utf32_output++ = char32_t(leading_byte);
   46|   697k|      pos++;
   47|   697k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (47:16): [True: 97.4k, False: 60.7k]
  ------------------
   48|       |      // We have a two-byte UTF-8
   49|  97.4k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (49:11): [True: 54, False: 97.4k]
  ------------------
   50|     54|        return 0;
   51|     54|      } // minimal bound checking
   52|  97.4k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (52:11): [True: 106, False: 97.3k]
  ------------------
   53|    106|        return 0;
   54|    106|      }
   55|       |      // range check
   56|  97.3k|      uint32_t code_point = (leading_byte & 0b00011111) << 6 |
   57|  97.3k|                            (uint8_t(data[pos + 1]) & 0b00111111);
   58|  97.3k|      if (code_point < 0x80) {
  ------------------
  |  Branch (58:11): [True: 12, False: 97.3k]
  ------------------
   59|     12|        return 0;
   60|     12|      }
   61|  97.3k|      *utf32_output++ = char32_t(code_point);
   62|  97.3k|      pos += 2;
   63|  97.3k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (63:16): [True: 53.7k, False: 6.99k]
  ------------------
   64|       |      // We have a three-byte UTF-8
   65|  53.7k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (65:11): [True: 18, False: 53.7k]
  ------------------
   66|     18|        return 0;
   67|     18|      } // minimal bound checking
   68|       |
   69|  53.7k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (69:11): [True: 52, False: 53.6k]
  ------------------
   70|     52|        return 0;
   71|     52|      }
   72|  53.6k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (72:11): [True: 16, False: 53.6k]
  ------------------
   73|     16|        return 0;
   74|     16|      }
   75|       |      // range check
   76|  53.6k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
   77|  53.6k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 6 |
   78|  53.6k|                            (uint8_t(data[pos + 2]) & 0b00111111);
   79|  53.6k|      if (code_point < 0x800 || (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (79:11): [True: 40, False: 53.5k]
  |  Branch (79:34): [True: 828, False: 52.7k]
  |  Branch (79:57): [True: 10, False: 818]
  ------------------
   80|     50|        return 0;
   81|     50|      }
   82|  53.5k|      *utf32_output++ = char32_t(code_point);
   83|  53.5k|      pos += 3;
   84|  53.5k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (84:16): [True: 6.70k, False: 290]
  ------------------
   85|       |      // we have a 4-byte UTF-8 word.
   86|  6.70k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (86:11): [True: 6, False: 6.69k]
  ------------------
   87|      6|        return 0;
   88|      6|      } // minimal bound checking
   89|  6.69k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (89:11): [True: 48, False: 6.65k]
  ------------------
   90|     48|        return 0;
   91|     48|      }
   92|  6.65k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (92:11): [True: 34, False: 6.61k]
  ------------------
   93|     34|        return 0;
   94|     34|      }
   95|  6.61k|      if ((uint8_t(data[pos + 3]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (95:11): [True: 10, False: 6.60k]
  ------------------
   96|     10|        return 0;
   97|     10|      }
   98|       |
   99|       |      // range check
  100|  6.60k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  101|  6.60k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 12 |
  102|  6.60k|                            (uint8_t(data[pos + 2]) & 0b00111111) << 6 |
  103|  6.60k|                            (uint8_t(data[pos + 3]) & 0b00111111);
  104|  6.60k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (104:11): [True: 48, False: 6.55k]
  |  Branch (104:35): [True: 32, False: 6.52k]
  ------------------
  105|     80|        return 0;
  106|     80|      }
  107|  6.52k|      *utf32_output++ = char32_t(code_point);
  108|  6.52k|      pos += 4;
  109|  6.52k|    } else {
  110|    290|      return 0;
  111|    290|    }
  112|   855k|  }
  113|    824|  return utf32_output - start;
  114|  1.60k|}

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

_ZNK7simdutf8fallback14implementation13validate_utf8EPKcm:
   37|  3.22k|implementation::validate_utf8(const char *buf, size_t len) const noexcept {
   38|  3.22k|  return scalar::utf8::validate(buf, len);
   39|  3.22k|}
_ZNK7simdutf8fallback14implementation25validate_utf8_with_errorsEPKcm:
   44|  3.22k|    const char *buf, size_t len) const noexcept {
   45|  3.22k|  return scalar::utf8::validate_with_errors(buf, len);
   46|  3.22k|}
_ZNK7simdutf8fallback14implementation16validate_utf16leEPKDsm:
   77|  1.30k|                                 size_t len) const noexcept {
   78|  1.30k|  return scalar::utf16::validate<endianness::LITTLE>(buf, len);
   79|  1.30k|}
_ZNK7simdutf8fallback14implementation16validate_utf16beEPKDsm:
   85|  1.23k|                                 size_t len) const noexcept {
   86|  1.23k|  return scalar::utf16::validate<endianness::BIG>(buf, len);
   87|  1.23k|}
_ZNK7simdutf8fallback14implementation28validate_utf16le_with_errorsEPKDsm:
   90|  1.30k|    const char16_t *buf, size_t len) const noexcept {
   91|  1.30k|  return scalar::utf16::validate_with_errors<endianness::LITTLE>(buf, len);
   92|  1.30k|}
_ZNK7simdutf8fallback14implementation28validate_utf16be_with_errorsEPKDsm:
   95|  1.23k|    const char16_t *buf, size_t len) const noexcept {
   96|  1.23k|  return scalar::utf16::validate_with_errors<endianness::BIG>(buf, len);
   97|  1.23k|}
_ZNK7simdutf8fallback14implementation14validate_utf32EPKDim:
  114|  2.41k|implementation::validate_utf32(const char32_t *buf, size_t len) const noexcept {
  115|  2.41k|  return scalar::utf32::validate(buf, len);
  116|  2.41k|}
_ZNK7simdutf8fallback14implementation26validate_utf32_with_errorsEPKDim:
  121|  2.41k|    const char32_t *buf, size_t len) const noexcept {
  122|  2.41k|  return scalar::utf32::validate_with_errors(buf, len);
  123|  2.41k|}
_ZNK7simdutf8fallback14implementation22convert_latin1_to_utf8EPKcmPc:
  128|    538|    const char *buf, size_t len, char *utf8_output) const noexcept {
  129|    538|  return scalar::latin1_to_utf8::convert(buf, len, utf8_output);
  130|    538|}
_ZNK7simdutf8fallback14implementation25convert_latin1_to_utf16leEPKcmPDs:
  135|     80|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  136|     80|  return scalar::latin1_to_utf16::convert<endianness::LITTLE>(buf, len,
  137|     80|                                                              utf16_output);
  138|     80|}
_ZNK7simdutf8fallback14implementation25convert_latin1_to_utf16beEPKcmPDs:
  141|     80|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  142|     80|  return scalar::latin1_to_utf16::convert<endianness::BIG>(buf, len,
  143|     80|                                                           utf16_output);
  144|     80|}
_ZNK7simdutf8fallback14implementation23convert_latin1_to_utf32EPKcmPDi:
  149|     90|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  150|     90|  return scalar::latin1_to_utf32::convert(buf, len, utf32_output);
  151|     90|}
_ZNK7simdutf8fallback14implementation22convert_utf8_to_latin1EPKcmPc:
  156|    562|    const char *buf, size_t len, char *latin1_output) const noexcept {
  157|    562|  return scalar::utf8_to_latin1::convert(buf, len, latin1_output);
  158|    562|}
_ZNK7simdutf8fallback14implementation34convert_utf8_to_latin1_with_errorsEPKcmPc:
  161|    516|    const char *buf, size_t len, char *latin1_output) const noexcept {
  162|    516|  return scalar::utf8_to_latin1::convert_with_errors(buf, len, latin1_output);
  163|    516|}
_ZNK7simdutf8fallback14implementation23convert_utf8_to_utf16leEPKcmPDs:
  173|    660|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  174|    660|  return scalar::utf8_to_utf16::convert<endianness::LITTLE>(buf, len,
  175|    660|                                                            utf16_output);
  176|    660|}
_ZNK7simdutf8fallback14implementation23convert_utf8_to_utf16beEPKcmPDs:
  179|    712|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  180|    712|  return scalar::utf8_to_utf16::convert<endianness::BIG>(buf, len,
  181|    712|                                                         utf16_output);
  182|    712|}
_ZNK7simdutf8fallback14implementation35convert_utf8_to_utf16le_with_errorsEPKcmPDs:
  185|    574|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  186|    574|  return scalar::utf8_to_utf16::convert_with_errors<endianness::LITTLE>(
  187|    574|      buf, len, utf16_output);
  188|    574|}
_ZNK7simdutf8fallback14implementation35convert_utf8_to_utf16be_with_errorsEPKcmPDs:
  191|    702|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  192|    702|  return scalar::utf8_to_utf16::convert_with_errors<endianness::BIG>(
  193|    702|      buf, len, utf16_output);
  194|    702|}
_ZNK7simdutf8fallback14implementation29convert_valid_utf8_to_utf16leEPKcmPDs:
  197|    368|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  198|    368|  return scalar::utf8_to_utf16::convert_valid<endianness::LITTLE>(buf, len,
  199|    368|                                                                  utf16_output);
  200|    368|}
_ZNK7simdutf8fallback14implementation29convert_valid_utf8_to_utf16beEPKcmPDs:
  203|    438|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  204|    438|  return scalar::utf8_to_utf16::convert_valid<endianness::BIG>(buf, len,
  205|    438|                                                               utf16_output);
  206|    438|}
_ZNK7simdutf8fallback14implementation21convert_utf8_to_utf32EPKcmPDi:
  211|    712|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  212|    712|  return scalar::utf8_to_utf32::convert(buf, len, utf32_output);
  213|    712|}
_ZNK7simdutf8fallback14implementation33convert_utf8_to_utf32_with_errorsEPKcmPDi:
  216|    738|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  217|    738|  return scalar::utf8_to_utf32::convert_with_errors(buf, len, utf32_output);
  218|    738|}
_ZNK7simdutf8fallback14implementation27convert_valid_utf8_to_utf32EPKcmPDi:
  221|    394|    const char *input, size_t size, char32_t *utf32_output) const noexcept {
  222|    394|  return scalar::utf8_to_utf32::convert_valid(input, size, utf32_output);
  223|    394|}
_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|    126|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  235|    126|  return scalar::utf16_to_latin1::convert<endianness::BIG>(buf, len,
  236|    126|                                                           latin1_output);
  237|    126|}
_ZNK7simdutf8fallback14implementation37convert_utf16le_to_latin1_with_errorsEPKDsmPc:
  241|    230|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  242|    230|  return scalar::utf16_to_latin1::convert_with_errors<endianness::LITTLE>(
  243|    230|      buf, len, latin1_output);
  244|    230|}
_ZNK7simdutf8fallback14implementation37convert_utf16be_to_latin1_with_errorsEPKDsmPc:
  248|    252|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  249|    252|  return scalar::utf16_to_latin1::convert_with_errors<endianness::BIG>(
  250|    252|      buf, len, latin1_output);
  251|    252|}
_ZNK7simdutf8fallback14implementation23convert_utf16le_to_utf8EPKDsmPc:
  268|    386|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  269|    386|  return scalar::utf16_to_utf8::convert<endianness::LITTLE>(buf, len,
  270|    386|                                                            utf8_output);
  271|    386|}
_ZNK7simdutf8fallback14implementation23convert_utf16be_to_utf8EPKDsmPc:
  274|    326|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  275|    326|  return scalar::utf16_to_utf8::convert<endianness::BIG>(buf, len, utf8_output);
  276|    326|}
_ZNK7simdutf8fallback14implementation35convert_utf16le_to_utf8_with_errorsEPKDsmPc:
  279|    630|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  280|    630|  return scalar::utf16_to_utf8::convert_with_errors<endianness::LITTLE>(
  281|    630|      buf, len, utf8_output);
  282|    630|}
_ZNK7simdutf8fallback14implementation35convert_utf16be_to_utf8_with_errorsEPKDsmPc:
  285|    586|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  286|    586|  return scalar::utf16_to_utf8::convert_with_errors<endianness::BIG>(
  287|    586|      buf, len, utf8_output);
  288|    586|}
_ZNK7simdutf8fallback14implementation29convert_valid_utf16le_to_utf8EPKDsmPc:
  291|    416|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  292|    416|  return scalar::utf16_to_utf8::convert_valid<endianness::LITTLE>(buf, len,
  293|    416|                                                                  utf8_output);
  294|    416|}
_ZNK7simdutf8fallback14implementation29convert_valid_utf16be_to_utf8EPKDsmPc:
  297|    442|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  298|    442|  return scalar::utf16_to_utf8::convert_valid<endianness::BIG>(buf, len,
  299|    442|                                                               utf8_output);
  300|    442|}
_ZNK7simdutf8fallback14implementation23convert_utf32_to_latin1EPKDimPc:
  305|    188|    const char32_t *buf, size_t len, char *latin1_output) const noexcept {
  306|    188|  return scalar::utf32_to_latin1::convert(buf, len, latin1_output);
  307|    188|}
_ZNK7simdutf8fallback14implementation35convert_utf32_to_latin1_with_errorsEPKDimPc:
  310|    420|    const char32_t *buf, size_t len, char *latin1_output) const noexcept {
  311|    420|  return scalar::utf32_to_latin1::convert_with_errors(buf, len, latin1_output);
  312|    420|}
_ZNK7simdutf8fallback14implementation21convert_utf32_to_utf8EPKDimPc:
  322|    604|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  323|    604|  return scalar::utf32_to_utf8::convert(buf, len, utf8_output);
  324|    604|}
_ZNK7simdutf8fallback14implementation33convert_utf32_to_utf8_with_errorsEPKDimPc:
  327|    830|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  328|    830|  return scalar::utf32_to_utf8::convert_with_errors(buf, len, utf8_output);
  329|    830|}
_ZNK7simdutf8fallback14implementation27convert_valid_utf32_to_utf8EPKDimPc:
  332|    192|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  333|    192|  return scalar::utf32_to_utf8::convert_valid(buf, len, utf8_output);
  334|    192|}
_ZNK7simdutf8fallback14implementation24convert_utf32_to_utf16leEPKDimPDs:
  339|    432|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  340|    432|  return scalar::utf32_to_utf16::convert<endianness::LITTLE>(buf, len,
  341|    432|                                                             utf16_output);
  342|    432|}
_ZNK7simdutf8fallback14implementation24convert_utf32_to_utf16beEPKDimPDs:
  345|    442|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  346|    442|  return scalar::utf32_to_utf16::convert<endianness::BIG>(buf, len,
  347|    442|                                                          utf16_output);
  348|    442|}
_ZNK7simdutf8fallback14implementation36convert_utf32_to_utf16le_with_errorsEPKDimPDs:
  351|    716|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  352|    716|  return scalar::utf32_to_utf16::convert_with_errors<endianness::LITTLE>(
  353|    716|      buf, len, utf16_output);
  354|    716|}
_ZNK7simdutf8fallback14implementation36convert_utf32_to_utf16be_with_errorsEPKDimPDs:
  357|    606|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  358|    606|  return scalar::utf32_to_utf16::convert_with_errors<endianness::BIG>(
  359|    606|      buf, len, utf16_output);
  360|    606|}
_ZNK7simdutf8fallback14implementation30convert_valid_utf32_to_utf16leEPKDimPDs:
  363|    290|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  364|    290|  return scalar::utf32_to_utf16::convert_valid<endianness::LITTLE>(
  365|    290|      buf, len, utf16_output);
  366|    290|}
_ZNK7simdutf8fallback14implementation30convert_valid_utf32_to_utf16beEPKDimPDs:
  369|     86|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  370|     86|  return scalar::utf32_to_utf16::convert_valid<endianness::BIG>(buf, len,
  371|     86|                                                                utf16_output);
  372|     86|}
_ZNK7simdutf8fallback14implementation24convert_utf16le_to_utf32EPKDsmPDi:
  375|    272|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  376|    272|  return scalar::utf16_to_utf32::convert<endianness::LITTLE>(buf, len,
  377|    272|                                                             utf32_output);
  378|    272|}
_ZNK7simdutf8fallback14implementation24convert_utf16be_to_utf32EPKDsmPDi:
  381|    226|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  382|    226|  return scalar::utf16_to_utf32::convert<endianness::BIG>(buf, len,
  383|    226|                                                          utf32_output);
  384|    226|}
_ZNK7simdutf8fallback14implementation36convert_utf16le_to_utf32_with_errorsEPKDsmPDi:
  387|    414|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  388|    414|  return scalar::utf16_to_utf32::convert_with_errors<endianness::LITTLE>(
  389|    414|      buf, len, utf32_output);
  390|    414|}
_ZNK7simdutf8fallback14implementation36convert_utf16be_to_utf32_with_errorsEPKDsmPDi:
  393|    300|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  394|    300|  return scalar::utf16_to_utf32::convert_with_errors<endianness::BIG>(
  395|    300|      buf, len, utf32_output);
  396|    300|}
_ZNK7simdutf8fallback14implementation30convert_valid_utf16le_to_utf32EPKDsmPDi:
  399|    112|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  400|    112|  return scalar::utf16_to_utf32::convert_valid<endianness::LITTLE>(
  401|    112|      buf, len, utf32_output);
  402|    112|}
_ZNK7simdutf8fallback14implementation30convert_valid_utf16be_to_utf32EPKDsmPDi:
  405|    140|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  406|    140|  return scalar::utf16_to_utf32::convert_valid<endianness::BIG>(buf, len,
  407|    140|                                                                utf32_output);
  408|    140|}
_ZNK7simdutf8fallback14implementation13count_utf16leEPKDsm:
  419|  1.30k|    const char16_t *input, size_t length) const noexcept {
  420|  1.30k|  return scalar::utf16::count_code_points<endianness::LITTLE>(input, length);
  421|  1.30k|}
_ZNK7simdutf8fallback14implementation13count_utf16beEPKDsm:
  424|  1.23k|    const char16_t *input, size_t length) const noexcept {
  425|  1.23k|  return scalar::utf16::count_code_points<endianness::BIG>(input, length);
  426|  1.23k|}
_ZNK7simdutf8fallback14implementation10count_utf8EPKcm:
  431|  3.22k|implementation::count_utf8(const char *input, size_t length) const noexcept {
  432|  3.22k|  return scalar::utf8::count_code_points(input, length);
  433|  3.22k|}
_ZNK7simdutf8fallback14implementation23latin1_length_from_utf8EPKcm:
  438|    539|    const char *buf, size_t len) const noexcept {
  439|    539|  return scalar::utf8::count_code_points(buf, len);
  440|    539|}
_ZNK7simdutf8fallback14implementation23utf8_length_from_latin1EPKcm:
  445|    269|    const char *input, size_t length) const noexcept {
  446|    269|  return scalar::latin1_to_utf8::utf8_length_from_latin1(input, length);
  447|    269|}
_ZNK7simdutf8fallback14implementation24utf8_length_from_utf16leEPKDsm:
  452|    727|    const char16_t *input, size_t length) const noexcept {
  453|    727|  return scalar::utf16::utf8_length_from_utf16<endianness::LITTLE>(input,
  454|    727|                                                                   length);
  455|    727|}
_ZNK7simdutf8fallback14implementation24utf8_length_from_utf16beEPKDsm:
  458|    696|    const char16_t *input, size_t length) const noexcept {
  459|    696|  return scalar::utf16::utf8_length_from_utf16<endianness::BIG>(input, length);
  460|    696|}
_ZNK7simdutf8fallback14implementation25utf32_length_from_utf16leEPKDsm:
  465|    404|    const char16_t *input, size_t length) const noexcept {
  466|    404|  return scalar::utf16::utf32_length_from_utf16<endianness::LITTLE>(input,
  467|    404|                                                                    length);
  468|    404|}
_ZNK7simdutf8fallback14implementation25utf32_length_from_utf16beEPKDsm:
  471|    351|    const char16_t *input, size_t length) const noexcept {
  472|    351|  return scalar::utf16::utf32_length_from_utf16<endianness::BIG>(input, length);
  473|    351|}
_ZNK7simdutf8fallback14implementation22utf16_length_from_utf8EPKcm:
  478|  1.74k|    const char *input, size_t length) const noexcept {
  479|  1.74k|  return scalar::utf8::utf16_length_from_utf8(input, length);
  480|  1.74k|}
_ZNK7simdutf8fallback14implementation22utf8_length_from_utf32EPKDim:
  513|    819|    const char32_t *input, size_t length) const noexcept {
  514|    819|  return scalar::utf32::utf8_length_from_utf32(input, length);
  515|    819|}
_ZNK7simdutf8fallback14implementation23utf16_length_from_utf32EPKDim:
  520|  1.29k|    const char32_t *input, size_t length) const noexcept {
  521|  1.29k|  return scalar::utf32::utf16_length_from_utf32(input, length);
  522|  1.29k|}
_ZNK7simdutf8fallback14implementation22utf32_length_from_utf8EPKcm:
  527|    933|    const char *input, size_t length) const noexcept {
  528|    933|  return scalar::utf8::count_code_points(input, length);
  529|    933|}

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

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

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf3222utf8_length_from_utf32EPKDim:
   11|    819|                                                    size_t length) {
   12|    819|  using vector_u32 = simd32<uint32_t>;
   13|       |
   14|    819|  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|    819|  const size_t max_increment = 3;
   19|       |
   20|    819|  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|    819|  const auto v_ffffff80 = vector_u32::splat(0xffffff80);
   28|    819|  const auto v_fffff800 = vector_u32::splat(0xfffff800);
   29|    819|  const auto v_ffff0000 = vector_u32::splat(0xffff0000);
   30|    819|  const auto one = vector_u32::splat(1);
   31|    819|#endif // SIMDUTF_SIMD_HAS_UNSIGNED_CMP
   32|       |
   33|    819|  size_t counter = 0;
   34|       |
   35|       |  // 1. vectorized loop unrolled 4 times
   36|    819|  {
   37|       |    // we use vector of uint32 counters, this is why this limit is used
   38|    819|    const size_t max_iterations =
   39|    819|        std::numeric_limits<uint32_t>::max() / (max_increment * 4);
   40|    819|    size_t blocks = length / (N * 4);
   41|    819|    length -= blocks * (N * 4);
   42|  1.01k|    while (blocks != 0) {
  ------------------
  |  Branch (42:12): [True: 191, False: 819]
  ------------------
   43|    191|      const size_t iterations = min(blocks, max_iterations);
   44|    191|      blocks -= iterations;
   45|       |
   46|    191|      simd32<uint32_t> acc = vector_u32::zero();
   47|  72.3k|      for (size_t i = 0; i < iterations; i++) {
  ------------------
  |  Branch (47:26): [True: 72.1k, False: 191]
  ------------------
   48|  72.1k|        const auto in0 = vector_u32(input + 0 * N);
   49|  72.1k|        const auto in1 = vector_u32(input + 1 * N);
   50|  72.1k|        const auto in2 = vector_u32(input + 2 * N);
   51|  72.1k|        const auto in3 = vector_u32(input + 3 * N);
   52|       |
   53|       |#if SIMDUTF_SIMD_HAS_UNSIGNED_CMP
   54|       |        acc -= as_vector_u32(in0 > v_0000007f);
   55|       |        acc -= as_vector_u32(in1 > v_0000007f);
   56|       |        acc -= as_vector_u32(in2 > v_0000007f);
   57|       |        acc -= as_vector_u32(in3 > v_0000007f);
   58|       |
   59|       |        acc -= as_vector_u32(in0 > v_000007ff);
   60|       |        acc -= as_vector_u32(in1 > v_000007ff);
   61|       |        acc -= as_vector_u32(in2 > v_000007ff);
   62|       |        acc -= as_vector_u32(in3 > v_000007ff);
   63|       |
   64|       |        acc -= as_vector_u32(in0 > v_0000ffff);
   65|       |        acc -= as_vector_u32(in1 > v_0000ffff);
   66|       |        acc -= as_vector_u32(in2 > v_0000ffff);
   67|       |        acc -= as_vector_u32(in3 > v_0000ffff);
   68|       |#else
   69|  72.1k|        acc += min(one, in0 & v_ffffff80);
   70|  72.1k|        acc += min(one, in1 & v_ffffff80);
   71|  72.1k|        acc += min(one, in2 & v_ffffff80);
   72|  72.1k|        acc += min(one, in3 & v_ffffff80);
   73|       |
   74|  72.1k|        acc += min(one, in0 & v_fffff800);
   75|  72.1k|        acc += min(one, in1 & v_fffff800);
   76|  72.1k|        acc += min(one, in2 & v_fffff800);
   77|  72.1k|        acc += min(one, in3 & v_fffff800);
   78|       |
   79|  72.1k|        acc += min(one, in0 & v_ffff0000);
   80|  72.1k|        acc += min(one, in1 & v_ffff0000);
   81|  72.1k|        acc += min(one, in2 & v_ffff0000);
   82|  72.1k|        acc += min(one, in3 & v_ffff0000);
   83|  72.1k|#endif // SIMDUTF_SIMD_HAS_UNSIGNED_CMP
   84|       |
   85|  72.1k|        input += 4 * N;
   86|  72.1k|      }
   87|       |
   88|    191|      counter += acc.sum();
   89|    191|    }
   90|    819|  }
   91|       |
   92|       |  // 2. vectorized loop for tail
   93|    819|  {
   94|    819|    const size_t max_iterations =
   95|    819|        std::numeric_limits<uint32_t>::max() / max_increment;
   96|    819|    size_t blocks = length / N;
   97|    819|    length -= blocks * N;
   98|  1.22k|    while (blocks != 0) {
  ------------------
  |  Branch (98:12): [True: 408, False: 819]
  ------------------
   99|    408|      const size_t iterations = min(blocks, max_iterations);
  100|    408|      blocks -= iterations;
  101|       |
  102|    408|      auto acc = vector_u32::zero();
  103|  1.41k|      for (size_t i = 0; i < iterations; i++) {
  ------------------
  |  Branch (103:26): [True: 1.00k, False: 408]
  ------------------
  104|  1.00k|        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.00k|        acc += min(one, in & v_ffffff80);
  112|  1.00k|        acc += min(one, in & v_fffff800);
  113|  1.00k|        acc += min(one, in & v_ffff0000);
  114|  1.00k|#endif // SIMDUTF_SIMD_HAS_UNSIGNED_CMP
  115|       |
  116|  1.00k|        input += N;
  117|  1.00k|      }
  118|       |
  119|    408|      counter += acc.sum();
  120|    408|    }
  121|    819|  }
  122|       |
  123|    819|  const size_t consumed = input - start;
  124|    819|  if (consumed != 0) {
  ------------------
  |  Branch (124:7): [True: 448, False: 371]
  ------------------
  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|    448|    counter += consumed;
  128|    448|  }
  129|       |
  130|    819|  return counter + scalar::utf32::utf8_length_from_utf32(input, length);
  131|    819|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf323minImEET_S4_S4_:
    8|    599|template <typename T> T min(T a, T b) { return a <= b ? a : b; }
  ------------------
  |  Branch (8:48): [True: 599, False: 0]
  ------------------
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf3222utf8_length_from_utf32EPKDim:
   11|    819|                                                    size_t length) {
   12|    819|  using vector_u32 = simd32<uint32_t>;
   13|       |
   14|    819|  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|    819|  const size_t max_increment = 3;
   19|       |
   20|    819|  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|    819|  const auto v_ffffff80 = vector_u32::splat(0xffffff80);
   28|    819|  const auto v_fffff800 = vector_u32::splat(0xfffff800);
   29|    819|  const auto v_ffff0000 = vector_u32::splat(0xffff0000);
   30|    819|  const auto one = vector_u32::splat(1);
   31|    819|#endif // SIMDUTF_SIMD_HAS_UNSIGNED_CMP
   32|       |
   33|    819|  size_t counter = 0;
   34|       |
   35|       |  // 1. vectorized loop unrolled 4 times
   36|    819|  {
   37|       |    // we use vector of uint32 counters, this is why this limit is used
   38|    819|    const size_t max_iterations =
   39|    819|        std::numeric_limits<uint32_t>::max() / (max_increment * 4);
   40|    819|    size_t blocks = length / (N * 4);
   41|    819|    length -= blocks * (N * 4);
   42|  1.24k|    while (blocks != 0) {
  ------------------
  |  Branch (42:12): [True: 430, False: 819]
  ------------------
   43|    430|      const size_t iterations = min(blocks, max_iterations);
   44|    430|      blocks -= iterations;
   45|       |
   46|    430|      simd32<uint32_t> acc = vector_u32::zero();
   47|   145k|      for (size_t i = 0; i < iterations; i++) {
  ------------------
  |  Branch (47:26): [True: 144k, False: 430]
  ------------------
   48|   144k|        const auto in0 = vector_u32(input + 0 * N);
   49|   144k|        const auto in1 = vector_u32(input + 1 * N);
   50|   144k|        const auto in2 = vector_u32(input + 2 * N);
   51|   144k|        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|   144k|        acc += min(one, in0 & v_ffffff80);
   70|   144k|        acc += min(one, in1 & v_ffffff80);
   71|   144k|        acc += min(one, in2 & v_ffffff80);
   72|   144k|        acc += min(one, in3 & v_ffffff80);
   73|       |
   74|   144k|        acc += min(one, in0 & v_fffff800);
   75|   144k|        acc += min(one, in1 & v_fffff800);
   76|   144k|        acc += min(one, in2 & v_fffff800);
   77|   144k|        acc += min(one, in3 & v_fffff800);
   78|       |
   79|   144k|        acc += min(one, in0 & v_ffff0000);
   80|   144k|        acc += min(one, in1 & v_ffff0000);
   81|   144k|        acc += min(one, in2 & v_ffff0000);
   82|   144k|        acc += min(one, in3 & v_ffff0000);
   83|   144k|#endif // SIMDUTF_SIMD_HAS_UNSIGNED_CMP
   84|       |
   85|   144k|        input += 4 * N;
   86|   144k|      }
   87|       |
   88|    430|      counter += acc.sum();
   89|    430|    }
   90|    819|  }
   91|       |
   92|       |  // 2. vectorized loop for tail
   93|    819|  {
   94|    819|    const size_t max_iterations =
   95|    819|        std::numeric_limits<uint32_t>::max() / max_increment;
   96|    819|    size_t blocks = length / N;
   97|    819|    length -= blocks * N;
   98|  1.26k|    while (blocks != 0) {
  ------------------
  |  Branch (98:12): [True: 447, False: 819]
  ------------------
   99|    447|      const size_t iterations = min(blocks, max_iterations);
  100|    447|      blocks -= iterations;
  101|       |
  102|    447|      auto acc = vector_u32::zero();
  103|  1.53k|      for (size_t i = 0; i < iterations; i++) {
  ------------------
  |  Branch (103:26): [True: 1.09k, False: 447]
  ------------------
  104|  1.09k|        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.09k|        acc += min(one, in & v_ffffff80);
  112|  1.09k|        acc += min(one, in & v_fffff800);
  113|  1.09k|        acc += min(one, in & v_ffff0000);
  114|  1.09k|#endif // SIMDUTF_SIMD_HAS_UNSIGNED_CMP
  115|       |
  116|  1.09k|        input += N;
  117|  1.09k|      }
  118|       |
  119|    447|      counter += acc.sum();
  120|    447|    }
  121|    819|  }
  122|       |
  123|    819|  const size_t consumed = input - start;
  124|    819|  if (consumed != 0) {
  ------------------
  |  Branch (124:7): [True: 490, False: 329]
  ------------------
  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|    490|    counter += consumed;
  128|    490|  }
  129|       |
  130|    819|  return counter + scalar::utf32::utf8_length_from_utf32(input, length);
  131|    819|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf323minImEET_S4_S4_:
    8|    877|template <typename T> T min(T a, T b) { return a <= b ? a : b; }
  ------------------
  |  Branch (8:48): [True: 877, False: 0]
  ------------------

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

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_114utf8_to_latin121validating_transcoderC2Ev:
  101|  1.07k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_114utf8_to_latin121validating_transcoder7convertEPKcmPc:
  115|    562|                                       char *latin1_output) {
  116|    562|    size_t pos = 0;
  117|    562|    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|    562|    size_t leading_byte = 0;
  125|    562|    size_t margin = size;
  126|  9.10k|    for (; margin > 0 && leading_byte < 16; margin--) {
  ------------------
  |  Branch (126:12): [True: 8.98k, False: 114]
  |  Branch (126:26): [True: 8.53k, False: 448]
  ------------------
  127|  8.53k|      leading_byte += (int8_t(in[margin - 1]) >
  128|  8.53k|                       -65); // twos complement of -65 is 1011 1111 ...
  129|  8.53k|    }
  130|       |    // If the input is long enough, then we have that margin-1 is the eight last
  131|       |    // leading byte.
  132|    562|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  133|   684k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (133:12): [True: 683k, False: 538]
  ------------------
  134|   683k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  135|   683k|      if (input.is_ascii()) {
  ------------------
  |  Branch (135:11): [True: 644k, False: 38.9k]
  ------------------
  136|   644k|        input.store((int8_t *)latin1_output);
  137|   644k|        latin1_output += 64;
  138|   644k|        pos += 64;
  139|   644k|      } else {
  140|       |        // you might think that a for-loop would work, but under Visual Studio,
  141|       |        // it is not good enough.
  142|  38.9k|        static_assert(
  143|  38.9k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  144|  38.9k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  145|  38.9k|            "We support either two or four chunks per 64-byte block.");
  146|  38.9k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  147|  38.9k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  148|  38.9k|          this->check_utf8_bytes(input.chunks[0], zero);
  149|  38.9k|          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|  38.9k|        uint64_t utf8_continuation_mask =
  157|  38.9k|            input.lt(-65 + 1); // -64 is 1100 0000 in twos complement. Note: in
  158|       |                               // this case, we also have ASCII to account for.
  159|  38.9k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (159:13): [True: 24, False: 38.9k]
  ------------------
  160|     24|          return 0; // error
  161|     24|        }
  162|  38.9k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  163|  38.9k|        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|  38.9k|        size_t max_starting_point = (pos + 64) - 12;
  168|       |        // Next loop is going to run at least five times.
  169|   386k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (169:16): [True: 347k, False: 38.9k]
  ------------------
  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|   347k|          size_t consumed = convert_masked_utf8_to_latin1(
  180|   347k|              in + pos, utf8_end_of_code_point_mask, latin1_output);
  181|   347k|          pos += consumed;
  182|   347k|          utf8_end_of_code_point_mask >>= consumed;
  183|   347k|        }
  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|  38.9k|      }
  189|   683k|    }
  190|    538|    if (errors()) {
  ------------------
  |  Branch (190:9): [True: 234, False: 304]
  ------------------
  191|    234|      return 0;
  192|    234|    }
  193|    304|    if (pos < size) {
  ------------------
  |  Branch (193:9): [True: 300, False: 4]
  ------------------
  194|    300|      size_t howmany =
  195|    300|          scalar::utf8_to_latin1::convert(in + pos, size - pos, latin1_output);
  196|    300|      if (howmany == 0) {
  ------------------
  |  Branch (196:11): [True: 128, False: 172]
  ------------------
  197|    128|        return 0;
  198|    128|      }
  199|    172|      latin1_output += howmany;
  200|    172|    }
  201|    176|    return latin1_output - start;
  202|    304|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_114utf8_to_latin121validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  106|   121k|                                              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|   121k|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  111|   121k|    this->error |= check_special_cases(input, prev1);
  112|   121k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_114utf8_to_latin119check_special_casesENS1_4simd5simd8IhEES5_:
    8|   121k|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|   121k|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   20|       |                                               // 11______ 11______
   21|   121k|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   22|   121k|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   23|   121k|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   24|   121k|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   25|   121k|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   26|   121k|  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|   121k|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   35|       |  // 11110101 1000____
   36|       |  // 1111011_ 1000____
   37|       |  // 11111___ 1000____
   38|   121k|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   39|   121k|  constexpr const uint8_t FORBIDDEN = 0xff;
   40|       |
   41|   121k|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   42|       |      // 0_______ ________ <ASCII in byte 1>
   43|   121k|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   44|   121k|      TOO_LONG,
   45|       |      // 10______ ________ <continuation in byte 1>
   46|   121k|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   47|       |      // 1100____ ________ <two byte lead in byte 1>
   48|   121k|      TOO_SHORT | OVERLONG_2,
   49|       |      // 1101____ ________ <two byte lead in byte 1>
   50|   121k|      FORBIDDEN,
   51|       |      // 1110____ ________ <three byte lead in byte 1>
   52|   121k|      FORBIDDEN,
   53|       |      // 1111____ ________ <four+ byte lead in byte 1>
   54|   121k|      FORBIDDEN);
   55|   121k|  constexpr const uint8_t CARRY =
   56|   121k|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   57|   121k|  const simd8<uint8_t> byte_1_low =
   58|   121k|      (prev1 & 0x0F)
   59|   121k|          .lookup_16<uint8_t>(
   60|       |              // ____0000 ________
   61|   121k|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   62|       |              // ____0001 ________
   63|   121k|              CARRY | OVERLONG_2,
   64|       |              // ____001_ ________
   65|   121k|              CARRY, CARRY,
   66|       |
   67|       |              // ____0100 ________
   68|   121k|              FORBIDDEN,
   69|       |              // ____0101 ________
   70|   121k|              FORBIDDEN,
   71|       |              // ____011_ ________
   72|   121k|              FORBIDDEN, FORBIDDEN,
   73|       |
   74|       |              // ____1___ ________
   75|   121k|              FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
   76|       |              // ____1101 ________
   77|   121k|              FORBIDDEN, FORBIDDEN, FORBIDDEN);
   78|   121k|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   79|       |      // ________ 0_______ <ASCII in byte 2>
   80|   121k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   81|   121k|      TOO_SHORT, TOO_SHORT,
   82|       |
   83|       |      // ________ 1000____
   84|   121k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   85|   121k|          OVERLONG_4,
   86|       |      // ________ 1001____
   87|   121k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   88|       |      // ________ 101_____
   89|   121k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   90|   121k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   91|       |
   92|       |      // ________ 11______
   93|   121k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   94|   121k|  return (byte_1_high & byte_1_low & byte_2_high);
   95|   121k|}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_114utf8_to_latin121validating_transcoder6errorsEv:
  308|  22.8k|  simdutf_really_inline bool errors() const {
  309|  22.8k|    return this->error.any_bits_set_anywhere();
  310|  22.8k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_114utf8_to_latin121validating_transcoder19convert_with_errorsEPKcmPc:
  205|    516|                                                   char *latin1_output) {
  206|    516|    size_t pos = 0;
  207|    516|    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|    516|    size_t leading_byte = 0;
  215|    516|    size_t margin = size;
  216|  4.72k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (216:12): [True: 4.60k, False: 122]
  |  Branch (216:26): [True: 4.20k, False: 394]
  ------------------
  217|  4.20k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  218|  4.20k|    }
  219|       |    // If the input is long enough, then we have that margin-1 is the eight last
  220|       |    // leading byte.
  221|    516|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  222|   381k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (222:12): [True: 381k, False: 432]
  ------------------
  223|   381k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  224|   381k|      if (input.is_ascii()) {
  ------------------
  |  Branch (224:11): [True: 359k, False: 21.8k]
  ------------------
  225|   359k|        input.store((int8_t *)latin1_output);
  226|   359k|        latin1_output += 64;
  227|   359k|        pos += 64;
  228|   359k|      } else {
  229|       |        // you might think that a for-loop would work, but under Visual Studio,
  230|       |        // it is not good enough.
  231|  21.8k|        static_assert(
  232|  21.8k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  233|  21.8k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  234|  21.8k|            "We support either two or four chunks per 64-byte block.");
  235|  21.8k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  236|  21.8k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  237|  21.8k|          this->check_utf8_bytes(input.chunks[0], zero);
  238|  21.8k|          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|  21.8k|        if (errors()) {
  ------------------
  |  Branch (245:13): [True: 84, False: 21.7k]
  ------------------
  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|     84|          result res = scalar::utf8_to_latin1::rewind_and_convert_with_errors(
  250|     84|              pos, in + pos, size - pos, latin1_output);
  251|     84|          res.count += pos;
  252|     84|          return res;
  253|     84|        }
  254|  21.7k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  255|  21.7k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  256|  21.7k|        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|  21.7k|        size_t max_starting_point = (pos + 64) - 12;
  261|       |        // Next loop is going to run at least five times.
  262|   217k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (262:16): [True: 195k, False: 21.7k]
  ------------------
  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|   195k|          size_t consumed = convert_masked_utf8_to_latin1(
  273|   195k|              in + pos, utf8_end_of_code_point_mask, latin1_output);
  274|   195k|          pos += consumed;
  275|   195k|          utf8_end_of_code_point_mask >>= consumed;
  276|   195k|        }
  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|  21.7k|      }
  282|   381k|    }
  283|    432|    if (errors()) {
  ------------------
  |  Branch (283:9): [True: 0, False: 432]
  ------------------
  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|    432|    if (pos < size) {
  ------------------
  |  Branch (292:9): [True: 428, 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|    428|      result res = scalar::utf8_to_latin1::rewind_and_convert_with_errors(
  297|    428|          pos, in + pos, size - pos, latin1_output);
  298|    428|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (298:11): [True: 202, False: 226]
  ------------------
  299|    202|        res.count += pos;
  300|    202|        return res;
  301|    226|      } else { // In case of success, we want the number of word written
  302|    226|        latin1_output += res.count;
  303|    226|      }
  304|    428|    }
  305|    230|    return result(error_code::SUCCESS, latin1_output - start);
  306|    432|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114utf8_to_latin121validating_transcoderC2Ev:
  101|  1.07k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114utf8_to_latin121validating_transcoder7convertEPKcmPc:
  115|    562|                                       char *latin1_output) {
  116|    562|    size_t pos = 0;
  117|    562|    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|    562|    size_t leading_byte = 0;
  125|    562|    size_t margin = size;
  126|  9.10k|    for (; margin > 0 && leading_byte < 16; margin--) {
  ------------------
  |  Branch (126:12): [True: 8.98k, False: 114]
  |  Branch (126:26): [True: 8.53k, False: 448]
  ------------------
  127|  8.53k|      leading_byte += (int8_t(in[margin - 1]) >
  128|  8.53k|                       -65); // twos complement of -65 is 1011 1111 ...
  129|  8.53k|    }
  130|       |    // If the input is long enough, then we have that margin-1 is the eight last
  131|       |    // leading byte.
  132|    562|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  133|   684k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (133:12): [True: 683k, False: 538]
  ------------------
  134|   683k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  135|   683k|      if (input.is_ascii()) {
  ------------------
  |  Branch (135:11): [True: 644k, False: 38.9k]
  ------------------
  136|   644k|        input.store((int8_t *)latin1_output);
  137|   644k|        latin1_output += 64;
  138|   644k|        pos += 64;
  139|   644k|      } else {
  140|       |        // you might think that a for-loop would work, but under Visual Studio,
  141|       |        // it is not good enough.
  142|  38.9k|        static_assert(
  143|  38.9k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  144|  38.9k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  145|  38.9k|            "We support either two or four chunks per 64-byte block.");
  146|  38.9k|        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|  38.9k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  151|  38.9k|          this->check_utf8_bytes(input.chunks[0], zero);
  152|  38.9k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  153|  38.9k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  154|  38.9k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  155|  38.9k|        }
  156|  38.9k|        uint64_t utf8_continuation_mask =
  157|  38.9k|            input.lt(-65 + 1); // -64 is 1100 0000 in twos complement. Note: in
  158|       |                               // this case, we also have ASCII to account for.
  159|  38.9k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (159:13): [True: 24, False: 38.9k]
  ------------------
  160|     24|          return 0; // error
  161|     24|        }
  162|  38.9k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  163|  38.9k|        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|  38.9k|        size_t max_starting_point = (pos + 64) - 12;
  168|       |        // Next loop is going to run at least five times.
  169|   386k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (169:16): [True: 347k, False: 38.9k]
  ------------------
  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|   347k|          size_t consumed = convert_masked_utf8_to_latin1(
  180|   347k|              in + pos, utf8_end_of_code_point_mask, latin1_output);
  181|   347k|          pos += consumed;
  182|   347k|          utf8_end_of_code_point_mask >>= consumed;
  183|   347k|        }
  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|  38.9k|      }
  189|   683k|    }
  190|    538|    if (errors()) {
  ------------------
  |  Branch (190:9): [True: 234, False: 304]
  ------------------
  191|    234|      return 0;
  192|    234|    }
  193|    304|    if (pos < size) {
  ------------------
  |  Branch (193:9): [True: 300, False: 4]
  ------------------
  194|    300|      size_t howmany =
  195|    300|          scalar::utf8_to_latin1::convert(in + pos, size - pos, latin1_output);
  196|    300|      if (howmany == 0) {
  ------------------
  |  Branch (196:11): [True: 128, False: 172]
  ------------------
  197|    128|        return 0;
  198|    128|      }
  199|    172|      latin1_output += howmany;
  200|    172|    }
  201|    176|    return latin1_output - start;
  202|    304|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114utf8_to_latin121validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  106|   243k|                                              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|   243k|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  111|   243k|    this->error |= check_special_cases(input, prev1);
  112|   243k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114utf8_to_latin119check_special_casesENS1_4simd5simd8IhEES5_:
    8|   243k|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|   243k|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   20|       |                                               // 11______ 11______
   21|   243k|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   22|   243k|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   23|   243k|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   24|   243k|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   25|   243k|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   26|   243k|  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|   243k|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   35|       |  // 11110101 1000____
   36|       |  // 1111011_ 1000____
   37|       |  // 11111___ 1000____
   38|   243k|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   39|   243k|  constexpr const uint8_t FORBIDDEN = 0xff;
   40|       |
   41|   243k|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   42|       |      // 0_______ ________ <ASCII in byte 1>
   43|   243k|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   44|   243k|      TOO_LONG,
   45|       |      // 10______ ________ <continuation in byte 1>
   46|   243k|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   47|       |      // 1100____ ________ <two byte lead in byte 1>
   48|   243k|      TOO_SHORT | OVERLONG_2,
   49|       |      // 1101____ ________ <two byte lead in byte 1>
   50|   243k|      FORBIDDEN,
   51|       |      // 1110____ ________ <three byte lead in byte 1>
   52|   243k|      FORBIDDEN,
   53|       |      // 1111____ ________ <four+ byte lead in byte 1>
   54|   243k|      FORBIDDEN);
   55|   243k|  constexpr const uint8_t CARRY =
   56|   243k|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   57|   243k|  const simd8<uint8_t> byte_1_low =
   58|   243k|      (prev1 & 0x0F)
   59|   243k|          .lookup_16<uint8_t>(
   60|       |              // ____0000 ________
   61|   243k|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   62|       |              // ____0001 ________
   63|   243k|              CARRY | OVERLONG_2,
   64|       |              // ____001_ ________
   65|   243k|              CARRY, CARRY,
   66|       |
   67|       |              // ____0100 ________
   68|   243k|              FORBIDDEN,
   69|       |              // ____0101 ________
   70|   243k|              FORBIDDEN,
   71|       |              // ____011_ ________
   72|   243k|              FORBIDDEN, FORBIDDEN,
   73|       |
   74|       |              // ____1___ ________
   75|   243k|              FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
   76|       |              // ____1101 ________
   77|   243k|              FORBIDDEN, FORBIDDEN, FORBIDDEN);
   78|   243k|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   79|       |      // ________ 0_______ <ASCII in byte 2>
   80|   243k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   81|   243k|      TOO_SHORT, TOO_SHORT,
   82|       |
   83|       |      // ________ 1000____
   84|   243k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   85|   243k|          OVERLONG_4,
   86|       |      // ________ 1001____
   87|   243k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   88|       |      // ________ 101_____
   89|   243k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   90|   243k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   91|       |
   92|       |      // ________ 11______
   93|   243k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   94|   243k|  return (byte_1_high & byte_1_low & byte_2_high);
   95|   243k|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_114utf8_to_latin121validating_transcoder6errorsEv:
  308|  22.8k|  simdutf_really_inline bool errors() const {
  309|  22.8k|    return this->error.any_bits_set_anywhere();
  310|  22.8k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114utf8_to_latin121validating_transcoder19convert_with_errorsEPKcmPc:
  205|    516|                                                   char *latin1_output) {
  206|    516|    size_t pos = 0;
  207|    516|    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|    516|    size_t leading_byte = 0;
  215|    516|    size_t margin = size;
  216|  4.72k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (216:12): [True: 4.60k, False: 122]
  |  Branch (216:26): [True: 4.20k, False: 394]
  ------------------
  217|  4.20k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  218|  4.20k|    }
  219|       |    // If the input is long enough, then we have that margin-1 is the eight last
  220|       |    // leading byte.
  221|    516|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  222|   381k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (222:12): [True: 381k, False: 432]
  ------------------
  223|   381k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  224|   381k|      if (input.is_ascii()) {
  ------------------
  |  Branch (224:11): [True: 359k, False: 21.8k]
  ------------------
  225|   359k|        input.store((int8_t *)latin1_output);
  226|   359k|        latin1_output += 64;
  227|   359k|        pos += 64;
  228|   359k|      } else {
  229|       |        // you might think that a for-loop would work, but under Visual Studio,
  230|       |        // it is not good enough.
  231|  21.8k|        static_assert(
  232|  21.8k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  233|  21.8k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  234|  21.8k|            "We support either two or four chunks per 64-byte block.");
  235|  21.8k|        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|  21.8k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  240|  21.8k|          this->check_utf8_bytes(input.chunks[0], zero);
  241|  21.8k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  242|  21.8k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  243|  21.8k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  244|  21.8k|        }
  245|  21.8k|        if (errors()) {
  ------------------
  |  Branch (245:13): [True: 84, False: 21.7k]
  ------------------
  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|     84|          result res = scalar::utf8_to_latin1::rewind_and_convert_with_errors(
  250|     84|              pos, in + pos, size - pos, latin1_output);
  251|     84|          res.count += pos;
  252|     84|          return res;
  253|     84|        }
  254|  21.7k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  255|  21.7k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  256|  21.7k|        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|  21.7k|        size_t max_starting_point = (pos + 64) - 12;
  261|       |        // Next loop is going to run at least five times.
  262|   217k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (262:16): [True: 195k, False: 21.7k]
  ------------------
  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|   195k|          size_t consumed = convert_masked_utf8_to_latin1(
  273|   195k|              in + pos, utf8_end_of_code_point_mask, latin1_output);
  274|   195k|          pos += consumed;
  275|   195k|          utf8_end_of_code_point_mask >>= consumed;
  276|   195k|        }
  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|  21.7k|      }
  282|   381k|    }
  283|    432|    if (errors()) {
  ------------------
  |  Branch (283:9): [True: 0, False: 432]
  ------------------
  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|    432|    if (pos < size) {
  ------------------
  |  Branch (292:9): [True: 428, 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|    428|      result res = scalar::utf8_to_latin1::rewind_and_convert_with_errors(
  297|    428|          pos, in + pos, size - pos, latin1_output);
  298|    428|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (298:11): [True: 202, False: 226]
  ------------------
  299|    202|        res.count += pos;
  300|    202|        return res;
  301|    226|      } else { // In case of success, we want the number of word written
  302|    226|        latin1_output += res.count;
  303|    226|      }
  304|    428|    }
  305|    230|    return result(error_code::SUCCESS, latin1_output - start);
  306|    432|  }

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoderC2Ev:
  114|  2.64k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoderC2Ev:
  114|  2.64k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder7convertILNS_10endiannessE0EEEmPKcmPDs:
  130|    660|                                       char16_t *utf16_output) {
  131|    660|    size_t pos = 0;
  132|    660|    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|    660|    size_t leading_byte = 0;
  140|    660|    size_t margin = size;
  141|  6.34k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (141:12): [True: 6.13k, False: 218]
  |  Branch (141:26): [True: 5.68k, False: 442]
  ------------------
  142|  5.68k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  143|  5.68k|    }
  144|       |    // If the input is long enough, then we have that margin-1 is the eight last
  145|       |    // leading byte.
  146|    660|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  147|   586k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (147:12): [True: 585k, False: 638]
  ------------------
  148|   585k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  149|   585k|      if (input.is_ascii()) {
  ------------------
  |  Branch (149:11): [True: 506k, False: 79.1k]
  ------------------
  150|   506k|        input.store_ascii_as_utf16<endian>(utf16_output);
  151|   506k|        utf16_output += 64;
  152|   506k|        pos += 64;
  153|   506k|      } else {
  154|       |        // you might think that a for-loop would work, but under Visual Studio,
  155|       |        // it is not good enough.
  156|  79.1k|        static_assert(
  157|  79.1k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  158|  79.1k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  159|  79.1k|            "We support either two or four chunks per 64-byte block.");
  160|  79.1k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  161|  79.1k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  162|  79.1k|          this->check_utf8_bytes(input.chunks[0], zero);
  163|  79.1k|          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|  79.1k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  171|  79.1k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (171:13): [True: 22, False: 79.1k]
  ------------------
  172|     22|          return 0; // error
  173|     22|        }
  174|  79.1k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  175|  79.1k|        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|  79.1k|        size_t max_starting_point = (pos + 64) - 12;
  180|       |        // Next loop is going to run at least five times.
  181|   779k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (181:16): [True: 700k, False: 79.1k]
  ------------------
  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|   700k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  192|   700k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  193|   700k|          pos += consumed;
  194|   700k|          utf8_end_of_code_point_mask >>= consumed;
  195|   700k|        }
  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|  79.1k|      }
  201|   585k|    }
  202|    638|    if (errors()) {
  ------------------
  |  Branch (202:9): [True: 250, False: 388]
  ------------------
  203|    250|      return 0;
  204|    250|    }
  205|    388|    if (pos < size) {
  ------------------
  |  Branch (205:9): [True: 384, False: 4]
  ------------------
  206|    384|      size_t howmany = scalar::utf8_to_utf16::convert<endian>(
  207|    384|          in + pos, size - pos, utf16_output);
  208|    384|      if (howmany == 0) {
  ------------------
  |  Branch (208:11): [True: 162, False: 222]
  ------------------
  209|    162|        return 0;
  210|    162|      }
  211|    222|      utf16_output += howmany;
  212|    222|    }
  213|    226|    return utf16_output - start;
  214|    388|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  119|   960k|                                              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|   960k|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  124|   960k|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  125|   960k|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  126|   960k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1619check_special_casesENS1_4simd5simd8IhEES5_:
    8|   960k|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|   960k|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   16|       |                                               // 11______ 11______
   17|   960k|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   18|   960k|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   19|   960k|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   20|   960k|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   21|   960k|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   22|   960k|  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|   960k|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   31|       |  // 11110101 1000____
   32|       |  // 1111011_ 1000____
   33|       |  // 11111___ 1000____
   34|   960k|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   35|       |
   36|   960k|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   37|       |      // 0_______ ________ <ASCII in byte 1>
   38|   960k|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   39|   960k|      TOO_LONG,
   40|       |      // 10______ ________ <continuation in byte 1>
   41|   960k|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   42|       |      // 1100____ ________ <two byte lead in byte 1>
   43|   960k|      TOO_SHORT | OVERLONG_2,
   44|       |      // 1101____ ________ <two byte lead in byte 1>
   45|   960k|      TOO_SHORT,
   46|       |      // 1110____ ________ <three byte lead in byte 1>
   47|   960k|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   48|       |      // 1111____ ________ <four+ byte lead in byte 1>
   49|   960k|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   50|   960k|  constexpr const uint8_t CARRY =
   51|   960k|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   52|   960k|  const simd8<uint8_t> byte_1_low =
   53|   960k|      (prev1 & 0x0F)
   54|   960k|          .lookup_16<uint8_t>(
   55|       |              // ____0000 ________
   56|   960k|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   57|       |              // ____0001 ________
   58|   960k|              CARRY | OVERLONG_2,
   59|       |              // ____001_ ________
   60|   960k|              CARRY, CARRY,
   61|       |
   62|       |              // ____0100 ________
   63|   960k|              CARRY | TOO_LARGE,
   64|       |              // ____0101 ________
   65|   960k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   66|       |              // ____011_ ________
   67|   960k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   68|   960k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|       |
   70|       |              // ____1___ ________
   71|   960k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   72|   960k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|   960k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|   960k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|   960k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|       |              // ____1101 ________
   77|   960k|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   78|   960k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   79|   960k|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   80|   960k|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   81|       |      // ________ 0_______ <ASCII in byte 2>
   82|   960k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   83|   960k|      TOO_SHORT, TOO_SHORT,
   84|       |
   85|       |      // ________ 1000____
   86|   960k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   87|   960k|          OVERLONG_4,
   88|       |      // ________ 1001____
   89|   960k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   90|       |      // ________ 101_____
   91|   960k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   92|   960k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|       |
   94|       |      // ________ 11______
   95|   960k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   96|   960k|  return (byte_1_high & byte_1_low & byte_2_high);
   97|   960k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1623check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  101|   960k|                        const simd8<uint8_t> sc) {
  102|   960k|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  103|   960k|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  104|   960k|  simd8<uint8_t> must23 =
  105|   960k|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  106|   960k|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  107|   960k|  return must23_80 ^ sc;
  108|   960k|}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder6errorsEv:
  324|   233k|  simdutf_really_inline bool errors() const {
  325|   233k|    return this->error.any_bits_set_anywhere();
  326|   233k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder7convertILNS_10endiannessE1EEEmPKcmPDs:
  130|    712|                                       char16_t *utf16_output) {
  131|    712|    size_t pos = 0;
  132|    712|    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|    712|    size_t leading_byte = 0;
  140|    712|    size_t margin = size;
  141|  6.53k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (141:12): [True: 6.32k, False: 214]
  |  Branch (141:26): [True: 5.82k, False: 498]
  ------------------
  142|  5.82k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  143|  5.82k|    }
  144|       |    // If the input is long enough, then we have that margin-1 is the eight last
  145|       |    // leading byte.
  146|    712|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  147|   700k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (147:12): [True: 699k, False: 688]
  ------------------
  148|   699k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  149|   699k|      if (input.is_ascii()) {
  ------------------
  |  Branch (149:11): [True: 529k, False: 170k]
  ------------------
  150|   529k|        input.store_ascii_as_utf16<endian>(utf16_output);
  151|   529k|        utf16_output += 64;
  152|   529k|        pos += 64;
  153|   529k|      } else {
  154|       |        // you might think that a for-loop would work, but under Visual Studio,
  155|       |        // it is not good enough.
  156|   170k|        static_assert(
  157|   170k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  158|   170k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  159|   170k|            "We support either two or four chunks per 64-byte block.");
  160|   170k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  161|   170k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  162|   170k|          this->check_utf8_bytes(input.chunks[0], zero);
  163|   170k|          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|   170k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  171|   170k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (171:13): [True: 24, False: 170k]
  ------------------
  172|     24|          return 0; // error
  173|     24|        }
  174|   170k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  175|   170k|        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|   170k|        size_t max_starting_point = (pos + 64) - 12;
  180|       |        // Next loop is going to run at least five times.
  181|  1.68M|        while (pos < max_starting_point) {
  ------------------
  |  Branch (181:16): [True: 1.51M, False: 170k]
  ------------------
  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.51M|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  192|  1.51M|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  193|  1.51M|          pos += consumed;
  194|  1.51M|          utf8_end_of_code_point_mask >>= consumed;
  195|  1.51M|        }
  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|   170k|      }
  201|   699k|    }
  202|    688|    if (errors()) {
  ------------------
  |  Branch (202:9): [True: 310, False: 378]
  ------------------
  203|    310|      return 0;
  204|    310|    }
  205|    378|    if (pos < size) {
  ------------------
  |  Branch (205:9): [True: 376, False: 2]
  ------------------
  206|    376|      size_t howmany = scalar::utf8_to_utf16::convert<endian>(
  207|    376|          in + pos, size - pos, utf16_output);
  208|    376|      if (howmany == 0) {
  ------------------
  |  Branch (208:11): [True: 184, False: 192]
  ------------------
  209|    184|        return 0;
  210|    184|      }
  211|    192|      utf16_output += howmany;
  212|    192|    }
  213|    194|    return utf16_output - start;
  214|    378|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder19convert_with_errorsILNS_10endiannessE0EEENS_6resultEPKcmPDs:
  218|    574|                                                   char16_t *utf16_output) {
  219|    574|    size_t pos = 0;
  220|    574|    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|    574|    size_t leading_byte = 0;
  228|    574|    size_t margin = size;
  229|  5.00k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (229:12): [True: 4.78k, False: 220]
  |  Branch (229:26): [True: 4.42k, False: 354]
  ------------------
  230|  4.42k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  231|  4.42k|    }
  232|       |    // If the input is long enough, then we have that margin-1 is the eight last
  233|       |    // leading byte.
  234|    574|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  235|   393k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (235:12): [True: 393k, False: 488]
  ------------------
  236|   393k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  237|   393k|      if (input.is_ascii()) {
  ------------------
  |  Branch (237:11): [True: 293k, False: 100k]
  ------------------
  238|   293k|        input.store_ascii_as_utf16<endian>(utf16_output);
  239|   293k|        utf16_output += 64;
  240|   293k|        pos += 64;
  241|   293k|      } else {
  242|       |        // you might think that a for-loop would work, but under Visual Studio,
  243|       |        // it is not good enough.
  244|   100k|        static_assert(
  245|   100k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  246|   100k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  247|   100k|            "We support either two or four chunks per 64-byte block.");
  248|   100k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  249|   100k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  250|   100k|          this->check_utf8_bytes(input.chunks[0], zero);
  251|   100k|          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|   100k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  259|   100k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (259:13): [True: 86, False: 99.9k]
  |  Branch (259:25): [True: 0, False: 99.9k]
  ------------------
  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|     86|          result res =
  264|     86|              scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  265|     86|                  pos, in + pos, size - pos, utf16_output);
  266|     86|          res.count += pos;
  267|     86|          return res;
  268|     86|        }
  269|  99.9k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  270|  99.9k|        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|  99.9k|        size_t max_starting_point = (pos + 64) - 12;
  275|       |        // Next loop is going to run at least five times.
  276|   985k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (276:16): [True: 885k, False: 99.9k]
  ------------------
  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|   885k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  287|   885k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  288|   885k|          pos += consumed;
  289|   885k|          utf8_end_of_code_point_mask >>= consumed;
  290|   885k|        }
  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|  99.9k|      }
  296|   393k|    }
  297|    488|    if (errors()) {
  ------------------
  |  Branch (297:9): [True: 0, False: 488]
  ------------------
  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|    488|    if (pos < size) {
  ------------------
  |  Branch (307:9): [True: 484, 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|    484|      result res =
  312|    484|          scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  313|    484|              pos, in + pos, size - pos, utf16_output);
  314|    484|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (314:11): [True: 242, False: 242]
  ------------------
  315|    242|        res.count += pos;
  316|    242|        return res;
  317|    242|      } else { // In case of success, we want the number of word written
  318|    242|        utf16_output += res.count;
  319|    242|      }
  320|    484|    }
  321|    246|    return result(error_code::SUCCESS, utf16_output - start);
  322|    488|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder19convert_with_errorsILNS_10endiannessE1EEENS_6resultEPKcmPDs:
  218|    702|                                                   char16_t *utf16_output) {
  219|    702|    size_t pos = 0;
  220|    702|    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|    702|    size_t leading_byte = 0;
  228|    702|    size_t margin = size;
  229|  6.13k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (229:12): [True: 5.88k, False: 250]
  |  Branch (229:26): [True: 5.42k, False: 452]
  ------------------
  230|  5.42k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  231|  5.42k|    }
  232|       |    // If the input is long enough, then we have that margin-1 is the eight last
  233|       |    // leading byte.
  234|    702|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  235|   441k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (235:12): [True: 440k, False: 634]
  ------------------
  236|   440k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  237|   440k|      if (input.is_ascii()) {
  ------------------
  |  Branch (237:11): [True: 309k, False: 131k]
  ------------------
  238|   309k|        input.store_ascii_as_utf16<endian>(utf16_output);
  239|   309k|        utf16_output += 64;
  240|   309k|        pos += 64;
  241|   309k|      } else {
  242|       |        // you might think that a for-loop would work, but under Visual Studio,
  243|       |        // it is not good enough.
  244|   131k|        static_assert(
  245|   131k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  246|   131k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  247|   131k|            "We support either two or four chunks per 64-byte block.");
  248|   131k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  249|   131k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  250|   131k|          this->check_utf8_bytes(input.chunks[0], zero);
  251|   131k|          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|   131k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  259|   131k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (259:13): [True: 68, False: 130k]
  |  Branch (259:25): [True: 0, False: 130k]
  ------------------
  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|     68|          result res =
  264|     68|              scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  265|     68|                  pos, in + pos, size - pos, utf16_output);
  266|     68|          res.count += pos;
  267|     68|          return res;
  268|     68|        }
  269|   130k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  270|   130k|        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|   130k|        size_t max_starting_point = (pos + 64) - 12;
  275|       |        // Next loop is going to run at least five times.
  276|  1.29M|        while (pos < max_starting_point) {
  ------------------
  |  Branch (276:16): [True: 1.16M, False: 130k]
  ------------------
  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|  1.16M|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  287|  1.16M|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  288|  1.16M|          pos += consumed;
  289|  1.16M|          utf8_end_of_code_point_mask >>= consumed;
  290|  1.16M|        }
  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|   130k|      }
  296|   440k|    }
  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: 320, False: 310]
  ------------------
  315|    320|        res.count += pos;
  316|    320|        return res;
  317|    320|      } else { // In case of success, we want the number of word written
  318|    310|        utf16_output += res.count;
  319|    310|      }
  320|    630|    }
  321|    314|    return result(error_code::SUCCESS, utf16_output - start);
  322|    634|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder7convertILNS_10endiannessE0EEEmPKcmPDs:
  130|    660|                                       char16_t *utf16_output) {
  131|    660|    size_t pos = 0;
  132|    660|    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|    660|    size_t leading_byte = 0;
  140|    660|    size_t margin = size;
  141|  6.34k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (141:12): [True: 6.13k, False: 218]
  |  Branch (141:26): [True: 5.68k, False: 442]
  ------------------
  142|  5.68k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  143|  5.68k|    }
  144|       |    // If the input is long enough, then we have that margin-1 is the eight last
  145|       |    // leading byte.
  146|    660|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  147|   586k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (147:12): [True: 585k, False: 638]
  ------------------
  148|   585k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  149|   585k|      if (input.is_ascii()) {
  ------------------
  |  Branch (149:11): [True: 506k, False: 79.1k]
  ------------------
  150|   506k|        input.store_ascii_as_utf16<endian>(utf16_output);
  151|   506k|        utf16_output += 64;
  152|   506k|        pos += 64;
  153|   506k|      } else {
  154|       |        // you might think that a for-loop would work, but under Visual Studio,
  155|       |        // it is not good enough.
  156|  79.1k|        static_assert(
  157|  79.1k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  158|  79.1k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  159|  79.1k|            "We support either two or four chunks per 64-byte block.");
  160|  79.1k|        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|  79.1k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  165|  79.1k|          this->check_utf8_bytes(input.chunks[0], zero);
  166|  79.1k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  167|  79.1k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  168|  79.1k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  169|  79.1k|        }
  170|  79.1k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  171|  79.1k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (171:13): [True: 22, False: 79.1k]
  ------------------
  172|     22|          return 0; // error
  173|     22|        }
  174|  79.1k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  175|  79.1k|        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|  79.1k|        size_t max_starting_point = (pos + 64) - 12;
  180|       |        // Next loop is going to run at least five times.
  181|   779k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (181:16): [True: 700k, False: 79.1k]
  ------------------
  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|   700k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  192|   700k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  193|   700k|          pos += consumed;
  194|   700k|          utf8_end_of_code_point_mask >>= consumed;
  195|   700k|        }
  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|  79.1k|      }
  201|   585k|    }
  202|    638|    if (errors()) {
  ------------------
  |  Branch (202:9): [True: 250, False: 388]
  ------------------
  203|    250|      return 0;
  204|    250|    }
  205|    388|    if (pos < size) {
  ------------------
  |  Branch (205:9): [True: 384, False: 4]
  ------------------
  206|    384|      size_t howmany = scalar::utf8_to_utf16::convert<endian>(
  207|    384|          in + pos, size - pos, utf16_output);
  208|    384|      if (howmany == 0) {
  ------------------
  |  Branch (208:11): [True: 162, False: 222]
  ------------------
  209|    162|        return 0;
  210|    162|      }
  211|    222|      utf16_output += howmany;
  212|    222|    }
  213|    226|    return utf16_output - start;
  214|    388|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  119|  1.92M|                                              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.92M|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  124|  1.92M|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  125|  1.92M|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  126|  1.92M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1619check_special_casesENS1_4simd5simd8IhEES5_:
    8|  1.92M|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.92M|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   16|       |                                               // 11______ 11______
   17|  1.92M|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   18|  1.92M|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   19|  1.92M|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   20|  1.92M|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   21|  1.92M|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   22|  1.92M|  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.92M|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   31|       |  // 11110101 1000____
   32|       |  // 1111011_ 1000____
   33|       |  // 11111___ 1000____
   34|  1.92M|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   35|       |
   36|  1.92M|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   37|       |      // 0_______ ________ <ASCII in byte 1>
   38|  1.92M|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   39|  1.92M|      TOO_LONG,
   40|       |      // 10______ ________ <continuation in byte 1>
   41|  1.92M|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   42|       |      // 1100____ ________ <two byte lead in byte 1>
   43|  1.92M|      TOO_SHORT | OVERLONG_2,
   44|       |      // 1101____ ________ <two byte lead in byte 1>
   45|  1.92M|      TOO_SHORT,
   46|       |      // 1110____ ________ <three byte lead in byte 1>
   47|  1.92M|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   48|       |      // 1111____ ________ <four+ byte lead in byte 1>
   49|  1.92M|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   50|  1.92M|  constexpr const uint8_t CARRY =
   51|  1.92M|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   52|  1.92M|  const simd8<uint8_t> byte_1_low =
   53|  1.92M|      (prev1 & 0x0F)
   54|  1.92M|          .lookup_16<uint8_t>(
   55|       |              // ____0000 ________
   56|  1.92M|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   57|       |              // ____0001 ________
   58|  1.92M|              CARRY | OVERLONG_2,
   59|       |              // ____001_ ________
   60|  1.92M|              CARRY, CARRY,
   61|       |
   62|       |              // ____0100 ________
   63|  1.92M|              CARRY | TOO_LARGE,
   64|       |              // ____0101 ________
   65|  1.92M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   66|       |              // ____011_ ________
   67|  1.92M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   68|  1.92M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|       |
   70|       |              // ____1___ ________
   71|  1.92M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   72|  1.92M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|  1.92M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|  1.92M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|  1.92M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|       |              // ____1101 ________
   77|  1.92M|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   78|  1.92M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   79|  1.92M|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   80|  1.92M|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   81|       |      // ________ 0_______ <ASCII in byte 2>
   82|  1.92M|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   83|  1.92M|      TOO_SHORT, TOO_SHORT,
   84|       |
   85|       |      // ________ 1000____
   86|  1.92M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   87|  1.92M|          OVERLONG_4,
   88|       |      // ________ 1001____
   89|  1.92M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   90|       |      // ________ 101_____
   91|  1.92M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   92|  1.92M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|       |
   94|       |      // ________ 11______
   95|  1.92M|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   96|  1.92M|  return (byte_1_high & byte_1_low & byte_2_high);
   97|  1.92M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1623check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  101|  1.92M|                        const simd8<uint8_t> sc) {
  102|  1.92M|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  103|  1.92M|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  104|  1.92M|  simd8<uint8_t> must23 =
  105|  1.92M|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  106|  1.92M|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  107|  1.92M|  return must23_80 ^ sc;
  108|  1.92M|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder6errorsEv:
  324|   233k|  simdutf_really_inline bool errors() const {
  325|   233k|    return this->error.any_bits_set_anywhere();
  326|   233k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder7convertILNS_10endiannessE1EEEmPKcmPDs:
  130|    712|                                       char16_t *utf16_output) {
  131|    712|    size_t pos = 0;
  132|    712|    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|    712|    size_t leading_byte = 0;
  140|    712|    size_t margin = size;
  141|  6.53k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (141:12): [True: 6.32k, False: 214]
  |  Branch (141:26): [True: 5.82k, False: 498]
  ------------------
  142|  5.82k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  143|  5.82k|    }
  144|       |    // If the input is long enough, then we have that margin-1 is the eight last
  145|       |    // leading byte.
  146|    712|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  147|   700k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (147:12): [True: 699k, False: 688]
  ------------------
  148|   699k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  149|   699k|      if (input.is_ascii()) {
  ------------------
  |  Branch (149:11): [True: 529k, False: 170k]
  ------------------
  150|   529k|        input.store_ascii_as_utf16<endian>(utf16_output);
  151|   529k|        utf16_output += 64;
  152|   529k|        pos += 64;
  153|   529k|      } else {
  154|       |        // you might think that a for-loop would work, but under Visual Studio,
  155|       |        // it is not good enough.
  156|   170k|        static_assert(
  157|   170k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  158|   170k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  159|   170k|            "We support either two or four chunks per 64-byte block.");
  160|   170k|        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|   170k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  165|   170k|          this->check_utf8_bytes(input.chunks[0], zero);
  166|   170k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  167|   170k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  168|   170k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  169|   170k|        }
  170|   170k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  171|   170k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (171:13): [True: 24, False: 170k]
  ------------------
  172|     24|          return 0; // error
  173|     24|        }
  174|   170k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  175|   170k|        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|   170k|        size_t max_starting_point = (pos + 64) - 12;
  180|       |        // Next loop is going to run at least five times.
  181|  1.68M|        while (pos < max_starting_point) {
  ------------------
  |  Branch (181:16): [True: 1.51M, False: 170k]
  ------------------
  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.51M|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  192|  1.51M|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  193|  1.51M|          pos += consumed;
  194|  1.51M|          utf8_end_of_code_point_mask >>= consumed;
  195|  1.51M|        }
  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|   170k|      }
  201|   699k|    }
  202|    688|    if (errors()) {
  ------------------
  |  Branch (202:9): [True: 310, False: 378]
  ------------------
  203|    310|      return 0;
  204|    310|    }
  205|    378|    if (pos < size) {
  ------------------
  |  Branch (205:9): [True: 376, False: 2]
  ------------------
  206|    376|      size_t howmany = scalar::utf8_to_utf16::convert<endian>(
  207|    376|          in + pos, size - pos, utf16_output);
  208|    376|      if (howmany == 0) {
  ------------------
  |  Branch (208:11): [True: 184, False: 192]
  ------------------
  209|    184|        return 0;
  210|    184|      }
  211|    192|      utf16_output += howmany;
  212|    192|    }
  213|    194|    return utf16_output - start;
  214|    378|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder19convert_with_errorsILNS_10endiannessE0EEENS_6resultEPKcmPDs:
  218|    574|                                                   char16_t *utf16_output) {
  219|    574|    size_t pos = 0;
  220|    574|    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|    574|    size_t leading_byte = 0;
  228|    574|    size_t margin = size;
  229|  5.00k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (229:12): [True: 4.78k, False: 220]
  |  Branch (229:26): [True: 4.42k, False: 354]
  ------------------
  230|  4.42k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  231|  4.42k|    }
  232|       |    // If the input is long enough, then we have that margin-1 is the eight last
  233|       |    // leading byte.
  234|    574|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  235|   393k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (235:12): [True: 393k, False: 488]
  ------------------
  236|   393k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  237|   393k|      if (input.is_ascii()) {
  ------------------
  |  Branch (237:11): [True: 293k, False: 100k]
  ------------------
  238|   293k|        input.store_ascii_as_utf16<endian>(utf16_output);
  239|   293k|        utf16_output += 64;
  240|   293k|        pos += 64;
  241|   293k|      } else {
  242|       |        // you might think that a for-loop would work, but under Visual Studio,
  243|       |        // it is not good enough.
  244|   100k|        static_assert(
  245|   100k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  246|   100k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  247|   100k|            "We support either two or four chunks per 64-byte block.");
  248|   100k|        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|   100k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  253|   100k|          this->check_utf8_bytes(input.chunks[0], zero);
  254|   100k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  255|   100k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  256|   100k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  257|   100k|        }
  258|   100k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  259|   100k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (259:13): [True: 86, False: 99.9k]
  |  Branch (259:25): [True: 0, False: 99.9k]
  ------------------
  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|     86|          result res =
  264|     86|              scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  265|     86|                  pos, in + pos, size - pos, utf16_output);
  266|     86|          res.count += pos;
  267|     86|          return res;
  268|     86|        }
  269|  99.9k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  270|  99.9k|        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|  99.9k|        size_t max_starting_point = (pos + 64) - 12;
  275|       |        // Next loop is going to run at least five times.
  276|   985k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (276:16): [True: 885k, False: 99.9k]
  ------------------
  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|   885k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  287|   885k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  288|   885k|          pos += consumed;
  289|   885k|          utf8_end_of_code_point_mask >>= consumed;
  290|   885k|        }
  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|  99.9k|      }
  296|   393k|    }
  297|    488|    if (errors()) {
  ------------------
  |  Branch (297:9): [True: 0, False: 488]
  ------------------
  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|    488|    if (pos < size) {
  ------------------
  |  Branch (307:9): [True: 484, 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|    484|      result res =
  312|    484|          scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  313|    484|              pos, in + pos, size - pos, utf16_output);
  314|    484|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (314:11): [True: 242, False: 242]
  ------------------
  315|    242|        res.count += pos;
  316|    242|        return res;
  317|    242|      } else { // In case of success, we want the number of word written
  318|    242|        utf16_output += res.count;
  319|    242|      }
  320|    484|    }
  321|    246|    return result(error_code::SUCCESS, utf16_output - start);
  322|    488|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder19convert_with_errorsILNS_10endiannessE1EEENS_6resultEPKcmPDs:
  218|    702|                                                   char16_t *utf16_output) {
  219|    702|    size_t pos = 0;
  220|    702|    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|    702|    size_t leading_byte = 0;
  228|    702|    size_t margin = size;
  229|  6.13k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (229:12): [True: 5.88k, False: 250]
  |  Branch (229:26): [True: 5.42k, False: 452]
  ------------------
  230|  5.42k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  231|  5.42k|    }
  232|       |    // If the input is long enough, then we have that margin-1 is the eight last
  233|       |    // leading byte.
  234|    702|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  235|   441k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (235:12): [True: 440k, False: 634]
  ------------------
  236|   440k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  237|   440k|      if (input.is_ascii()) {
  ------------------
  |  Branch (237:11): [True: 309k, False: 131k]
  ------------------
  238|   309k|        input.store_ascii_as_utf16<endian>(utf16_output);
  239|   309k|        utf16_output += 64;
  240|   309k|        pos += 64;
  241|   309k|      } else {
  242|       |        // you might think that a for-loop would work, but under Visual Studio,
  243|       |        // it is not good enough.
  244|   131k|        static_assert(
  245|   131k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  246|   131k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  247|   131k|            "We support either two or four chunks per 64-byte block.");
  248|   131k|        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|   131k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  253|   131k|          this->check_utf8_bytes(input.chunks[0], zero);
  254|   131k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  255|   131k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  256|   131k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  257|   131k|        }
  258|   131k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  259|   131k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (259:13): [True: 68, False: 130k]
  |  Branch (259:25): [True: 0, False: 130k]
  ------------------
  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|     68|          result res =
  264|     68|              scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  265|     68|                  pos, in + pos, size - pos, utf16_output);
  266|     68|          res.count += pos;
  267|     68|          return res;
  268|     68|        }
  269|   130k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  270|   130k|        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|   130k|        size_t max_starting_point = (pos + 64) - 12;
  275|       |        // Next loop is going to run at least five times.
  276|  1.29M|        while (pos < max_starting_point) {
  ------------------
  |  Branch (276:16): [True: 1.16M, False: 130k]
  ------------------
  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|  1.16M|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  287|  1.16M|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  288|  1.16M|          pos += consumed;
  289|  1.16M|          utf8_end_of_code_point_mask >>= consumed;
  290|  1.16M|        }
  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|   130k|      }
  296|   440k|    }
  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: 320, False: 310]
  ------------------
  315|    320|        res.count += pos;
  316|    320|        return res;
  317|    320|      } else { // In case of success, we want the number of word written
  318|    310|        utf16_output += res.count;
  319|    310|      }
  320|    630|    }
  321|    314|    return result(error_code::SUCCESS, utf16_output - start);
  322|    634|  }

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1613convert_validILNS_10endiannessE0EEEmPKcmPDs:
   10|    368|                                         char16_t *utf16_output) noexcept {
   11|       |  // The implementation is not specific to haswell and should be moved to the
   12|       |  // generic directory.
   13|    368|  size_t pos = 0;
   14|    368|  char16_t *start{utf16_output};
   15|    368|  const size_t safety_margin = 16; // to avoid overruns!
   16|   406k|  while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (16:10): [True: 405k, False: 368]
  ------------------
   17|       |    // this loop could be unrolled further. For example, we could process the
   18|       |    // mask far more than 64 bytes.
   19|   405k|    simd8x64<int8_t> in(reinterpret_cast<const int8_t *>(input + pos));
   20|   405k|    if (in.is_ascii()) {
  ------------------
  |  Branch (20:9): [True: 261k, False: 144k]
  ------------------
   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|   144k|      uint64_t utf8_continuation_mask = in.lt(-65 + 1);
   29|       |      // -65 is 0b10111111 in two-complement's, so largest possible continuation
   30|       |      // byte
   31|   144k|      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|   144k|      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|   144k|      size_t max_starting_point = (pos + 64) - 12;
   39|       |      // Next loop is going to run at least five times when using solely
   40|       |      // the slow/regular path, and at least four times if there are fast paths.
   41|  1.42M|      while (pos < max_starting_point) {
  ------------------
  |  Branch (41:14): [True: 1.28M, False: 144k]
  ------------------
   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.28M|        size_t consumed = convert_masked_utf8_to_utf16<endian>(
   56|  1.28M|            input + pos, utf8_end_of_code_point_mask, utf16_output);
   57|  1.28M|        pos += consumed;
   58|  1.28M|        utf8_end_of_code_point_mask >>= consumed;
   59|  1.28M|      }
   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|   144k|    }
   65|   405k|  }
   66|    368|  utf16_output += scalar::utf8_to_utf16::convert_valid<endian>(
   67|    368|      input + pos, size - pos, utf16_output);
   68|    368|  return utf16_output - start;
   69|    368|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1613convert_validILNS_10endiannessE1EEEmPKcmPDs:
   10|    438|                                         char16_t *utf16_output) noexcept {
   11|       |  // The implementation is not specific to haswell and should be moved to the
   12|       |  // generic directory.
   13|    438|  size_t pos = 0;
   14|    438|  char16_t *start{utf16_output};
   15|    438|  const size_t safety_margin = 16; // to avoid overruns!
   16|   325k|  while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (16:10): [True: 325k, False: 438]
  ------------------
   17|       |    // this loop could be unrolled further. For example, we could process the
   18|       |    // mask far more than 64 bytes.
   19|   325k|    simd8x64<int8_t> in(reinterpret_cast<const int8_t *>(input + pos));
   20|   325k|    if (in.is_ascii()) {
  ------------------
  |  Branch (20:9): [True: 276k, False: 49.2k]
  ------------------
   21|   276k|      in.store_ascii_as_utf16<endian>(utf16_output);
   22|   276k|      utf16_output += 64;
   23|   276k|      pos += 64;
   24|   276k|    } 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|  49.2k|      uint64_t utf8_continuation_mask = in.lt(-65 + 1);
   29|       |      // -65 is 0b10111111 in two-complement's, so largest possible continuation
   30|       |      // byte
   31|  49.2k|      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|  49.2k|      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|  49.2k|      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|   464k|      while (pos < max_starting_point) {
  ------------------
  |  Branch (41:14): [True: 415k, False: 49.2k]
  ------------------
   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|   415k|        size_t consumed = convert_masked_utf8_to_utf16<endian>(
   56|   415k|            input + pos, utf8_end_of_code_point_mask, utf16_output);
   57|   415k|        pos += consumed;
   58|   415k|        utf8_end_of_code_point_mask >>= consumed;
   59|   415k|      }
   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|  49.2k|    }
   65|   325k|  }
   66|    438|  utf16_output += scalar::utf8_to_utf16::convert_valid<endian>(
   67|    438|      input + pos, size - pos, utf16_output);
   68|    438|  return utf16_output - start;
   69|    438|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1613convert_validILNS_10endiannessE0EEEmPKcmPDs:
   10|    368|                                         char16_t *utf16_output) noexcept {
   11|       |  // The implementation is not specific to haswell and should be moved to the
   12|       |  // generic directory.
   13|    368|  size_t pos = 0;
   14|    368|  char16_t *start{utf16_output};
   15|    368|  const size_t safety_margin = 16; // to avoid overruns!
   16|   406k|  while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (16:10): [True: 405k, False: 368]
  ------------------
   17|       |    // this loop could be unrolled further. For example, we could process the
   18|       |    // mask far more than 64 bytes.
   19|   405k|    simd8x64<int8_t> in(reinterpret_cast<const int8_t *>(input + pos));
   20|   405k|    if (in.is_ascii()) {
  ------------------
  |  Branch (20:9): [True: 261k, False: 144k]
  ------------------
   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|   144k|      uint64_t utf8_continuation_mask = in.lt(-65 + 1);
   29|       |      // -65 is 0b10111111 in two-complement's, so largest possible continuation
   30|       |      // byte
   31|   144k|      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|   144k|      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|   144k|      size_t max_starting_point = (pos + 64) - 12;
   39|       |      // Next loop is going to run at least five times when using solely
   40|       |      // the slow/regular path, and at least four times if there are fast paths.
   41|  1.42M|      while (pos < max_starting_point) {
  ------------------
  |  Branch (41:14): [True: 1.28M, False: 144k]
  ------------------
   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.28M|        size_t consumed = convert_masked_utf8_to_utf16<endian>(
   56|  1.28M|            input + pos, utf8_end_of_code_point_mask, utf16_output);
   57|  1.28M|        pos += consumed;
   58|  1.28M|        utf8_end_of_code_point_mask >>= consumed;
   59|  1.28M|      }
   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|   144k|    }
   65|   405k|  }
   66|    368|  utf16_output += scalar::utf8_to_utf16::convert_valid<endian>(
   67|    368|      input + pos, size - pos, utf16_output);
   68|    368|  return utf16_output - start;
   69|    368|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1613convert_validILNS_10endiannessE1EEEmPKcmPDs:
   10|    438|                                         char16_t *utf16_output) noexcept {
   11|       |  // The implementation is not specific to haswell and should be moved to the
   12|       |  // generic directory.
   13|    438|  size_t pos = 0;
   14|    438|  char16_t *start{utf16_output};
   15|    438|  const size_t safety_margin = 16; // to avoid overruns!
   16|   325k|  while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (16:10): [True: 325k, False: 438]
  ------------------
   17|       |    // this loop could be unrolled further. For example, we could process the
   18|       |    // mask far more than 64 bytes.
   19|   325k|    simd8x64<int8_t> in(reinterpret_cast<const int8_t *>(input + pos));
   20|   325k|    if (in.is_ascii()) {
  ------------------
  |  Branch (20:9): [True: 276k, False: 49.2k]
  ------------------
   21|   276k|      in.store_ascii_as_utf16<endian>(utf16_output);
   22|   276k|      utf16_output += 64;
   23|   276k|      pos += 64;
   24|   276k|    } 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|  49.2k|      uint64_t utf8_continuation_mask = in.lt(-65 + 1);
   29|       |      // -65 is 0b10111111 in two-complement's, so largest possible continuation
   30|       |      // byte
   31|  49.2k|      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|  49.2k|      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|  49.2k|      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|   464k|      while (pos < max_starting_point) {
  ------------------
  |  Branch (41:14): [True: 415k, False: 49.2k]
  ------------------
   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|   415k|        size_t consumed = convert_masked_utf8_to_utf16<endian>(
   56|   415k|            input + pos, utf8_end_of_code_point_mask, utf16_output);
   57|   415k|        pos += consumed;
   58|   415k|        utf8_end_of_code_point_mask >>= consumed;
   59|   415k|      }
   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|  49.2k|    }
   65|   325k|  }
   66|    438|  utf16_output += scalar::utf8_to_utf16::convert_valid<endian>(
   67|    438|      input + pos, size - pos, utf16_output);
   68|    438|  return utf16_output - start;
   69|    438|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3221validating_transcoderC2Ev:
  114|  1.45k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3221validating_transcoder7convertEPKcmPDi:
  129|    712|                                       char32_t *utf32_output) {
  130|    712|    size_t pos = 0;
  131|    712|    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|    712|    size_t leading_byte = 0;
  139|    712|    size_t margin = size;
  140|  6.55k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (140:12): [True: 6.32k, False: 232]
  |  Branch (140:26): [True: 5.84k, False: 480]
  ------------------
  141|  5.84k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  142|  5.84k|    }
  143|       |    // If the input is long enough, then we have that margin-1 is the fourth
  144|       |    // last leading byte.
  145|    712|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  146|   724k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (146:12): [True: 724k, False: 690]
  ------------------
  147|   724k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  148|   724k|      if (input.is_ascii()) {
  ------------------
  |  Branch (148:11): [True: 473k, False: 250k]
  ------------------
  149|   473k|        input.store_ascii_as_utf32(utf32_output);
  150|   473k|        utf32_output += 64;
  151|   473k|        pos += 64;
  152|   473k|      } else {
  153|       |        // you might think that a for-loop would work, but under Visual Studio,
  154|       |        // it is not good enough.
  155|   250k|        static_assert(
  156|   250k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  157|   250k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  158|   250k|            "We support either two or four chunks per 64-byte block.");
  159|   250k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  160|   250k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  161|   250k|          this->check_utf8_bytes(input.chunks[0], zero);
  162|   250k|          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|   250k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  170|   250k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (170:13): [True: 22, False: 250k]
  ------------------
  171|     22|          return 0; // we have an error
  172|     22|        }
  173|   250k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  174|   250k|        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|   250k|        size_t max_starting_point = (pos + 64) - 12;
  179|       |        // Next loop is going to run at least five times.
  180|  2.49M|        while (pos < max_starting_point) {
  ------------------
  |  Branch (180:16): [True: 2.23M, False: 250k]
  ------------------
  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|  2.23M|          size_t consumed = convert_masked_utf8_to_utf32(
  191|  2.23M|              in + pos, utf8_end_of_code_point_mask, utf32_output);
  192|  2.23M|          pos += consumed;
  193|  2.23M|          utf8_end_of_code_point_mask >>= consumed;
  194|  2.23M|        }
  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|   250k|      }
  200|   724k|    }
  201|    690|    if (errors()) {
  ------------------
  |  Branch (201:9): [True: 244, False: 446]
  ------------------
  202|    244|      return 0;
  203|    244|    }
  204|    446|    if (pos < size) {
  ------------------
  |  Branch (204:9): [True: 444, False: 2]
  ------------------
  205|    444|      size_t howmany =
  206|    444|          scalar::utf8_to_utf32::convert(in + pos, size - pos, utf32_output);
  207|    444|      if (howmany == 0) {
  ------------------
  |  Branch (207:11): [True: 170, False: 274]
  ------------------
  208|    170|        return 0;
  209|    170|      }
  210|    274|      utf32_output += howmany;
  211|    274|    }
  212|    276|    return utf32_output - start;
  213|    446|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3221validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  119|   582k|                                              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|   582k|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  124|   582k|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  125|   582k|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  126|   582k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3219check_special_casesENS1_4simd5simd8IhEES5_:
    8|   582k|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|   582k|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   16|       |                                               // 11______ 11______
   17|   582k|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   18|   582k|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   19|   582k|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   20|   582k|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   21|   582k|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   22|   582k|  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|   582k|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   31|       |  // 11110101 1000____
   32|       |  // 1111011_ 1000____
   33|       |  // 11111___ 1000____
   34|   582k|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   35|       |
   36|   582k|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   37|       |      // 0_______ ________ <ASCII in byte 1>
   38|   582k|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   39|   582k|      TOO_LONG,
   40|       |      // 10______ ________ <continuation in byte 1>
   41|   582k|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   42|       |      // 1100____ ________ <two byte lead in byte 1>
   43|   582k|      TOO_SHORT | OVERLONG_2,
   44|       |      // 1101____ ________ <two byte lead in byte 1>
   45|   582k|      TOO_SHORT,
   46|       |      // 1110____ ________ <three byte lead in byte 1>
   47|   582k|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   48|       |      // 1111____ ________ <four+ byte lead in byte 1>
   49|   582k|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   50|   582k|  constexpr const uint8_t CARRY =
   51|   582k|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   52|   582k|  const simd8<uint8_t> byte_1_low =
   53|   582k|      (prev1 & 0x0F)
   54|   582k|          .lookup_16<uint8_t>(
   55|       |              // ____0000 ________
   56|   582k|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   57|       |              // ____0001 ________
   58|   582k|              CARRY | OVERLONG_2,
   59|       |              // ____001_ ________
   60|   582k|              CARRY, CARRY,
   61|       |
   62|       |              // ____0100 ________
   63|   582k|              CARRY | TOO_LARGE,
   64|       |              // ____0101 ________
   65|   582k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   66|       |              // ____011_ ________
   67|   582k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   68|   582k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|       |
   70|       |              // ____1___ ________
   71|   582k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   72|   582k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|   582k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|   582k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|   582k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|       |              // ____1101 ________
   77|   582k|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   78|   582k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   79|   582k|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   80|   582k|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   81|       |      // ________ 0_______ <ASCII in byte 2>
   82|   582k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   83|   582k|      TOO_SHORT, TOO_SHORT,
   84|       |
   85|       |      // ________ 1000____
   86|   582k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   87|   582k|          OVERLONG_4,
   88|       |      // ________ 1001____
   89|   582k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   90|       |      // ________ 101_____
   91|   582k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   92|   582k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|       |
   94|       |      // ________ 11______
   95|   582k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   96|   582k|  return (byte_1_high & byte_1_low & byte_2_high);
   97|   582k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3223check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  101|   582k|                        const simd8<uint8_t> sc) {
  102|   582k|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  103|   582k|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  104|   582k|  simd8<uint8_t> must23 =
  105|   582k|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  106|   582k|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  107|   582k|  return must23_80 ^ sc;
  108|   582k|}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3221validating_transcoder6errorsEv:
  310|  42.1k|  simdutf_really_inline bool errors() const {
  311|  42.1k|    return this->error.any_bits_set_anywhere();
  312|  42.1k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3221validating_transcoder19convert_with_errorsEPKcmPDi:
  216|    738|                                                   char32_t *utf32_output) {
  217|    738|    size_t pos = 0;
  218|    738|    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|    738|    size_t leading_byte = 0;
  226|    738|    size_t margin = size;
  227|  6.50k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (227:12): [True: 6.27k, False: 224]
  |  Branch (227:26): [True: 5.76k, False: 514]
  ------------------
  228|  5.76k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  229|  5.76k|    }
  230|       |    // If the input is long enough, then we have that margin-1 is the fourth
  231|       |    // last leading byte.
  232|    738|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  233|   442k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (233:12): [True: 441k, False: 652]
  ------------------
  234|   441k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  235|   441k|      if (input.is_ascii()) {
  ------------------
  |  Branch (235:11): [True: 400k, False: 40.8k]
  ------------------
  236|   400k|        input.store_ascii_as_utf32(utf32_output);
  237|   400k|        utf32_output += 64;
  238|   400k|        pos += 64;
  239|   400k|      } else {
  240|       |        // you might think that a for-loop would work, but under Visual Studio,
  241|       |        // it is not good enough.
  242|  40.8k|        static_assert(
  243|  40.8k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  244|  40.8k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  245|  40.8k|            "We support either two or four chunks per 64-byte block.");
  246|  40.8k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  247|  40.8k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  248|  40.8k|          this->check_utf8_bytes(input.chunks[0], zero);
  249|  40.8k|          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|  40.8k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  257|  40.8k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (257:13): [True: 86, False: 40.7k]
  |  Branch (257:25): [True: 0, False: 40.7k]
  ------------------
  258|     86|          result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(
  259|     86|              pos, in + pos, size - pos, utf32_output);
  260|     86|          res.count += pos;
  261|     86|          return res;
  262|     86|        }
  263|  40.7k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  264|  40.7k|        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|  40.7k|        size_t max_starting_point = (pos + 64) - 12;
  269|       |        // Next loop is going to run at least five times.
  270|   395k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (270:16): [True: 354k, False: 40.7k]
  ------------------
  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|   354k|          size_t consumed = convert_masked_utf8_to_utf32(
  281|   354k|              in + pos, utf8_end_of_code_point_mask, utf32_output);
  282|   354k|          pos += consumed;
  283|   354k|          utf8_end_of_code_point_mask >>= consumed;
  284|   354k|        }
  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|  40.7k|      }
  290|   441k|    }
  291|    652|    if (errors()) {
  ------------------
  |  Branch (291:9): [True: 0, False: 652]
  ------------------
  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|    652|    if (pos < size) {
  ------------------
  |  Branch (297:9): [True: 648, False: 4]
  ------------------
  298|    648|      result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(
  299|    648|          pos, in + pos, size - pos, utf32_output);
  300|    648|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (300:11): [True: 312, False: 336]
  ------------------
  301|    312|        res.count += pos;
  302|    312|        return res;
  303|    336|      } else { // In case of success, we want the number of word written
  304|    336|        utf32_output += res.count;
  305|    336|      }
  306|    648|    }
  307|    340|    return result(error_code::SUCCESS, utf32_output - start);
  308|    652|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3221validating_transcoderC2Ev:
  114|  1.45k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3221validating_transcoder7convertEPKcmPDi:
  129|    712|                                       char32_t *utf32_output) {
  130|    712|    size_t pos = 0;
  131|    712|    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|    712|    size_t leading_byte = 0;
  139|    712|    size_t margin = size;
  140|  6.55k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (140:12): [True: 6.32k, False: 232]
  |  Branch (140:26): [True: 5.84k, False: 480]
  ------------------
  141|  5.84k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  142|  5.84k|    }
  143|       |    // If the input is long enough, then we have that margin-1 is the fourth
  144|       |    // last leading byte.
  145|    712|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  146|   724k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (146:12): [True: 724k, False: 690]
  ------------------
  147|   724k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  148|   724k|      if (input.is_ascii()) {
  ------------------
  |  Branch (148:11): [True: 473k, False: 250k]
  ------------------
  149|   473k|        input.store_ascii_as_utf32(utf32_output);
  150|   473k|        utf32_output += 64;
  151|   473k|        pos += 64;
  152|   473k|      } else {
  153|       |        // you might think that a for-loop would work, but under Visual Studio,
  154|       |        // it is not good enough.
  155|   250k|        static_assert(
  156|   250k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  157|   250k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  158|   250k|            "We support either two or four chunks per 64-byte block.");
  159|   250k|        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|   250k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  164|   250k|          this->check_utf8_bytes(input.chunks[0], zero);
  165|   250k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  166|   250k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  167|   250k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  168|   250k|        }
  169|   250k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  170|   250k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (170:13): [True: 22, False: 250k]
  ------------------
  171|     22|          return 0; // we have an error
  172|     22|        }
  173|   250k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  174|   250k|        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|   250k|        size_t max_starting_point = (pos + 64) - 12;
  179|       |        // Next loop is going to run at least five times.
  180|  2.49M|        while (pos < max_starting_point) {
  ------------------
  |  Branch (180:16): [True: 2.23M, False: 250k]
  ------------------
  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|  2.23M|          size_t consumed = convert_masked_utf8_to_utf32(
  191|  2.23M|              in + pos, utf8_end_of_code_point_mask, utf32_output);
  192|  2.23M|          pos += consumed;
  193|  2.23M|          utf8_end_of_code_point_mask >>= consumed;
  194|  2.23M|        }
  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|   250k|      }
  200|   724k|    }
  201|    690|    if (errors()) {
  ------------------
  |  Branch (201:9): [True: 244, False: 446]
  ------------------
  202|    244|      return 0;
  203|    244|    }
  204|    446|    if (pos < size) {
  ------------------
  |  Branch (204:9): [True: 444, False: 2]
  ------------------
  205|    444|      size_t howmany =
  206|    444|          scalar::utf8_to_utf32::convert(in + pos, size - pos, utf32_output);
  207|    444|      if (howmany == 0) {
  ------------------
  |  Branch (207:11): [True: 170, False: 274]
  ------------------
  208|    170|        return 0;
  209|    170|      }
  210|    274|      utf32_output += howmany;
  211|    274|    }
  212|    276|    return utf32_output - start;
  213|    446|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3221validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  119|  1.16M|                                              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.16M|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  124|  1.16M|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  125|  1.16M|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  126|  1.16M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3219check_special_casesENS1_4simd5simd8IhEES5_:
    8|  1.16M|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.16M|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   16|       |                                               // 11______ 11______
   17|  1.16M|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   18|  1.16M|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   19|  1.16M|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   20|  1.16M|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   21|  1.16M|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   22|  1.16M|  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.16M|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   31|       |  // 11110101 1000____
   32|       |  // 1111011_ 1000____
   33|       |  // 11111___ 1000____
   34|  1.16M|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   35|       |
   36|  1.16M|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   37|       |      // 0_______ ________ <ASCII in byte 1>
   38|  1.16M|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   39|  1.16M|      TOO_LONG,
   40|       |      // 10______ ________ <continuation in byte 1>
   41|  1.16M|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   42|       |      // 1100____ ________ <two byte lead in byte 1>
   43|  1.16M|      TOO_SHORT | OVERLONG_2,
   44|       |      // 1101____ ________ <two byte lead in byte 1>
   45|  1.16M|      TOO_SHORT,
   46|       |      // 1110____ ________ <three byte lead in byte 1>
   47|  1.16M|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   48|       |      // 1111____ ________ <four+ byte lead in byte 1>
   49|  1.16M|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   50|  1.16M|  constexpr const uint8_t CARRY =
   51|  1.16M|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   52|  1.16M|  const simd8<uint8_t> byte_1_low =
   53|  1.16M|      (prev1 & 0x0F)
   54|  1.16M|          .lookup_16<uint8_t>(
   55|       |              // ____0000 ________
   56|  1.16M|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   57|       |              // ____0001 ________
   58|  1.16M|              CARRY | OVERLONG_2,
   59|       |              // ____001_ ________
   60|  1.16M|              CARRY, CARRY,
   61|       |
   62|       |              // ____0100 ________
   63|  1.16M|              CARRY | TOO_LARGE,
   64|       |              // ____0101 ________
   65|  1.16M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   66|       |              // ____011_ ________
   67|  1.16M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   68|  1.16M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|       |
   70|       |              // ____1___ ________
   71|  1.16M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   72|  1.16M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|  1.16M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|  1.16M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|  1.16M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|       |              // ____1101 ________
   77|  1.16M|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   78|  1.16M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   79|  1.16M|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   80|  1.16M|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   81|       |      // ________ 0_______ <ASCII in byte 2>
   82|  1.16M|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   83|  1.16M|      TOO_SHORT, TOO_SHORT,
   84|       |
   85|       |      // ________ 1000____
   86|  1.16M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   87|  1.16M|          OVERLONG_4,
   88|       |      // ________ 1001____
   89|  1.16M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   90|       |      // ________ 101_____
   91|  1.16M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   92|  1.16M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|       |
   94|       |      // ________ 11______
   95|  1.16M|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   96|  1.16M|  return (byte_1_high & byte_1_low & byte_2_high);
   97|  1.16M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3223check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  101|  1.16M|                        const simd8<uint8_t> sc) {
  102|  1.16M|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  103|  1.16M|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  104|  1.16M|  simd8<uint8_t> must23 =
  105|  1.16M|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  106|  1.16M|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  107|  1.16M|  return must23_80 ^ sc;
  108|  1.16M|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3221validating_transcoder6errorsEv:
  310|  42.1k|  simdutf_really_inline bool errors() const {
  311|  42.1k|    return this->error.any_bits_set_anywhere();
  312|  42.1k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3221validating_transcoder19convert_with_errorsEPKcmPDi:
  216|    738|                                                   char32_t *utf32_output) {
  217|    738|    size_t pos = 0;
  218|    738|    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|    738|    size_t leading_byte = 0;
  226|    738|    size_t margin = size;
  227|  6.50k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (227:12): [True: 6.27k, False: 224]
  |  Branch (227:26): [True: 5.76k, False: 514]
  ------------------
  228|  5.76k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  229|  5.76k|    }
  230|       |    // If the input is long enough, then we have that margin-1 is the fourth
  231|       |    // last leading byte.
  232|    738|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  233|   442k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (233:12): [True: 441k, False: 652]
  ------------------
  234|   441k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  235|   441k|      if (input.is_ascii()) {
  ------------------
  |  Branch (235:11): [True: 400k, False: 40.8k]
  ------------------
  236|   400k|        input.store_ascii_as_utf32(utf32_output);
  237|   400k|        utf32_output += 64;
  238|   400k|        pos += 64;
  239|   400k|      } else {
  240|       |        // you might think that a for-loop would work, but under Visual Studio,
  241|       |        // it is not good enough.
  242|  40.8k|        static_assert(
  243|  40.8k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  244|  40.8k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  245|  40.8k|            "We support either two or four chunks per 64-byte block.");
  246|  40.8k|        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|  40.8k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  251|  40.8k|          this->check_utf8_bytes(input.chunks[0], zero);
  252|  40.8k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  253|  40.8k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  254|  40.8k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  255|  40.8k|        }
  256|  40.8k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  257|  40.8k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (257:13): [True: 86, False: 40.7k]
  |  Branch (257:25): [True: 0, False: 40.7k]
  ------------------
  258|     86|          result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(
  259|     86|              pos, in + pos, size - pos, utf32_output);
  260|     86|          res.count += pos;
  261|     86|          return res;
  262|     86|        }
  263|  40.7k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  264|  40.7k|        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|  40.7k|        size_t max_starting_point = (pos + 64) - 12;
  269|       |        // Next loop is going to run at least five times.
  270|   395k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (270:16): [True: 354k, False: 40.7k]
  ------------------
  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|   354k|          size_t consumed = convert_masked_utf8_to_utf32(
  281|   354k|              in + pos, utf8_end_of_code_point_mask, utf32_output);
  282|   354k|          pos += consumed;
  283|   354k|          utf8_end_of_code_point_mask >>= consumed;
  284|   354k|        }
  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|  40.7k|      }
  290|   441k|    }
  291|    652|    if (errors()) {
  ------------------
  |  Branch (291:9): [True: 0, False: 652]
  ------------------
  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|    652|    if (pos < size) {
  ------------------
  |  Branch (297:9): [True: 648, False: 4]
  ------------------
  298|    648|      result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(
  299|    648|          pos, in + pos, size - pos, utf32_output);
  300|    648|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (300:11): [True: 312, False: 336]
  ------------------
  301|    312|        res.count += pos;
  302|    312|        return res;
  303|    336|      } else { // In case of success, we want the number of word written
  304|    336|        utf32_output += res.count;
  305|    336|      }
  306|    648|    }
  307|    340|    return result(error_code::SUCCESS, utf32_output - start);
  308|    652|  }

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

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

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE0EEEKNS_6resultEPKDsm:
   49|  2.59k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  2.59k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.59k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 17, False: 2.58k]
  |  |  ------------------
  ------------------
   51|     17|    return result(error_code::SUCCESS, 0);
   52|     17|  }
   53|       |
   54|  2.58k|  const char16_t *start = input;
   55|  2.58k|  const char16_t *end = input + size;
   56|       |
   57|  2.58k|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|  2.58k|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|  2.58k|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|  2.58k|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|  2.70M|  while (input + simd16<uint16_t>::SIZE * 2 < end) {
  ------------------
  |  Branch (62:10): [True: 2.70M, False: 2.42k]
  ------------------
   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.70M|    auto in0 = simd16<uint16_t>(input);
   67|  2.70M|    auto in1 =
   68|  2.70M|        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.70M|    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.70M|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   76|  2.70M|    const uint16_t surrogates_bitmask =
   77|  2.70M|        static_cast<uint16_t>(surrogates_wordmask.to_bitmask());
   78|  2.70M|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (78:9): [True: 2.68M, False: 20.5k]
  ------------------
   79|  2.68M|      input += 16;
   80|  2.68M|    } 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.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|  20.5k|      const auto vH = (in & v_fc) == v_dc;
   93|  20.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|  20.5k|      const uint16_t L = static_cast<uint16_t>(~H & surrogates_bitmask);
   98|       |
   99|  20.5k|      const uint16_t a = static_cast<uint16_t>(
  100|  20.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|  20.5k|      const uint16_t b = static_cast<uint16_t>(
  104|  20.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|  20.5k|      const uint16_t c = static_cast<uint16_t>(
  107|  20.5k|          V | a | b); // Combine all the masks into the final one.
  108|       |
  109|  20.5k|      if (c == 0xffff) {
  ------------------
  |  Branch (109:11): [True: 15.4k, False: 5.16k]
  ------------------
  110|       |        // The whole input register contains valid UTF-16, i.e.,
  111|       |        // either single code units or proper surrogate pairs.
  112|  15.4k|        input += 16;
  113|  15.4k|      } else if (c == 0x7fff) {
  ------------------
  |  Branch (113:18): [True: 5.00k, False: 158]
  ------------------
  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|  5.00k|        input += 15;
  119|  5.00k|      } else {
  120|    158|        return result(error_code::SURROGATE, input - start);
  121|    158|      }
  122|  20.5k|    }
  123|  2.70M|  }
  124|       |
  125|  2.42k|  return result(error_code::SUCCESS, input - start);
  126|  2.58k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE1EEEKNS_6resultEPKDsm:
   49|  2.45k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  2.45k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.45k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 15, False: 2.44k]
  |  |  ------------------
  ------------------
   51|     15|    return result(error_code::SUCCESS, 0);
   52|     15|  }
   53|       |
   54|  2.44k|  const char16_t *start = input;
   55|  2.44k|  const char16_t *end = input + size;
   56|       |
   57|  2.44k|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|  2.44k|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|  2.44k|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|  2.44k|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|  2.80M|  while (input + simd16<uint16_t>::SIZE * 2 < end) {
  ------------------
  |  Branch (62:10): [True: 2.80M, False: 2.24k]
  ------------------
   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.80M|    auto in0 = simd16<uint16_t>(input);
   67|  2.80M|    auto in1 =
   68|  2.80M|        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.80M|    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.80M|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   76|  2.80M|    const uint16_t surrogates_bitmask =
   77|  2.80M|        static_cast<uint16_t>(surrogates_wordmask.to_bitmask());
   78|  2.80M|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (78:9): [True: 2.78M, False: 19.3k]
  ------------------
   79|  2.78M|      input += 16;
   80|  2.78M|    } 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.3k|      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.3k|      const auto vH = (in & v_fc) == v_dc;
   93|  19.3k|      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.3k|      const uint16_t L = static_cast<uint16_t>(~H & surrogates_bitmask);
   98|       |
   99|  19.3k|      const uint16_t a = static_cast<uint16_t>(
  100|  19.3k|          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.3k|      const uint16_t b = static_cast<uint16_t>(
  104|  19.3k|          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.3k|      const uint16_t c = static_cast<uint16_t>(
  107|  19.3k|          V | a | b); // Combine all the masks into the final one.
  108|       |
  109|  19.3k|      if (c == 0xffff) {
  ------------------
  |  Branch (109:11): [True: 15.0k, False: 4.30k]
  ------------------
  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.10k, False: 196]
  ------------------
  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.10k|        input += 15;
  119|  4.10k|      } else {
  120|    196|        return result(error_code::SURROGATE, input - start);
  121|    196|      }
  122|  19.3k|    }
  123|  2.80M|  }
  124|       |
  125|  2.24k|  return result(error_code::SUCCESS, input - start);
  126|  2.44k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE0EEEKNS_6resultEPKDsm:
   49|  2.59k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  2.59k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.59k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 17, False: 2.58k]
  |  |  ------------------
  ------------------
   51|     17|    return result(error_code::SUCCESS, 0);
   52|     17|  }
   53|       |
   54|  2.58k|  const char16_t *start = input;
   55|  2.58k|  const char16_t *end = input + size;
   56|       |
   57|  2.58k|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|  2.58k|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|  2.58k|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|  2.58k|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|  2.70M|  while (input + simd16<uint16_t>::SIZE * 2 < end) {
  ------------------
  |  Branch (62:10): [True: 2.70M, 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.70M|    auto in0 = simd16<uint16_t>(input);
   67|  2.70M|    auto in1 =
   68|  2.70M|        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.70M|    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.70M|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   76|  2.70M|    const uint16_t surrogates_bitmask =
   77|  2.70M|        static_cast<uint16_t>(surrogates_wordmask.to_bitmask());
   78|  2.70M|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (78:9): [True: 2.68M, False: 21.1k]
  ------------------
   79|  2.68M|      input += 16;
   80|  2.68M|    } 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|  21.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|  21.1k|      const auto vH = (in & v_fc) == v_dc;
   93|  21.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|  21.1k|      const uint16_t L = static_cast<uint16_t>(~H & surrogates_bitmask);
   98|       |
   99|  21.1k|      const uint16_t a = static_cast<uint16_t>(
  100|  21.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|  21.1k|      const uint16_t b = static_cast<uint16_t>(
  104|  21.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|  21.1k|      const uint16_t c = static_cast<uint16_t>(
  107|  21.1k|          V | a | b); // Combine all the masks into the final one.
  108|       |
  109|  21.1k|      if (c == 0xffff) {
  ------------------
  |  Branch (109:11): [True: 15.7k, False: 5.34k]
  ------------------
  110|       |        // The whole input register contains valid UTF-16, i.e.,
  111|       |        // either single code units or proper surrogate pairs.
  112|  15.7k|        input += 16;
  113|  15.7k|      } else if (c == 0x7fff) {
  ------------------
  |  Branch (113:18): [True: 5.09k, False: 250]
  ------------------
  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|  5.09k|        input += 15;
  119|  5.09k|      } else {
  120|    250|        return result(error_code::SURROGATE, input - start);
  121|    250|      }
  122|  21.1k|    }
  123|  2.70M|  }
  124|       |
  125|  2.33k|  return result(error_code::SUCCESS, input - start);
  126|  2.58k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE1EEEKNS_6resultEPKDsm:
   49|  2.45k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  2.45k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.45k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 15, False: 2.44k]
  |  |  ------------------
  ------------------
   51|     15|    return result(error_code::SUCCESS, 0);
   52|     15|  }
   53|       |
   54|  2.44k|  const char16_t *start = input;
   55|  2.44k|  const char16_t *end = input + size;
   56|       |
   57|  2.44k|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|  2.44k|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|  2.44k|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|  2.44k|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|  2.80M|  while (input + simd16<uint16_t>::SIZE * 2 < end) {
  ------------------
  |  Branch (62:10): [True: 2.80M, False: 2.18k]
  ------------------
   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.80M|    auto in0 = simd16<uint16_t>(input);
   67|  2.80M|    auto in1 =
   68|  2.80M|        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.80M|    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.80M|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   76|  2.80M|    const uint16_t surrogates_bitmask =
   77|  2.80M|        static_cast<uint16_t>(surrogates_wordmask.to_bitmask());
   78|  2.80M|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (78:9): [True: 2.78M, False: 19.7k]
  ------------------
   79|  2.78M|      input += 16;
   80|  2.78M|    } 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.7k|      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.7k|      const auto vH = (in & v_fc) == v_dc;
   93|  19.7k|      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.7k|      const uint16_t L = static_cast<uint16_t>(~H & surrogates_bitmask);
   98|       |
   99|  19.7k|      const uint16_t a = static_cast<uint16_t>(
  100|  19.7k|          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.7k|      const uint16_t b = static_cast<uint16_t>(
  104|  19.7k|          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.7k|      const uint16_t c = static_cast<uint16_t>(
  107|  19.7k|          V | a | b); // Combine all the masks into the final one.
  108|       |
  109|  19.7k|      if (c == 0xffff) {
  ------------------
  |  Branch (109:11): [True: 15.2k, False: 4.47k]
  ------------------
  110|       |        // The whole input register contains valid UTF-16, i.e.,
  111|       |        // either single code units or proper surrogate pairs.
  112|  15.2k|        input += 16;
  113|  15.2k|      } else if (c == 0x7fff) {
  ------------------
  |  Branch (113:18): [True: 4.21k, False: 262]
  ------------------
  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.21k|        input += 15;
  119|  4.21k|      } else {
  120|    262|        return result(error_code::SURROGATE, input - start);
  121|    262|      }
  122|  19.7k|    }
  123|  2.80M|  }
  124|       |
  125|  2.18k|  return result(error_code::SUCCESS, input - start);
  126|  2.44k|}

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

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

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

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

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_127avx2_convert_utf16_to_utf32ILNS_10endiannessE0EEENSt3__14pairIPKDsPDiEES7_mS8_:
   57|    384|                            char32_t *utf32_output) {
   58|    384|  const char16_t *end = buf + len;
   59|    384|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
   60|    384|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
   61|       |
   62|   162k|  while (end - buf >= 16) {
  ------------------
  |  Branch (62:10): [True: 162k, False: 288]
  ------------------
   63|   162k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
   64|   162k|    if (big_endian) {
  ------------------
  |  Branch (64:9): [Folded, False: 162k]
  ------------------
   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|   162k|    const __m256i surrogates_bytemask =
   75|   162k|        _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|   162k|    const uint32_t surrogates_bitmask =
   80|   162k|        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|   162k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (83:9): [True: 158k, False: 3.89k]
  ------------------
   84|       |      // case: we extend all sixteen 16-bit code units to sixteen 32-bit code
   85|       |      // units
   86|   158k|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
   87|   158k|                          _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in)));
   88|   158k|      _mm256_storeu_si256(
   89|   158k|          reinterpret_cast<__m256i *>(utf32_output + 8),
   90|   158k|          _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1)));
   91|   158k|      utf32_output += 16;
   92|   158k|      buf += 16;
   93|       |      // surrogate pair(s) in a register
   94|   158k|    } 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|  3.89k|      size_t forward = 15;
   99|  3.89k|      size_t k = 0;
  100|  3.89k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (100:11): [True: 0, False: 3.89k]
  ------------------
  101|      0|        forward = size_t(end - buf - 1);
  102|      0|      }
  103|  56.8k|      for (; k < forward; k++) {
  ------------------
  |  Branch (103:14): [True: 53.0k, False: 3.80k]
  ------------------
  104|  53.0k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  105|  53.0k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (105:13): [True: 48.1k, False: 4.87k]
  ------------------
  106|       |          // No surrogate pair
  107|  48.1k|          *utf32_output++ = char32_t(word);
  108|  48.1k|        } else {
  109|       |          // must be a surrogate pair
  110|  4.87k|          uint16_t diff = uint16_t(word - 0xD800);
  111|  4.87k|          uint16_t next_word =
  112|  4.87k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  113|  4.87k|          k++;
  114|  4.87k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  115|  4.87k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (115:15): [True: 96, False: 4.77k]
  ------------------
  116|     96|            return std::make_pair(nullptr, utf32_output);
  117|     96|          }
  118|  4.77k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  119|  4.77k|          *utf32_output++ = char32_t(value);
  120|  4.77k|        }
  121|  53.0k|      }
  122|  3.80k|      buf += k;
  123|  3.80k|    }
  124|   162k|  } // while
  125|    288|  return std::make_pair(buf, utf32_output);
  126|    384|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_127avx2_convert_utf16_to_utf32ILNS_10endiannessE1EEENSt3__14pairIPKDsPDiEES7_mS8_:
   57|    366|                            char32_t *utf32_output) {
   58|    366|  const char16_t *end = buf + len;
   59|    366|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
   60|    366|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
   61|       |
   62|   322k|  while (end - buf >= 16) {
  ------------------
  |  Branch (62:10): [True: 321k, False: 310]
  ------------------
   63|   321k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
   64|   321k|    if (big_endian) {
  ------------------
  |  Branch (64:9): [True: 321k, Folded]
  ------------------
   65|   321k|      const __m256i swap = _mm256_setr_epi8(
   66|   321k|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   67|   321k|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   68|   321k|      in = _mm256_shuffle_epi8(in, swap);
   69|   321k|    }
   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|   321k|    const __m256i surrogates_bytemask =
   75|   321k|        _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|   321k|    const uint32_t surrogates_bitmask =
   80|   321k|        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|   321k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (83:9): [True: 320k, False: 1.07k]
  ------------------
   84|       |      // case: we extend all sixteen 16-bit code units to sixteen 32-bit code
   85|       |      // units
   86|   320k|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
   87|   320k|                          _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in)));
   88|   320k|      _mm256_storeu_si256(
   89|   320k|          reinterpret_cast<__m256i *>(utf32_output + 8),
   90|   320k|          _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1)));
   91|   320k|      utf32_output += 16;
   92|   320k|      buf += 16;
   93|       |      // surrogate pair(s) in a register
   94|   320k|    } 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.07k|      size_t forward = 15;
   99|  1.07k|      size_t k = 0;
  100|  1.07k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (100:11): [True: 0, False: 1.07k]
  ------------------
  101|      0|        forward = size_t(end - buf - 1);
  102|      0|      }
  103|  15.0k|      for (; k < forward; k++) {
  ------------------
  |  Branch (103:14): [True: 14.0k, False: 1.02k]
  ------------------
  104|  14.0k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  105|  14.0k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (105:13): [True: 12.3k, False: 1.77k]
  ------------------
  106|       |          // No surrogate pair
  107|  12.3k|          *utf32_output++ = char32_t(word);
  108|  12.3k|        } else {
  109|       |          // must be a surrogate pair
  110|  1.77k|          uint16_t diff = uint16_t(word - 0xD800);
  111|  1.77k|          uint16_t next_word =
  112|  1.77k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  113|  1.77k|          k++;
  114|  1.77k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  115|  1.77k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (115:15): [True: 56, False: 1.71k]
  ------------------
  116|     56|            return std::make_pair(nullptr, utf32_output);
  117|     56|          }
  118|  1.71k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  119|  1.71k|          *utf32_output++ = char32_t(value);
  120|  1.71k|        }
  121|  14.0k|      }
  122|  1.02k|      buf += k;
  123|  1.02k|    }
  124|   321k|  } // while
  125|    310|  return std::make_pair(buf, utf32_output);
  126|    366|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_139avx2_convert_utf16_to_utf32_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPDiEEPKDsmS7_:
  138|    414|                                        char32_t *utf32_output) {
  139|    414|  const char16_t *start = buf;
  140|    414|  const char16_t *end = buf + len;
  141|    414|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
  142|    414|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
  143|       |
  144|   157k|  while (end - buf >= 16) {
  ------------------
  |  Branch (144:10): [True: 157k, False: 290]
  ------------------
  145|   157k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
  146|   157k|    if (big_endian) {
  ------------------
  |  Branch (146:9): [Folded, False: 157k]
  ------------------
  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|   157k|    const __m256i surrogates_bytemask =
  157|   157k|        _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|   157k|    const uint32_t surrogates_bitmask =
  162|   157k|        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|   157k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (165:9): [True: 150k, False: 6.77k]
  ------------------
  166|       |      // case: we extend all sixteen 16-bit code units to sixteen 32-bit code
  167|       |      // units
  168|   150k|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
  169|   150k|                          _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in)));
  170|   150k|      _mm256_storeu_si256(
  171|   150k|          reinterpret_cast<__m256i *>(utf32_output + 8),
  172|   150k|          _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1)));
  173|   150k|      utf32_output += 16;
  174|   150k|      buf += 16;
  175|       |      // surrogate pair(s) in a register
  176|   150k|    } 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|  6.77k|      size_t forward = 15;
  181|  6.77k|      size_t k = 0;
  182|  6.77k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (182:11): [True: 0, False: 6.77k]
  ------------------
  183|      0|        forward = size_t(end - buf - 1);
  184|      0|      }
  185|  96.5k|      for (; k < forward; k++) {
  ------------------
  |  Branch (185:14): [True: 89.9k, False: 6.64k]
  ------------------
  186|  89.9k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  187|  89.9k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (187:13): [True: 78.5k, False: 11.4k]
  ------------------
  188|       |          // No surrogate pair
  189|  78.5k|          *utf32_output++ = char32_t(word);
  190|  78.5k|        } else {
  191|       |          // must be a surrogate pair
  192|  11.4k|          uint16_t diff = uint16_t(word - 0xD800);
  193|  11.4k|          uint16_t next_word =
  194|  11.4k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  195|  11.4k|          k++;
  196|  11.4k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  197|  11.4k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (197:15): [True: 124, False: 11.2k]
  ------------------
  198|    124|            return std::make_pair(
  199|    124|                result(error_code::SURROGATE, buf - start + k - 1),
  200|    124|                utf32_output);
  201|    124|          }
  202|  11.2k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  203|  11.2k|          *utf32_output++ = char32_t(value);
  204|  11.2k|        }
  205|  89.9k|      }
  206|  6.64k|      buf += k;
  207|  6.64k|    }
  208|   157k|  } // while
  209|    290|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output);
  210|    414|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_139avx2_convert_utf16_to_utf32_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPDiEEPKDsmS7_:
  138|    300|                                        char32_t *utf32_output) {
  139|    300|  const char16_t *start = buf;
  140|    300|  const char16_t *end = buf + len;
  141|    300|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
  142|    300|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
  143|       |
  144|   213k|  while (end - buf >= 16) {
  ------------------
  |  Branch (144:10): [True: 213k, False: 246]
  ------------------
  145|   213k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
  146|   213k|    if (big_endian) {
  ------------------
  |  Branch (146:9): [True: 213k, Folded]
  ------------------
  147|   213k|      const __m256i swap = _mm256_setr_epi8(
  148|   213k|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
  149|   213k|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
  150|   213k|      in = _mm256_shuffle_epi8(in, swap);
  151|   213k|    }
  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|   213k|    const __m256i surrogates_bytemask =
  157|   213k|        _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|   213k|    const uint32_t surrogates_bitmask =
  162|   213k|        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|   213k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (165:9): [True: 209k, False: 3.95k]
  ------------------
  166|       |      // case: we extend all sixteen 16-bit code units to sixteen 32-bit code
  167|       |      // units
  168|   209k|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
  169|   209k|                          _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in)));
  170|   209k|      _mm256_storeu_si256(
  171|   209k|          reinterpret_cast<__m256i *>(utf32_output + 8),
  172|   209k|          _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1)));
  173|   209k|      utf32_output += 16;
  174|   209k|      buf += 16;
  175|       |      // surrogate pair(s) in a register
  176|   209k|    } 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|  3.95k|      size_t forward = 15;
  181|  3.95k|      size_t k = 0;
  182|  3.95k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (182:11): [True: 0, False: 3.95k]
  ------------------
  183|      0|        forward = size_t(end - buf - 1);
  184|      0|      }
  185|  53.6k|      for (; k < forward; k++) {
  ------------------
  |  Branch (185:14): [True: 49.7k, False: 3.89k]
  ------------------
  186|  49.7k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  187|  49.7k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (187:13): [True: 39.8k, False: 9.99k]
  ------------------
  188|       |          // No surrogate pair
  189|  39.8k|          *utf32_output++ = char32_t(word);
  190|  39.8k|        } else {
  191|       |          // must be a surrogate pair
  192|  9.99k|          uint16_t diff = uint16_t(word - 0xD800);
  193|  9.99k|          uint16_t next_word =
  194|  9.99k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  195|  9.99k|          k++;
  196|  9.99k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  197|  9.99k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (197:15): [True: 54, False: 9.93k]
  ------------------
  198|     54|            return std::make_pair(
  199|     54|                result(error_code::SURROGATE, buf - start + k - 1),
  200|     54|                utf32_output);
  201|     54|          }
  202|  9.93k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  203|  9.93k|          *utf32_output++ = char32_t(value);
  204|  9.93k|        }
  205|  49.7k|      }
  206|  3.89k|      buf += k;
  207|  3.89k|    }
  208|   213k|  } // while
  209|    246|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output);
  210|    300|}

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

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_127avx2_convert_utf32_to_utf16ILNS_10endiannessE0EEENSt3__14pairIPKDiPDsEES7_mS8_:
    4|    722|                            char16_t *utf16_output) {
    5|    722|  const char32_t *end = buf + len;
    6|       |
    7|    722|  const size_t safety_margin =
    8|    722|      12; // to avoid overruns, see issue
    9|       |          // https://github.com/simdutf/simdutf/issues/92
   10|    722|  __m256i forbidden_bytemask = _mm256_setzero_si256();
   11|       |
   12|    722|  const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000);
   13|    722|  const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800);
   14|    722|  const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800);
   15|       |
   16|  10.9k|  while (end - buf >= std::ptrdiff_t(8 + safety_margin)) {
  ------------------
  |  Branch (16:10): [True: 10.3k, False: 650]
  ------------------
   17|  10.3k|    const __m256i in = _mm256_loadu_si256((__m256i *)buf);
   18|       |
   19|  10.3k|    if (simdutf_likely(_mm256_testz_si256(in, v_ffff0000))) {
  ------------------
  |  |   90|  10.3k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 7.99k, False: 2.31k]
  |  |  ------------------
  ------------------
   20|       |      // no bits set above 16th bit <=> can pack to UTF16
   21|       |      // without surrogate pairs
   22|  7.99k|      forbidden_bytemask = _mm256_or_si256(
   23|  7.99k|          forbidden_bytemask,
   24|  7.99k|          _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800));
   25|       |
   26|  7.99k|      __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),
   27|  7.99k|                                              _mm256_extractf128_si256(in, 1));
   28|  7.99k|      if (big_endian) {
  ------------------
  |  Branch (28:11): [Folded, False: 7.99k]
  ------------------
   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|  7.99k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
   34|  7.99k|      utf16_output += 8;
   35|  7.99k|      buf += 8;
   36|  7.99k|    } else {
   37|  2.31k|      size_t forward = 7;
   38|  2.31k|      size_t k = 0;
   39|  2.31k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (39:11): [True: 0, False: 2.31k]
  ------------------
   40|      0|        forward = size_t(end - buf - 1);
   41|      0|      }
   42|  18.2k|      for (; k < forward; k++) {
  ------------------
  |  Branch (42:14): [True: 15.9k, False: 2.24k]
  ------------------
   43|  15.9k|        uint32_t word = buf[k];
   44|  15.9k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (44:13): [True: 7.23k, False: 8.73k]
  ------------------
   45|       |          // will not generate a surrogate pair
   46|  7.23k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (46:15): [True: 844, False: 6.38k]
  |  Branch (46:33): [True: 2, False: 842]
  ------------------
   47|      2|            return std::make_pair(nullptr, utf16_output);
   48|      2|          }
   49|  7.22k|          *utf16_output++ =
   50|  7.22k|              big_endian
  ------------------
  |  Branch (50:15): [Folded, False: 7.22k]
  ------------------
   51|  7.22k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
   52|  7.22k|                  : char16_t(word);
   53|  8.73k|        } else {
   54|       |          // will generate a surrogate pair
   55|  8.73k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (55:15): [True: 70, False: 8.66k]
  ------------------
   56|     70|            return std::make_pair(nullptr, utf16_output);
   57|     70|          }
   58|  8.66k|          word -= 0x10000;
   59|  8.66k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   60|  8.66k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   61|  8.66k|          if (big_endian) {
  ------------------
  |  Branch (61:15): [Folded, False: 8.66k]
  ------------------
   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|  8.66k|          *utf16_output++ = char16_t(high_surrogate);
   68|  8.66k|          *utf16_output++ = char16_t(low_surrogate);
   69|  8.66k|        }
   70|  15.9k|      }
   71|  2.24k|      buf += k;
   72|  2.24k|    }
   73|  10.3k|  }
   74|       |
   75|       |  // check for invalid input
   76|    650|  if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (76:7): [True: 44, False: 606]
  ------------------
   77|     44|    return std::make_pair(nullptr, utf16_output);
   78|     44|  }
   79|       |
   80|    606|  return std::make_pair(buf, utf16_output);
   81|    650|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_127avx2_convert_utf32_to_utf16ILNS_10endiannessE1EEENSt3__14pairIPKDiPDsEES7_mS8_:
    4|    528|                            char16_t *utf16_output) {
    5|    528|  const char32_t *end = buf + len;
    6|       |
    7|    528|  const size_t safety_margin =
    8|    528|      12; // to avoid overruns, see issue
    9|       |          // https://github.com/simdutf/simdutf/issues/92
   10|    528|  __m256i forbidden_bytemask = _mm256_setzero_si256();
   11|       |
   12|    528|  const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000);
   13|    528|  const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800);
   14|    528|  const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800);
   15|       |
   16|  7.73k|  while (end - buf >= std::ptrdiff_t(8 + safety_margin)) {
  ------------------
  |  Branch (16:10): [True: 7.33k, False: 400]
  ------------------
   17|  7.33k|    const __m256i in = _mm256_loadu_si256((__m256i *)buf);
   18|       |
   19|  7.33k|    if (simdutf_likely(_mm256_testz_si256(in, v_ffff0000))) {
  ------------------
  |  |   90|  7.33k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 6.50k, False: 828]
  |  |  ------------------
  ------------------
   20|       |      // no bits set above 16th bit <=> can pack to UTF16
   21|       |      // without surrogate pairs
   22|  6.50k|      forbidden_bytemask = _mm256_or_si256(
   23|  6.50k|          forbidden_bytemask,
   24|  6.50k|          _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800));
   25|       |
   26|  6.50k|      __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),
   27|  6.50k|                                              _mm256_extractf128_si256(in, 1));
   28|  6.50k|      if (big_endian) {
  ------------------
  |  Branch (28:11): [True: 6.50k, Folded]
  ------------------
   29|  6.50k|        const __m128i swap =
   30|  6.50k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   31|  6.50k|        utf16_packed = _mm_shuffle_epi8(utf16_packed, swap);
   32|  6.50k|      }
   33|  6.50k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
   34|  6.50k|      utf16_output += 8;
   35|  6.50k|      buf += 8;
   36|  6.50k|    } else {
   37|    828|      size_t forward = 7;
   38|    828|      size_t k = 0;
   39|    828|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (39:11): [True: 0, False: 828]
  ------------------
   40|      0|        forward = size_t(end - buf - 1);
   41|      0|      }
   42|  6.00k|      for (; k < forward; k++) {
  ------------------
  |  Branch (42:14): [True: 5.30k, False: 700]
  ------------------
   43|  5.30k|        uint32_t word = buf[k];
   44|  5.30k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (44:13): [True: 1.33k, False: 3.96k]
  ------------------
   45|       |          // will not generate a surrogate pair
   46|  1.33k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (46:15): [True: 262, False: 1.07k]
  |  Branch (46:33): [True: 20, False: 242]
  ------------------
   47|     20|            return std::make_pair(nullptr, utf16_output);
   48|     20|          }
   49|  1.31k|          *utf16_output++ =
   50|  1.31k|              big_endian
  ------------------
  |  Branch (50:15): [True: 1.31k, Folded]
  ------------------
   51|  1.31k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
   52|  1.31k|                  : char16_t(word);
   53|  3.96k|        } else {
   54|       |          // will generate a surrogate pair
   55|  3.96k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (55:15): [True: 108, False: 3.85k]
  ------------------
   56|    108|            return std::make_pair(nullptr, utf16_output);
   57|    108|          }
   58|  3.85k|          word -= 0x10000;
   59|  3.85k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   60|  3.85k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   61|  3.85k|          if (big_endian) {
  ------------------
  |  Branch (61:15): [True: 3.85k, Folded]
  ------------------
   62|  3.85k|            high_surrogate =
   63|  3.85k|                uint16_t((high_surrogate >> 8) | (high_surrogate << 8));
   64|  3.85k|            low_surrogate =
   65|  3.85k|                uint16_t((low_surrogate >> 8) | (low_surrogate << 8));
   66|  3.85k|          }
   67|  3.85k|          *utf16_output++ = char16_t(high_surrogate);
   68|  3.85k|          *utf16_output++ = char16_t(low_surrogate);
   69|  3.85k|        }
   70|  5.30k|      }
   71|    700|      buf += k;
   72|    700|    }
   73|  7.33k|  }
   74|       |
   75|       |  // check for invalid input
   76|    400|  if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (76:7): [True: 36, False: 364]
  ------------------
   77|     36|    return std::make_pair(nullptr, utf16_output);
   78|     36|  }
   79|       |
   80|    364|  return std::make_pair(buf, utf16_output);
   81|    400|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_139avx2_convert_utf32_to_utf16_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPDsEEPKDimS7_:
   86|    716|                                        char16_t *utf16_output) {
   87|    716|  const char32_t *start = buf;
   88|    716|  const char32_t *end = buf + len;
   89|       |
   90|    716|  const size_t safety_margin =
   91|    716|      12; // to avoid overruns, see issue
   92|       |          // https://github.com/simdutf/simdutf/issues/92
   93|       |
   94|    716|  const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000);
   95|    716|  const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800);
   96|    716|  const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800);
   97|       |
   98|  88.6k|  while (end - buf >= std::ptrdiff_t(8 + safety_margin)) {
  ------------------
  |  Branch (98:10): [True: 88.1k, False: 498]
  ------------------
   99|  88.1k|    const __m256i in = _mm256_loadu_si256((__m256i *)buf);
  100|       |
  101|  88.1k|    if (simdutf_likely(_mm256_testz_si256(in, v_ffff0000))) {
  ------------------
  |  |   90|  88.1k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 85.3k, False: 2.81k]
  |  |  ------------------
  ------------------
  102|       |      // no bits set above 16th bit <=> can pack to UTF16 without surrogate
  103|       |      // pairs
  104|  85.3k|      const __m256i forbidden_bytemask =
  105|  85.3k|          _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800);
  106|  85.3k|      if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) !=
  ------------------
  |  Branch (106:11): [True: 32, False: 85.3k]
  ------------------
  107|  85.3k|          0x0) {
  108|     32|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  109|     32|                              utf16_output);
  110|     32|      }
  111|       |
  112|  85.3k|      __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),
  113|  85.3k|                                              _mm256_extractf128_si256(in, 1));
  114|  85.3k|      if (big_endian) {
  ------------------
  |  Branch (114:11): [Folded, False: 85.3k]
  ------------------
  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|  85.3k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
  120|  85.3k|      utf16_output += 8;
  121|  85.3k|      buf += 8;
  122|  85.3k|    } else {
  123|  2.81k|      size_t forward = 7;
  124|  2.81k|      size_t k = 0;
  125|  2.81k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (125:11): [True: 0, False: 2.81k]
  ------------------
  126|      0|        forward = size_t(end - buf - 1);
  127|      0|      }
  128|  21.6k|      for (; k < forward; k++) {
  ------------------
  |  Branch (128:14): [True: 19.0k, False: 2.62k]
  ------------------
  129|  19.0k|        uint32_t word = buf[k];
  130|  19.0k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (130:13): [True: 9.45k, False: 9.55k]
  ------------------
  131|       |          // will not generate a surrogate pair
  132|  9.45k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (132:15): [True: 820, False: 8.63k]
  |  Branch (132:33): [True: 16, False: 804]
  ------------------
  133|     16|            return std::make_pair(
  134|     16|                result(error_code::SURROGATE, buf - start + k), utf16_output);
  135|     16|          }
  136|  9.43k|          *utf16_output++ =
  137|  9.43k|              big_endian
  ------------------
  |  Branch (137:15): [Folded, False: 9.43k]
  ------------------
  138|  9.43k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
  139|  9.43k|                  : char16_t(word);
  140|  9.55k|        } else {
  141|       |          // will generate a surrogate pair
  142|  9.55k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (142:15): [True: 170, False: 9.38k]
  ------------------
  143|    170|            return std::make_pair(
  144|    170|                result(error_code::TOO_LARGE, buf - start + k), utf16_output);
  145|    170|          }
  146|  9.38k|          word -= 0x10000;
  147|  9.38k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
  148|  9.38k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
  149|  9.38k|          if (big_endian) {
  ------------------
  |  Branch (149:15): [Folded, False: 9.38k]
  ------------------
  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|  9.38k|          *utf16_output++ = char16_t(high_surrogate);
  156|  9.38k|          *utf16_output++ = char16_t(low_surrogate);
  157|  9.38k|        }
  158|  19.0k|      }
  159|  2.62k|      buf += k;
  160|  2.62k|    }
  161|  88.1k|  }
  162|       |
  163|    498|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output);
  164|    716|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_139avx2_convert_utf32_to_utf16_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPDsEEPKDimS7_:
   86|    606|                                        char16_t *utf16_output) {
   87|    606|  const char32_t *start = buf;
   88|    606|  const char32_t *end = buf + len;
   89|       |
   90|    606|  const size_t safety_margin =
   91|    606|      12; // to avoid overruns, see issue
   92|       |          // https://github.com/simdutf/simdutf/issues/92
   93|       |
   94|    606|  const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000);
   95|    606|  const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800);
   96|    606|  const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800);
   97|       |
   98|  12.9k|  while (end - buf >= std::ptrdiff_t(8 + safety_margin)) {
  ------------------
  |  Branch (98:10): [True: 12.4k, False: 458]
  ------------------
   99|  12.4k|    const __m256i in = _mm256_loadu_si256((__m256i *)buf);
  100|       |
  101|  12.4k|    if (simdutf_likely(_mm256_testz_si256(in, v_ffff0000))) {
  ------------------
  |  |   90|  12.4k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 11.4k, False: 1.04k]
  |  |  ------------------
  ------------------
  102|       |      // no bits set above 16th bit <=> can pack to UTF16 without surrogate
  103|       |      // pairs
  104|  11.4k|      const __m256i forbidden_bytemask =
  105|  11.4k|          _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800);
  106|  11.4k|      if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) !=
  ------------------
  |  Branch (106:11): [True: 8, False: 11.4k]
  ------------------
  107|  11.4k|          0x0) {
  108|      8|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  109|      8|                              utf16_output);
  110|      8|      }
  111|       |
  112|  11.4k|      __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),
  113|  11.4k|                                              _mm256_extractf128_si256(in, 1));
  114|  11.4k|      if (big_endian) {
  ------------------
  |  Branch (114:11): [True: 11.4k, Folded]
  ------------------
  115|  11.4k|        const __m128i swap =
  116|  11.4k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  117|  11.4k|        utf16_packed = _mm_shuffle_epi8(utf16_packed, swap);
  118|  11.4k|      }
  119|  11.4k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
  120|  11.4k|      utf16_output += 8;
  121|  11.4k|      buf += 8;
  122|  11.4k|    } else {
  123|  1.04k|      size_t forward = 7;
  124|  1.04k|      size_t k = 0;
  125|  1.04k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (125:11): [True: 0, False: 1.04k]
  ------------------
  126|      0|        forward = size_t(end - buf - 1);
  127|      0|      }
  128|  7.66k|      for (; k < forward; k++) {
  ------------------
  |  Branch (128:14): [True: 6.76k, False: 900]
  ------------------
  129|  6.76k|        uint32_t word = buf[k];
  130|  6.76k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (130:13): [True: 3.82k, False: 2.94k]
  ------------------
  131|       |          // will not generate a surrogate pair
  132|  3.82k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (132:15): [True: 786, False: 3.03k]
  |  Branch (132:33): [True: 6, False: 780]
  ------------------
  133|      6|            return std::make_pair(
  134|      6|                result(error_code::SURROGATE, buf - start + k), utf16_output);
  135|      6|          }
  136|  3.81k|          *utf16_output++ =
  137|  3.81k|              big_endian
  ------------------
  |  Branch (137:15): [True: 3.81k, Folded]
  ------------------
  138|  3.81k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
  139|  3.81k|                  : char16_t(word);
  140|  3.81k|        } else {
  141|       |          // will generate a surrogate pair
  142|  2.94k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (142:15): [True: 134, False: 2.80k]
  ------------------
  143|    134|            return std::make_pair(
  144|    134|                result(error_code::TOO_LARGE, buf - start + k), utf16_output);
  145|    134|          }
  146|  2.80k|          word -= 0x10000;
  147|  2.80k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
  148|  2.80k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
  149|  2.80k|          if (big_endian) {
  ------------------
  |  Branch (149:15): [True: 2.80k, Folded]
  ------------------
  150|  2.80k|            high_surrogate =
  151|  2.80k|                uint16_t((high_surrogate >> 8) | (high_surrogate << 8));
  152|  2.80k|            low_surrogate =
  153|  2.80k|                uint16_t((low_surrogate >> 8) | (low_surrogate << 8));
  154|  2.80k|          }
  155|  2.80k|          *utf16_output++ = char16_t(high_surrogate);
  156|  2.80k|          *utf16_output++ = char16_t(low_surrogate);
  157|  2.80k|        }
  158|  6.76k|      }
  159|    900|      buf += k;
  160|    900|    }
  161|  12.4k|  }
  162|       |
  163|    458|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output);
  164|    606|}

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_129convert_masked_utf8_to_latin1EPKcmRPc:
    9|   543k|                                     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|   543k|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   21|       |
   22|   543k|  const uint16_t input_utf8_end_of_code_point_mask =
   23|   543k|      utf8_end_of_code_point_mask &
   24|   543k|      0xfff; // we are only processing 12 bytes in case it is not all ASCII
   25|       |
   26|   543k|  if (utf8_end_of_code_point_mask == 0xfff) {
  ------------------
  |  Branch (26:7): [True: 3.58k, False: 539k]
  ------------------
   27|       |    // We process the data in chunks of 12 bytes.
   28|  3.58k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(latin1_output), in);
   29|  3.58k|    latin1_output += 12; // We wrote 12 characters.
   30|  3.58k|    return 12;           // We consumed 1 bytes.
   31|  3.58k|  }
   32|       |  /// We do not have a fast path available, so we fallback.
   33|   539k|  const uint8_t idx =
   34|   539k|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0];
   35|   539k|  const uint8_t consumed =
   36|   539k|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1];
   37|       |  // this indicates an invalid input:
   38|   539k|  if (idx >= 64) {
  ------------------
  |  Branch (38:7): [True: 12.2k, False: 527k]
  ------------------
   39|  12.2k|    return consumed;
   40|  12.2k|  }
   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|   527k|  const __m128i sh =
   48|   527k|      _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
   49|   527k|  const __m128i perm = _mm_shuffle_epi8(in, sh);
   50|   527k|  const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   51|   527k|  const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   52|   527k|  __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   53|   527k|  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|   527k|  _mm_storel_epi64((__m128i *)latin1_output, latin1_packed);
   58|   527k|  latin1_output += 6; // We wrote 6 bytes.
   59|   527k|  return consumed;
   60|   539k|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_128convert_masked_utf8_to_utf16ILNS_10endiannessE0EEEmPKcmRPDs:
   10|  2.87M|                                    char16_t *&utf16_output) {
   11|       |  // we use an approach where we try to process up to 12 input bytes.
   12|       |  // Why 12 input bytes and not 16? Because we are concerned with the size of
   13|       |  // the lookup tables. Also 12 is nicely divisible by two and three.
   14|       |  //
   15|       |  //
   16|       |  // Optimization note: our main path below is load-latency dependent. Thus it
   17|       |  // is maybe beneficial to have fast paths that depend on branch prediction but
   18|       |  // have less latency. This results in more instructions but, potentially, also
   19|       |  // higher speeds.
   20|       |  //
   21|       |  // We first try a few fast paths.
   22|  2.87M|  const __m128i swap =
   23|  2.87M|      _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   24|  2.87M|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   25|  2.87M|  const uint16_t input_utf8_end_of_code_point_mask =
   26|  2.87M|      utf8_end_of_code_point_mask & 0xfff;
   27|  2.87M|  if (utf8_end_of_code_point_mask == 0xfff) {
  ------------------
  |  Branch (27:7): [True: 9.93k, False: 2.86M]
  ------------------
   28|       |    // We process the data in chunks of 12 bytes.
   29|  9.93k|    __m256i ascii = _mm256_cvtepu8_epi16(in);
   30|  9.93k|    if (big_endian) {
  ------------------
  |  Branch (30:9): [Folded, False: 9.93k]
  ------------------
   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|  9.93k|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf16_output), ascii);
   37|  9.93k|    utf16_output += 12; // We wrote 12 16-bit characters.
   38|  9.93k|    return 12;          // We consumed 12 bytes.
   39|  9.93k|  }
   40|  2.86M|  if (((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa)) {
  ------------------
  |  Branch (40:7): [True: 11.2k, False: 2.84M]
  ------------------
   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|  11.2k|    const __m128i sh =
   45|  11.2k|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   46|  11.2k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   47|  11.2k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   48|  11.2k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   49|  11.2k|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   50|  11.2k|    if (big_endian)
  ------------------
  |  Branch (50:9): [Folded, False: 11.2k]
  ------------------
   51|      0|      composed = _mm_shuffle_epi8(composed, swap);
   52|  11.2k|    _mm_storeu_si128((__m128i *)utf16_output, composed);
   53|  11.2k|    utf16_output += 8; // We wrote 16 bytes, 8 code points.
   54|  11.2k|    return 16;
   55|  11.2k|  }
   56|  2.84M|  if (input_utf8_end_of_code_point_mask == 0x924) {
  ------------------
  |  Branch (56:7): [True: 2.85k, False: 2.84M]
  ------------------
   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.85k|    const __m128i sh =
   61|  2.85k|        _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1);
   62|  2.85k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   63|  2.85k|    const __m128i ascii =
   64|  2.85k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   65|  2.85k|    const __m128i middlebyte =
   66|  2.85k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
   67|  2.85k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
   68|  2.85k|    const __m128i highbyte =
   69|  2.85k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
   70|  2.85k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
   71|  2.85k|    const __m128i composed =
   72|  2.85k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
   73|  2.85k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
   74|  2.85k|    if (big_endian)
  ------------------
  |  Branch (74:9): [Folded, False: 2.85k]
  ------------------
   75|      0|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
   76|  2.85k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
   77|  2.85k|    utf16_output += 4;
   78|  2.85k|    return 12;
   79|  2.85k|  }
   80|       |
   81|  2.84M|  const uint8_t idx = simdutf::tables::utf8_to_utf16::utf8bigindex
   82|  2.84M|      [input_utf8_end_of_code_point_mask][0];
   83|  2.84M|  const uint8_t consumed = simdutf::tables::utf8_to_utf16::utf8bigindex
   84|  2.84M|      [input_utf8_end_of_code_point_mask][1];
   85|  2.84M|  if (idx < 64) {
  ------------------
  |  Branch (85:7): [True: 2.40M, False: 439k]
  ------------------
   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.40M|    const __m128i sh = _mm_loadu_si128(
   93|  2.40M|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
   94|  2.40M|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   95|  2.40M|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   96|  2.40M|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   97|  2.40M|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   98|  2.40M|    if (big_endian)
  ------------------
  |  Branch (98:9): [Folded, False: 2.40M]
  ------------------
   99|      0|      composed = _mm_shuffle_epi8(composed, swap);
  100|  2.40M|    _mm_storeu_si128((__m128i *)utf16_output, composed);
  101|  2.40M|    utf16_output += 6; // We wrote 12 bytes, 6 code points. There is a potential
  102|       |                       // overflow of 4 bytes.
  103|  2.40M|  } else if (idx < 145) {
  ------------------
  |  Branch (103:14): [True: 390k, False: 48.5k]
  ------------------
  104|       |    // FOUR (4) input code-code units
  105|   390k|    const __m128i sh = _mm_loadu_si128(
  106|   390k|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
  107|   390k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  108|   390k|    const __m128i ascii =
  109|   390k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
  110|   390k|    const __m128i middlebyte =
  111|   390k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
  112|   390k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  113|   390k|    const __m128i highbyte =
  114|   390k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
  115|   390k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
  116|   390k|    const __m128i composed =
  117|   390k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
  118|   390k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
  119|   390k|    if (big_endian)
  ------------------
  |  Branch (119:9): [Folded, False: 390k]
  ------------------
  120|      0|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
  121|   390k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
  122|   390k|    utf16_output += 4; // Here we overflow by 8 bytes.
  123|   390k|  } else if (idx < 209) {
  ------------------
  |  Branch (123:14): [True: 47.7k, False: 756]
  ------------------
  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|  47.7k|    const __m128i sh = _mm_loadu_si128(
  135|  47.7k|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
  136|  47.7k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  137|  47.7k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f));
  138|  47.7k|    const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00));
  139|  47.7k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  140|  47.7k|    __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000));
  141|       |    // correct for spurious high bit
  142|  47.7k|    const __m128i correct =
  143|  47.7k|        _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1);
  144|  47.7k|    middlehighbyte = _mm_xor_si128(correct, middlehighbyte);
  145|  47.7k|    const __m128i middlehighbyte_shifted = _mm_srli_epi32(middlehighbyte, 4);
  146|       |    // We deliberately carry the leading four bits in highbyte if they are
  147|       |    // present, we remove them later when computing hightenbits.
  148|  47.7k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0xff000000));
  149|  47.7k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 6);
  150|       |    // When we need to generate a surrogate pair (leading byte > 0xF0), then
  151|       |    // the corresponding 32-bit value in 'composed'  will be greater than
  152|       |    // > (0xff00000>>6) or > 0x3c00000. This can be used later to identify the
  153|       |    // location of the surrogate pairs.
  154|  47.7k|    const __m128i composed =
  155|  47.7k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted),
  156|  47.7k|                     _mm_or_si128(highbyte_shifted, middlehighbyte_shifted));
  157|  47.7k|    const __m128i composedminus =
  158|  47.7k|        _mm_sub_epi32(composed, _mm_set1_epi32(0x10000));
  159|  47.7k|    const __m128i lowtenbits =
  160|  47.7k|        _mm_and_si128(composedminus, _mm_set1_epi32(0x3ff));
  161|       |    // Notice the 0x3ff mask:
  162|  47.7k|    const __m128i hightenbits =
  163|  47.7k|        _mm_and_si128(_mm_srli_epi32(composedminus, 10), _mm_set1_epi32(0x3ff));
  164|  47.7k|    const __m128i lowtenbitsadd =
  165|  47.7k|        _mm_add_epi32(lowtenbits, _mm_set1_epi32(0xDC00));
  166|  47.7k|    const __m128i hightenbitsadd =
  167|  47.7k|        _mm_add_epi32(hightenbits, _mm_set1_epi32(0xD800));
  168|  47.7k|    const __m128i lowtenbitsaddshifted = _mm_slli_epi32(lowtenbitsadd, 16);
  169|  47.7k|    __m128i surrogates = _mm_or_si128(hightenbitsadd, lowtenbitsaddshifted);
  170|  47.7k|    uint32_t basic_buffer[4];
  171|  47.7k|    uint32_t basic_buffer_swap[4];
  172|  47.7k|    if (big_endian) {
  ------------------
  |  Branch (172:9): [Folded, False: 47.7k]
  ------------------
  173|      0|      _mm_storeu_si128((__m128i *)basic_buffer_swap,
  174|      0|                       _mm_shuffle_epi8(composed, swap));
  175|      0|      surrogates = _mm_shuffle_epi8(surrogates, swap);
  176|      0|    }
  177|  47.7k|    _mm_storeu_si128((__m128i *)basic_buffer, composed);
  178|  47.7k|    uint32_t surrogate_buffer[4];
  179|  47.7k|    _mm_storeu_si128((__m128i *)surrogate_buffer, surrogates);
  180|   191k|    for (size_t i = 0; i < 3; i++) {
  ------------------
  |  Branch (180:24): [True: 143k, False: 47.7k]
  ------------------
  181|   143k|      if (basic_buffer[i] > 0x3c00000) {
  ------------------
  |  Branch (181:11): [True: 40.1k, False: 103k]
  ------------------
  182|  40.1k|        utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff);
  183|  40.1k|        utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16);
  184|  40.1k|        utf16_output += 2;
  185|   103k|      } else {
  186|   103k|        utf16_output[0] = big_endian ? uint16_t(basic_buffer_swap[i])
  ------------------
  |  Branch (186:27): [Folded, False: 103k]
  ------------------
  187|   103k|                                     : uint16_t(basic_buffer[i]);
  188|   103k|        utf16_output++;
  189|   103k|      }
  190|   143k|    }
  191|  47.7k|  } else {
  192|       |    // here we know that there is an error but we do not handle errors
  193|    756|  }
  194|  2.84M|  return consumed;
  195|  2.84M|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_128convert_masked_utf8_to_utf16ILNS_10endiannessE1EEEmPKcmRPDs:
   10|  3.09M|                                    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.09M|  const __m128i swap =
   23|  3.09M|      _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   24|  3.09M|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   25|  3.09M|  const uint16_t input_utf8_end_of_code_point_mask =
   26|  3.09M|      utf8_end_of_code_point_mask & 0xfff;
   27|  3.09M|  if (utf8_end_of_code_point_mask == 0xfff) {
  ------------------
  |  Branch (27:7): [True: 8.76k, False: 3.09M]
  ------------------
   28|       |    // We process the data in chunks of 12 bytes.
   29|  8.76k|    __m256i ascii = _mm256_cvtepu8_epi16(in);
   30|  8.76k|    if (big_endian) {
  ------------------
  |  Branch (30:9): [True: 8.76k, Folded]
  ------------------
   31|  8.76k|      const __m256i swap256 = _mm256_setr_epi8(
   32|  8.76k|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   33|  8.76k|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   34|  8.76k|      ascii = _mm256_shuffle_epi8(ascii, swap256);
   35|  8.76k|    }
   36|  8.76k|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf16_output), ascii);
   37|  8.76k|    utf16_output += 12; // We wrote 12 16-bit characters.
   38|  8.76k|    return 12;          // We consumed 12 bytes.
   39|  8.76k|  }
   40|  3.09M|  if (((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa)) {
  ------------------
  |  Branch (40:7): [True: 20.4k, False: 3.07M]
  ------------------
   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|  20.4k|    const __m128i sh =
   45|  20.4k|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   46|  20.4k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   47|  20.4k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   48|  20.4k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   49|  20.4k|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   50|  20.4k|    if (big_endian)
  ------------------
  |  Branch (50:9): [True: 20.4k, Folded]
  ------------------
   51|  20.4k|      composed = _mm_shuffle_epi8(composed, swap);
   52|  20.4k|    _mm_storeu_si128((__m128i *)utf16_output, composed);
   53|  20.4k|    utf16_output += 8; // We wrote 16 bytes, 8 code points.
   54|  20.4k|    return 16;
   55|  20.4k|  }
   56|  3.07M|  if (input_utf8_end_of_code_point_mask == 0x924) {
  ------------------
  |  Branch (56:7): [True: 4.37k, False: 3.06M]
  ------------------
   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|  4.37k|    const __m128i sh =
   61|  4.37k|        _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1);
   62|  4.37k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   63|  4.37k|    const __m128i ascii =
   64|  4.37k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   65|  4.37k|    const __m128i middlebyte =
   66|  4.37k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
   67|  4.37k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
   68|  4.37k|    const __m128i highbyte =
   69|  4.37k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
   70|  4.37k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
   71|  4.37k|    const __m128i composed =
   72|  4.37k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
   73|  4.37k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
   74|  4.37k|    if (big_endian)
  ------------------
  |  Branch (74:9): [True: 4.37k, Folded]
  ------------------
   75|  4.37k|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
   76|  4.37k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
   77|  4.37k|    utf16_output += 4;
   78|  4.37k|    return 12;
   79|  4.37k|  }
   80|       |
   81|  3.06M|  const uint8_t idx = simdutf::tables::utf8_to_utf16::utf8bigindex
   82|  3.06M|      [input_utf8_end_of_code_point_mask][0];
   83|  3.06M|  const uint8_t consumed = simdutf::tables::utf8_to_utf16::utf8bigindex
   84|  3.06M|      [input_utf8_end_of_code_point_mask][1];
   85|  3.06M|  if (idx < 64) {
  ------------------
  |  Branch (85:7): [True: 2.75M, False: 306k]
  ------------------
   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.75M|    const __m128i sh = _mm_loadu_si128(
   93|  2.75M|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
   94|  2.75M|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   95|  2.75M|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   96|  2.75M|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   97|  2.75M|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   98|  2.75M|    if (big_endian)
  ------------------
  |  Branch (98:9): [True: 2.75M, Folded]
  ------------------
   99|  2.75M|      composed = _mm_shuffle_epi8(composed, swap);
  100|  2.75M|    _mm_storeu_si128((__m128i *)utf16_output, composed);
  101|  2.75M|    utf16_output += 6; // We wrote 12 bytes, 6 code points. There is a potential
  102|       |                       // overflow of 4 bytes.
  103|  2.75M|  } else if (idx < 145) {
  ------------------
  |  Branch (103:14): [True: 253k, False: 52.3k]
  ------------------
  104|       |    // FOUR (4) input code-code units
  105|   253k|    const __m128i sh = _mm_loadu_si128(
  106|   253k|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
  107|   253k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  108|   253k|    const __m128i ascii =
  109|   253k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
  110|   253k|    const __m128i middlebyte =
  111|   253k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
  112|   253k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  113|   253k|    const __m128i highbyte =
  114|   253k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
  115|   253k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
  116|   253k|    const __m128i composed =
  117|   253k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
  118|   253k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
  119|   253k|    if (big_endian)
  ------------------
  |  Branch (119:9): [True: 253k, Folded]
  ------------------
  120|   253k|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
  121|   253k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
  122|   253k|    utf16_output += 4; // Here we overflow by 8 bytes.
  123|   253k|  } else if (idx < 209) {
  ------------------
  |  Branch (123:14): [True: 51.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|  51.0k|    const __m128i sh = _mm_loadu_si128(
  135|  51.0k|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
  136|  51.0k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  137|  51.0k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f));
  138|  51.0k|    const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00));
  139|  51.0k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  140|  51.0k|    __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000));
  141|       |    // correct for spurious high bit
  142|  51.0k|    const __m128i correct =
  143|  51.0k|        _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1);
  144|  51.0k|    middlehighbyte = _mm_xor_si128(correct, middlehighbyte);
  145|  51.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|  51.0k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0xff000000));
  149|  51.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|  51.0k|    const __m128i composed =
  155|  51.0k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted),
  156|  51.0k|                     _mm_or_si128(highbyte_shifted, middlehighbyte_shifted));
  157|  51.0k|    const __m128i composedminus =
  158|  51.0k|        _mm_sub_epi32(composed, _mm_set1_epi32(0x10000));
  159|  51.0k|    const __m128i lowtenbits =
  160|  51.0k|        _mm_and_si128(composedminus, _mm_set1_epi32(0x3ff));
  161|       |    // Notice the 0x3ff mask:
  162|  51.0k|    const __m128i hightenbits =
  163|  51.0k|        _mm_and_si128(_mm_srli_epi32(composedminus, 10), _mm_set1_epi32(0x3ff));
  164|  51.0k|    const __m128i lowtenbitsadd =
  165|  51.0k|        _mm_add_epi32(lowtenbits, _mm_set1_epi32(0xDC00));
  166|  51.0k|    const __m128i hightenbitsadd =
  167|  51.0k|        _mm_add_epi32(hightenbits, _mm_set1_epi32(0xD800));
  168|  51.0k|    const __m128i lowtenbitsaddshifted = _mm_slli_epi32(lowtenbitsadd, 16);
  169|  51.0k|    __m128i surrogates = _mm_or_si128(hightenbitsadd, lowtenbitsaddshifted);
  170|  51.0k|    uint32_t basic_buffer[4];
  171|  51.0k|    uint32_t basic_buffer_swap[4];
  172|  51.0k|    if (big_endian) {
  ------------------
  |  Branch (172:9): [True: 51.0k, Folded]
  ------------------
  173|  51.0k|      _mm_storeu_si128((__m128i *)basic_buffer_swap,
  174|  51.0k|                       _mm_shuffle_epi8(composed, swap));
  175|  51.0k|      surrogates = _mm_shuffle_epi8(surrogates, swap);
  176|  51.0k|    }
  177|  51.0k|    _mm_storeu_si128((__m128i *)basic_buffer, composed);
  178|  51.0k|    uint32_t surrogate_buffer[4];
  179|  51.0k|    _mm_storeu_si128((__m128i *)surrogate_buffer, surrogates);
  180|   204k|    for (size_t i = 0; i < 3; i++) {
  ------------------
  |  Branch (180:24): [True: 153k, False: 51.0k]
  ------------------
  181|   153k|      if (basic_buffer[i] > 0x3c00000) {
  ------------------
  |  Branch (181:11): [True: 42.9k, False: 110k]
  ------------------
  182|  42.9k|        utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff);
  183|  42.9k|        utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16);
  184|  42.9k|        utf16_output += 2;
  185|   110k|      } else {
  186|   110k|        utf16_output[0] = big_endian ? uint16_t(basic_buffer_swap[i])
  ------------------
  |  Branch (186:27): [True: 110k, Folded]
  ------------------
  187|   110k|                                     : uint16_t(basic_buffer[i]);
  188|   110k|        utf16_output++;
  189|   110k|      }
  190|   153k|    }
  191|  51.0k|  } else {
  192|       |    // here we know that there is an error but we do not handle errors
  193|  1.31k|  }
  194|  3.06M|  return consumed;
  195|  3.07M|}

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

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

_ZNK7simdutf7haswell14implementation13validate_utf8EPKcm:
  266|  3.22k|implementation::validate_utf8(const char *buf, size_t len) const noexcept {
  267|  3.22k|  return haswell::utf8_validation::generic_validate_utf8(buf, len);
  268|  3.22k|}
_ZNK7simdutf7haswell14implementation25validate_utf8_with_errorsEPKcm:
  273|  3.22k|    const char *buf, size_t len) const noexcept {
  274|  3.22k|  return haswell::utf8_validation::generic_validate_utf8_with_errors(buf, len);
  275|  3.22k|}
_ZNK7simdutf7haswell14implementation16validate_utf16leEPKDsm:
  312|  1.30k|                                 size_t len) const noexcept {
  313|  1.30k|  if (simdutf_unlikely(len == 0)) {
  ------------------
  |  |   93|  1.30k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 17, False: 1.29k]
  |  |  ------------------
  ------------------
  314|       |    // empty input is valid UTF-16. protect the implementation from
  315|       |    // handling nullptr
  316|     17|    return true;
  317|     17|  }
  318|  1.29k|  const auto res =
  319|  1.29k|      haswell::utf16::validate_utf16_with_errors<endianness::LITTLE>(buf, len);
  320|  1.29k|  if (res.is_err()) {
  ------------------
  |  Branch (320:7): [True: 79, False: 1.21k]
  ------------------
  321|     79|    return false;
  322|     79|  }
  323|       |
  324|  1.21k|  if (res.count == len) {
  ------------------
  |  Branch (324:7): [True: 0, False: 1.21k]
  ------------------
  325|      0|    return true;
  326|      0|  }
  327|       |
  328|  1.21k|  return scalar::utf16::validate<endianness::LITTLE>(buf + res.count,
  329|  1.21k|                                                     len - res.count);
  330|  1.21k|}
_ZNK7simdutf7haswell14implementation16validate_utf16beEPKDsm:
  336|  1.23k|                                 size_t len) const noexcept {
  337|  1.23k|  if (simdutf_unlikely(len == 0)) {
  ------------------
  |  |   93|  1.23k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 15, False: 1.22k]
  |  |  ------------------
  ------------------
  338|       |    // empty input is valid UTF-16. protect the implementation from
  339|       |    // handling nullptr
  340|     15|    return true;
  341|     15|  }
  342|  1.22k|  const auto res =
  343|  1.22k|      haswell::utf16::validate_utf16_with_errors<endianness::BIG>(buf, len);
  344|  1.22k|  if (res.is_err()) {
  ------------------
  |  Branch (344:7): [True: 98, False: 1.12k]
  ------------------
  345|     98|    return false;
  346|     98|  }
  347|       |
  348|  1.12k|  if (res.count == len) {
  ------------------
  |  Branch (348:7): [True: 0, False: 1.12k]
  ------------------
  349|      0|    return true;
  350|      0|  }
  351|       |
  352|  1.12k|  return scalar::utf16::validate<endianness::BIG>(buf + res.count,
  353|  1.12k|                                                  len - res.count);
  354|  1.12k|}
_ZNK7simdutf7haswell14implementation28validate_utf16le_with_errorsEPKDsm:
  357|  1.30k|    const char16_t *buf, size_t len) const noexcept {
  358|       |
  359|  1.30k|  const result res =
  360|  1.30k|      haswell::utf16::validate_utf16_with_errors<endianness::LITTLE>(buf, len);
  361|  1.30k|  if (res.count != len) {
  ------------------
  |  Branch (361:7): [True: 1.29k, False: 17]
  ------------------
  362|  1.29k|    const result scalar_res =
  363|  1.29k|        scalar::utf16::validate_with_errors<endianness::LITTLE>(
  364|  1.29k|            buf + res.count, len - res.count);
  365|  1.29k|    return result(scalar_res.error, res.count + scalar_res.count);
  366|  1.29k|  } else {
  367|     17|    return res;
  368|     17|  }
  369|  1.30k|}
_ZNK7simdutf7haswell14implementation28validate_utf16be_with_errorsEPKDsm:
  372|  1.23k|    const char16_t *buf, size_t len) const noexcept {
  373|  1.23k|  const result res =
  374|  1.23k|      haswell::utf16::validate_utf16_with_errors<endianness::BIG>(buf, len);
  375|  1.23k|  if (res.count != len) {
  ------------------
  |  Branch (375:7): [True: 1.22k, False: 15]
  ------------------
  376|  1.22k|    const result scalar_res =
  377|  1.22k|        scalar::utf16::validate_with_errors<endianness::BIG>(buf + res.count,
  378|  1.22k|                                                             len - res.count);
  379|  1.22k|    return result(scalar_res.error, res.count + scalar_res.count);
  380|  1.22k|  } else {
  381|     15|    return res;
  382|     15|  }
  383|  1.23k|}
_ZNK7simdutf7haswell14implementation14validate_utf32EPKDim:
  398|  2.41k|implementation::validate_utf32(const char32_t *buf, size_t len) const noexcept {
  399|  2.41k|  return utf32::validate(buf, len);
  400|  2.41k|}
_ZNK7simdutf7haswell14implementation26validate_utf32_with_errorsEPKDim:
  405|  2.41k|    const char32_t *buf, size_t len) const noexcept {
  406|  2.41k|  return utf32::validate_with_errors(buf, len);
  407|  2.41k|}
_ZNK7simdutf7haswell14implementation22convert_latin1_to_utf8EPKcmPc:
  412|    538|    const char *buf, size_t len, char *utf8_output) const noexcept {
  413|    538|  std::pair<const char *, char *> ret =
  414|    538|      avx2_convert_latin1_to_utf8(buf, len, utf8_output);
  415|    538|  size_t converted_chars = ret.second - utf8_output;
  416|       |
  417|    538|  if (ret.first != buf + len) {
  ------------------
  |  Branch (417:7): [True: 534, False: 4]
  ------------------
  418|    534|    const size_t scalar_converted_chars = scalar::latin1_to_utf8::convert(
  419|    534|        ret.first, len - (ret.first - buf), ret.second);
  420|    534|    converted_chars += scalar_converted_chars;
  421|    534|  }
  422|       |
  423|    538|  return converted_chars;
  424|    538|}
_ZNK7simdutf7haswell14implementation25convert_latin1_to_utf16leEPKcmPDs:
  429|     80|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  430|     80|  std::pair<const char *, char16_t *> ret =
  431|     80|      avx2_convert_latin1_to_utf16<endianness::LITTLE>(buf, len, utf16_output);
  432|     80|  if (ret.first == nullptr) {
  ------------------
  |  Branch (432:7): [True: 4, False: 76]
  ------------------
  433|      4|    return 0;
  434|      4|  }
  435|     76|  size_t converted_chars = ret.second - utf16_output;
  436|     76|  if (ret.first != buf + len) {
  ------------------
  |  Branch (436:7): [True: 62, False: 14]
  ------------------
  437|     62|    const size_t scalar_converted_chars =
  438|     62|        scalar::latin1_to_utf16::convert<endianness::LITTLE>(
  439|     62|            ret.first, len - (ret.first - buf), ret.second);
  440|     62|    if (scalar_converted_chars == 0) {
  ------------------
  |  Branch (440:9): [True: 0, False: 62]
  ------------------
  441|      0|      return 0;
  442|      0|    }
  443|     62|    converted_chars += scalar_converted_chars;
  444|     62|  }
  445|     76|  return converted_chars;
  446|     76|}
_ZNK7simdutf7haswell14implementation25convert_latin1_to_utf16beEPKcmPDs:
  449|     80|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  450|     80|  std::pair<const char *, char16_t *> ret =
  451|     80|      avx2_convert_latin1_to_utf16<endianness::BIG>(buf, len, utf16_output);
  452|     80|  if (ret.first == nullptr) {
  ------------------
  |  Branch (452:7): [True: 4, False: 76]
  ------------------
  453|      4|    return 0;
  454|      4|  }
  455|     76|  size_t converted_chars = ret.second - utf16_output;
  456|     76|  if (ret.first != buf + len) {
  ------------------
  |  Branch (456:7): [True: 62, False: 14]
  ------------------
  457|     62|    const size_t scalar_converted_chars =
  458|     62|        scalar::latin1_to_utf16::convert<endianness::BIG>(
  459|     62|            ret.first, len - (ret.first - buf), ret.second);
  460|     62|    if (scalar_converted_chars == 0) {
  ------------------
  |  Branch (460:9): [True: 0, False: 62]
  ------------------
  461|      0|      return 0;
  462|      0|    }
  463|     62|    converted_chars += scalar_converted_chars;
  464|     62|  }
  465|     76|  return converted_chars;
  466|     76|}
_ZNK7simdutf7haswell14implementation23convert_latin1_to_utf32EPKcmPDi:
  471|     90|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  472|     90|  std::pair<const char *, char32_t *> ret =
  473|     90|      avx2_convert_latin1_to_utf32(buf, len, utf32_output);
  474|     90|  if (ret.first == nullptr) {
  ------------------
  |  Branch (474:7): [True: 4, False: 86]
  ------------------
  475|      4|    return 0;
  476|      4|  }
  477|     86|  size_t converted_chars = ret.second - utf32_output;
  478|     86|  if (ret.first != buf + len) {
  ------------------
  |  Branch (478:7): [True: 58, False: 28]
  ------------------
  479|     58|    const size_t scalar_converted_chars = scalar::latin1_to_utf32::convert(
  480|     58|        ret.first, len - (ret.first - buf), ret.second);
  481|     58|    if (scalar_converted_chars == 0) {
  ------------------
  |  Branch (481:9): [True: 0, False: 58]
  ------------------
  482|      0|      return 0;
  483|      0|    }
  484|     58|    converted_chars += scalar_converted_chars;
  485|     58|  }
  486|     86|  return converted_chars;
  487|     86|}
_ZNK7simdutf7haswell14implementation22convert_utf8_to_latin1EPKcmPc:
  492|    562|    const char *buf, size_t len, char *latin1_output) const noexcept {
  493|    562|  utf8_to_latin1::validating_transcoder converter;
  494|    562|  return converter.convert(buf, len, latin1_output);
  495|    562|}
_ZNK7simdutf7haswell14implementation34convert_utf8_to_latin1_with_errorsEPKcmPc:
  498|    516|    const char *buf, size_t len, char *latin1_output) const noexcept {
  499|    516|  utf8_to_latin1::validating_transcoder converter;
  500|    516|  return converter.convert_with_errors(buf, len, latin1_output);
  501|    516|}
_ZNK7simdutf7haswell14implementation23convert_utf8_to_utf16leEPKcmPDs:
  511|    660|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  512|    660|  utf8_to_utf16::validating_transcoder converter;
  513|    660|  return converter.convert<endianness::LITTLE>(buf, len, utf16_output);
  514|    660|}
_ZNK7simdutf7haswell14implementation23convert_utf8_to_utf16beEPKcmPDs:
  517|    712|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  518|    712|  utf8_to_utf16::validating_transcoder converter;
  519|    712|  return converter.convert<endianness::BIG>(buf, len, utf16_output);
  520|    712|}
_ZNK7simdutf7haswell14implementation35convert_utf8_to_utf16le_with_errorsEPKcmPDs:
  523|    574|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  524|    574|  utf8_to_utf16::validating_transcoder converter;
  525|    574|  return converter.convert_with_errors<endianness::LITTLE>(buf, len,
  526|    574|                                                           utf16_output);
  527|    574|}
_ZNK7simdutf7haswell14implementation35convert_utf8_to_utf16be_with_errorsEPKcmPDs:
  530|    702|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  531|    702|  utf8_to_utf16::validating_transcoder converter;
  532|    702|  return converter.convert_with_errors<endianness::BIG>(buf, len, utf16_output);
  533|    702|}
_ZNK7simdutf7haswell14implementation29convert_valid_utf8_to_utf16leEPKcmPDs:
  536|    368|    const char *input, size_t size, char16_t *utf16_output) const noexcept {
  537|    368|  return utf8_to_utf16::convert_valid<endianness::LITTLE>(input, size,
  538|    368|                                                          utf16_output);
  539|    368|}
_ZNK7simdutf7haswell14implementation29convert_valid_utf8_to_utf16beEPKcmPDs:
  542|    438|    const char *input, size_t size, char16_t *utf16_output) const noexcept {
  543|    438|  return utf8_to_utf16::convert_valid<endianness::BIG>(input, size,
  544|    438|                                                       utf16_output);
  545|    438|}
_ZNK7simdutf7haswell14implementation21convert_utf8_to_utf32EPKcmPDi:
  550|    712|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  551|    712|  utf8_to_utf32::validating_transcoder converter;
  552|    712|  return converter.convert(buf, len, utf32_output);
  553|    712|}
_ZNK7simdutf7haswell14implementation33convert_utf8_to_utf32_with_errorsEPKcmPDi:
  556|    738|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  557|    738|  utf8_to_utf32::validating_transcoder converter;
  558|    738|  return converter.convert_with_errors(buf, len, utf32_output);
  559|    738|}
_ZNK7simdutf7haswell14implementation27convert_valid_utf8_to_utf32EPKcmPDi:
  562|    394|    const char *input, size_t size, char32_t *utf32_output) const noexcept {
  563|    394|  return utf8_to_utf32::convert_valid(input, size, utf32_output);
  564|    394|}
_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: 34, False: 90]
  ------------------
  574|     34|    return 0;
  575|     34|  }
  576|     90|  size_t saved_bytes = ret.second - latin1_output;
  577|     90|  if (ret.first != buf + len) {
  ------------------
  |  Branch (577:7): [True: 76, False: 14]
  ------------------
  578|     76|    const size_t scalar_saved_bytes =
  579|     76|        scalar::utf16_to_latin1::convert<endianness::LITTLE>(
  580|     76|            ret.first, len - (ret.first - buf), ret.second);
  581|     76|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (581:9): [True: 50, False: 26]
  ------------------
  582|     50|      return 0;
  583|     50|    }
  584|     26|    saved_bytes += scalar_saved_bytes;
  585|     26|  }
  586|     40|  return saved_bytes;
  587|     90|}
_ZNK7simdutf7haswell14implementation25convert_utf16be_to_latin1EPKDsmPc:
  590|    126|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  591|    126|  std::pair<const char16_t *, char *> ret =
  592|    126|      haswell::avx2_convert_utf16_to_latin1<endianness::BIG>(buf, len,
  593|    126|                                                             latin1_output);
  594|    126|  if (ret.first == nullptr) {
  ------------------
  |  Branch (594:7): [True: 26, False: 100]
  ------------------
  595|     26|    return 0;
  596|     26|  }
  597|    100|  size_t saved_bytes = ret.second - latin1_output;
  598|    100|  if (ret.first != buf + len) {
  ------------------
  |  Branch (598:7): [True: 86, False: 14]
  ------------------
  599|     86|    const size_t scalar_saved_bytes =
  600|     86|        scalar::utf16_to_latin1::convert<endianness::BIG>(
  601|     86|            ret.first, len - (ret.first - buf), ret.second);
  602|     86|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (602:9): [True: 36, False: 50]
  ------------------
  603|     36|      return 0;
  604|     36|    }
  605|     50|    saved_bytes += scalar_saved_bytes;
  606|     50|  }
  607|     64|  return saved_bytes;
  608|    100|}
_ZNK7simdutf7haswell14implementation37convert_utf16le_to_latin1_with_errorsEPKDsmPc:
  612|    230|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  613|    230|  std::pair<result, char *> ret =
  614|    230|      avx2_convert_utf16_to_latin1_with_errors<endianness::LITTLE>(
  615|    230|          buf, len, latin1_output);
  616|    230|  if (ret.first.error) {
  ------------------
  |  Branch (616:7): [True: 92, False: 138]
  ------------------
  617|     92|    return ret.first;
  618|     92|  } // Can return directly since scalar fallback already found correct
  619|       |    // ret.first.count
  620|    138|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (620:7): [True: 102, False: 36]
  ------------------
  621|    102|    result scalar_res =
  622|    102|        scalar::utf16_to_latin1::convert_with_errors<endianness::LITTLE>(
  623|    102|            buf + ret.first.count, len - ret.first.count, ret.second);
  624|    102|    if (scalar_res.error) {
  ------------------
  |  Branch (624:9): [True: 56, False: 46]
  ------------------
  625|     56|      scalar_res.count += ret.first.count;
  626|     56|      return scalar_res;
  627|     56|    } else {
  628|     46|      ret.second += scalar_res.count;
  629|     46|    }
  630|    102|  }
  631|     82|  ret.first.count =
  632|     82|      ret.second -
  633|     82|      latin1_output; // Set count to the number of 8-bit code units written
  634|     82|  return ret.first;
  635|    138|}
_ZNK7simdutf7haswell14implementation37convert_utf16be_to_latin1_with_errorsEPKDsmPc:
  639|    252|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  640|    252|  std::pair<result, char *> ret =
  641|    252|      avx2_convert_utf16_to_latin1_with_errors<endianness::BIG>(buf, len,
  642|    252|                                                                latin1_output);
  643|    252|  if (ret.first.error) {
  ------------------
  |  Branch (643:7): [True: 102, False: 150]
  ------------------
  644|    102|    return ret.first;
  645|    102|  } // Can return directly since scalar fallback already found correct
  646|       |    // ret.first.count
  647|    150|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (647:7): [True: 118, False: 32]
  ------------------
  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: 54, False: 64]
  ------------------
  652|     54|      scalar_res.count += ret.first.count;
  653|     54|      return scalar_res;
  654|     64|    } else {
  655|     64|      ret.second += scalar_res.count;
  656|     64|    }
  657|    118|  }
  658|     96|  ret.first.count =
  659|     96|      ret.second -
  660|     96|      latin1_output; // Set count to the number of 8-bit code units written
  661|     96|  return ret.first;
  662|    150|}
_ZNK7simdutf7haswell14implementation23convert_utf16le_to_utf8EPKDsmPc:
  679|    802|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  680|    802|  std::pair<const char16_t *, char *> ret =
  681|    802|      haswell::avx2_convert_utf16_to_utf8<endianness::LITTLE>(buf, len,
  682|    802|                                                              utf8_output);
  683|    802|  if (ret.first == nullptr) {
  ------------------
  |  Branch (683:7): [True: 106, False: 696]
  ------------------
  684|    106|    return 0;
  685|    106|  }
  686|    696|  size_t saved_bytes = ret.second - utf8_output;
  687|    696|  if (ret.first != buf + len) {
  ------------------
  |  Branch (687:7): [True: 694, False: 2]
  ------------------
  688|    694|    const size_t scalar_saved_bytes =
  689|    694|        scalar::utf16_to_utf8::convert<endianness::LITTLE>(
  690|    694|            ret.first, len - (ret.first - buf), ret.second);
  691|    694|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (691:9): [True: 60, False: 634]
  ------------------
  692|     60|      return 0;
  693|     60|    }
  694|    634|    saved_bytes += scalar_saved_bytes;
  695|    634|  }
  696|    636|  return saved_bytes;
  697|    696|}
_ZNK7simdutf7haswell14implementation23convert_utf16be_to_utf8EPKDsmPc:
  700|    768|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  701|    768|  std::pair<const char16_t *, char *> ret =
  702|    768|      haswell::avx2_convert_utf16_to_utf8<endianness::BIG>(buf, len,
  703|    768|                                                           utf8_output);
  704|    768|  if (ret.first == nullptr) {
  ------------------
  |  Branch (704:7): [True: 90, False: 678]
  ------------------
  705|     90|    return 0;
  706|     90|  }
  707|    678|  size_t saved_bytes = ret.second - utf8_output;
  708|    678|  if (ret.first != buf + len) {
  ------------------
  |  Branch (708:7): [True: 676, False: 2]
  ------------------
  709|    676|    const size_t scalar_saved_bytes =
  710|    676|        scalar::utf16_to_utf8::convert<endianness::BIG>(
  711|    676|            ret.first, len - (ret.first - buf), ret.second);
  712|    676|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (712:9): [True: 46, False: 630]
  ------------------
  713|     46|      return 0;
  714|     46|    }
  715|    630|    saved_bytes += scalar_saved_bytes;
  716|    630|  }
  717|    632|  return saved_bytes;
  718|    678|}
_ZNK7simdutf7haswell14implementation35convert_utf16le_to_utf8_with_errorsEPKDsmPc:
  742|    630|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  743|    630|  return convert_utf16_to_utf8_with_details<endianness::LITTLE>(buf, len,
  744|    630|                                                                utf8_output);
  745|    630|}
_ZNK7simdutf7haswell14implementation35convert_utf16be_to_utf8_with_errorsEPKDsmPc:
  748|    586|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  749|    586|  return convert_utf16_to_utf8_with_details<endianness::BIG>(buf, len,
  750|    586|                                                             utf8_output);
  751|    586|}
_ZNK7simdutf7haswell14implementation29convert_valid_utf16le_to_utf8EPKDsmPc:
  754|    416|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  755|    416|  return convert_utf16le_to_utf8(buf, len, utf8_output);
  756|    416|}
_ZNK7simdutf7haswell14implementation29convert_valid_utf16be_to_utf8EPKDsmPc:
  759|    442|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  760|    442|  return convert_utf16be_to_utf8(buf, len, utf8_output);
  761|    442|}
_ZNK7simdutf7haswell14implementation21convert_utf32_to_utf8EPKDimPc:
  766|    796|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  767|    796|  std::pair<const char32_t *, char *> ret =
  768|    796|      avx2_convert_utf32_to_utf8(buf, len, utf8_output);
  769|    796|  if (ret.first == nullptr) {
  ------------------
  |  Branch (769:7): [True: 278, False: 518]
  ------------------
  770|    278|    return 0;
  771|    278|  }
  772|    518|  size_t saved_bytes = ret.second - utf8_output;
  773|    518|  if (ret.first != buf + len) {
  ------------------
  |  Branch (773:7): [True: 516, False: 2]
  ------------------
  774|    516|    const size_t scalar_saved_bytes = scalar::utf32_to_utf8::convert(
  775|    516|        ret.first, len - (ret.first - buf), ret.second);
  776|    516|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (776:9): [True: 226, False: 290]
  ------------------
  777|    226|      return 0;
  778|    226|    }
  779|    290|    saved_bytes += scalar_saved_bytes;
  780|    290|  }
  781|    292|  return saved_bytes;
  782|    518|}
_ZNK7simdutf7haswell14implementation23convert_utf32_to_latin1EPKDimPc:
  787|    188|    const char32_t *buf, size_t len, char *latin1_output) const noexcept {
  788|    188|  std::pair<const char32_t *, char *> ret =
  789|    188|      avx2_convert_utf32_to_latin1(buf, len, latin1_output);
  790|    188|  if (ret.first == nullptr) {
  ------------------
  |  Branch (790:7): [True: 32, False: 156]
  ------------------
  791|     32|    return 0;
  792|     32|  }
  793|    156|  size_t saved_bytes = ret.second - latin1_output;
  794|    156|  if (ret.first != buf + len) {
  ------------------
  |  Branch (794:7): [True: 142, False: 14]
  ------------------
  795|    142|    const size_t scalar_saved_bytes = scalar::utf32_to_latin1::convert(
  796|    142|        ret.first, len - (ret.first - buf), ret.second);
  797|    142|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (797:9): [True: 98, False: 44]
  ------------------
  798|     98|      return 0;
  799|     98|    }
  800|     44|    saved_bytes += scalar_saved_bytes;
  801|     44|  }
  802|     58|  return saved_bytes;
  803|    156|}
_ZNK7simdutf7haswell14implementation35convert_utf32_to_latin1_with_errorsEPKDimPc:
  806|    420|    const char32_t *buf, size_t len, char *latin1_output) const noexcept {
  807|       |  // ret.first.count is always the position in the buffer, not the number of
  808|       |  // code units written even if finished
  809|    420|  std::pair<result, char *> ret =
  810|    420|      avx2_convert_utf32_to_latin1_with_errors(buf, len, latin1_output);
  811|    420|  if (ret.first.count != len) {
  ------------------
  |  Branch (811:7): [True: 404, False: 16]
  ------------------
  812|    404|    result scalar_res = scalar::utf32_to_latin1::convert_with_errors(
  813|    404|        buf + ret.first.count, len - ret.first.count, ret.second);
  814|    404|    if (scalar_res.error) {
  ------------------
  |  Branch (814:9): [True: 370, False: 34]
  ------------------
  815|    370|      scalar_res.count += ret.first.count;
  816|    370|      return scalar_res;
  817|    370|    } else {
  818|     34|      ret.second += scalar_res.count;
  819|     34|    }
  820|    404|  }
  821|     50|  ret.first.count =
  822|     50|      ret.second -
  823|     50|      latin1_output; // Set count to the number of 8-bit code units written
  824|     50|  return ret.first;
  825|    420|}
_ZNK7simdutf7haswell14implementation33convert_utf32_to_utf8_with_errorsEPKDimPc:
  835|    830|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  836|       |  // ret.first.count is always the position in the buffer, not the number of
  837|       |  // code units written even if finished
  838|    830|  std::pair<result, char *> ret =
  839|    830|      haswell::avx2_convert_utf32_to_utf8_with_errors(buf, len, utf8_output);
  840|    830|  if (ret.first.count != len) {
  ------------------
  |  Branch (840:7): [True: 826, False: 4]
  ------------------
  841|    826|    result scalar_res = scalar::utf32_to_utf8::convert_with_errors(
  842|    826|        buf + ret.first.count, len - ret.first.count, ret.second);
  843|    826|    if (scalar_res.error) {
  ------------------
  |  Branch (843:9): [True: 632, False: 194]
  ------------------
  844|    632|      scalar_res.count += ret.first.count;
  845|    632|      return scalar_res;
  846|    632|    } else {
  847|    194|      ret.second += scalar_res.count;
  848|    194|    }
  849|    826|  }
  850|    198|  ret.first.count =
  851|    198|      ret.second -
  852|    198|      utf8_output; // Set count to the number of 8-bit code units written
  853|    198|  return ret.first;
  854|    830|}
_ZNK7simdutf7haswell14implementation24convert_utf16le_to_utf32EPKDsmPDi:
  859|    384|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  860|    384|  std::pair<const char16_t *, char32_t *> ret =
  861|    384|      haswell::avx2_convert_utf16_to_utf32<endianness::LITTLE>(buf, len,
  862|    384|                                                               utf32_output);
  863|    384|  if (ret.first == nullptr) {
  ------------------
  |  Branch (863:7): [True: 102, False: 282]
  ------------------
  864|    102|    return 0;
  865|    102|  }
  866|    282|  size_t saved_bytes = ret.second - utf32_output;
  867|    282|  if (ret.first != buf + len) {
  ------------------
  |  Branch (867:7): [True: 238, False: 44]
  ------------------
  868|    238|    const size_t scalar_saved_bytes =
  869|    238|        scalar::utf16_to_utf32::convert<endianness::LITTLE>(
  870|    238|            ret.first, len - (ret.first - buf), ret.second);
  871|    238|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (871:9): [True: 74, False: 164]
  ------------------
  872|     74|      return 0;
  873|     74|    }
  874|    164|    saved_bytes += scalar_saved_bytes;
  875|    164|  }
  876|    208|  return saved_bytes;
  877|    282|}
_ZNK7simdutf7haswell14implementation24convert_utf16be_to_utf32EPKDsmPDi:
  880|    366|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  881|    366|  std::pair<const char16_t *, char32_t *> ret =
  882|    366|      haswell::avx2_convert_utf16_to_utf32<endianness::BIG>(buf, len,
  883|    366|                                                            utf32_output);
  884|    366|  if (ret.first == nullptr) {
  ------------------
  |  Branch (884:7): [True: 60, False: 306]
  ------------------
  885|     60|    return 0;
  886|     60|  }
  887|    306|  size_t saved_bytes = ret.second - utf32_output;
  888|    306|  if (ret.first != buf + len) {
  ------------------
  |  Branch (888:7): [True: 264, False: 42]
  ------------------
  889|    264|    const size_t scalar_saved_bytes =
  890|    264|        scalar::utf16_to_utf32::convert<endianness::BIG>(
  891|    264|            ret.first, len - (ret.first - buf), ret.second);
  892|    264|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (892:9): [True: 92, False: 172]
  ------------------
  893|     92|      return 0;
  894|     92|    }
  895|    172|    saved_bytes += scalar_saved_bytes;
  896|    172|  }
  897|    214|  return saved_bytes;
  898|    306|}
_ZNK7simdutf7haswell14implementation36convert_utf16le_to_utf32_with_errorsEPKDsmPDi:
  901|    414|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  902|       |  // ret.first.count is always the position in the buffer, not the number of
  903|       |  // code units written even if finished
  904|    414|  std::pair<result, char32_t *> ret =
  905|    414|      haswell::avx2_convert_utf16_to_utf32_with_errors<endianness::LITTLE>(
  906|    414|          buf, len, utf32_output);
  907|    414|  if (ret.first.error) {
  ------------------
  |  Branch (907:7): [True: 124, False: 290]
  ------------------
  908|    124|    return ret.first;
  909|    124|  } // Can return directly since scalar fallback already found correct
  910|       |    // ret.first.count
  911|    290|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (911:7): [True: 260, False: 30]
  ------------------
  912|    260|    result scalar_res =
  913|    260|        scalar::utf16_to_utf32::convert_with_errors<endianness::LITTLE>(
  914|    260|            buf + ret.first.count, len - ret.first.count, ret.second);
  915|    260|    if (scalar_res.error) {
  ------------------
  |  Branch (915:9): [True: 100, False: 160]
  ------------------
  916|    100|      scalar_res.count += ret.first.count;
  917|    100|      return scalar_res;
  918|    160|    } else {
  919|    160|      ret.second += scalar_res.count;
  920|    160|    }
  921|    260|  }
  922|    190|  ret.first.count =
  923|    190|      ret.second -
  924|    190|      utf32_output; // Set count to the number of 8-bit code units written
  925|    190|  return ret.first;
  926|    290|}
_ZNK7simdutf7haswell14implementation36convert_utf16be_to_utf32_with_errorsEPKDsmPDi:
  929|    300|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  930|       |  // ret.first.count is always the position in the buffer, not the number of
  931|       |  // code units written even if finished
  932|    300|  std::pair<result, char32_t *> ret =
  933|    300|      haswell::avx2_convert_utf16_to_utf32_with_errors<endianness::BIG>(
  934|    300|          buf, len, utf32_output);
  935|    300|  if (ret.first.error) {
  ------------------
  |  Branch (935:7): [True: 54, False: 246]
  ------------------
  936|     54|    return ret.first;
  937|     54|  } // Can return directly since scalar fallback already found correct
  938|       |    // ret.first.count
  939|    246|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (939:7): [True: 216, False: 30]
  ------------------
  940|    216|    result scalar_res =
  941|    216|        scalar::utf16_to_utf32::convert_with_errors<endianness::BIG>(
  942|    216|            buf + ret.first.count, len - ret.first.count, ret.second);
  943|    216|    if (scalar_res.error) {
  ------------------
  |  Branch (943:9): [True: 86, False: 130]
  ------------------
  944|     86|      scalar_res.count += ret.first.count;
  945|     86|      return scalar_res;
  946|    130|    } else {
  947|    130|      ret.second += scalar_res.count;
  948|    130|    }
  949|    216|  }
  950|    160|  ret.first.count =
  951|    160|      ret.second -
  952|    160|      utf32_output; // Set count to the number of 8-bit code units written
  953|    160|  return ret.first;
  954|    246|}
_ZNK7simdutf7haswell14implementation27convert_valid_utf32_to_utf8EPKDimPc:
  959|    192|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  960|    192|  return convert_utf32_to_utf8(buf, len, utf8_output);
  961|    192|}
_ZNK7simdutf7haswell14implementation24convert_utf32_to_utf16leEPKDimPDs:
  966|    722|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  967|    722|  std::pair<const char32_t *, char16_t *> ret =
  968|    722|      avx2_convert_utf32_to_utf16<endianness::LITTLE>(buf, len, utf16_output);
  969|    722|  if (ret.first == nullptr) {
  ------------------
  |  Branch (969:7): [True: 120, False: 602]
  ------------------
  970|    120|    return 0;
  971|    120|  }
  972|    602|  size_t saved_bytes = ret.second - utf16_output;
  973|    602|  if (ret.first != buf + len) {
  ------------------
  |  Branch (973:7): [True: 598, False: 4]
  ------------------
  974|    598|    const size_t scalar_saved_bytes =
  975|    598|        scalar::utf32_to_utf16::convert<endianness::LITTLE>(
  976|    598|            ret.first, len - (ret.first - buf), ret.second);
  977|    598|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (977:9): [True: 166, False: 432]
  ------------------
  978|    166|      return 0;
  979|    166|    }
  980|    432|    saved_bytes += scalar_saved_bytes;
  981|    432|  }
  982|    436|  return saved_bytes;
  983|    602|}
_ZNK7simdutf7haswell14implementation24convert_utf32_to_utf16beEPKDimPDs:
  986|    528|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  987|    528|  std::pair<const char32_t *, char16_t *> ret =
  988|    528|      avx2_convert_utf32_to_utf16<endianness::BIG>(buf, len, utf16_output);
  989|    528|  if (ret.first == nullptr) {
  ------------------
  |  Branch (989:7): [True: 168, False: 360]
  ------------------
  990|    168|    return 0;
  991|    168|  }
  992|    360|  size_t saved_bytes = ret.second - utf16_output;
  993|    360|  if (ret.first != buf + len) {
  ------------------
  |  Branch (993:7): [True: 358, False: 2]
  ------------------
  994|    358|    const size_t scalar_saved_bytes =
  995|    358|        scalar::utf32_to_utf16::convert<endianness::BIG>(
  996|    358|            ret.first, len - (ret.first - buf), ret.second);
  997|    358|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (997:9): [True: 164, False: 194]
  ------------------
  998|    164|      return 0;
  999|    164|    }
 1000|    194|    saved_bytes += scalar_saved_bytes;
 1001|    194|  }
 1002|    196|  return saved_bytes;
 1003|    360|}
_ZNK7simdutf7haswell14implementation36convert_utf32_to_utf16le_with_errorsEPKDimPDs:
 1006|    716|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1007|       |  // ret.first.count is always the position in the buffer, not the number of
 1008|       |  // code units written even if finished
 1009|    716|  std::pair<result, char16_t *> ret =
 1010|    716|      haswell::avx2_convert_utf32_to_utf16_with_errors<endianness::LITTLE>(
 1011|    716|          buf, len, utf16_output);
 1012|    716|  if (ret.first.count != len) {
  ------------------
  |  Branch (1012:7): [True: 712, False: 4]
  ------------------
 1013|    712|    result scalar_res =
 1014|    712|        scalar::utf32_to_utf16::convert_with_errors<endianness::LITTLE>(
 1015|    712|            buf + ret.first.count, len - ret.first.count, ret.second);
 1016|    712|    if (scalar_res.error) {
  ------------------
  |  Branch (1016:9): [True: 530, False: 182]
  ------------------
 1017|    530|      scalar_res.count += ret.first.count;
 1018|    530|      return scalar_res;
 1019|    530|    } else {
 1020|    182|      ret.second += scalar_res.count;
 1021|    182|    }
 1022|    712|  }
 1023|    186|  ret.first.count =
 1024|    186|      ret.second -
 1025|    186|      utf16_output; // Set count to the number of 8-bit code units written
 1026|    186|  return ret.first;
 1027|    716|}
_ZNK7simdutf7haswell14implementation36convert_utf32_to_utf16be_with_errorsEPKDimPDs:
 1030|    606|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1031|       |  // ret.first.count is always the position in the buffer, not the number of
 1032|       |  // code units written even if finished
 1033|    606|  std::pair<result, char16_t *> ret =
 1034|    606|      haswell::avx2_convert_utf32_to_utf16_with_errors<endianness::BIG>(
 1035|    606|          buf, len, utf16_output);
 1036|    606|  if (ret.first.count != len) {
  ------------------
  |  Branch (1036:7): [True: 602, False: 4]
  ------------------
 1037|    602|    result scalar_res =
 1038|    602|        scalar::utf32_to_utf16::convert_with_errors<endianness::BIG>(
 1039|    602|            buf + ret.first.count, len - ret.first.count, ret.second);
 1040|    602|    if (scalar_res.error) {
  ------------------
  |  Branch (1040:9): [True: 434, False: 168]
  ------------------
 1041|    434|      scalar_res.count += ret.first.count;
 1042|    434|      return scalar_res;
 1043|    434|    } else {
 1044|    168|      ret.second += scalar_res.count;
 1045|    168|    }
 1046|    602|  }
 1047|    172|  ret.first.count =
 1048|    172|      ret.second -
 1049|    172|      utf16_output; // Set count to the number of 8-bit code units written
 1050|    172|  return ret.first;
 1051|    606|}
_ZNK7simdutf7haswell14implementation30convert_valid_utf32_to_utf16leEPKDimPDs:
 1054|    290|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1055|    290|  return convert_utf32_to_utf16le(buf, len, utf16_output);
 1056|    290|}
_ZNK7simdutf7haswell14implementation30convert_valid_utf32_to_utf16beEPKDimPDs:
 1059|     86|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1060|     86|  return convert_utf32_to_utf16be(buf, len, utf16_output);
 1061|     86|}
_ZNK7simdutf7haswell14implementation30convert_valid_utf16le_to_utf32EPKDsmPDi:
 1064|    112|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
 1065|    112|  return convert_utf16le_to_utf32(buf, len, utf32_output);
 1066|    112|}
_ZNK7simdutf7haswell14implementation30convert_valid_utf16be_to_utf32EPKDsmPDi:
 1069|    140|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
 1070|    140|  return convert_utf16be_to_utf32(buf, len, utf32_output);
 1071|    140|}
_ZNK7simdutf7haswell14implementation13count_utf16leEPKDsm:
 1082|  1.30k|    const char16_t *input, size_t length) const noexcept {
 1083|  1.30k|  return utf16::count_code_points<endianness::LITTLE>(input, length);
 1084|  1.30k|}
_ZNK7simdutf7haswell14implementation13count_utf16beEPKDsm:
 1087|  1.23k|    const char16_t *input, size_t length) const noexcept {
 1088|  1.23k|  return utf16::count_code_points<endianness::BIG>(input, length);
 1089|  1.23k|}
_ZNK7simdutf7haswell14implementation10count_utf8EPKcm:
 1094|  3.76k|implementation::count_utf8(const char *in, size_t size) const noexcept {
 1095|  3.76k|  return utf8::count_code_points_bytemask(in, size);
 1096|  3.76k|}
_ZNK7simdutf7haswell14implementation23latin1_length_from_utf8EPKcm:
 1101|    539|    const char *buf, size_t len) const noexcept {
 1102|    539|  return count_utf8(buf, len);
 1103|    539|}
_ZNK7simdutf7haswell14implementation24utf8_length_from_utf16leEPKDsm:
 1108|    727|    const char16_t *input, size_t length) const noexcept {
 1109|    727|  return utf16::utf8_length_from_utf16_bytemask<endianness::LITTLE>(input,
 1110|    727|                                                                    length);
 1111|    727|}
_ZNK7simdutf7haswell14implementation24utf8_length_from_utf16beEPKDsm:
 1114|    696|    const char16_t *input, size_t length) const noexcept {
 1115|    696|  return utf16::utf8_length_from_utf16_bytemask<endianness::BIG>(input, length);
 1116|    696|}
_ZNK7simdutf7haswell14implementation25utf32_length_from_utf16leEPKDsm:
 1121|    404|    const char16_t *input, size_t length) const noexcept {
 1122|    404|  return utf16::utf32_length_from_utf16<endianness::LITTLE>(input, length);
 1123|    404|}
_ZNK7simdutf7haswell14implementation25utf32_length_from_utf16beEPKDsm:
 1126|    351|    const char16_t *input, size_t length) const noexcept {
 1127|    351|  return utf16::utf32_length_from_utf16<endianness::BIG>(input, length);
 1128|    351|}
_ZNK7simdutf7haswell14implementation22utf16_length_from_utf8EPKcm:
 1133|  1.74k|    const char *input, size_t length) const noexcept {
 1134|  1.74k|  return utf8::utf16_length_from_utf8_bytemask(input, length);
 1135|  1.74k|}
_ZNK7simdutf7haswell14implementation23utf8_length_from_latin1EPKcm:
 1174|    269|    const char *input, size_t len) const noexcept {
 1175|    269|  const uint8_t *data = reinterpret_cast<const uint8_t *>(input);
 1176|    269|  size_t answer = len / sizeof(__m256i) * sizeof(__m256i);
 1177|    269|  size_t i = 0;
 1178|    269|  if (answer >= 2048) { // long strings optimization
  ------------------
  |  Branch (1178:7): [True: 118, False: 151]
  ------------------
 1179|    118|    __m256i four_64bits = _mm256_setzero_si256();
 1180|  2.61k|    while (i + sizeof(__m256i) <= len) {
  ------------------
  |  Branch (1180:12): [True: 2.50k, False: 118]
  ------------------
 1181|  2.50k|      __m256i runner = _mm256_setzero_si256();
 1182|       |      // We can do up to 255 loops without overflow.
 1183|  2.50k|      size_t iterations = (len - i) / sizeof(__m256i);
 1184|  2.50k|      if (iterations > 255) {
  ------------------
  |  Branch (1184:11): [True: 2.38k, False: 118]
  ------------------
 1185|  2.38k|        iterations = 255;
 1186|  2.38k|      }
 1187|  2.50k|      size_t max_i = i + iterations * sizeof(__m256i) - sizeof(__m256i);
 1188|   154k|      for (; i + 4 * sizeof(__m256i) <= max_i; i += 4 * sizeof(__m256i)) {
  ------------------
  |  Branch (1188:14): [True: 152k, False: 2.50k]
  ------------------
 1189|   152k|        __m256i input1 = _mm256_loadu_si256((const __m256i *)(data + i));
 1190|   152k|        __m256i input2 =
 1191|   152k|            _mm256_loadu_si256((const __m256i *)(data + i + sizeof(__m256i)));
 1192|   152k|        __m256i input3 = _mm256_loadu_si256(
 1193|   152k|            (const __m256i *)(data + i + 2 * sizeof(__m256i)));
 1194|   152k|        __m256i input4 = _mm256_loadu_si256(
 1195|   152k|            (const __m256i *)(data + i + 3 * sizeof(__m256i)));
 1196|   152k|        __m256i input12 =
 1197|   152k|            _mm256_add_epi8(_mm256_cmpgt_epi8(_mm256_setzero_si256(), input1),
 1198|   152k|                            _mm256_cmpgt_epi8(_mm256_setzero_si256(), input2));
 1199|   152k|        __m256i input23 =
 1200|   152k|            _mm256_add_epi8(_mm256_cmpgt_epi8(_mm256_setzero_si256(), input3),
 1201|   152k|                            _mm256_cmpgt_epi8(_mm256_setzero_si256(), input4));
 1202|   152k|        __m256i input1234 = _mm256_add_epi8(input12, input23);
 1203|   152k|        runner = _mm256_sub_epi8(runner, input1234);
 1204|   152k|      }
 1205|  9.92k|      for (; i <= max_i; i += sizeof(__m256i)) {
  ------------------
  |  Branch (1205:14): [True: 7.42k, False: 2.50k]
  ------------------
 1206|  7.42k|        __m256i input_256_chunk =
 1207|  7.42k|            _mm256_loadu_si256((const __m256i *)(data + i));
 1208|  7.42k|        runner = _mm256_sub_epi8(
 1209|  7.42k|            runner, _mm256_cmpgt_epi8(_mm256_setzero_si256(), input_256_chunk));
 1210|  7.42k|      }
 1211|  2.50k|      four_64bits = _mm256_add_epi64(
 1212|  2.50k|          four_64bits, _mm256_sad_epu8(runner, _mm256_setzero_si256()));
 1213|  2.50k|    }
 1214|    118|    answer += _mm256_extract_epi64(four_64bits, 0) +
 1215|    118|              _mm256_extract_epi64(four_64bits, 1) +
 1216|    118|              _mm256_extract_epi64(four_64bits, 2) +
 1217|    118|              _mm256_extract_epi64(four_64bits, 3);
 1218|    151|  } else if (answer > 0) {
  ------------------
  |  Branch (1218:14): [True: 80, False: 71]
  ------------------
 1219|  1.36k|    for (; i + sizeof(__m256i) <= len; i += sizeof(__m256i)) {
  ------------------
  |  Branch (1219:12): [True: 1.28k, False: 80]
  ------------------
 1220|  1.28k|      __m256i latin = _mm256_loadu_si256((const __m256i *)(data + i));
 1221|  1.28k|      uint32_t non_ascii = _mm256_movemask_epi8(latin);
 1222|  1.28k|      answer += count_ones(non_ascii);
 1223|  1.28k|    }
 1224|     80|  }
 1225|    269|  return answer + scalar::latin1::utf8_length_from_latin1(
 1226|    269|                      reinterpret_cast<const char *>(data + i), len - i);
 1227|    269|}
_ZNK7simdutf7haswell14implementation22utf8_length_from_utf32EPKDim:
 1232|    819|    const char32_t *input, size_t length) const noexcept {
 1233|    819|  return utf32::utf8_length_from_utf32(input, length);
 1234|    819|}
_ZNK7simdutf7haswell14implementation23utf16_length_from_utf32EPKDim:
 1239|  1.29k|    const char32_t *input, size_t length) const noexcept {
 1240|  1.29k|  const __m256i v_00000000 = _mm256_setzero_si256();
 1241|  1.29k|  const __m256i v_ffff0000 = _mm256_set1_epi32((uint32_t)0xffff0000);
 1242|  1.29k|  size_t pos = 0;
 1243|  1.29k|  size_t count = 0;
 1244|   672k|  for (; pos + 8 <= length; pos += 8) {
  ------------------
  |  Branch (1244:10): [True: 671k, False: 1.29k]
  ------------------
 1245|   671k|    __m256i in = _mm256_loadu_si256((__m256i *)(input + pos));
 1246|   671k|    const __m256i surrogate_bytemask =
 1247|   671k|        _mm256_cmpeq_epi32(_mm256_and_si256(in, v_ffff0000), v_00000000);
 1248|   671k|    const uint32_t surrogate_bitmask =
 1249|   671k|        static_cast<uint32_t>(_mm256_movemask_epi8(surrogate_bytemask));
 1250|   671k|    size_t surrogate_count = (32 - count_ones(surrogate_bitmask)) / 4;
 1251|   671k|    count += 8 + surrogate_count;
 1252|   671k|  }
 1253|  1.29k|  return count +
 1254|  1.29k|         scalar::utf32::utf16_length_from_utf32(input + pos, length - pos);
 1255|  1.29k|}
_ZNK7simdutf7haswell14implementation22utf32_length_from_utf8EPKcm:
 1260|    933|    const char *input, size_t length) const noexcept {
 1261|    933|  return utf8::count_code_points(input, length);
 1262|    933|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_18is_asciiERKNS1_4simd8simd8x64IhEE:
   13|  4.64M|simdutf_really_inline bool is_ascii(const simd8x64<uint8_t> &input) {
   14|  4.64M|  return input.reduce_or().is_ascii();
   15|  4.64M|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_124must_be_2_3_continuationENS1_4simd5simd8IhEES4_:
   22|  3.20M|                         const simd8<uint8_t> prev3) {
   23|  3.20M|  simd8<uint8_t> is_third_byte =
   24|  3.20M|      prev2.saturating_sub(0xe0u - 0x80); // Only 111_____ will be > 0x80
   25|  3.20M|  simd8<uint8_t> is_fourth_byte =
   26|  3.20M|      prev3.saturating_sub(0xf0u - 0x80); // Only 1111____ will be > 0x80
   27|  3.20M|  return simd8<bool>(is_third_byte | is_fourth_byte);
   28|  3.20M|}
_ZN7simdutf7haswell34convert_utf16_to_utf8_with_detailsILNS_10endiannessE0EEENS_11full_resultEPKDsmPc:
  722|    630|    const char16_t *buf, size_t len, char *utf8_output) {
  723|    630|  std::pair<result, char *> ret =
  724|    630|      haswell::avx2_convert_utf16_to_utf8_with_errors<big_endian>(buf, len,
  725|    630|                                                                  utf8_output);
  726|    630|  if (ret.first.error) {
  ------------------
  |  Branch (726:7): [True: 128, False: 502]
  ------------------
  727|    128|    return full_result(ret.first.error, ret.first.count,
  728|    128|                       size_t(ret.second - utf8_output));
  729|    128|  }
  730|    502|  if (ret.first.count != len) {
  ------------------
  |  Branch (730:7): [True: 498, False: 4]
  ------------------
  731|    498|    full_result sres =
  732|    498|        scalar::utf16_to_utf8::convert_with_errors<big_endian, false>(
  733|    498|            buf + ret.first.count, len - ret.first.count, ret.second, 0);
  734|    498|    return full_result(sres.error, ret.first.count + sres.input_count,
  735|    498|                       size_t(ret.second - utf8_output) + sres.output_count);
  736|    498|  }
  737|      4|  return full_result(error_code::SUCCESS, len,
  738|      4|                     size_t(ret.second - utf8_output));
  739|    502|}
_ZN7simdutf7haswell34convert_utf16_to_utf8_with_detailsILNS_10endiannessE1EEENS_11full_resultEPKDsmPc:
  722|    586|    const char16_t *buf, size_t len, char *utf8_output) {
  723|    586|  std::pair<result, char *> ret =
  724|    586|      haswell::avx2_convert_utf16_to_utf8_with_errors<big_endian>(buf, len,
  725|    586|                                                                  utf8_output);
  726|    586|  if (ret.first.error) {
  ------------------
  |  Branch (726:7): [True: 164, False: 422]
  ------------------
  727|    164|    return full_result(ret.first.error, ret.first.count,
  728|    164|                       size_t(ret.second - utf8_output));
  729|    164|  }
  730|    422|  if (ret.first.count != len) {
  ------------------
  |  Branch (730:7): [True: 418, False: 4]
  ------------------
  731|    418|    full_result sres =
  732|    418|        scalar::utf16_to_utf8::convert_with_errors<big_endian, false>(
  733|    418|            buf + ret.first.count, len - ret.first.count, ret.second, 0);
  734|    418|    return full_result(sres.error, ret.first.count + sres.input_count,
  735|    418|                       size_t(ret.second - utf8_output) + sres.output_count);
  736|    418|  }
  737|      4|  return full_result(error_code::SUCCESS, len,
  738|      4|                     size_t(ret.second - utf8_output));
  739|    422|}

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

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

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

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

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

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

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

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEC2Ev:
  183|  19.3k|  simdutf_really_inline simd8() : base8_numeric<uint8_t>() {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhEC2Ev:
  118|  19.3k|  simdutf_really_inline base8_numeric() : base8<T>() {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEEC2Ev:
   68|  19.3k|  simdutf_really_inline base8() : base<simd8<T>>() {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEC2Ev:
   13|  19.3k|  simdutf_really_inline base() : value{__m128i()} {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IhE9reduce_orEv:
  290|  4.64M|  simdutf_really_inline simd8<T> reduce_or() const {
  291|  4.64M|    return (this->chunks[0] | this->chunks[1]) |
  292|  4.64M|           (this->chunks[2] | this->chunks[3]);
  293|  4.64M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEorES5_:
   42|  30.7M|  simdutf_really_inline Child operator|(const Child other) const {
   43|  30.7M|    return _mm_or_si128(*this, other);
   44|  30.7M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEC2EDv2_x:
  185|   314M|      : base8_numeric<uint8_t>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhEC2EDv2_x:
  120|   314M|      : base8<T>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEEC2EDv2_x:
   69|   314M|  simdutf_really_inline base8(const __m128i _value) : base<simd8<T>>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEC2EDv2_x:
   16|   314M|  simdutf_really_inline base(const __m128i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE8is_asciiEv:
  228|  4.64M|  simdutf_really_inline bool is_ascii() const {
  229|  4.64M|    return _mm_movemask_epi8(*this) == 0;
  230|  4.64M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEoRES5_:
   51|  10.4M|  simdutf_really_inline Child &operator|=(const Child other) {
   52|  10.4M|    auto this_cast = static_cast<Child *>(this);
   53|  10.4M|    *this_cast = *this_cast | other;
   54|  10.4M|    return *this_cast;
   55|  10.4M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEE4prevILi1EEENS4_IhEES8_:
   79|  6.64M|  simdutf_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
   80|       |    return _mm_alignr_epi8(*this, prev_chunk, 16 - N);
   81|  6.64M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE3shrILi4EEES4_v:
  238|  13.2M|  template <int N> simdutf_really_inline simd8<uint8_t> shr() const {
  239|  13.2M|    return simd8<uint8_t>(_mm_srli_epi16(*this, N)) & uint8_t(0xFFu >> N);
  240|  13.2M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE9lookup_16IhEENS2_5simd8IT_EES7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_:
  151|  19.9M|            L replace15) const {
  152|  19.9M|    return lookup_16(simd8<L>::repeat_16(
  153|  19.9M|        replace0, replace1, replace2, replace3, replace4, replace5, replace6,
  154|  19.9M|        replace7, replace8, replace9, replace10, replace11, replace12,
  155|  19.9M|        replace13, replace14, replace15));
  156|  19.9M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE9lookup_16IhEENS2_5simd8IT_EES8_:
  142|  19.9M|  simdutf_really_inline simd8<L> lookup_16(simd8<L> lookup_table) const {
  143|  19.9M|    return _mm_shuffle_epi8(lookup_table, *this);
  144|  19.9M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE9repeat_16Ehhhhhhhhhhhhhhhh:
  113|  19.9M|                                                  T v14, T v15) {
  114|  19.9M|    return simd8<T>(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
  115|  19.9M|                    v14, v15);
  116|  19.9M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEC2Ehhhhhhhhhhhhhhhh:
  196|  19.9M|      : simd8(_mm_setr_epi8(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
  197|  19.9M|                            v12, v13, v14, v15)) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEC2Eh:
  188|  45.9M|  simdutf_really_inline simd8(uint8_t _value) : simd8(splat(_value)) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEE4prevILi2EEENS4_IhEES8_:
   79|  6.40M|  simdutf_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
   80|       |    return _mm_alignr_epi8(*this, prev_chunk, 16 - N);
   81|  6.40M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEE4prevILi3EEENS4_IhEES8_:
   79|  6.40M|  simdutf_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
   80|       |    return _mm_alignr_epi8(*this, prev_chunk, 16 - N);
   81|  6.40M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE14saturating_subES4_:
  201|  13.6M|  saturating_sub(const simd8<uint8_t> other) const {
  202|  13.6M|    return _mm_subs_epu8(*this, other);
  203|  13.6M|  }
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.40M|  simdutf_really_inline Child operator^(const Child other) const {
   49|  6.40M|    return _mm_xor_si128(*this, other);
   50|  6.40M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEC2EPKh:
  190|   828k|  simdutf_really_inline simd8(const uint8_t *values) : simd8(load(values)) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE4loadEPKh:
  106|  19.4M|  static simdutf_really_inline simd8<T> load(const T values[16]) {
  107|  19.4M|    return _mm_loadu_si128(reinterpret_cast<const __m128i *>(values));
  108|  19.4M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE7gt_bitsES4_:
  212|   828k|  gt_bits(const simd8<uint8_t> other) const {
  213|   828k|    return this->saturating_sub(other);
  214|   828k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16ItEEEC2EDv2_x:
   16|   128M|  simdutf_really_inline base(const __m128i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16ItEEEcvRKDv2_xEv:
   18|   173M|  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.19M|  simdutf_really_inline bool any_bits_set_anywhere() const {
  236|  2.19M|    return !bits_not_set_anywhere();
  237|  2.19M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE21bits_not_set_anywhereEv:
  232|  2.19M|  simdutf_really_inline bool bits_not_set_anywhere() const {
  233|  2.19M|    return _mm_testz_si128(*this, *this);
  234|  2.19M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaEC2EPKa:
  270|  5.92M|      : chunks{simd8<T>::load(ptr),
  271|  5.92M|               simd8<T>::load(ptr + sizeof(simd8<T>) / sizeof(T)),
  272|  5.92M|               simd8<T>::load(ptr + 2 * sizeof(simd8<T>) / sizeof(T)),
  273|  5.92M|               simd8<T>::load(ptr + 3 * sizeof(simd8<T>) / sizeof(T))} {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIaE4loadEPKa:
  106|  43.0M|  static simdutf_really_inline simd8<T> load(const T values[16]) {
  107|  43.0M|    return _mm_loadu_si128(reinterpret_cast<const __m128i *>(values));
  108|  43.0M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IaEC2EDv2_x:
  163|  79.8M|      : base8_numeric<int8_t>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIaEC2EDv2_x:
  120|  79.8M|      : base8<T>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5base8IaNS2_5simd8IbEEEC2EDv2_x:
   69|  79.8M|  simdutf_really_inline base8(const __m128i _value) : base<simd8<T>>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IaEEEC2EDv2_x:
   16|  79.8M|  simdutf_really_inline base(const __m128i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE8is_asciiEv:
  295|  5.25M|  simdutf_really_inline bool is_ascii() const {
  296|  5.25M|    return this->reduce_or().is_ascii();
  297|  5.25M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE9reduce_orEv:
  290|  5.25M|  simdutf_really_inline simd8<T> reduce_or() const {
  291|  5.25M|    return (this->chunks[0] | this->chunks[1]) |
  292|  5.25M|           (this->chunks[2] | this->chunks[3]);
  293|  5.25M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IaEEEorES5_:
   42|  15.7M|  simdutf_really_inline Child operator|(const Child other) const {
   43|  15.7M|    return _mm_or_si128(*this, other);
   44|  15.7M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IaEEEcvRKDv2_xEv:
   18|   126M|  simdutf_really_inline operator const __m128i &() const { return this->value; }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IaE8is_asciiEv:
  168|  5.25M|  simdutf_really_inline bool is_ascii() const {
  169|  5.25M|    return _mm_movemask_epi8(*this) == 0;
  170|  5.25M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE5storeEPa:
  275|  1.00M|  simdutf_really_inline void store(T *ptr) const {
  276|  1.00M|    this->chunks[0].store(ptr + sizeof(simd8<T>) * 0 / sizeof(T));
  277|  1.00M|    this->chunks[1].store(ptr + sizeof(simd8<T>) * 1 / sizeof(T));
  278|  1.00M|    this->chunks[2].store(ptr + sizeof(simd8<T>) * 2 / sizeof(T));
  279|  1.00M|    this->chunks[3].store(ptr + sizeof(simd8<T>) * 3 / sizeof(T));
  280|  1.00M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIaE5storeEPa:
  123|  4.01M|  simdutf_really_inline void store(T dst[16]) const {
  124|  4.01M|    return _mm_storeu_si128(reinterpret_cast<__m128i *>(dst), *this);
  125|  4.01M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IaEcvNS3_IhEEEv:
  251|  5.82M|simdutf_really_inline simd8<int8_t>::operator simd8<uint8_t>() const {
  252|  5.82M|  return this->value;
  253|  5.82M|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE2ltEa:
  326|  1.07M|  simdutf_really_inline uint64_t lt(const T m) const {
  327|  1.07M|    const simd8<T> mask = simd8<T>::splat(m);
  328|  1.07M|    return simd8x64<bool>(this->chunks[0] < mask, this->chunks[1] < mask,
  329|  1.07M|                          this->chunks[2] < mask, this->chunks[3] < mask)
  330|  1.07M|        .to_bitmask();
  331|  1.07M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIaE5splatEa:
  102|  21.0M|  static simdutf_really_inline simd8<T> splat(T _value) {
  103|  21.0M|    return _mm_set1_epi8(_value);
  104|  21.0M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IaEltES4_:
  176|  4.28M|  simdutf_really_inline simd8<bool> operator<(const simd8<int8_t> other) const {
  177|  4.28M|    return _mm_cmpgt_epi8(other, *this);
  178|  4.28M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IbEC2ENS2_5simd8IbEES6_S6_S6_:
  268|  1.73M|      : chunks{chunk0, chunk1, chunk2, chunk3} {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IbE10to_bitmaskEv:
  318|  1.73M|  simdutf_really_inline uint64_t to_bitmask() const {
  319|  1.73M|    uint64_t r0 = uint32_t(this->chunks[0].to_bitmask());
  320|  1.73M|    uint64_t r1 = this->chunks[1].to_bitmask();
  321|  1.73M|    uint64_t r2 = this->chunks[2].to_bitmask();
  322|  1.73M|    uint64_t r3 = this->chunks[3].to_bitmask();
  323|  1.73M|    return r0 | (r1 << 16) | (r2 << 32) | (r3 << 48);
  324|  1.73M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE20store_ascii_as_utf32EPDi:
  311|  1.00M|  simdutf_really_inline void store_ascii_as_utf32(char32_t *ptr) const {
  312|  1.00M|    this->chunks[0].store_ascii_as_utf32(ptr + sizeof(simd8<T>) * 0);
  313|  1.00M|    this->chunks[1].store_ascii_as_utf32(ptr + sizeof(simd8<T>) * 1);
  314|  1.00M|    this->chunks[2].store_ascii_as_utf32(ptr + sizeof(simd8<T>) * 2);
  315|  1.00M|    this->chunks[3].store_ascii_as_utf32(ptr + sizeof(simd8<T>) * 3);
  316|  1.00M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IaEEE20store_ascii_as_utf32EPDi:
   32|  4.02M|  simdutf_really_inline void store_ascii_as_utf32(char32_t *p) const {
   33|  4.02M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p), _mm_cvtepu8_epi32(*this));
   34|  4.02M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p + 4),
   35|  4.02M|                     _mm_cvtepu8_epi32(_mm_srli_si128(*this, 4)));
   36|  4.02M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p + 8),
   37|  4.02M|                     _mm_cvtepu8_epi32(_mm_srli_si128(*this, 8)));
   38|  4.02M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p + 12),
   39|       |                     _mm_cvtepu8_epi32(_mm_srli_si128(*this, 12)));
   40|  4.02M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE4zeroEv:
  105|   204k|  static simdutf_really_inline simd8<T> zero() { return _mm_setzero_si128(); }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IaEgtES4_:
  173|  21.9M|  simdutf_really_inline simd8<bool> operator>(const simd8<int8_t> other) const {
  174|  21.9M|    return _mm_cmpgt_epi8(*this, other);
  175|  21.9M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IaEC2Ea:
  165|  19.3M|  simdutf_really_inline simd8(int8_t _value) : simd8(splat(_value)) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhEmIENS2_5simd8IhEE:
  134|  25.2M|  simdutf_really_inline simd8<T> &operator-=(const simd8<T> other) {
  135|  25.2M|    *this = *this - other;
  136|  25.2M|    return *static_cast<simd8<T> *>(this);
  137|  25.2M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhEmiENS2_5simd8IhEE:
  131|  25.2M|  simdutf_really_inline simd8<T> operator-(const simd8<T> other) const {
  132|  25.2M|    return _mm_sub_epi8(*this, other);
  133|  25.2M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd10sum_8bytesENS2_5simd8IhEE:
  366|  99.5k|simdutf_really_inline simd64<uint64_t> sum_8bytes(const simd8<uint8_t> v) {
  367|  99.5k|  return _mm_sad_epu8(v.value, simd8<uint8_t>::zero());
  368|  99.5k|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE9sum_bytesEv:
  245|  3.52k|  simdutf_really_inline uint64_t sum_bytes() const {
  246|  3.52k|    const auto tmp = _mm_sad_epu8(value, _mm_setzero_si128());
  247|  3.52k|    return _mm_extract_epi64(tmp, 0) + _mm_extract_epi64(tmp, 1);
  248|  3.52k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEgeES4_:
  217|  5.97M|  operator>=(const simd8<uint8_t> other) const {
  218|  5.97M|    return other.min_val(*this) == other;
  219|  5.97M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE7min_valES4_:
  207|  5.97M|  min_val(const simd8<uint8_t> other) const {
  208|  5.97M|    return _mm_min_epu8(*this, other);
  209|  5.97M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE2gtEa:
  333|   665k|  simdutf_really_inline uint64_t gt(const T m) const {
  334|   665k|    const simd8<T> mask = simd8<T>::splat(m);
  335|   665k|    return simd8x64<bool>(this->chunks[0] > mask, this->chunks[1] > mask,
  336|   665k|                          this->chunks[2] > mask, this->chunks[3] > mask)
  337|   665k|        .to_bitmask();
  338|   665k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16IbEEEC2EDv2_x:
   16|  32.3M|  simdutf_really_inline base(const __m128i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16IbEEEcvRKDv2_xEv:
   18|  32.3M|  simdutf_really_inline operator const __m128i &() const { return this->value; }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE5splatEh:
  102|  45.9M|  static simdutf_really_inline simd8<T> splat(T _value) {
  103|  45.9M|    return _mm_set1_epi8(_value);
  104|  45.9M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEcvRKDv2_xEv:
   18|   385M|  simdutf_really_inline operator const __m128i &() const { return this->value; }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdeqENS2_5simd8IhEES4_:
   72|  11.5M|                                               const simd8<T> rhs) {
   73|  11.5M|    return _mm_cmpeq_epi8(lhs, rhs);
   74|  11.5M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEanES5_:
   45|  45.1M|  simdutf_really_inline Child operator&(const Child other) const {
   46|  45.1M|    return _mm_and_si128(*this, other);
   47|  45.1M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IhEC2EPKh:
  270|  4.64M|      : chunks{simd8<T>::load(ptr),
  271|  4.64M|               simd8<T>::load(ptr + sizeof(simd8<T>) / sizeof(T)),
  272|  4.64M|               simd8<T>::load(ptr + 2 * sizeof(simd8<T>) / sizeof(T)),
  273|  4.64M|               simd8<T>::load(ptr + 3 * sizeof(simd8<T>) / sizeof(T))} {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16ItEEEanES5_:
   45|  19.4M|  simdutf_really_inline Child operator&(const Child other) const {
   46|  19.4M|    return _mm_and_si128(*this, other);
   47|  19.4M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE20store_ascii_as_utf16ILNS_10endiannessE0EEEvPDs:
  300|  1.06M|  simdutf_really_inline void store_ascii_as_utf16(char16_t *ptr) const {
  301|  1.06M|    this->chunks[0].template store_ascii_as_utf16<endian>(ptr +
  302|  1.06M|                                                          sizeof(simd8<T>) * 0);
  303|  1.06M|    this->chunks[1].template store_ascii_as_utf16<endian>(ptr +
  304|  1.06M|                                                          sizeof(simd8<T>) * 1);
  305|  1.06M|    this->chunks[2].template store_ascii_as_utf16<endian>(ptr +
  306|  1.06M|                                                          sizeof(simd8<T>) * 2);
  307|  1.06M|    this->chunks[3].template store_ascii_as_utf16<endian>(ptr +
  308|  1.06M|                                                          sizeof(simd8<T>) * 3);
  309|  1.06M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IaEEE20store_ascii_as_utf16ILNS_10endiannessE0EEEvPDs:
   20|  4.24M|  simdutf_really_inline void store_ascii_as_utf16(char16_t *p) const {
   21|  4.24M|    __m128i first = _mm_cvtepu8_epi16(*this);
   22|  4.24M|    __m128i second = _mm_cvtepu8_epi16(_mm_srli_si128(*this, 8));
   23|  4.24M|    if (big_endian) {
  ------------------
  |  Branch (23:9): [Folded, False: 4.24M]
  ------------------
   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.24M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p), first);
   30|  4.24M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p + 8), second);
   31|  4.24M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE20store_ascii_as_utf16ILNS_10endiannessE1EEEvPDs:
  300|  1.11M|  simdutf_really_inline void store_ascii_as_utf16(char16_t *ptr) const {
  301|  1.11M|    this->chunks[0].template store_ascii_as_utf16<endian>(ptr +
  302|  1.11M|                                                          sizeof(simd8<T>) * 0);
  303|  1.11M|    this->chunks[1].template store_ascii_as_utf16<endian>(ptr +
  304|  1.11M|                                                          sizeof(simd8<T>) * 1);
  305|  1.11M|    this->chunks[2].template store_ascii_as_utf16<endian>(ptr +
  306|  1.11M|                                                          sizeof(simd8<T>) * 2);
  307|  1.11M|    this->chunks[3].template store_ascii_as_utf16<endian>(ptr +
  308|  1.11M|                                                          sizeof(simd8<T>) * 3);
  309|  1.11M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IaEEE20store_ascii_as_utf16ILNS_10endiannessE1EEEvPDs:
   20|  4.45M|  simdutf_really_inline void store_ascii_as_utf16(char16_t *p) const {
   21|  4.45M|    __m128i first = _mm_cvtepu8_epi16(*this);
   22|  4.45M|    __m128i second = _mm_cvtepu8_epi16(_mm_srli_si128(*this, 8));
   23|  4.45M|    if (big_endian) {
  ------------------
  |  Branch (23:9): [True: 4.45M, Folded]
  ------------------
   24|  4.45M|      const __m128i swap =
   25|  4.45M|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   26|  4.45M|      first = _mm_shuffle_epi8(first, swap);
   27|  4.45M|      second = _mm_shuffle_epi8(second, swap);
   28|  4.45M|    }
   29|  4.45M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p), first);
   30|  4.45M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p + 8), second);
   31|  4.45M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd12as_vector_u8ENS2_6simd32IjEE:
  370|  5.80k|simdutf_really_inline simd8<uint8_t> as_vector_u8(const simd32<uint32_t> v) {
  371|  5.80k|  return simd8<uint8_t>(v.value);
  372|  5.80k|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16IbEEEorES5_:
   42|  9.25M|  simdutf_really_inline Child operator|(const Child other) const {
   43|  9.25M|    return _mm_or_si128(*this, other);
   44|  9.25M|  }

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

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

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

_ZNK7simdutf8westmere14implementation13validate_utf8EPKcm:
  299|  3.22k|implementation::validate_utf8(const char *buf, size_t len) const noexcept {
  300|  3.22k|  return westmere::utf8_validation::generic_validate_utf8(buf, len);
  301|  3.22k|}
_ZNK7simdutf8westmere14implementation25validate_utf8_with_errorsEPKcm:
  306|  3.22k|    const char *buf, size_t len) const noexcept {
  307|  3.22k|  return westmere::utf8_validation::generic_validate_utf8_with_errors(buf, len);
  308|  3.22k|}
_ZNK7simdutf8westmere14implementation16validate_utf16leEPKDsm:
  345|  1.30k|                                 size_t len) const noexcept {
  346|  1.30k|  if (simdutf_unlikely(len == 0)) {
  ------------------
  |  |   93|  1.30k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 17, False: 1.29k]
  |  |  ------------------
  ------------------
  347|       |    // empty input is valid UTF-16. protect the implementation from
  348|       |    // handling nullptr
  349|     17|    return true;
  350|     17|  }
  351|  1.29k|  const auto res =
  352|  1.29k|      westmere::utf16::validate_utf16_with_errors<endianness::LITTLE>(buf, len);
  353|  1.29k|  if (res.is_err()) {
  ------------------
  |  Branch (353:7): [True: 125, False: 1.16k]
  ------------------
  354|    125|    return false;
  355|    125|  }
  356|       |
  357|  1.16k|  if (res.count == len)
  ------------------
  |  Branch (357:7): [True: 0, False: 1.16k]
  ------------------
  358|      0|    return true;
  359|       |
  360|  1.16k|  return scalar::utf16::validate<endianness::LITTLE>(buf + res.count,
  361|  1.16k|                                                     len - res.count);
  362|  1.16k|}
_ZNK7simdutf8westmere14implementation16validate_utf16beEPKDsm:
  368|  1.23k|                                 size_t len) const noexcept {
  369|  1.23k|  if (simdutf_unlikely(len == 0)) {
  ------------------
  |  |   93|  1.23k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 15, False: 1.22k]
  |  |  ------------------
  ------------------
  370|       |    // empty input is valid UTF-16. protect the implementation from
  371|       |    // handling nullptr
  372|     15|    return true;
  373|     15|  }
  374|  1.22k|  const auto res =
  375|  1.22k|      westmere::utf16::validate_utf16_with_errors<endianness::BIG>(buf, len);
  376|  1.22k|  if (res.is_err()) {
  ------------------
  |  Branch (376:7): [True: 131, False: 1.09k]
  ------------------
  377|    131|    return false;
  378|    131|  }
  379|       |
  380|  1.09k|  if (res.count == len)
  ------------------
  |  Branch (380:7): [True: 0, False: 1.09k]
  ------------------
  381|      0|    return true;
  382|       |
  383|  1.09k|  return scalar::utf16::validate<endianness::BIG>(buf + res.count,
  384|  1.09k|                                                  len - res.count);
  385|  1.09k|}
_ZNK7simdutf8westmere14implementation28validate_utf16le_with_errorsEPKDsm:
  388|  1.30k|    const char16_t *buf, size_t len) const noexcept {
  389|  1.30k|  const result res =
  390|  1.30k|      westmere::utf16::validate_utf16_with_errors<endianness::LITTLE>(buf, len);
  391|  1.30k|  if (res.count != len) {
  ------------------
  |  Branch (391:7): [True: 1.29k, False: 17]
  ------------------
  392|  1.29k|    const result scalar_res =
  393|  1.29k|        scalar::utf16::validate_with_errors<endianness::LITTLE>(
  394|  1.29k|            buf + res.count, len - res.count);
  395|  1.29k|    return result(scalar_res.error, res.count + scalar_res.count);
  396|  1.29k|  } else {
  397|     17|    return res;
  398|     17|  }
  399|  1.30k|}
_ZNK7simdutf8westmere14implementation28validate_utf16be_with_errorsEPKDsm:
  402|  1.23k|    const char16_t *buf, size_t len) const noexcept {
  403|  1.23k|  const result res =
  404|  1.23k|      westmere::utf16::validate_utf16_with_errors<endianness::BIG>(buf, len);
  405|  1.23k|  if (res.count != len) {
  ------------------
  |  Branch (405:7): [True: 1.22k, False: 15]
  ------------------
  406|  1.22k|    result scalar_res = scalar::utf16::validate_with_errors<endianness::BIG>(
  407|  1.22k|        buf + res.count, len - res.count);
  408|  1.22k|    return result(scalar_res.error, res.count + scalar_res.count);
  409|  1.22k|  } else {
  410|     15|    return res;
  411|     15|  }
  412|  1.23k|}
_ZNK7simdutf8westmere14implementation14validate_utf32EPKDim:
  427|  2.41k|implementation::validate_utf32(const char32_t *buf, size_t len) const noexcept {
  428|  2.41k|  return utf32::validate(buf, len);
  429|  2.41k|}
_ZNK7simdutf8westmere14implementation26validate_utf32_with_errorsEPKDim:
  434|  2.41k|    const char32_t *buf, size_t len) const noexcept {
  435|  2.41k|  return utf32::validate_with_errors(buf, len);
  436|  2.41k|}
_ZNK7simdutf8westmere14implementation22convert_latin1_to_utf8EPKcmPc:
  441|    538|    const char *buf, size_t len, char *utf8_output) const noexcept {
  442|       |
  443|    538|  std::pair<const char *, char *> ret =
  444|    538|      sse_convert_latin1_to_utf8(buf, len, utf8_output);
  445|    538|  size_t converted_chars = ret.second - utf8_output;
  446|       |
  447|    538|  if (ret.first != buf + len) {
  ------------------
  |  Branch (447:7): [True: 452, False: 86]
  ------------------
  448|    452|    const size_t scalar_converted_chars = scalar::latin1_to_utf8::convert(
  449|    452|        ret.first, len - (ret.first - buf), ret.second);
  450|    452|    converted_chars += scalar_converted_chars;
  451|    452|  }
  452|       |
  453|    538|  return converted_chars;
  454|    538|}
_ZNK7simdutf8westmere14implementation25convert_latin1_to_utf16leEPKcmPDs:
  459|     80|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  460|     80|  std::pair<const char *, char16_t *> ret =
  461|     80|      sse_convert_latin1_to_utf16<endianness::LITTLE>(buf, len, utf16_output);
  462|     80|  if (ret.first == nullptr) {
  ------------------
  |  Branch (462:7): [True: 4, False: 76]
  ------------------
  463|      4|    return 0;
  464|      4|  }
  465|     76|  size_t converted_chars = ret.second - utf16_output;
  466|     76|  if (ret.first != buf + len) {
  ------------------
  |  Branch (466:7): [True: 62, False: 14]
  ------------------
  467|     62|    const size_t scalar_converted_chars =
  468|     62|        scalar::latin1_to_utf16::convert<endianness::LITTLE>(
  469|     62|            ret.first, len - (ret.first - buf), ret.second);
  470|     62|    if (scalar_converted_chars == 0) {
  ------------------
  |  Branch (470:9): [True: 0, False: 62]
  ------------------
  471|      0|      return 0;
  472|      0|    }
  473|     62|    converted_chars += scalar_converted_chars;
  474|     62|  }
  475|     76|  return converted_chars;
  476|     76|}
_ZNK7simdutf8westmere14implementation25convert_latin1_to_utf16beEPKcmPDs:
  479|     80|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  480|     80|  std::pair<const char *, char16_t *> ret =
  481|     80|      sse_convert_latin1_to_utf16<endianness::BIG>(buf, len, utf16_output);
  482|     80|  if (ret.first == nullptr) {
  ------------------
  |  Branch (482:7): [True: 4, False: 76]
  ------------------
  483|      4|    return 0;
  484|      4|  }
  485|     76|  size_t converted_chars = ret.second - utf16_output;
  486|     76|  if (ret.first != buf + len) {
  ------------------
  |  Branch (486:7): [True: 62, False: 14]
  ------------------
  487|     62|    const size_t scalar_converted_chars =
  488|     62|        scalar::latin1_to_utf16::convert<endianness::BIG>(
  489|     62|            ret.first, len - (ret.first - buf), ret.second);
  490|     62|    if (scalar_converted_chars == 0) {
  ------------------
  |  Branch (490:9): [True: 0, False: 62]
  ------------------
  491|      0|      return 0;
  492|      0|    }
  493|     62|    converted_chars += scalar_converted_chars;
  494|     62|  }
  495|     76|  return converted_chars;
  496|     76|}
_ZNK7simdutf8westmere14implementation23convert_latin1_to_utf32EPKcmPDi:
  501|     90|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  502|     90|  std::pair<const char *, char32_t *> ret =
  503|     90|      sse_convert_latin1_to_utf32(buf, len, utf32_output);
  504|     90|  if (ret.first == nullptr) {
  ------------------
  |  Branch (504:7): [True: 4, False: 86]
  ------------------
  505|      4|    return 0;
  506|      4|  }
  507|     86|  size_t converted_chars = ret.second - utf32_output;
  508|     86|  if (ret.first != buf + len) {
  ------------------
  |  Branch (508:7): [True: 70, False: 16]
  ------------------
  509|     70|    const size_t scalar_converted_chars = scalar::latin1_to_utf32::convert(
  510|     70|        ret.first, len - (ret.first - buf), ret.second);
  511|     70|    if (scalar_converted_chars == 0) {
  ------------------
  |  Branch (511:9): [True: 0, False: 70]
  ------------------
  512|      0|      return 0;
  513|      0|    }
  514|     70|    converted_chars += scalar_converted_chars;
  515|     70|  }
  516|     86|  return converted_chars;
  517|     86|}
_ZNK7simdutf8westmere14implementation22convert_utf8_to_latin1EPKcmPc:
  522|    562|    const char *buf, size_t len, char *latin1_output) const noexcept {
  523|    562|  utf8_to_latin1::validating_transcoder converter;
  524|    562|  return converter.convert(buf, len, latin1_output);
  525|    562|}
_ZNK7simdutf8westmere14implementation34convert_utf8_to_latin1_with_errorsEPKcmPc:
  528|    516|    const char *buf, size_t len, char *latin1_output) const noexcept {
  529|    516|  utf8_to_latin1::validating_transcoder converter;
  530|    516|  return converter.convert_with_errors(buf, len, latin1_output);
  531|    516|}
_ZNK7simdutf8westmere14implementation23convert_utf8_to_utf16leEPKcmPDs:
  541|    660|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  542|    660|  utf8_to_utf16::validating_transcoder converter;
  543|    660|  return converter.convert<endianness::LITTLE>(buf, len, utf16_output);
  544|    660|}
_ZNK7simdutf8westmere14implementation23convert_utf8_to_utf16beEPKcmPDs:
  547|    712|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  548|    712|  utf8_to_utf16::validating_transcoder converter;
  549|    712|  return converter.convert<endianness::BIG>(buf, len, utf16_output);
  550|    712|}
_ZNK7simdutf8westmere14implementation35convert_utf8_to_utf16le_with_errorsEPKcmPDs:
  553|    574|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  554|    574|  utf8_to_utf16::validating_transcoder converter;
  555|    574|  return converter.convert_with_errors<endianness::LITTLE>(buf, len,
  556|    574|                                                           utf16_output);
  557|    574|}
_ZNK7simdutf8westmere14implementation35convert_utf8_to_utf16be_with_errorsEPKcmPDs:
  560|    702|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  561|    702|  utf8_to_utf16::validating_transcoder converter;
  562|    702|  return converter.convert_with_errors<endianness::BIG>(buf, len, utf16_output);
  563|    702|}
_ZNK7simdutf8westmere14implementation29convert_valid_utf8_to_utf16leEPKcmPDs:
  566|    368|    const char *input, size_t size, char16_t *utf16_output) const noexcept {
  567|    368|  return utf8_to_utf16::convert_valid<endianness::LITTLE>(input, size,
  568|    368|                                                          utf16_output);
  569|    368|}
_ZNK7simdutf8westmere14implementation29convert_valid_utf8_to_utf16beEPKcmPDs:
  572|    438|    const char *input, size_t size, char16_t *utf16_output) const noexcept {
  573|    438|  return utf8_to_utf16::convert_valid<endianness::BIG>(input, size,
  574|    438|                                                       utf16_output);
  575|    438|}
_ZNK7simdutf8westmere14implementation21convert_utf8_to_utf32EPKcmPDi:
  580|    712|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  581|    712|  utf8_to_utf32::validating_transcoder converter;
  582|    712|  return converter.convert(buf, len, utf32_output);
  583|    712|}
_ZNK7simdutf8westmere14implementation33convert_utf8_to_utf32_with_errorsEPKcmPDi:
  586|    738|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  587|    738|  utf8_to_utf32::validating_transcoder converter;
  588|    738|  return converter.convert_with_errors(buf, len, utf32_output);
  589|    738|}
_ZNK7simdutf8westmere14implementation27convert_valid_utf8_to_utf32EPKcmPDi:
  592|    394|    const char *input, size_t size, char32_t *utf32_output) const noexcept {
  593|    394|  return utf8_to_utf32::convert_valid(input, size, utf32_output);
  594|    394|}
_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: 54, False: 70]
  ------------------
  603|     54|    return 0;
  604|     54|  }
  605|     70|  size_t saved_bytes = ret.second - latin1_output;
  606|       |
  607|     70|  if (ret.first != buf + len) {
  ------------------
  |  Branch (607:7): [True: 52, False: 18]
  ------------------
  608|     52|    const size_t scalar_saved_bytes =
  609|     52|        scalar::utf16_to_latin1::convert<endianness::LITTLE>(
  610|     52|            ret.first, len - (ret.first - buf), ret.second);
  611|     52|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (611:9): [True: 30, False: 22]
  ------------------
  612|     30|      return 0;
  613|     30|    }
  614|     22|    saved_bytes += scalar_saved_bytes;
  615|     22|  }
  616|     40|  return saved_bytes;
  617|     70|}
_ZNK7simdutf8westmere14implementation25convert_utf16be_to_latin1EPKDsmPc:
  620|    126|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  621|    126|  std::pair<const char16_t *, char *> ret =
  622|    126|      sse_convert_utf16_to_latin1<endianness::BIG>(buf, len, latin1_output);
  623|    126|  if (ret.first == nullptr) {
  ------------------
  |  Branch (623:7): [True: 38, False: 88]
  ------------------
  624|     38|    return 0;
  625|     38|  }
  626|     88|  size_t saved_bytes = ret.second - latin1_output;
  627|       |
  628|     88|  if (ret.first != buf + len) {
  ------------------
  |  Branch (628:7): [True: 70, False: 18]
  ------------------
  629|     70|    const size_t scalar_saved_bytes =
  630|     70|        scalar::utf16_to_latin1::convert<endianness::BIG>(
  631|     70|            ret.first, len - (ret.first - buf), ret.second);
  632|     70|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (632:9): [True: 24, False: 46]
  ------------------
  633|     24|      return 0;
  634|     24|    }
  635|     46|    saved_bytes += scalar_saved_bytes;
  636|     46|  }
  637|     64|  return saved_bytes;
  638|     88|}
_ZNK7simdutf8westmere14implementation37convert_utf16le_to_latin1_with_errorsEPKDsmPc:
  642|    230|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  643|    230|  std::pair<result, char *> ret =
  644|    230|      sse_convert_utf16_to_latin1_with_errors<endianness::LITTLE>(
  645|    230|          buf, len, latin1_output);
  646|    230|  if (ret.first.error) {
  ------------------
  |  Branch (646:7): [True: 128, False: 102]
  ------------------
  647|    128|    return ret.first;
  648|    128|  } // Can return directly since scalar fallback already found correct
  649|       |    // ret.first.count
  650|    102|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (650:7): [True: 64, False: 38]
  ------------------
  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: 20, False: 44]
  ------------------
  655|     20|      scalar_res.count += ret.first.count;
  656|     20|      return scalar_res;
  657|     44|    } else {
  658|     44|      ret.second += scalar_res.count;
  659|     44|    }
  660|     64|  }
  661|     82|  ret.first.count =
  662|     82|      ret.second -
  663|     82|      latin1_output; // Set count to the number of 8-bit code units written
  664|     82|  return ret.first;
  665|    102|}
_ZNK7simdutf8westmere14implementation37convert_utf16be_to_latin1_with_errorsEPKDsmPc:
  669|    252|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  670|    252|  std::pair<result, char *> ret =
  671|    252|      sse_convert_utf16_to_latin1_with_errors<endianness::BIG>(buf, len,
  672|    252|                                                               latin1_output);
  673|    252|  if (ret.first.error) {
  ------------------
  |  Branch (673:7): [True: 128, False: 124]
  ------------------
  674|    128|    return ret.first;
  675|    128|  } // 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: 28, False: 52]
  ------------------
  682|     28|      scalar_res.count += ret.first.count;
  683|     28|      return scalar_res;
  684|     52|    } else {
  685|     52|      ret.second += scalar_res.count;
  686|     52|    }
  687|     80|  }
  688|     96|  ret.first.count =
  689|     96|      ret.second -
  690|     96|      latin1_output; // Set count to the number of 8-bit code units written
  691|     96|  return ret.first;
  692|    124|}
_ZNK7simdutf8westmere14implementation23convert_utf16le_to_utf8EPKDsmPc:
  709|    802|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  710|    802|  std::pair<const char16_t *, char *> ret =
  711|    802|      sse_convert_utf16_to_utf8<endianness::LITTLE>(buf, len, utf8_output);
  712|    802|  if (ret.first == nullptr) {
  ------------------
  |  Branch (712:7): [True: 90, False: 712]
  ------------------
  713|     90|    return 0;
  714|     90|  }
  715|    712|  size_t saved_bytes = ret.second - utf8_output;
  716|    712|  if (ret.first != buf + len) {
  ------------------
  |  Branch (716:7): [True: 710, False: 2]
  ------------------
  717|    710|    const size_t scalar_saved_bytes =
  718|    710|        scalar::utf16_to_utf8::convert<endianness::LITTLE>(
  719|    710|            ret.first, len - (ret.first - buf), ret.second);
  720|    710|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (720:9): [True: 76, False: 634]
  ------------------
  721|     76|      return 0;
  722|     76|    }
  723|    634|    saved_bytes += scalar_saved_bytes;
  724|    634|  }
  725|    636|  return saved_bytes;
  726|    712|}
_ZNK7simdutf8westmere14implementation23convert_utf16be_to_utf8EPKDsmPc:
  729|    768|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  730|    768|  std::pair<const char16_t *, char *> ret =
  731|    768|      sse_convert_utf16_to_utf8<endianness::BIG>(buf, len, utf8_output);
  732|    768|  if (ret.first == nullptr) {
  ------------------
  |  Branch (732:7): [True: 82, False: 686]
  ------------------
  733|     82|    return 0;
  734|     82|  }
  735|    686|  size_t saved_bytes = ret.second - utf8_output;
  736|    686|  if (ret.first != buf + len) {
  ------------------
  |  Branch (736:7): [True: 684, False: 2]
  ------------------
  737|    684|    const size_t scalar_saved_bytes =
  738|    684|        scalar::utf16_to_utf8::convert<endianness::BIG>(
  739|    684|            ret.first, len - (ret.first - buf), ret.second);
  740|    684|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (740:9): [True: 54, False: 630]
  ------------------
  741|     54|      return 0;
  742|     54|    }
  743|    630|    saved_bytes += scalar_saved_bytes;
  744|    630|  }
  745|    632|  return saved_bytes;
  746|    686|}
_ZNK7simdutf8westmere14implementation35convert_utf16le_to_utf8_with_errorsEPKDsmPc:
  770|    630|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  771|    630|  return convert_utf16_to_utf8_with_details<endianness::LITTLE>(buf, len,
  772|    630|                                                                utf8_output);
  773|    630|}
_ZNK7simdutf8westmere14implementation35convert_utf16be_to_utf8_with_errorsEPKDsmPc:
  776|    586|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  777|    586|  return convert_utf16_to_utf8_with_details<endianness::BIG>(buf, len,
  778|    586|                                                             utf8_output);
  779|    586|}
_ZNK7simdutf8westmere14implementation29convert_valid_utf16le_to_utf8EPKDsmPc:
  782|    416|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  783|    416|  return convert_utf16le_to_utf8(buf, len, utf8_output);
  784|    416|}
_ZNK7simdutf8westmere14implementation29convert_valid_utf16be_to_utf8EPKDsmPc:
  787|    442|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  788|    442|  return convert_utf16be_to_utf8(buf, len, utf8_output);
  789|    442|}
_ZNK7simdutf8westmere14implementation23convert_utf32_to_latin1EPKDimPc:
  794|    188|    const char32_t *buf, size_t len, char *latin1_output) const noexcept {
  795|    188|  std::pair<const char32_t *, char *> ret =
  796|    188|      sse_convert_utf32_to_latin1(buf, len, latin1_output);
  797|    188|  if (ret.first == nullptr) {
  ------------------
  |  Branch (797:7): [True: 46, False: 142]
  ------------------
  798|     46|    return 0;
  799|     46|  }
  800|    142|  size_t saved_bytes = ret.second - latin1_output;
  801|       |  // if (ret.first != buf + len) {
  802|    142|  if (ret.first < buf + len) {
  ------------------
  |  Branch (802:7): [True: 126, False: 16]
  ------------------
  803|    126|    const size_t scalar_saved_bytes = scalar::utf32_to_latin1::convert(
  804|    126|        ret.first, len - (ret.first - buf), ret.second);
  805|    126|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (805:9): [True: 84, False: 42]
  ------------------
  806|     84|      return 0;
  807|     84|    }
  808|     42|    saved_bytes += scalar_saved_bytes;
  809|     42|  }
  810|     58|  return saved_bytes;
  811|    142|}
_ZNK7simdutf8westmere14implementation35convert_utf32_to_latin1_with_errorsEPKDimPc:
  814|    420|    const char32_t *buf, size_t len, char *latin1_output) const noexcept {
  815|       |  // ret.first.count is always the position in the buffer, not the number of
  816|       |  // code units written even if finished
  817|    420|  std::pair<result, char *> ret =
  818|    420|      westmere::sse_convert_utf32_to_latin1_with_errors(buf, len,
  819|    420|                                                        latin1_output);
  820|    420|  if (ret.first.count != len) {
  ------------------
  |  Branch (820:7): [True: 396, False: 24]
  ------------------
  821|    396|    result scalar_res = scalar::utf32_to_latin1::convert_with_errors(
  822|    396|        buf + ret.first.count, len - ret.first.count, ret.second);
  823|    396|    if (scalar_res.error) {
  ------------------
  |  Branch (823:9): [True: 370, False: 26]
  ------------------
  824|    370|      scalar_res.count += ret.first.count;
  825|    370|      return scalar_res;
  826|    370|    } else {
  827|     26|      ret.second += scalar_res.count;
  828|     26|    }
  829|    396|  }
  830|     50|  ret.first.count =
  831|     50|      ret.second -
  832|     50|      latin1_output; // Set count to the number of 8-bit code units written
  833|     50|  return ret.first;
  834|    420|}
_ZNK7simdutf8westmere14implementation21convert_utf32_to_utf8EPKDimPc:
  845|    796|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  846|    796|  std::pair<const char32_t *, char *> ret =
  847|    796|      sse_convert_utf32_to_utf8(buf, len, utf8_output);
  848|    796|  if (ret.first == nullptr) {
  ------------------
  |  Branch (848:7): [True: 244, False: 552]
  ------------------
  849|    244|    return 0;
  850|    244|  }
  851|    552|  size_t saved_bytes = ret.second - utf8_output;
  852|    552|  if (ret.first != buf + len) {
  ------------------
  |  Branch (852:7): [True: 550, False: 2]
  ------------------
  853|    550|    const size_t scalar_saved_bytes = scalar::utf32_to_utf8::convert(
  854|    550|        ret.first, len - (ret.first - buf), ret.second);
  855|    550|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (855:9): [True: 260, False: 290]
  ------------------
  856|    260|      return 0;
  857|    260|    }
  858|    290|    saved_bytes += scalar_saved_bytes;
  859|    290|  }
  860|    292|  return saved_bytes;
  861|    552|}
_ZNK7simdutf8westmere14implementation33convert_utf32_to_utf8_with_errorsEPKDimPc:
  864|    830|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  865|       |  // ret.first.count is always the position in the buffer, not the number of
  866|       |  // code units written even if finished
  867|    830|  std::pair<result, char *> ret =
  868|    830|      westmere::sse_convert_utf32_to_utf8_with_errors(buf, len, utf8_output);
  869|    830|  if (ret.first.count != len) {
  ------------------
  |  Branch (869:7): [True: 826, False: 4]
  ------------------
  870|    826|    result scalar_res = scalar::utf32_to_utf8::convert_with_errors(
  871|    826|        buf + ret.first.count, len - ret.first.count, ret.second);
  872|    826|    if (scalar_res.error) {
  ------------------
  |  Branch (872:9): [True: 632, False: 194]
  ------------------
  873|    632|      scalar_res.count += ret.first.count;
  874|    632|      return scalar_res;
  875|    632|    } else {
  876|    194|      ret.second += scalar_res.count;
  877|    194|    }
  878|    826|  }
  879|    198|  ret.first.count =
  880|    198|      ret.second -
  881|    198|      utf8_output; // Set count to the number of 8-bit code units written
  882|    198|  return ret.first;
  883|    830|}
_ZNK7simdutf8westmere14implementation24convert_utf16le_to_utf32EPKDsmPDi:
  888|    384|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  889|    384|  std::pair<const char16_t *, char32_t *> ret =
  890|    384|      sse_convert_utf16_to_utf32<endianness::LITTLE>(buf, len, utf32_output);
  891|    384|  if (ret.first == nullptr) {
  ------------------
  |  Branch (891:7): [True: 118, False: 266]
  ------------------
  892|    118|    return 0;
  893|    118|  }
  894|    266|  size_t saved_bytes = ret.second - utf32_output;
  895|    266|  if (ret.first != buf + len) {
  ------------------
  |  Branch (895:7): [True: 202, False: 64]
  ------------------
  896|    202|    const size_t scalar_saved_bytes =
  897|    202|        scalar::utf16_to_utf32::convert<endianness::LITTLE>(
  898|    202|            ret.first, len - (ret.first - buf), ret.second);
  899|    202|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (899:9): [True: 58, False: 144]
  ------------------
  900|     58|      return 0;
  901|     58|    }
  902|    144|    saved_bytes += scalar_saved_bytes;
  903|    144|  }
  904|    208|  return saved_bytes;
  905|    266|}
_ZNK7simdutf8westmere14implementation24convert_utf16be_to_utf32EPKDsmPDi:
  908|    366|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  909|    366|  std::pair<const char16_t *, char32_t *> ret =
  910|    366|      sse_convert_utf16_to_utf32<endianness::BIG>(buf, len, utf32_output);
  911|    366|  if (ret.first == nullptr) {
  ------------------
  |  Branch (911:7): [True: 86, False: 280]
  ------------------
  912|     86|    return 0;
  913|     86|  }
  914|    280|  size_t saved_bytes = ret.second - utf32_output;
  915|    280|  if (ret.first != buf + len) {
  ------------------
  |  Branch (915:7): [True: 218, False: 62]
  ------------------
  916|    218|    const size_t scalar_saved_bytes =
  917|    218|        scalar::utf16_to_utf32::convert<endianness::BIG>(
  918|    218|            ret.first, len - (ret.first - buf), ret.second);
  919|    218|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (919:9): [True: 66, False: 152]
  ------------------
  920|     66|      return 0;
  921|     66|    }
  922|    152|    saved_bytes += scalar_saved_bytes;
  923|    152|  }
  924|    214|  return saved_bytes;
  925|    280|}
_ZNK7simdutf8westmere14implementation36convert_utf16le_to_utf32_with_errorsEPKDsmPDi:
  928|    414|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  929|       |  // ret.first.count is always the position in the buffer, not the number of
  930|       |  // code units written even if finished
  931|    414|  std::pair<result, char32_t *> ret =
  932|    414|      westmere::sse_convert_utf16_to_utf32_with_errors<endianness::LITTLE>(
  933|    414|          buf, len, utf32_output);
  934|    414|  if (ret.first.error) {
  ------------------
  |  Branch (934:7): [True: 148, False: 266]
  ------------------
  935|    148|    return ret.first;
  936|    148|  } // Can return directly since scalar fallback already found correct
  937|       |    // ret.first.count
  938|    266|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (938:7): [True: 218, False: 48]
  ------------------
  939|    218|    result scalar_res =
  940|    218|        scalar::utf16_to_utf32::convert_with_errors<endianness::LITTLE>(
  941|    218|            buf + ret.first.count, len - ret.first.count, ret.second);
  942|    218|    if (scalar_res.error) {
  ------------------
  |  Branch (942:9): [True: 76, False: 142]
  ------------------
  943|     76|      scalar_res.count += ret.first.count;
  944|     76|      return scalar_res;
  945|    142|    } else {
  946|    142|      ret.second += scalar_res.count;
  947|    142|    }
  948|    218|  }
  949|    190|  ret.first.count =
  950|    190|      ret.second -
  951|    190|      utf32_output; // Set count to the number of 8-bit code units written
  952|    190|  return ret.first;
  953|    266|}
_ZNK7simdutf8westmere14implementation36convert_utf16be_to_utf32_with_errorsEPKDsmPDi:
  956|    300|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  957|       |  // ret.first.count is always the position in the buffer, not the number of
  958|       |  // code units written even if finished
  959|    300|  std::pair<result, char32_t *> ret =
  960|    300|      westmere::sse_convert_utf16_to_utf32_with_errors<endianness::BIG>(
  961|    300|          buf, len, utf32_output);
  962|    300|  if (ret.first.error) {
  ------------------
  |  Branch (962:7): [True: 76, False: 224]
  ------------------
  963|     76|    return ret.first;
  964|     76|  } // Can return directly since scalar fallback already found correct
  965|       |    // ret.first.count
  966|    224|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (966:7): [True: 186, False: 38]
  ------------------
  967|    186|    result scalar_res =
  968|    186|        scalar::utf16_to_utf32::convert_with_errors<endianness::BIG>(
  969|    186|            buf + ret.first.count, len - ret.first.count, ret.second);
  970|    186|    if (scalar_res.error) {
  ------------------
  |  Branch (970:9): [True: 64, False: 122]
  ------------------
  971|     64|      scalar_res.count += ret.first.count;
  972|     64|      return scalar_res;
  973|    122|    } else {
  974|    122|      ret.second += scalar_res.count;
  975|    122|    }
  976|    186|  }
  977|    160|  ret.first.count =
  978|    160|      ret.second -
  979|    160|      utf32_output; // Set count to the number of 8-bit code units written
  980|    160|  return ret.first;
  981|    224|}
_ZNK7simdutf8westmere14implementation27convert_valid_utf32_to_utf8EPKDimPc:
  986|    192|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  987|    192|  return convert_utf32_to_utf8(buf, len, utf8_output);
  988|    192|}
_ZNK7simdutf8westmere14implementation24convert_utf32_to_utf16leEPKDimPDs:
  993|    722|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  994|    722|  std::pair<const char32_t *, char16_t *> ret =
  995|    722|      sse_convert_utf32_to_utf16<endianness::LITTLE>(buf, len, utf16_output);
  996|    722|  if (ret.first == nullptr) {
  ------------------
  |  Branch (996:7): [True: 52, False: 670]
  ------------------
  997|     52|    return 0;
  998|     52|  }
  999|    670|  size_t saved_bytes = ret.second - utf16_output;
 1000|    670|  if (ret.first != buf + len) {
  ------------------
  |  Branch (1000:7): [True: 666, False: 4]
  ------------------
 1001|    666|    const size_t scalar_saved_bytes =
 1002|    666|        scalar::utf32_to_utf16::convert<endianness::LITTLE>(
 1003|    666|            ret.first, len - (ret.first - buf), ret.second);
 1004|    666|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (1004:9): [True: 234, False: 432]
  ------------------
 1005|    234|      return 0;
 1006|    234|    }
 1007|    432|    saved_bytes += scalar_saved_bytes;
 1008|    432|  }
 1009|    436|  return saved_bytes;
 1010|    670|}
_ZNK7simdutf8westmere14implementation24convert_utf32_to_utf16beEPKDimPDs:
 1013|    528|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1014|    528|  std::pair<const char32_t *, char16_t *> ret =
 1015|    528|      sse_convert_utf32_to_utf16<endianness::BIG>(buf, len, utf16_output);
 1016|    528|  if (ret.first == nullptr) {
  ------------------
  |  Branch (1016:7): [True: 44, False: 484]
  ------------------
 1017|     44|    return 0;
 1018|     44|  }
 1019|    484|  size_t saved_bytes = ret.second - utf16_output;
 1020|    484|  if (ret.first != buf + len) {
  ------------------
  |  Branch (1020:7): [True: 482, False: 2]
  ------------------
 1021|    482|    const size_t scalar_saved_bytes =
 1022|    482|        scalar::utf32_to_utf16::convert<endianness::BIG>(
 1023|    482|            ret.first, len - (ret.first - buf), ret.second);
 1024|    482|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (1024:9): [True: 288, False: 194]
  ------------------
 1025|    288|      return 0;
 1026|    288|    }
 1027|    194|    saved_bytes += scalar_saved_bytes;
 1028|    194|  }
 1029|    196|  return saved_bytes;
 1030|    484|}
_ZNK7simdutf8westmere14implementation36convert_utf32_to_utf16le_with_errorsEPKDimPDs:
 1033|    716|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1034|       |  // ret.first.count is always the position in the buffer, not the number of
 1035|       |  // code units written even if finished
 1036|    716|  std::pair<result, char16_t *> ret =
 1037|    716|      westmere::sse_convert_utf32_to_utf16_with_errors<endianness::LITTLE>(
 1038|    716|          buf, len, utf16_output);
 1039|    716|  if (ret.first.count != len) {
  ------------------
  |  Branch (1039:7): [True: 692, False: 24]
  ------------------
 1040|    692|    result scalar_res =
 1041|    692|        scalar::utf32_to_utf16::convert_with_errors<endianness::LITTLE>(
 1042|    692|            buf + ret.first.count, len - ret.first.count, ret.second);
 1043|    692|    if (scalar_res.error) {
  ------------------
  |  Branch (1043:9): [True: 530, False: 162]
  ------------------
 1044|    530|      scalar_res.count += ret.first.count;
 1045|    530|      return scalar_res;
 1046|    530|    } else {
 1047|    162|      ret.second += scalar_res.count;
 1048|    162|    }
 1049|    692|  }
 1050|    186|  ret.first.count =
 1051|    186|      ret.second -
 1052|    186|      utf16_output; // Set count to the number of 8-bit code units written
 1053|    186|  return ret.first;
 1054|    716|}
_ZNK7simdutf8westmere14implementation36convert_utf32_to_utf16be_with_errorsEPKDimPDs:
 1057|    606|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1058|       |  // ret.first.count is always the position in the buffer, not the number of
 1059|       |  // code units written even if finished
 1060|    606|  std::pair<result, char16_t *> ret =
 1061|    606|      westmere::sse_convert_utf32_to_utf16_with_errors<endianness::BIG>(
 1062|    606|          buf, len, utf16_output);
 1063|    606|  if (ret.first.count != len) {
  ------------------
  |  Branch (1063:7): [True: 584, False: 22]
  ------------------
 1064|    584|    result scalar_res =
 1065|    584|        scalar::utf32_to_utf16::convert_with_errors<endianness::BIG>(
 1066|    584|            buf + ret.first.count, len - ret.first.count, ret.second);
 1067|    584|    if (scalar_res.error) {
  ------------------
  |  Branch (1067:9): [True: 434, False: 150]
  ------------------
 1068|    434|      scalar_res.count += ret.first.count;
 1069|    434|      return scalar_res;
 1070|    434|    } else {
 1071|    150|      ret.second += scalar_res.count;
 1072|    150|    }
 1073|    584|  }
 1074|    172|  ret.first.count =
 1075|    172|      ret.second -
 1076|    172|      utf16_output; // Set count to the number of 8-bit code units written
 1077|    172|  return ret.first;
 1078|    606|}
_ZNK7simdutf8westmere14implementation30convert_valid_utf32_to_utf16leEPKDimPDs:
 1081|    290|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1082|    290|  return convert_utf32_to_utf16le(buf, len, utf16_output);
 1083|    290|}
_ZNK7simdutf8westmere14implementation30convert_valid_utf32_to_utf16beEPKDimPDs:
 1086|     86|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1087|     86|  return convert_utf32_to_utf16be(buf, len, utf16_output);
 1088|     86|}
_ZNK7simdutf8westmere14implementation30convert_valid_utf16le_to_utf32EPKDsmPDi:
 1091|    112|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
 1092|    112|  return convert_utf16le_to_utf32(buf, len, utf32_output);
 1093|    112|}
_ZNK7simdutf8westmere14implementation30convert_valid_utf16be_to_utf32EPKDsmPDi:
 1096|    140|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
 1097|    140|  return convert_utf16be_to_utf32(buf, len, utf32_output);
 1098|    140|}
_ZNK7simdutf8westmere14implementation13count_utf16leEPKDsm:
 1109|  1.30k|    const char16_t *input, size_t length) const noexcept {
 1110|  1.30k|  return utf16::count_code_points<endianness::LITTLE>(input, length);
 1111|  1.30k|}
_ZNK7simdutf8westmere14implementation13count_utf16beEPKDsm:
 1114|  1.23k|    const char16_t *input, size_t length) const noexcept {
 1115|  1.23k|  return utf16::count_code_points<endianness::BIG>(input, length);
 1116|  1.23k|}
_ZNK7simdutf8westmere14implementation10count_utf8EPKcm:
 1121|  3.76k|implementation::count_utf8(const char *input, size_t length) const noexcept {
 1122|  3.76k|  return utf8::count_code_points_bytemask(input, length);
 1123|  3.76k|}
_ZNK7simdutf8westmere14implementation23latin1_length_from_utf8EPKcm:
 1128|    539|    const char *buf, size_t len) const noexcept {
 1129|    539|  return count_utf8(buf, len);
 1130|    539|}
_ZNK7simdutf8westmere14implementation24utf8_length_from_utf16leEPKDsm:
 1135|    727|    const char16_t *input, size_t length) const noexcept {
 1136|    727|  return utf16::utf8_length_from_utf16_bytemask<endianness::LITTLE>(input,
 1137|    727|                                                                    length);
 1138|    727|}
_ZNK7simdutf8westmere14implementation24utf8_length_from_utf16beEPKDsm:
 1141|    696|    const char16_t *input, size_t length) const noexcept {
 1142|    696|  return utf16::utf8_length_from_utf16_bytemask<endianness::BIG>(input, length);
 1143|    696|}
_ZNK7simdutf8westmere14implementation23utf8_length_from_latin1EPKcm:
 1148|    269|    const char *input, size_t len) const noexcept {
 1149|    269|  const uint8_t *str = reinterpret_cast<const uint8_t *>(input);
 1150|    269|  size_t answer = len / sizeof(__m128i) * sizeof(__m128i);
 1151|    269|  size_t i = 0;
 1152|    269|  if (answer >= 2048) { // long strings optimization
  ------------------
  |  Branch (1152:7): [True: 118, False: 151]
  ------------------
 1153|    118|    __m128i two_64bits = _mm_setzero_si128();
 1154|  5.04k|    while (i + sizeof(__m128i) <= len) {
  ------------------
  |  Branch (1154:12): [True: 4.92k, False: 118]
  ------------------
 1155|  4.92k|      __m128i runner = _mm_setzero_si128();
 1156|  4.92k|      size_t iterations = (len - i) / sizeof(__m128i);
 1157|  4.92k|      if (iterations > 255) {
  ------------------
  |  Branch (1157:11): [True: 4.81k, False: 118]
  ------------------
 1158|  4.81k|        iterations = 255;
 1159|  4.81k|      }
 1160|  4.92k|      size_t max_i = i + iterations * sizeof(__m128i) - sizeof(__m128i);
 1161|   309k|      for (; i + 4 * sizeof(__m128i) <= max_i; i += 4 * sizeof(__m128i)) {
  ------------------
  |  Branch (1161:14): [True: 304k, False: 4.92k]
  ------------------
 1162|   304k|        __m128i input1 = _mm_loadu_si128((const __m128i *)(str + i));
 1163|   304k|        __m128i input2 =
 1164|   304k|            _mm_loadu_si128((const __m128i *)(str + i + sizeof(__m128i)));
 1165|   304k|        __m128i input3 =
 1166|   304k|            _mm_loadu_si128((const __m128i *)(str + i + 2 * sizeof(__m128i)));
 1167|   304k|        __m128i input4 =
 1168|   304k|            _mm_loadu_si128((const __m128i *)(str + i + 3 * sizeof(__m128i)));
 1169|   304k|        __m128i input12 =
 1170|   304k|            _mm_add_epi8(_mm_cmpgt_epi8(_mm_setzero_si128(), input1),
 1171|   304k|                         _mm_cmpgt_epi8(_mm_setzero_si128(), input2));
 1172|   304k|        __m128i input34 =
 1173|   304k|            _mm_add_epi8(_mm_cmpgt_epi8(_mm_setzero_si128(), input3),
 1174|   304k|                         _mm_cmpgt_epi8(_mm_setzero_si128(), input4));
 1175|   304k|        __m128i input1234 = _mm_add_epi8(input12, input34);
 1176|   304k|        runner = _mm_sub_epi8(runner, input1234);
 1177|   304k|      }
 1178|  19.6k|      for (; i <= max_i; i += sizeof(__m128i)) {
  ------------------
  |  Branch (1178:14): [True: 14.6k, False: 4.92k]
  ------------------
 1179|  14.6k|        __m128i more_input = _mm_loadu_si128((const __m128i *)(str + i));
 1180|  14.6k|        runner = _mm_sub_epi8(runner,
 1181|  14.6k|                              _mm_cmpgt_epi8(_mm_setzero_si128(), more_input));
 1182|  14.6k|      }
 1183|  4.92k|      two_64bits =
 1184|  4.92k|          _mm_add_epi64(two_64bits, _mm_sad_epu8(runner, _mm_setzero_si128()));
 1185|  4.92k|    }
 1186|    118|    answer +=
 1187|    118|        _mm_extract_epi64(two_64bits, 0) + _mm_extract_epi64(two_64bits, 1);
 1188|    151|  } else if (answer > 0) { // short string optimization
  ------------------
  |  Branch (1188:14): [True: 101, False: 50]
  ------------------
 1189|  1.38k|    for (; i + 2 * sizeof(__m128i) <= len; i += 2 * sizeof(__m128i)) {
  ------------------
  |  Branch (1189:12): [True: 1.28k, False: 101]
  ------------------
 1190|  1.28k|      __m128i latin = _mm_loadu_si128((const __m128i *)(input + i));
 1191|  1.28k|      uint16_t non_ascii = (uint16_t)_mm_movemask_epi8(latin);
 1192|  1.28k|      answer += count_ones(non_ascii);
 1193|  1.28k|      latin = _mm_loadu_si128((const __m128i *)(input + i) + 1);
 1194|  1.28k|      non_ascii = (uint16_t)_mm_movemask_epi8(latin);
 1195|  1.28k|      answer += count_ones(non_ascii);
 1196|  1.28k|    }
 1197|    151|    for (; i + sizeof(__m128i) <= len; i += sizeof(__m128i)) {
  ------------------
  |  Branch (1197:12): [True: 50, False: 101]
  ------------------
 1198|     50|      __m128i latin = _mm_loadu_si128((const __m128i *)(input + i));
 1199|     50|      uint16_t non_ascii = (uint16_t)_mm_movemask_epi8(latin);
 1200|     50|      answer += count_ones(non_ascii);
 1201|     50|    }
 1202|    101|  }
 1203|    269|  return answer + scalar::latin1::utf8_length_from_latin1(
 1204|    269|                      reinterpret_cast<const char *>(str + i), len - i);
 1205|    269|}
_ZNK7simdutf8westmere14implementation25utf32_length_from_utf16leEPKDsm:
 1210|    404|    const char16_t *input, size_t length) const noexcept {
 1211|    404|  return utf16::utf32_length_from_utf16<endianness::LITTLE>(input, length);
 1212|    404|}
_ZNK7simdutf8westmere14implementation25utf32_length_from_utf16beEPKDsm:
 1215|    351|    const char16_t *input, size_t length) const noexcept {
 1216|    351|  return utf16::utf32_length_from_utf16<endianness::BIG>(input, length);
 1217|    351|}
_ZNK7simdutf8westmere14implementation22utf16_length_from_utf8EPKcm:
 1222|  1.74k|    const char *input, size_t length) const noexcept {
 1223|  1.74k|  return utf8::utf16_length_from_utf8_bytemask(input, length);
 1224|  1.74k|}
_ZNK7simdutf8westmere14implementation22utf8_length_from_utf32EPKDim:
 1263|    819|    const char32_t *input, size_t length) const noexcept {
 1264|    819|  return utf32::utf8_length_from_utf32(input, length);
 1265|    819|}
_ZNK7simdutf8westmere14implementation23utf16_length_from_utf32EPKDim:
 1270|  1.29k|    const char32_t *input, size_t length) const noexcept {
 1271|  1.29k|  const __m128i v_00000000 = _mm_setzero_si128();
 1272|  1.29k|  const __m128i v_ffff0000 = _mm_set1_epi32((uint32_t)0xffff0000);
 1273|  1.29k|  size_t pos = 0;
 1274|  1.29k|  size_t count = 0;
 1275|  1.34M|  for (; pos + 4 <= length; pos += 4) {
  ------------------
  |  Branch (1275:10): [True: 1.34M, False: 1.29k]
  ------------------
 1276|  1.34M|    __m128i in = _mm_loadu_si128((__m128i *)(input + pos));
 1277|  1.34M|    const __m128i surrogate_bytemask =
 1278|  1.34M|        _mm_cmpeq_epi32(_mm_and_si128(in, v_ffff0000), v_00000000);
 1279|  1.34M|    const uint16_t surrogate_bitmask =
 1280|  1.34M|        static_cast<uint16_t>(_mm_movemask_epi8(surrogate_bytemask));
 1281|  1.34M|    size_t surrogate_count = (16 - count_ones(surrogate_bitmask)) / 4;
 1282|  1.34M|    count += 4 + surrogate_count;
 1283|  1.34M|  }
 1284|  1.29k|  return count +
 1285|  1.29k|         scalar::utf32::utf16_length_from_utf32(input + pos, length - pos);
 1286|  1.29k|}
_ZNK7simdutf8westmere14implementation22utf32_length_from_utf8EPKcm:
 1291|    933|    const char *input, size_t length) const noexcept {
 1292|    933|  return utf8::count_code_points(input, length);
 1293|    933|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_18is_asciiERKNS1_4simd8simd8x64IhEE:
   13|  4.64M|simdutf_really_inline bool is_ascii(const simd8x64<uint8_t> &input) {
   14|  4.64M|  return input.reduce_or().is_ascii();
   15|  4.64M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_124must_be_2_3_continuationENS1_4simd5simd8IhEES4_:
   22|  6.40M|                         const simd8<uint8_t> prev3) {
   23|  6.40M|  simd8<uint8_t> is_third_byte =
   24|  6.40M|      prev2.saturating_sub(0xe0u - 0x80); // Only 111_____ will be >= 0x80
   25|  6.40M|  simd8<uint8_t> is_fourth_byte =
   26|  6.40M|      prev3.saturating_sub(0xf0u - 0x80); // Only 1111____ will be >= 0x80
   27|  6.40M|  return simd8<bool>(is_third_byte | is_fourth_byte);
   28|  6.40M|}
_ZN7simdutf8westmere34convert_utf16_to_utf8_with_detailsILNS_10endiannessE0EEENS_11full_resultEPKDsmPc:
  750|    630|    const char16_t *buf, size_t len, char *utf8_output) {
  751|    630|  std::pair<result, char *> ret =
  752|    630|      westmere::sse_convert_utf16_to_utf8_with_errors<big_endian>(buf, len,
  753|    630|                                                                  utf8_output);
  754|    630|  if (ret.first.error) {
  ------------------
  |  Branch (754:7): [True: 112, False: 518]
  ------------------
  755|    112|    return full_result(ret.first.error, ret.first.count,
  756|    112|                       size_t(ret.second - utf8_output));
  757|    112|  }
  758|    518|  if (ret.first.count != len) {
  ------------------
  |  Branch (758:7): [True: 514, False: 4]
  ------------------
  759|    514|    full_result sres =
  760|    514|        scalar::utf16_to_utf8::convert_with_errors<big_endian, false>(
  761|    514|            buf + ret.first.count, len - ret.first.count, ret.second, 0);
  762|    514|    return full_result(sres.error, ret.first.count + sres.input_count,
  763|    514|                       size_t(ret.second - utf8_output) + sres.output_count);
  764|    514|  }
  765|      4|  return full_result(error_code::SUCCESS, len,
  766|      4|                     size_t(ret.second - utf8_output));
  767|    518|}
_ZN7simdutf8westmere34convert_utf16_to_utf8_with_detailsILNS_10endiannessE1EEENS_11full_resultEPKDsmPc:
  750|    586|    const char16_t *buf, size_t len, char *utf8_output) {
  751|    586|  std::pair<result, char *> ret =
  752|    586|      westmere::sse_convert_utf16_to_utf8_with_errors<big_endian>(buf, len,
  753|    586|                                                                  utf8_output);
  754|    586|  if (ret.first.error) {
  ------------------
  |  Branch (754:7): [True: 142, False: 444]
  ------------------
  755|    142|    return full_result(ret.first.error, ret.first.count,
  756|    142|                       size_t(ret.second - utf8_output));
  757|    142|  }
  758|    444|  if (ret.first.count != len) {
  ------------------
  |  Branch (758:7): [True: 440, False: 4]
  ------------------
  759|    440|    full_result sres =
  760|    440|        scalar::utf16_to_utf8::convert_with_errors<big_endian, false>(
  761|    440|            buf + ret.first.count, len - ret.first.count, ret.second, 0);
  762|    440|    return full_result(sres.error, ret.first.count + sres.input_count,
  763|    440|                       size_t(ret.second - utf8_output) + sres.output_count);
  764|    440|  }
  765|      4|  return full_result(error_code::SUCCESS, len,
  766|      4|                     size_t(ret.second - utf8_output));
  767|    444|}

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

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

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

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

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|  39.1k|  while (end - buf >= 8) {
  ------------------
  |  Branch (6:10): [True: 39.1k, False: 74]
  ------------------
    7|       |    // Load 8 UTF-16 characters into 128-bit SSE register
    8|  39.1k|    __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|  39.1k|    __m128i high_byte_mask = _mm_set1_epi16((int16_t)0xFF00);
   17|  39.1k|    if (_mm_testz_si128(in, high_byte_mask)) {
  ------------------
  |  Branch (17:9): [True: 39.0k, False: 50]
  ------------------
   18|       |      // Pack 16-bit characters into 8-bit and store in latin1_output
   19|  39.0k|      __m128i latin1_packed = _mm_packus_epi16(in, in);
   20|  39.0k|      _mm_storel_epi64(reinterpret_cast<__m128i *>(latin1_output),
   21|  39.0k|                       latin1_packed);
   22|       |      // Adjust pointers for next iteration
   23|  39.0k|      buf += 8;
   24|  39.0k|      latin1_output += 8;
   25|  39.0k|    } else {
   26|     50|      return std::make_pair(nullptr, reinterpret_cast<char *>(latin1_output));
   27|     50|    }
   28|  39.1k|  } // while
   29|     74|  return std::make_pair(buf, latin1_output);
   30|    124|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_127sse_convert_utf16_to_latin1ILNS_10endiannessE1EEENSt3__14pairIPKDsPcEES7_mS8_:
    4|    126|                            char *latin1_output) {
    5|    126|  const char16_t *end = buf + len;
    6|  69.3k|  while (end - buf >= 8) {
  ------------------
  |  Branch (6:10): [True: 69.2k, False: 92]
  ------------------
    7|       |    // Load 8 UTF-16 characters into 128-bit SSE register
    8|  69.2k|    __m128i in = _mm_loadu_si128(reinterpret_cast<const __m128i *>(buf));
    9|       |
   10|  69.2k|    if constexpr (!match_system(big_endian)) {
   11|  69.2k|      const __m128i swap =
   12|  69.2k|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   13|  69.2k|      in = _mm_shuffle_epi8(in, swap);
   14|  69.2k|    }
   15|       |
   16|  69.2k|    __m128i high_byte_mask = _mm_set1_epi16((int16_t)0xFF00);
   17|  69.2k|    if (_mm_testz_si128(in, high_byte_mask)) {
  ------------------
  |  Branch (17:9): [True: 69.2k, False: 34]
  ------------------
   18|       |      // Pack 16-bit characters into 8-bit and store in latin1_output
   19|  69.2k|      __m128i latin1_packed = _mm_packus_epi16(in, in);
   20|  69.2k|      _mm_storel_epi64(reinterpret_cast<__m128i *>(latin1_output),
   21|  69.2k|                       latin1_packed);
   22|       |      // Adjust pointers for next iteration
   23|  69.2k|      buf += 8;
   24|  69.2k|      latin1_output += 8;
   25|  69.2k|    } else {
   26|     34|      return std::make_pair(nullptr, reinterpret_cast<char *>(latin1_output));
   27|     34|    }
   28|  69.2k|  } // while
   29|     92|  return std::make_pair(buf, latin1_output);
   30|    126|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_139sse_convert_utf16_to_latin1_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
   35|    230|                                        char *latin1_output) {
   36|    230|  const char16_t *start = buf;
   37|    230|  const char16_t *end = buf + len;
   38|   903k|  while (end - buf >= 8) {
  ------------------
  |  Branch (38:10): [True: 903k, False: 102]
  ------------------
   39|   903k|    __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|   903k|    __m128i high_byte_mask = _mm_set1_epi16((int16_t)0xFF00);
   48|   903k|    if (_mm_testz_si128(in, high_byte_mask)) {
  ------------------
  |  Branch (48:9): [True: 903k, False: 128]
  ------------------
   49|   903k|      __m128i latin1_packed = _mm_packus_epi16(in, in);
   50|   903k|      _mm_storel_epi64(reinterpret_cast<__m128i *>(latin1_output),
   51|   903k|                       latin1_packed);
   52|   903k|      buf += 8;
   53|   903k|      latin1_output += 8;
   54|   903k|    } else {
   55|       |      // Fallback to scalar code for handling errors
   56|    458|      for (int k = 0; k < 8; k++) {
  ------------------
  |  Branch (56:23): [True: 458, False: 0]
  ------------------
   57|    458|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
   58|    458|        if (word <= 0xff) {
  ------------------
  |  Branch (58:13): [True: 330, False: 128]
  ------------------
   59|    330|          *latin1_output++ = char(word);
   60|    330|        } else {
   61|    128|          return std::make_pair(result(error_code::TOO_LARGE, buf - start + k),
   62|    128|                                latin1_output);
   63|    128|        }
   64|    458|      }
   65|      0|      buf += 8;
   66|      0|    }
   67|   903k|  } // while
   68|    102|  return std::make_pair(result(error_code::SUCCESS, buf - start),
   69|    102|                        latin1_output);
   70|    230|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_139sse_convert_utf16_to_latin1_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
   35|    252|                                        char *latin1_output) {
   36|    252|  const char16_t *start = buf;
   37|    252|  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: 128]
  ------------------
   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|    448|      for (int k = 0; k < 8; k++) {
  ------------------
  |  Branch (56:23): [True: 448, False: 0]
  ------------------
   57|    448|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
   58|    448|        if (word <= 0xff) {
  ------------------
  |  Branch (58:13): [True: 320, False: 128]
  ------------------
   59|    320|          *latin1_output++ = char(word);
   60|    320|        } else {
   61|    128|          return std::make_pair(result(error_code::TOO_LARGE, buf - start + k),
   62|    128|                                latin1_output);
   63|    128|        }
   64|    448|      }
   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|    252|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_utf16_to_utf32ILNS_10endiannessE0EEENSt3__14pairIPKDsPDiEES7_mS8_:
   57|    384|                           char32_t *utf32_output) {
   58|    384|  const char16_t *end = buf + len;
   59|       |
   60|    384|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
   61|    384|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
   62|       |
   63|   321k|  while (end - buf >= 8) {
  ------------------
  |  Branch (63:10): [True: 320k, False: 272]
  ------------------
   64|   320k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   65|       |
   66|   320k|    if (big_endian) {
  ------------------
  |  Branch (66:9): [Folded, False: 320k]
  ------------------
   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|   320k|    const __m128i surrogates_bytemask =
   76|   320k|        _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|   320k|    const uint16_t surrogates_bitmask =
   81|   320k|        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|   320k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (84:9): [True: 316k, False: 3.82k]
  ------------------
   85|       |      // case: no surrogate pair, extend 16-bit code units to 32-bit code units
   86|   316k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
   87|   316k|                       _mm_cvtepu16_epi32(in));
   88|   316k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
   89|   316k|                       _mm_cvtepu16_epi32(_mm_srli_si128(in, 8)));
   90|   316k|      utf32_output += 8;
   91|   316k|      buf += 8;
   92|       |      // surrogate pair(s) in a register
   93|   316k|    } 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|  3.82k|      size_t forward = 15;
   98|  3.82k|      size_t k = 0;
   99|  3.82k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (99:11): [True: 70, False: 3.75k]
  ------------------
  100|     70|        forward = size_t(end - buf - 1);
  101|     70|      }
  102|  55.0k|      for (; k < forward; k++) {
  ------------------
  |  Branch (102:14): [True: 51.3k, False: 3.71k]
  ------------------
  103|  51.3k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  104|  51.3k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (104:13): [True: 46.3k, False: 4.96k]
  ------------------
  105|  46.3k|          *utf32_output++ = char32_t(word);
  106|  46.3k|        } else {
  107|       |          // must be a surrogate pair
  108|  4.96k|          uint16_t diff = uint16_t(word - 0xD800);
  109|  4.96k|          uint16_t next_word =
  110|  4.96k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  111|  4.96k|          k++;
  112|  4.96k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  113|  4.96k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (113:15): [True: 112, False: 4.84k]
  ------------------
  114|    112|            return std::make_pair(nullptr, utf32_output);
  115|    112|          }
  116|  4.84k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  117|  4.84k|          *utf32_output++ = char32_t(value);
  118|  4.84k|        }
  119|  51.3k|      }
  120|  3.71k|      buf += k;
  121|  3.71k|    }
  122|   320k|  } // while
  123|    272|  return std::make_pair(buf, utf32_output);
  124|    384|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_utf16_to_utf32ILNS_10endiannessE1EEENSt3__14pairIPKDsPDiEES7_mS8_:
   57|    366|                           char32_t *utf32_output) {
   58|    366|  const char16_t *end = buf + len;
   59|       |
   60|    366|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
   61|    366|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
   62|       |
   63|   643k|  while (end - buf >= 8) {
  ------------------
  |  Branch (63:10): [True: 642k, False: 284]
  ------------------
   64|   642k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   65|       |
   66|   642k|    if (big_endian) {
  ------------------
  |  Branch (66:9): [True: 642k, Folded]
  ------------------
   67|   642k|      const __m128i swap =
   68|   642k|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   69|   642k|      in = _mm_shuffle_epi8(in, swap);
   70|   642k|    }
   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|   642k|    const __m128i surrogates_bytemask =
   76|   642k|        _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|   642k|    const uint16_t surrogates_bitmask =
   81|   642k|        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|   642k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (84:9): [True: 641k, False: 1.09k]
  ------------------
   85|       |      // case: no surrogate pair, extend 16-bit code units to 32-bit code units
   86|   641k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
   87|   641k|                       _mm_cvtepu16_epi32(in));
   88|   641k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
   89|   641k|                       _mm_cvtepu16_epi32(_mm_srli_si128(in, 8)));
   90|   641k|      utf32_output += 8;
   91|   641k|      buf += 8;
   92|       |      // surrogate pair(s) in a register
   93|   641k|    } 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.09k|      size_t forward = 15;
   98|  1.09k|      size_t k = 0;
   99|  1.09k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (99:11): [True: 82, False: 1.01k]
  ------------------
  100|     82|        forward = size_t(end - buf - 1);
  101|     82|      }
  102|  14.5k|      for (; k < forward; k++) {
  ------------------
  |  Branch (102:14): [True: 13.5k, False: 1.01k]
  ------------------
  103|  13.5k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  104|  13.5k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (104:13): [True: 11.7k, False: 1.88k]
  ------------------
  105|  11.7k|          *utf32_output++ = char32_t(word);
  106|  11.7k|        } else {
  107|       |          // must be a surrogate pair
  108|  1.88k|          uint16_t diff = uint16_t(word - 0xD800);
  109|  1.88k|          uint16_t next_word =
  110|  1.88k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  111|  1.88k|          k++;
  112|  1.88k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  113|  1.88k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (113:15): [True: 82, False: 1.79k]
  ------------------
  114|     82|            return std::make_pair(nullptr, utf32_output);
  115|     82|          }
  116|  1.79k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  117|  1.79k|          *utf32_output++ = char32_t(value);
  118|  1.79k|        }
  119|  13.5k|      }
  120|  1.01k|      buf += k;
  121|  1.01k|    }
  122|   642k|  } // while
  123|    284|  return std::make_pair(buf, utf32_output);
  124|    366|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_138sse_convert_utf16_to_utf32_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPDiEEPKDsmS7_:
  136|    414|                                       char32_t *utf32_output) {
  137|    414|  const char16_t *start = buf;
  138|    414|  const char16_t *end = buf + len;
  139|       |
  140|    414|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
  141|    414|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
  142|       |
  143|   308k|  while (end - buf >= 8) {
  ------------------
  |  Branch (143:10): [True: 307k, False: 266]
  ------------------
  144|   307k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  145|       |
  146|   307k|    if (big_endian) {
  ------------------
  |  Branch (146:9): [Folded, False: 307k]
  ------------------
  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|   307k|    const __m128i surrogates_bytemask =
  156|   307k|        _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|   307k|    const uint16_t surrogates_bitmask =
  161|   307k|        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|   307k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (164:9): [True: 301k, False: 6.57k]
  ------------------
  165|       |      // case: no surrogate pair, extend 16-bit code units to 32-bit code units
  166|   301k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
  167|   301k|                       _mm_cvtepu16_epi32(in));
  168|   301k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
  169|   301k|                       _mm_cvtepu16_epi32(_mm_srli_si128(in, 8)));
  170|   301k|      utf32_output += 8;
  171|   301k|      buf += 8;
  172|       |      // surrogate pair(s) in a register
  173|   301k|    } 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|  6.57k|      size_t forward = 15;
  178|  6.57k|      size_t k = 0;
  179|  6.57k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (179:11): [True: 88, False: 6.48k]
  ------------------
  180|     88|        forward = size_t(end - buf - 1);
  181|     88|      }
  182|  92.4k|      for (; k < forward; k++) {
  ------------------
  |  Branch (182:14): [True: 86.0k, False: 6.42k]
  ------------------
  183|  86.0k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  184|  86.0k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (184:13): [True: 74.4k, False: 11.5k]
  ------------------
  185|  74.4k|          *utf32_output++ = char32_t(word);
  186|  74.4k|        } else {
  187|       |          // must be a surrogate pair
  188|  11.5k|          uint16_t diff = uint16_t(word - 0xD800);
  189|  11.5k|          uint16_t next_word =
  190|  11.5k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  191|  11.5k|          k++;
  192|  11.5k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  193|  11.5k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (193:15): [True: 148, False: 11.3k]
  ------------------
  194|    148|            return std::make_pair(
  195|    148|                result(error_code::SURROGATE, buf - start + k - 1),
  196|    148|                utf32_output);
  197|    148|          }
  198|  11.3k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  199|  11.3k|          *utf32_output++ = char32_t(value);
  200|  11.3k|        }
  201|  86.0k|      }
  202|  6.42k|      buf += k;
  203|  6.42k|    }
  204|   307k|  } // while
  205|    266|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output);
  206|    414|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_138sse_convert_utf16_to_utf32_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPDiEEPKDsmS7_:
  136|    300|                                       char32_t *utf32_output) {
  137|    300|  const char16_t *start = buf;
  138|    300|  const char16_t *end = buf + len;
  139|       |
  140|    300|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
  141|    300|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
  142|       |
  143|   422k|  while (end - buf >= 8) {
  ------------------
  |  Branch (143:10): [True: 422k, False: 224]
  ------------------
  144|   422k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  145|       |
  146|   422k|    if (big_endian) {
  ------------------
  |  Branch (146:9): [True: 422k, Folded]
  ------------------
  147|   422k|      const __m128i swap =
  148|   422k|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  149|   422k|      in = _mm_shuffle_epi8(in, swap);
  150|   422k|    }
  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|   422k|    const __m128i surrogates_bytemask =
  156|   422k|        _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|   422k|    const uint16_t surrogates_bitmask =
  161|   422k|        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|   422k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (164:9): [True: 418k, False: 3.87k]
  ------------------
  165|       |      // case: no surrogate pair, extend 16-bit code units to 32-bit code units
  166|   418k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
  167|   418k|                       _mm_cvtepu16_epi32(in));
  168|   418k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
  169|   418k|                       _mm_cvtepu16_epi32(_mm_srli_si128(in, 8)));
  170|   418k|      utf32_output += 8;
  171|   418k|      buf += 8;
  172|       |      // surrogate pair(s) in a register
  173|   418k|    } 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|  3.87k|      size_t forward = 15;
  178|  3.87k|      size_t k = 0;
  179|  3.87k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (179:11): [True: 54, False: 3.82k]
  ------------------
  180|     54|        forward = size_t(end - buf - 1);
  181|     54|      }
  182|  51.8k|      for (; k < forward; k++) {
  ------------------
  |  Branch (182:14): [True: 48.0k, False: 3.80k]
  ------------------
  183|  48.0k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  184|  48.0k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (184:13): [True: 37.9k, False: 10.0k]
  ------------------
  185|  37.9k|          *utf32_output++ = char32_t(word);
  186|  37.9k|        } else {
  187|       |          // must be a surrogate pair
  188|  10.0k|          uint16_t diff = uint16_t(word - 0xD800);
  189|  10.0k|          uint16_t next_word =
  190|  10.0k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  191|  10.0k|          k++;
  192|  10.0k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  193|  10.0k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (193:15): [True: 76, False: 10.0k]
  ------------------
  194|     76|            return std::make_pair(
  195|     76|                result(error_code::SURROGATE, buf - start + k - 1),
  196|     76|                utf32_output);
  197|     76|          }
  198|  10.0k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  199|  10.0k|          *utf32_output++ = char32_t(value);
  200|  10.0k|        }
  201|  48.0k|      }
  202|  3.80k|      buf += k;
  203|  3.80k|    }
  204|   422k|  } // while
  205|    224|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output);
  206|    300|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_125sse_convert_utf16_to_utf8ILNS_10endiannessE0EEENSt3__14pairIPKDsPcEES7_mS8_:
   56|    802|sse_convert_utf16_to_utf8(const char16_t *buf, size_t len, char *utf8_output) {
   57|       |
   58|    802|  const char16_t *end = buf + len;
   59|       |
   60|    802|  const __m128i v_0000 = _mm_setzero_si128();
   61|    802|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
   62|    802|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
   63|    802|  const size_t safety_margin =
   64|    802|      12; // to avoid overruns, see issue
   65|       |          // https://github.com/simdutf/simdutf/issues/92
   66|       |
   67|  1.16M|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (67:10): [True: 1.16M, False: 718]
  ------------------
   68|  1.16M|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   69|  1.16M|    if (big_endian) {
  ------------------
  |  Branch (69:9): [Folded, False: 1.16M]
  ------------------
   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.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: 1.02M, False: 139k]
  ------------------
   77|  1.02M|      __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
   78|  1.02M|      if (big_endian) {
  ------------------
  |  Branch (78:11): [Folded, False: 1.02M]
  ------------------
   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|  1.02M|      if (!_mm_testz_si128(nextin, v_ff80)) {
  ------------------
  |  Branch (83:11): [True: 30.5k, False: 991k]
  ------------------
   84|       |        // 1. pack the bytes
   85|       |        // obviously suboptimal.
   86|  30.5k|        const __m128i utf8_packed = _mm_packus_epi16(in, in);
   87|       |        // 2. store (16 bytes)
   88|  30.5k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   89|       |        // 3. adjust pointers
   90|  30.5k|        buf += 8;
   91|  30.5k|        utf8_output += 8;
   92|  30.5k|        in = nextin;
   93|   991k|      } else {
   94|       |        // 1. pack the bytes
   95|       |        // obviously suboptimal.
   96|   991k|        const __m128i utf8_packed = _mm_packus_epi16(in, nextin);
   97|       |        // 2. store (16 bytes)
   98|   991k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   99|       |        // 3. adjust pointers
  100|   991k|        buf += 16;
  101|   991k|        utf8_output += 16;
  102|   991k|        continue; // we are done for this round!
  103|   991k|      }
  104|  1.02M|    }
  105|       |
  106|       |    // no bits set above 7th bit
  107|   169k|    const __m128i one_byte_bytemask =
  108|   169k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000);
  109|   169k|    const uint16_t one_byte_bitmask =
  110|   169k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  111|       |
  112|       |    // no bits set above 11th bit
  113|   169k|    const __m128i one_or_two_bytes_bytemask =
  114|   169k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000);
  115|   169k|    const uint16_t one_or_two_bytes_bitmask =
  116|   169k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  117|       |
  118|   169k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (118:9): [True: 50.9k, False: 118k]
  ------------------
  119|  50.9k|      internal::westmere::write_v_u16_11bits_to_utf8(
  120|  50.9k|          in, utf8_output, one_byte_bytemask, one_byte_bitmask);
  121|  50.9k|      buf += 8;
  122|  50.9k|      continue;
  123|  50.9k|    }
  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|   118k|    const __m128i surrogates_bytemask =
  129|   118k|        _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|   118k|    const uint16_t surrogates_bitmask =
  134|   118k|        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|   118k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (137:9): [True: 111k, False: 6.99k]
  ------------------
  138|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  139|   111k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  140|   111k|                                              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|   111k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  170|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  171|   111k|      const __m128i t0 = _mm_shuffle_epi8(in, dup_even);
  172|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  173|   111k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  169|   111k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  174|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  175|   111k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  169|   111k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  176|       |
  177|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  178|   111k|      const __m128i s0 = _mm_srli_epi16(in, 4);
  179|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  180|   111k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  169|   111k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  181|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  182|   111k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  169|   111k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  183|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  184|   111k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  169|   111k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  185|   111k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  186|   111k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  169|   111k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  187|   111k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  188|   111k|#undef simdutf_vec
  189|       |
  190|       |      // 4. expand code units 16-bit => 32-bit
  191|   111k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  192|   111k|      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|   111k|      const uint16_t mask =
  196|   111k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  197|   111k|      if (mask == 0) {
  ------------------
  |  Branch (197:11): [True: 26.9k, False: 84.6k]
  ------------------
  198|       |        // We only have three-byte code units. Use fast path.
  199|  26.9k|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  200|  26.9k|                                              15, 13, -1, -1, -1, -1);
  201|  26.9k|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  202|  26.9k|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  203|  26.9k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  204|  26.9k|        utf8_output += 12;
  205|  26.9k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  206|  26.9k|        utf8_output += 12;
  207|  26.9k|        buf += 8;
  208|  26.9k|        continue;
  209|  26.9k|      }
  210|  84.6k|      const uint8_t mask0 = uint8_t(mask);
  211|       |
  212|  84.6k|      const uint8_t *row0 =
  213|  84.6k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  214|  84.6k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  215|  84.6k|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  216|       |
  217|  84.6k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  218|       |
  219|  84.6k|      const uint8_t *row1 =
  220|  84.6k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  221|  84.6k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  222|  84.6k|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  223|       |
  224|  84.6k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  225|  84.6k|      utf8_output += row0[0];
  226|  84.6k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  227|  84.6k|      utf8_output += row1[0];
  228|       |
  229|  84.6k|      buf += 8;
  230|       |      // surrogate pair(s) in a register
  231|  84.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.99k|      size_t forward = 15;
  236|  6.99k|      size_t k = 0;
  237|  6.99k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (237:11): [True: 0, False: 6.99k]
  ------------------
  238|      0|        forward = size_t(end - buf - 1);
  239|      0|      }
  240|   103k|      for (; k < forward; k++) {
  ------------------
  |  Branch (240:14): [True: 96.1k, False: 6.90k]
  ------------------
  241|  96.1k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  242|  96.1k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (242:13): [True: 13.0k, False: 83.1k]
  ------------------
  243|  13.0k|          *utf8_output++ = char(word);
  244|  83.1k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (244:20): [True: 4.49k, False: 78.6k]
  ------------------
  245|  4.49k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  246|  4.49k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  247|  78.6k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (247:20): [True: 70.4k, False: 8.13k]
  ------------------
  248|  70.4k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  249|  70.4k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  250|  70.4k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  251|  70.4k|        } else {
  252|       |          // must be a surrogate pair
  253|  8.13k|          uint16_t diff = uint16_t(word - 0xD800);
  254|  8.13k|          uint16_t next_word =
  255|  8.13k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  256|  8.13k|          k++;
  257|  8.13k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  258|  8.13k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (258:15): [True: 84, False: 8.05k]
  ------------------
  259|     84|            return std::make_pair(nullptr, utf8_output);
  260|     84|          }
  261|  8.05k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  262|  8.05k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  263|  8.05k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  264|  8.05k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  265|  8.05k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  266|  8.05k|        }
  267|  96.1k|      }
  268|  6.90k|      buf += k;
  269|  6.90k|    }
  270|   118k|  } // while
  271|       |
  272|    718|  return std::make_pair(buf, utf8_output);
  273|    802|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_125sse_convert_utf16_to_utf8ILNS_10endiannessE1EEENSt3__14pairIPKDsPcEES7_mS8_:
   56|    768|sse_convert_utf16_to_utf8(const char16_t *buf, size_t len, char *utf8_output) {
   57|       |
   58|    768|  const char16_t *end = buf + len;
   59|       |
   60|    768|  const __m128i v_0000 = _mm_setzero_si128();
   61|    768|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
   62|    768|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
   63|    768|  const size_t safety_margin =
   64|    768|      12; // to avoid overruns, see issue
   65|       |          // https://github.com/simdutf/simdutf/issues/92
   66|       |
   67|  1.35M|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (67:10): [True: 1.35M, False: 690]
  ------------------
   68|  1.35M|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   69|  1.35M|    if (big_endian) {
  ------------------
  |  Branch (69:9): [True: 1.35M, Folded]
  ------------------
   70|  1.35M|      const __m128i swap =
   71|  1.35M|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   72|  1.35M|      in = _mm_shuffle_epi8(in, swap);
   73|  1.35M|    }
   74|       |    // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes
   75|  1.35M|    const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80);
   76|  1.35M|    if (_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (76:9): [True: 847k, False: 504k]
  ------------------
   77|   847k|      __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
   78|   847k|      if (big_endian) {
  ------------------
  |  Branch (78:11): [True: 847k, Folded]
  ------------------
   79|   847k|        const __m128i swap =
   80|   847k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   81|   847k|        nextin = _mm_shuffle_epi8(nextin, swap);
   82|   847k|      }
   83|   847k|      if (!_mm_testz_si128(nextin, v_ff80)) {
  ------------------
  |  Branch (83:11): [True: 45.0k, False: 802k]
  ------------------
   84|       |        // 1. pack the bytes
   85|       |        // obviously suboptimal.
   86|  45.0k|        const __m128i utf8_packed = _mm_packus_epi16(in, in);
   87|       |        // 2. store (16 bytes)
   88|  45.0k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   89|       |        // 3. adjust pointers
   90|  45.0k|        buf += 8;
   91|  45.0k|        utf8_output += 8;
   92|  45.0k|        in = nextin;
   93|   802k|      } else {
   94|       |        // 1. pack the bytes
   95|       |        // obviously suboptimal.
   96|   802k|        const __m128i utf8_packed = _mm_packus_epi16(in, nextin);
   97|       |        // 2. store (16 bytes)
   98|   802k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   99|       |        // 3. adjust pointers
  100|   802k|        buf += 16;
  101|   802k|        utf8_output += 16;
  102|   802k|        continue; // we are done for this round!
  103|   802k|      }
  104|   847k|    }
  105|       |
  106|       |    // no bits set above 7th bit
  107|   549k|    const __m128i one_byte_bytemask =
  108|   549k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000);
  109|   549k|    const uint16_t one_byte_bitmask =
  110|   549k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  111|       |
  112|       |    // no bits set above 11th bit
  113|   549k|    const __m128i one_or_two_bytes_bytemask =
  114|   549k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000);
  115|   549k|    const uint16_t one_or_two_bytes_bitmask =
  116|   549k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  117|       |
  118|   549k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (118:9): [True: 34.5k, False: 514k]
  ------------------
  119|  34.5k|      internal::westmere::write_v_u16_11bits_to_utf8(
  120|  34.5k|          in, utf8_output, one_byte_bytemask, one_byte_bitmask);
  121|  34.5k|      buf += 8;
  122|  34.5k|      continue;
  123|  34.5k|    }
  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|   514k|    const __m128i surrogates_bytemask =
  129|   514k|        _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|   514k|    const uint16_t surrogates_bitmask =
  134|   514k|        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|   514k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (137:9): [True: 508k, False: 6.71k]
  ------------------
  138|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  139|   508k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  140|   508k|                                              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|   508k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  170|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  171|   508k|      const __m128i t0 = _mm_shuffle_epi8(in, dup_even);
  172|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  173|   508k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  169|   508k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  174|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  175|   508k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  169|   508k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  176|       |
  177|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  178|   508k|      const __m128i s0 = _mm_srli_epi16(in, 4);
  179|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  180|   508k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  169|   508k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  181|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  182|   508k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  169|   508k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  183|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  184|   508k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  169|   508k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  185|   508k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  186|   508k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  169|   508k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  187|   508k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  188|   508k|#undef simdutf_vec
  189|       |
  190|       |      // 4. expand code units 16-bit => 32-bit
  191|   508k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  192|   508k|      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|   508k|      const uint16_t mask =
  196|   508k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  197|   508k|      if (mask == 0) {
  ------------------
  |  Branch (197:11): [True: 274k, False: 233k]
  ------------------
  198|       |        // We only have three-byte code units. Use fast path.
  199|   274k|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  200|   274k|                                              15, 13, -1, -1, -1, -1);
  201|   274k|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  202|   274k|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  203|   274k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  204|   274k|        utf8_output += 12;
  205|   274k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  206|   274k|        utf8_output += 12;
  207|   274k|        buf += 8;
  208|   274k|        continue;
  209|   274k|      }
  210|   233k|      const uint8_t mask0 = uint8_t(mask);
  211|       |
  212|   233k|      const uint8_t *row0 =
  213|   233k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  214|   233k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  215|   233k|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  216|       |
  217|   233k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  218|       |
  219|   233k|      const uint8_t *row1 =
  220|   233k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  221|   233k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  222|   233k|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  223|       |
  224|   233k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  225|   233k|      utf8_output += row0[0];
  226|   233k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  227|   233k|      utf8_output += row1[0];
  228|       |
  229|   233k|      buf += 8;
  230|       |      // surrogate pair(s) in a register
  231|   233k|    } 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.71k|      size_t forward = 15;
  236|  6.71k|      size_t k = 0;
  237|  6.71k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (237:11): [True: 0, False: 6.71k]
  ------------------
  238|      0|        forward = size_t(end - buf - 1);
  239|      0|      }
  240|  98.6k|      for (; k < forward; k++) {
  ------------------
  |  Branch (240:14): [True: 91.9k, False: 6.63k]
  ------------------
  241|  91.9k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  242|  91.9k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (242:13): [True: 10.7k, False: 81.1k]
  ------------------
  243|  10.7k|          *utf8_output++ = char(word);
  244|  81.1k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (244:20): [True: 2.13k, False: 79.0k]
  ------------------
  245|  2.13k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  246|  2.13k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  247|  79.0k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (247:20): [True: 70.8k, False: 8.15k]
  ------------------
  248|  70.8k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  249|  70.8k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  250|  70.8k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  251|  70.8k|        } else {
  252|       |          // must be a surrogate pair
  253|  8.15k|          uint16_t diff = uint16_t(word - 0xD800);
  254|  8.15k|          uint16_t next_word =
  255|  8.15k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  256|  8.15k|          k++;
  257|  8.15k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  258|  8.15k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (258:15): [True: 78, False: 8.07k]
  ------------------
  259|     78|            return std::make_pair(nullptr, utf8_output);
  260|     78|          }
  261|  8.07k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  262|  8.07k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  263|  8.07k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  264|  8.07k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  265|  8.07k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  266|  8.07k|        }
  267|  91.9k|      }
  268|  6.63k|      buf += k;
  269|  6.63k|    }
  270|   514k|  } // while
  271|       |
  272|    690|  return std::make_pair(buf, utf8_output);
  273|    768|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_137sse_convert_utf16_to_utf8_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
  285|    630|                                      char *utf8_output) {
  286|    630|  const char16_t *start = buf;
  287|    630|  const char16_t *end = buf + len;
  288|       |
  289|    630|  const __m128i v_0000 = _mm_setzero_si128();
  290|    630|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
  291|    630|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
  292|    630|  const size_t safety_margin =
  293|    630|      12; // to avoid overruns, see issue
  294|       |          // https://github.com/simdutf/simdutf/issues/92
  295|       |
  296|  1.06M|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (296:10): [True: 1.06M, False: 518]
  ------------------
  297|  1.06M|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  298|  1.06M|    if (big_endian) {
  ------------------
  |  Branch (298:9): [Folded, False: 1.06M]
  ------------------
  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|  1.06M|    const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80);
  305|  1.06M|    if (_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (305:9): [True: 479k, False: 589k]
  ------------------
  306|   479k|      __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  307|   479k|      if (big_endian) {
  ------------------
  |  Branch (307:11): [Folded, False: 479k]
  ------------------
  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|   479k|      if (!_mm_testz_si128(nextin, v_ff80)) {
  ------------------
  |  Branch (312:11): [True: 15.2k, False: 464k]
  ------------------
  313|       |        // 1. pack the bytes
  314|       |        // obviously suboptimal.
  315|  15.2k|        const __m128i utf8_packed = _mm_packus_epi16(in, in);
  316|       |        // 2. store (16 bytes)
  317|  15.2k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  318|       |        // 3. adjust pointers
  319|  15.2k|        buf += 8;
  320|  15.2k|        utf8_output += 8;
  321|  15.2k|        in = nextin;
  322|   464k|      } else {
  323|       |        // 1. pack the bytes
  324|       |        // obviously suboptimal.
  325|   464k|        const __m128i utf8_packed = _mm_packus_epi16(in, nextin);
  326|       |        // 2. store (16 bytes)
  327|   464k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  328|       |        // 3. adjust pointers
  329|   464k|        buf += 16;
  330|   464k|        utf8_output += 16;
  331|   464k|        continue; // we are done for this round!
  332|   464k|      }
  333|   479k|    }
  334|       |
  335|       |    // no bits set above 7th bit
  336|   605k|    const __m128i one_byte_bytemask =
  337|   605k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000);
  338|   605k|    const uint16_t one_byte_bitmask =
  339|   605k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  340|       |
  341|       |    // no bits set above 11th bit
  342|   605k|    const __m128i one_or_two_bytes_bytemask =
  343|   605k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000);
  344|   605k|    const uint16_t one_or_two_bytes_bitmask =
  345|   605k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  346|       |
  347|   605k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (347:9): [True: 188k, False: 416k]
  ------------------
  348|   188k|      internal::westmere::write_v_u16_11bits_to_utf8(
  349|   188k|          in, utf8_output, one_byte_bytemask, one_byte_bitmask);
  350|   188k|      buf += 8;
  351|   188k|      continue;
  352|   188k|    }
  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|   416k|    const __m128i surrogates_bytemask =
  358|   416k|        _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|   416k|    const uint16_t surrogates_bitmask =
  363|   416k|        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|   416k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (366:9): [True: 412k, False: 3.55k]
  ------------------
  367|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  368|   412k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  369|   412k|                                              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|   412k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  399|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  400|   412k|      const __m128i t0 = _mm_shuffle_epi8(in, dup_even);
  401|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  402|   412k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  398|   412k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  403|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  404|   412k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  398|   412k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  405|       |
  406|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  407|   412k|      const __m128i s0 = _mm_srli_epi16(in, 4);
  408|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  409|   412k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  398|   412k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  410|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  411|   412k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  398|   412k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  412|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  413|   412k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  398|   412k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  414|   412k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  415|   412k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  398|   412k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  416|   412k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  417|   412k|#undef simdutf_vec
  418|       |
  419|       |      // 4. expand code units 16-bit => 32-bit
  420|   412k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  421|   412k|      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|   412k|      const uint16_t mask =
  425|   412k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  426|   412k|      if (mask == 0) {
  ------------------
  |  Branch (426:11): [True: 318k, False: 94.5k]
  ------------------
  427|       |        // We only have three-byte code units. Use fast path.
  428|   318k|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  429|   318k|                                              15, 13, -1, -1, -1, -1);
  430|   318k|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  431|   318k|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  432|   318k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  433|   318k|        utf8_output += 12;
  434|   318k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  435|   318k|        utf8_output += 12;
  436|   318k|        buf += 8;
  437|   318k|        continue;
  438|   318k|      }
  439|  94.5k|      const uint8_t mask0 = uint8_t(mask);
  440|       |
  441|  94.5k|      const uint8_t *row0 =
  442|  94.5k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  443|  94.5k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  444|  94.5k|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  445|       |
  446|  94.5k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  447|       |
  448|  94.5k|      const uint8_t *row1 =
  449|  94.5k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  450|  94.5k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  451|  94.5k|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  452|       |
  453|  94.5k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  454|  94.5k|      utf8_output += row0[0];
  455|  94.5k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  456|  94.5k|      utf8_output += row1[0];
  457|       |
  458|  94.5k|      buf += 8;
  459|       |      // surrogate pair(s) in a register
  460|  94.5k|    } 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|  3.55k|      size_t forward = 15;
  465|  3.55k|      size_t k = 0;
  466|  3.55k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (466:11): [True: 0, False: 3.55k]
  ------------------
  467|      0|        forward = size_t(end - buf - 1);
  468|      0|      }
  469|  51.6k|      for (; k < forward; k++) {
  ------------------
  |  Branch (469:14): [True: 48.1k, False: 3.44k]
  ------------------
  470|  48.1k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  471|  48.1k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (471:13): [True: 8.91k, False: 39.2k]
  ------------------
  472|  8.91k|          *utf8_output++ = char(word);
  473|  39.2k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (473:20): [True: 2.02k, False: 37.2k]
  ------------------
  474|  2.02k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  475|  2.02k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  476|  37.2k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (476:20): [True: 33.0k, False: 4.19k]
  ------------------
  477|  33.0k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  478|  33.0k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  479|  33.0k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  480|  33.0k|        } else {
  481|       |          // must be a surrogate pair
  482|  4.19k|          uint16_t diff = uint16_t(word - 0xD800);
  483|  4.19k|          uint16_t next_word =
  484|  4.19k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  485|  4.19k|          k++;
  486|  4.19k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  487|  4.19k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (487:15): [True: 112, False: 4.08k]
  ------------------
  488|    112|            return std::make_pair(
  489|    112|                result(error_code::SURROGATE, buf - start + k - 1),
  490|    112|                utf8_output);
  491|    112|          }
  492|  4.08k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  493|  4.08k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  494|  4.08k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  495|  4.08k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  496|  4.08k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  497|  4.08k|        }
  498|  48.1k|      }
  499|  3.44k|      buf += k;
  500|  3.44k|    }
  501|   416k|  } // while
  502|       |
  503|    518|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output);
  504|    630|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_137sse_convert_utf16_to_utf8_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
  285|    586|                                      char *utf8_output) {
  286|    586|  const char16_t *start = buf;
  287|    586|  const char16_t *end = buf + len;
  288|       |
  289|    586|  const __m128i v_0000 = _mm_setzero_si128();
  290|    586|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
  291|    586|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
  292|    586|  const size_t safety_margin =
  293|    586|      12; // to avoid overruns, see issue
  294|       |          // https://github.com/simdutf/simdutf/issues/92
  295|       |
  296|   523k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (296:10): [True: 522k, False: 444]
  ------------------
  297|   522k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  298|   522k|    if (big_endian) {
  ------------------
  |  Branch (298:9): [True: 522k, Folded]
  ------------------
  299|   522k|      const __m128i swap =
  300|   522k|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  301|   522k|      in = _mm_shuffle_epi8(in, swap);
  302|   522k|    }
  303|       |    // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes
  304|   522k|    const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80);
  305|   522k|    if (_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (305:9): [True: 405k, False: 117k]
  ------------------
  306|   405k|      __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  307|   405k|      if (big_endian) {
  ------------------
  |  Branch (307:11): [True: 405k, Folded]
  ------------------
  308|   405k|        const __m128i swap =
  309|   405k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  310|   405k|        nextin = _mm_shuffle_epi8(nextin, swap);
  311|   405k|      }
  312|   405k|      if (!_mm_testz_si128(nextin, v_ff80)) {
  ------------------
  |  Branch (312:11): [True: 31.3k, False: 373k]
  ------------------
  313|       |        // 1. pack the bytes
  314|       |        // obviously suboptimal.
  315|  31.3k|        const __m128i utf8_packed = _mm_packus_epi16(in, in);
  316|       |        // 2. store (16 bytes)
  317|  31.3k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  318|       |        // 3. adjust pointers
  319|  31.3k|        buf += 8;
  320|  31.3k|        utf8_output += 8;
  321|  31.3k|        in = nextin;
  322|   373k|      } else {
  323|       |        // 1. pack the bytes
  324|       |        // obviously suboptimal.
  325|   373k|        const __m128i utf8_packed = _mm_packus_epi16(in, nextin);
  326|       |        // 2. store (16 bytes)
  327|   373k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  328|       |        // 3. adjust pointers
  329|   373k|        buf += 16;
  330|   373k|        utf8_output += 16;
  331|   373k|        continue; // we are done for this round!
  332|   373k|      }
  333|   405k|    }
  334|       |
  335|       |    // no bits set above 7th bit
  336|   148k|    const __m128i one_byte_bytemask =
  337|   148k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000);
  338|   148k|    const uint16_t one_byte_bitmask =
  339|   148k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  340|       |
  341|       |    // no bits set above 11th bit
  342|   148k|    const __m128i one_or_two_bytes_bytemask =
  343|   148k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000);
  344|   148k|    const uint16_t one_or_two_bytes_bitmask =
  345|   148k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  346|       |
  347|   148k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (347:9): [True: 39.7k, False: 109k]
  ------------------
  348|  39.7k|      internal::westmere::write_v_u16_11bits_to_utf8(
  349|  39.7k|          in, utf8_output, one_byte_bytemask, one_byte_bitmask);
  350|  39.7k|      buf += 8;
  351|  39.7k|      continue;
  352|  39.7k|    }
  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|   109k|    const __m128i surrogates_bytemask =
  358|   109k|        _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|   109k|    const uint16_t surrogates_bitmask =
  363|   109k|        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|   109k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (366:9): [True: 102k, False: 6.74k]
  ------------------
  367|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  368|   102k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  369|   102k|                                              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|   102k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  399|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  400|   102k|      const __m128i t0 = _mm_shuffle_epi8(in, dup_even);
  401|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  402|   102k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  398|   102k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  403|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  404|   102k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  398|   102k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  405|       |
  406|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  407|   102k|      const __m128i s0 = _mm_srli_epi16(in, 4);
  408|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  409|   102k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  398|   102k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  410|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  411|   102k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  398|   102k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  412|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  413|   102k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  398|   102k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  414|   102k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  415|   102k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  398|   102k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  416|   102k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  417|   102k|#undef simdutf_vec
  418|       |
  419|       |      // 4. expand code units 16-bit => 32-bit
  420|   102k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  421|   102k|      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|   102k|      const uint16_t mask =
  425|   102k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  426|   102k|      if (mask == 0) {
  ------------------
  |  Branch (426:11): [True: 27.1k, False: 75.1k]
  ------------------
  427|       |        // We only have three-byte code units. Use fast path.
  428|  27.1k|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  429|  27.1k|                                              15, 13, -1, -1, -1, -1);
  430|  27.1k|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  431|  27.1k|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  432|  27.1k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  433|  27.1k|        utf8_output += 12;
  434|  27.1k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  435|  27.1k|        utf8_output += 12;
  436|  27.1k|        buf += 8;
  437|  27.1k|        continue;
  438|  27.1k|      }
  439|  75.1k|      const uint8_t mask0 = uint8_t(mask);
  440|       |
  441|  75.1k|      const uint8_t *row0 =
  442|  75.1k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  443|  75.1k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  444|  75.1k|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  445|       |
  446|  75.1k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  447|       |
  448|  75.1k|      const uint8_t *row1 =
  449|  75.1k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  450|  75.1k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  451|  75.1k|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  452|       |
  453|  75.1k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  454|  75.1k|      utf8_output += row0[0];
  455|  75.1k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  456|  75.1k|      utf8_output += row1[0];
  457|       |
  458|  75.1k|      buf += 8;
  459|       |      // surrogate pair(s) in a register
  460|  75.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|  6.74k|      size_t forward = 15;
  465|  6.74k|      size_t k = 0;
  466|  6.74k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (466:11): [True: 0, False: 6.74k]
  ------------------
  467|      0|        forward = size_t(end - buf - 1);
  468|      0|      }
  469|  98.6k|      for (; k < forward; k++) {
  ------------------
  |  Branch (469:14): [True: 92.0k, False: 6.59k]
  ------------------
  470|  92.0k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  471|  92.0k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (471:13): [True: 31.4k, False: 60.6k]
  ------------------
  472|  31.4k|          *utf8_output++ = char(word);
  473|  60.6k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (473:20): [True: 4.65k, False: 55.9k]
  ------------------
  474|  4.65k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  475|  4.65k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  476|  55.9k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (476:20): [True: 48.1k, False: 7.83k]
  ------------------
  477|  48.1k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  478|  48.1k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  479|  48.1k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  480|  48.1k|        } else {
  481|       |          // must be a surrogate pair
  482|  7.83k|          uint16_t diff = uint16_t(word - 0xD800);
  483|  7.83k|          uint16_t next_word =
  484|  7.83k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  485|  7.83k|          k++;
  486|  7.83k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  487|  7.83k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (487:15): [True: 142, False: 7.69k]
  ------------------
  488|    142|            return std::make_pair(
  489|    142|                result(error_code::SURROGATE, buf - start + k - 1),
  490|    142|                utf8_output);
  491|    142|          }
  492|  7.69k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  493|  7.69k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  494|  7.69k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  495|  7.69k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  496|  7.69k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  497|  7.69k|        }
  498|  92.0k|      }
  499|  6.59k|      buf += k;
  500|  6.59k|    }
  501|   109k|  } // while
  502|       |
  503|    444|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output);
  504|    586|}

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

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_utf32_to_utf16ILNS_10endiannessE0EEENSt3__14pairIPKDiPDsEES7_mS8_:
   58|    722|                           char16_t *utf16_output) {
   59|       |
   60|    722|  const char32_t *end = buf + len;
   61|       |
   62|    722|  const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000);
   63|    722|  __m128i forbidden_bytemask = _mm_setzero_si128();
   64|       |
   65|  5.66k|  while (end - buf >= 16 + 8) {
  ------------------
  |  Branch (65:10): [True: 4.97k, False: 692]
  ------------------
   66|  4.97k|    const __m128i *ptr = reinterpret_cast<const __m128i *>(buf);
   67|  4.97k|    const __m128i in0 = _mm_loadu_si128(ptr + 0);
   68|  4.97k|    const __m128i in1 = _mm_loadu_si128(ptr + 1);
   69|  4.97k|    const __m128i in2 = _mm_loadu_si128(ptr + 2);
   70|  4.97k|    const __m128i in3 = _mm_loadu_si128(ptr + 3);
   71|       |
   72|  4.97k|    const __m128i combined =
   73|  4.97k|        _mm_or_si128(_mm_or_si128(in2, in3), _mm_or_si128(in0, in1));
   74|  4.97k|    if (simdutf_likely(_mm_testz_si128(combined, v_ffff0000))) {
  ------------------
  |  |   90|  4.97k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 3.80k, False: 1.16k]
  |  |  ------------------
  ------------------
   75|       |      // No bits set above 16th, directly pack UTF-32 to UTF-16
   76|  3.80k|      __m128i utf16_packed0 = _mm_packus_epi32(in0, in1);
   77|  3.80k|      __m128i utf16_packed1 = _mm_packus_epi32(in2, in3);
   78|       |
   79|  3.80k|      const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
   80|  3.80k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
   81|  3.80k|      forbidden_bytemask = _mm_or_si128(
   82|  3.80k|          forbidden_bytemask,
   83|  3.80k|          _mm_or_si128(
   84|  3.80k|              _mm_cmpeq_epi16(_mm_and_si128(utf16_packed0, v_f800), v_d800),
   85|  3.80k|              _mm_cmpeq_epi16(_mm_and_si128(utf16_packed1, v_f800), v_d800)));
   86|       |
   87|  3.80k|      if (big_endian) {
  ------------------
  |  Branch (87:11): [Folded, False: 3.80k]
  ------------------
   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|  3.80k|      _mm_storeu_si128((__m128i *)utf16_output + 0, utf16_packed0);
   95|  3.80k|      _mm_storeu_si128((__m128i *)utf16_output + 1, utf16_packed1);
   96|  3.80k|      utf16_output += 16;
   97|  3.80k|      buf += 16;
   98|  3.80k|    } else {
   99|  1.16k|      if (!validate_utf32(in0, in1) || !validate_utf32(in2, in3)) {
  ------------------
  |  Branch (99:11): [True: 12, False: 1.15k]
  |  Branch (99:40): [True: 18, False: 1.13k]
  ------------------
  100|     30|        return std::make_pair(nullptr, utf16_output);
  101|     30|      }
  102|       |
  103|  1.13k|      const auto ret0 = sse_expand_surrogate<big_endian>(in0);
  104|  1.13k|      _mm_storeu_si128((__m128i *)utf16_output, ret0.compressed);
  105|  1.13k|      utf16_output += ret0.u16count;
  106|       |
  107|  1.13k|      const auto ret1 = sse_expand_surrogate<big_endian>(in1);
  108|  1.13k|      _mm_storeu_si128((__m128i *)utf16_output, ret1.compressed);
  109|  1.13k|      utf16_output += ret1.u16count;
  110|       |
  111|  1.13k|      const auto ret2 = sse_expand_surrogate<big_endian>(in2);
  112|  1.13k|      _mm_storeu_si128((__m128i *)utf16_output, ret2.compressed);
  113|  1.13k|      utf16_output += ret2.u16count;
  114|       |
  115|  1.13k|      const auto ret3 = sse_expand_surrogate<big_endian>(in3);
  116|  1.13k|      _mm_storeu_si128((__m128i *)utf16_output, ret3.compressed);
  117|  1.13k|      utf16_output += ret3.u16count;
  118|       |
  119|  1.13k|      buf += 16;
  120|  1.13k|    }
  121|  4.97k|  }
  122|       |
  123|       |  // check for invalid input
  124|    692|  if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (124:7): [True: 18, False: 674]
  ------------------
  125|     18|    return std::make_pair(nullptr, utf16_output);
  126|     18|  }
  127|       |
  128|    674|  return std::make_pair(buf, utf16_output);
  129|    692|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114validate_utf32EDv2_xS2_:
   37|  3.00k|simdutf_really_inline bool validate_utf32(const __m128i a, const __m128i b) {
   38|  3.00k|  using vector_u32 = simd32<uint32_t>;
   39|       |
   40|  3.00k|  const auto in0 = vector_u32(a);
   41|  3.00k|  const auto in1 = vector_u32(b);
   42|       |
   43|  3.00k|  const auto standardmax = vector_u32::splat(0x10ffff);
   44|  3.00k|  const auto offset = vector_u32::splat(0xffff2000);
   45|  3.00k|  const auto standardoffsetmax = vector_u32::splat(0xfffff7ff);
   46|       |
   47|  3.00k|  const auto too_large = max(in0, in1) > standardmax;
   48|  3.00k|  const auto surrogate0 = (in0 + offset) > standardoffsetmax;
   49|  3.00k|  const auto surrogate1 = (in1 + offset) > standardoffsetmax;
   50|       |
   51|  3.00k|  const auto combined = too_large | surrogate0 | surrogate1;
   52|  3.00k|  return !combined.any();
   53|  3.00k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_120sse_expand_surrogateILNS_10endiannessE0EEENS1_18expansion_result_tEDv2_x:
    9|  4.53k|expansion_result_t sse_expand_surrogate(const __m128i x) {
   10|  4.53k|  using vector_u32 = simd32<uint32_t>;
   11|  4.53k|  using vector_u8 = simd8<uint8_t>;
   12|       |
   13|  4.53k|  const auto in = vector_u32(x);
   14|       |
   15|  4.53k|  const auto non_surrogate_mask = (in & uint32_t(0xffff0000)) == uint32_t(0);
   16|  4.53k|  const auto mask = (~non_surrogate_mask.to_4bit_bitmask()) & 0xf;
   17|       |
   18|  4.53k|  const auto t0 = in - uint32_t(0x00010000);
   19|  4.53k|  const auto hi = t0.shr<10>() & uint32_t(0x000003ff);
   20|  4.53k|  const auto lo = t0.shl<16>() & uint32_t(0x03ff0000);
   21|  4.53k|  const auto surrogates = (lo | hi) | uint32_t(0xdc00d800);
   22|       |
   23|  4.53k|  const auto merged = as_vector_u8(select(non_surrogate_mask, in, surrogates));
   24|       |
   25|  4.53k|  const auto shuffle = vector_u8::load(
   26|  4.53k|      (byte_order == endianness::LITTLE)
  ------------------
  |  Branch (26:7): [True: 4.53k, Folded]
  ------------------
   27|  4.53k|          ? tables::utf32_to_utf16::pack_utf32_to_utf16le[mask]
   28|  4.53k|          : tables::utf32_to_utf16::pack_utf32_to_utf16be[mask]);
   29|       |
   30|  4.53k|  const size_t u16count = (4 + count_ones(mask));
   31|  4.53k|  const auto compressed = shuffle.lookup_16(merged);
   32|       |
   33|  4.53k|  return {u16count, compressed};
   34|  4.53k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_utf32_to_utf16ILNS_10endiannessE1EEENSt3__14pairIPKDiPDsEES7_mS8_:
   58|    528|                           char16_t *utf16_output) {
   59|       |
   60|    528|  const char32_t *end = buf + len;
   61|       |
   62|    528|  const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000);
   63|    528|  __m128i forbidden_bytemask = _mm_setzero_si128();
   64|       |
   65|  4.06k|  while (end - buf >= 16 + 8) {
  ------------------
  |  Branch (65:10): [True: 3.57k, False: 494]
  ------------------
   66|  3.57k|    const __m128i *ptr = reinterpret_cast<const __m128i *>(buf);
   67|  3.57k|    const __m128i in0 = _mm_loadu_si128(ptr + 0);
   68|  3.57k|    const __m128i in1 = _mm_loadu_si128(ptr + 1);
   69|  3.57k|    const __m128i in2 = _mm_loadu_si128(ptr + 2);
   70|  3.57k|    const __m128i in3 = _mm_loadu_si128(ptr + 3);
   71|       |
   72|  3.57k|    const __m128i combined =
   73|  3.57k|        _mm_or_si128(_mm_or_si128(in2, in3), _mm_or_si128(in0, in1));
   74|  3.57k|    if (simdutf_likely(_mm_testz_si128(combined, v_ffff0000))) {
  ------------------
  |  |   90|  3.57k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 3.21k, False: 352]
  |  |  ------------------
  ------------------
   75|       |      // No bits set above 16th, directly pack UTF-32 to UTF-16
   76|  3.21k|      __m128i utf16_packed0 = _mm_packus_epi32(in0, in1);
   77|  3.21k|      __m128i utf16_packed1 = _mm_packus_epi32(in2, in3);
   78|       |
   79|  3.21k|      const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
   80|  3.21k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
   81|  3.21k|      forbidden_bytemask = _mm_or_si128(
   82|  3.21k|          forbidden_bytemask,
   83|  3.21k|          _mm_or_si128(
   84|  3.21k|              _mm_cmpeq_epi16(_mm_and_si128(utf16_packed0, v_f800), v_d800),
   85|  3.21k|              _mm_cmpeq_epi16(_mm_and_si128(utf16_packed1, v_f800), v_d800)));
   86|       |
   87|  3.21k|      if (big_endian) {
  ------------------
  |  Branch (87:11): [True: 3.21k, Folded]
  ------------------
   88|  3.21k|        const __m128i swap =
   89|  3.21k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   90|  3.21k|        utf16_packed0 = _mm_shuffle_epi8(utf16_packed0, swap);
   91|  3.21k|        utf16_packed1 = _mm_shuffle_epi8(utf16_packed1, swap);
   92|  3.21k|      }
   93|       |
   94|  3.21k|      _mm_storeu_si128((__m128i *)utf16_output + 0, utf16_packed0);
   95|  3.21k|      _mm_storeu_si128((__m128i *)utf16_output + 1, utf16_packed1);
   96|  3.21k|      utf16_output += 16;
   97|  3.21k|      buf += 16;
   98|  3.21k|    } else {
   99|    352|      if (!validate_utf32(in0, in1) || !validate_utf32(in2, in3)) {
  ------------------
  |  Branch (99:11): [True: 14, False: 338]
  |  Branch (99:40): [True: 20, False: 318]
  ------------------
  100|     34|        return std::make_pair(nullptr, utf16_output);
  101|     34|      }
  102|       |
  103|    318|      const auto ret0 = sse_expand_surrogate<big_endian>(in0);
  104|    318|      _mm_storeu_si128((__m128i *)utf16_output, ret0.compressed);
  105|    318|      utf16_output += ret0.u16count;
  106|       |
  107|    318|      const auto ret1 = sse_expand_surrogate<big_endian>(in1);
  108|    318|      _mm_storeu_si128((__m128i *)utf16_output, ret1.compressed);
  109|    318|      utf16_output += ret1.u16count;
  110|       |
  111|    318|      const auto ret2 = sse_expand_surrogate<big_endian>(in2);
  112|    318|      _mm_storeu_si128((__m128i *)utf16_output, ret2.compressed);
  113|    318|      utf16_output += ret2.u16count;
  114|       |
  115|    318|      const auto ret3 = sse_expand_surrogate<big_endian>(in3);
  116|    318|      _mm_storeu_si128((__m128i *)utf16_output, ret3.compressed);
  117|    318|      utf16_output += ret3.u16count;
  118|       |
  119|    318|      buf += 16;
  120|    318|    }
  121|  3.57k|  }
  122|       |
  123|       |  // check for invalid input
  124|    494|  if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (124:7): [True: 6, False: 488]
  ------------------
  125|      6|    return std::make_pair(nullptr, utf16_output);
  126|      6|  }
  127|       |
  128|    488|  return std::make_pair(buf, utf16_output);
  129|    494|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_120sse_expand_surrogateILNS_10endiannessE1EEENS1_18expansion_result_tEDv2_x:
    9|  1.27k|expansion_result_t sse_expand_surrogate(const __m128i x) {
   10|  1.27k|  using vector_u32 = simd32<uint32_t>;
   11|  1.27k|  using vector_u8 = simd8<uint8_t>;
   12|       |
   13|  1.27k|  const auto in = vector_u32(x);
   14|       |
   15|  1.27k|  const auto non_surrogate_mask = (in & uint32_t(0xffff0000)) == uint32_t(0);
   16|  1.27k|  const auto mask = (~non_surrogate_mask.to_4bit_bitmask()) & 0xf;
   17|       |
   18|  1.27k|  const auto t0 = in - uint32_t(0x00010000);
   19|  1.27k|  const auto hi = t0.shr<10>() & uint32_t(0x000003ff);
   20|  1.27k|  const auto lo = t0.shl<16>() & uint32_t(0x03ff0000);
   21|  1.27k|  const auto surrogates = (lo | hi) | uint32_t(0xdc00d800);
   22|       |
   23|  1.27k|  const auto merged = as_vector_u8(select(non_surrogate_mask, in, surrogates));
   24|       |
   25|  1.27k|  const auto shuffle = vector_u8::load(
   26|  1.27k|      (byte_order == endianness::LITTLE)
  ------------------
  |  Branch (26:7): [Folded, False: 1.27k]
  ------------------
   27|  1.27k|          ? tables::utf32_to_utf16::pack_utf32_to_utf16le[mask]
   28|  1.27k|          : tables::utf32_to_utf16::pack_utf32_to_utf16be[mask]);
   29|       |
   30|  1.27k|  const size_t u16count = (4 + count_ones(mask));
   31|  1.27k|  const auto compressed = shuffle.lookup_16(merged);
   32|       |
   33|  1.27k|  return {u16count, compressed};
   34|  1.27k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_138sse_convert_utf32_to_utf16_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPDsEEPKDimS7_:
  134|    716|                                       char16_t *utf16_output) {
  135|    716|  const char32_t *start = buf;
  136|    716|  const char32_t *end = buf + len;
  137|       |
  138|    716|  const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000);
  139|       |
  140|  88.8k|  while (end - buf >= 8) {
  ------------------
  |  Branch (140:10): [True: 88.4k, False: 326]
  ------------------
  141|  88.4k|    const __m128i in = _mm_loadu_si128((__m128i *)buf);
  142|  88.4k|    const __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  143|       |
  144|  88.4k|    const __m128i combined = _mm_or_si128(in, nextin);
  145|  88.4k|    if (simdutf_likely(_mm_testz_si128(combined, v_ffff0000))) {
  ------------------
  |  |   90|  88.4k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 85.4k, False: 3.03k]
  |  |  ------------------
  ------------------
  146|       |      // No bits set above 16th, directly pack UTF-32 to UTF-16
  147|  85.4k|      __m128i utf16_packed = _mm_packus_epi32(in, nextin);
  148|       |
  149|  85.4k|      const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
  150|  85.4k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
  151|  85.4k|      const __m128i forbidden_bytemask =
  152|  85.4k|          _mm_cmpeq_epi16(_mm_and_si128(utf16_packed, v_f800), v_d800);
  153|  85.4k|      if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (153:11): [True: 52, False: 85.3k]
  ------------------
  154|     52|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  155|     52|                              utf16_output);
  156|     52|      }
  157|       |
  158|  85.3k|      if (big_endian) {
  ------------------
  |  Branch (158:11): [Folded, False: 85.3k]
  ------------------
  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|  85.3k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
  165|  85.3k|      utf16_output += 8;
  166|  85.3k|      buf += 8;
  167|  85.3k|    } else {
  168|  3.03k|      size_t forward = 7;
  169|  3.03k|      size_t k = 0;
  170|  3.03k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (170:11): [True: 0, False: 3.03k]
  ------------------
  171|      0|        forward = size_t(end - buf - 1);
  172|      0|      }
  173|  22.7k|      for (; k < forward; k++) {
  ------------------
  |  Branch (173:14): [True: 20.0k, False: 2.69k]
  ------------------
  174|  20.0k|        uint32_t word = buf[k];
  175|  20.0k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (175:13): [True: 9.99k, False: 10.0k]
  ------------------
  176|       |          // will not generate a surrogate pair
  177|  9.99k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (177:15): [True: 986, False: 9.00k]
  |  Branch (177:33): [True: 40, False: 946]
  ------------------
  178|     40|            return std::make_pair(
  179|     40|                result(error_code::SURROGATE, buf - start + k), utf16_output);
  180|     40|          }
  181|  9.95k|          *utf16_output++ =
  182|  9.95k|              big_endian
  ------------------
  |  Branch (182:15): [Folded, False: 9.95k]
  ------------------
  183|  9.95k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
  184|  9.95k|                  : char16_t(word);
  185|  10.0k|        } else {
  186|       |          // will generate a surrogate pair
  187|  10.0k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (187:15): [True: 298, False: 9.71k]
  ------------------
  188|    298|            return std::make_pair(
  189|    298|                result(error_code::TOO_LARGE, buf - start + k), utf16_output);
  190|    298|          }
  191|  9.71k|          word -= 0x10000;
  192|  9.71k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
  193|  9.71k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
  194|  9.71k|          if (big_endian) {
  ------------------
  |  Branch (194:15): [Folded, False: 9.71k]
  ------------------
  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|  9.71k|          *utf16_output++ = char16_t(high_surrogate);
  201|  9.71k|          *utf16_output++ = char16_t(low_surrogate);
  202|  9.71k|        }
  203|  20.0k|      }
  204|  2.69k|      buf += k;
  205|  2.69k|    }
  206|  88.4k|  }
  207|       |
  208|    326|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output);
  209|    716|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_138sse_convert_utf32_to_utf16_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPDsEEPKDimS7_:
  134|    606|                                       char16_t *utf16_output) {
  135|    606|  const char32_t *start = buf;
  136|    606|  const char32_t *end = buf + len;
  137|       |
  138|    606|  const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000);
  139|       |
  140|  13.0k|  while (end - buf >= 8) {
  ------------------
  |  Branch (140:10): [True: 12.7k, False: 306]
  ------------------
  141|  12.7k|    const __m128i in = _mm_loadu_si128((__m128i *)buf);
  142|  12.7k|    const __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  143|       |
  144|  12.7k|    const __m128i combined = _mm_or_si128(in, nextin);
  145|  12.7k|    if (simdutf_likely(_mm_testz_si128(combined, v_ffff0000))) {
  ------------------
  |  |   90|  12.7k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 11.4k, False: 1.24k]
  |  |  ------------------
  ------------------
  146|       |      // No bits set above 16th, directly pack UTF-32 to UTF-16
  147|  11.4k|      __m128i utf16_packed = _mm_packus_epi32(in, nextin);
  148|       |
  149|  11.4k|      const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
  150|  11.4k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
  151|  11.4k|      const __m128i forbidden_bytemask =
  152|  11.4k|          _mm_cmpeq_epi16(_mm_and_si128(utf16_packed, v_f800), v_d800);
  153|  11.4k|      if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (153:11): [True: 24, False: 11.4k]
  ------------------
  154|     24|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  155|     24|                              utf16_output);
  156|     24|      }
  157|       |
  158|  11.4k|      if (big_endian) {
  ------------------
  |  Branch (158:11): [True: 11.4k, Folded]
  ------------------
  159|  11.4k|        const __m128i swap =
  160|  11.4k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  161|  11.4k|        utf16_packed = _mm_shuffle_epi8(utf16_packed, swap);
  162|  11.4k|      }
  163|       |
  164|  11.4k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
  165|  11.4k|      utf16_output += 8;
  166|  11.4k|      buf += 8;
  167|  11.4k|    } else {
  168|  1.24k|      size_t forward = 7;
  169|  1.24k|      size_t k = 0;
  170|  1.24k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (170:11): [True: 0, False: 1.24k]
  ------------------
  171|      0|        forward = size_t(end - buf - 1);
  172|      0|      }
  173|  8.65k|      for (; k < forward; k++) {
  ------------------
  |  Branch (173:14): [True: 7.68k, False: 972]
  ------------------
  174|  7.68k|        uint32_t word = buf[k];
  175|  7.68k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (175:13): [True: 4.35k, False: 3.33k]
  ------------------
  176|       |          // will not generate a surrogate pair
  177|  4.35k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (177:15): [True: 968, False: 3.38k]
  |  Branch (177:33): [True: 18, False: 950]
  ------------------
  178|     18|            return std::make_pair(
  179|     18|                result(error_code::SURROGATE, buf - start + k), utf16_output);
  180|     18|          }
  181|  4.33k|          *utf16_output++ =
  182|  4.33k|              big_endian
  ------------------
  |  Branch (182:15): [True: 4.33k, Folded]
  ------------------
  183|  4.33k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
  184|  4.33k|                  : char16_t(word);
  185|  4.33k|        } else {
  186|       |          // will generate a surrogate pair
  187|  3.33k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (187:15): [True: 258, False: 3.07k]
  ------------------
  188|    258|            return std::make_pair(
  189|    258|                result(error_code::TOO_LARGE, buf - start + k), utf16_output);
  190|    258|          }
  191|  3.07k|          word -= 0x10000;
  192|  3.07k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
  193|  3.07k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
  194|  3.07k|          if (big_endian) {
  ------------------
  |  Branch (194:15): [True: 3.07k, Folded]
  ------------------
  195|  3.07k|            high_surrogate =
  196|  3.07k|                uint16_t((high_surrogate >> 8) | (high_surrogate << 8));
  197|  3.07k|            low_surrogate =
  198|  3.07k|                uint16_t((low_surrogate >> 8) | (low_surrogate << 8));
  199|  3.07k|          }
  200|  3.07k|          *utf16_output++ = char16_t(high_surrogate);
  201|  3.07k|          *utf16_output++ = char16_t(low_surrogate);
  202|  3.07k|        }
  203|  7.68k|      }
  204|    972|      buf += k;
  205|    972|    }
  206|  12.7k|  }
  207|       |
  208|    306|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output);
  209|    606|}

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

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_129convert_masked_utf8_to_latin1EPKcmRPc:
    9|   543k|                                     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|   543k|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   21|   543k|  const uint16_t input_utf8_end_of_code_point_mask =
   22|   543k|      utf8_end_of_code_point_mask &
   23|   543k|      0xfff; // we are only processing 12 bytes in case it is not all ASCII
   24|   543k|  if (utf8_end_of_code_point_mask == 0xfff) {
  ------------------
  |  Branch (24:7): [True: 3.58k, False: 539k]
  ------------------
   25|       |    // We process the data in chunks of 12 bytes.
   26|  3.58k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(latin1_output), in);
   27|  3.58k|    latin1_output += 12; // We wrote 12 characters.
   28|  3.58k|    return 12;           // We consumed 12 bytes.
   29|  3.58k|  }
   30|       |  /// We do not have a fast path available, so we fallback.
   31|   539k|  const uint8_t idx =
   32|   539k|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0];
   33|   539k|  const uint8_t consumed =
   34|   539k|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1];
   35|       |  // this indicates an invalid input:
   36|   539k|  if (idx >= 64) {
  ------------------
  |  Branch (36:7): [True: 12.2k, False: 527k]
  ------------------
   37|  12.2k|    return consumed;
   38|  12.2k|  }
   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|   527k|  const __m128i sh =
   46|   527k|      _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
   47|   527k|  const __m128i perm = _mm_shuffle_epi8(in, sh);
   48|   527k|  const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   49|   527k|  const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   50|   527k|  __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   51|   527k|  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|   527k|  _mm_storel_epi64((__m128i *)latin1_output, latin1_packed);
   56|   527k|  latin1_output += 6; // We wrote 6 bytes.
   57|   527k|  return consumed;
   58|   539k|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_128convert_masked_utf8_to_utf16ILNS_10endiannessE0EEEmPKcmRPDs:
   10|  2.87M|                                    char16_t *&utf16_output) {
   11|       |  // we use an approach where we try to process up to 12 input bytes.
   12|       |  // Why 12 input bytes and not 16? Because we are concerned with the size of
   13|       |  // the lookup tables. Also 12 is nicely divisible by two and three.
   14|       |  //
   15|       |  //
   16|       |  // Optimization note: our main path below is load-latency dependent. Thus it
   17|       |  // is maybe beneficial to have fast paths that depend on branch prediction but
   18|       |  // have less latency. This results in more instructions but, potentially, also
   19|       |  // higher speeds.
   20|       |  //
   21|       |  // We first try a few fast paths.
   22|  2.87M|  const __m128i swap =
   23|  2.87M|      _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   24|  2.87M|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   25|  2.87M|  const uint16_t input_utf8_end_of_code_point_mask =
   26|  2.87M|      utf8_end_of_code_point_mask & 0xfff;
   27|  2.87M|  if (utf8_end_of_code_point_mask == 0xfff) {
  ------------------
  |  Branch (27:7): [True: 9.93k, False: 2.86M]
  ------------------
   28|       |    // We process the data in chunks of 12 bytes.
   29|       |    // Note: using 16 bytes is unsafe, see issue_ossfuzz_71218
   30|  9.93k|    __m128i ascii_first = _mm_cvtepu8_epi16(in);
   31|  9.93k|    __m128i ascii_second = _mm_cvtepu8_epi16(_mm_srli_si128(in, 8));
   32|  9.93k|    if (big_endian) {
  ------------------
  |  Branch (32:9): [Folded, False: 9.93k]
  ------------------
   33|      0|      ascii_first = _mm_shuffle_epi8(ascii_first, swap);
   34|      0|      ascii_second = _mm_shuffle_epi8(ascii_second, swap);
   35|      0|    }
   36|  9.93k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf16_output), ascii_first);
   37|  9.93k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf16_output + 8),
   38|  9.93k|                     ascii_second);
   39|  9.93k|    utf16_output += 12; // We wrote 12 16-bit characters.
   40|  9.93k|    return 12;          // We consumed 12 bytes.
   41|  9.93k|  }
   42|  2.86M|  if (((utf8_end_of_code_point_mask & 0xFFFF) == 0xaaaa)) {
  ------------------
  |  Branch (42:7): [True: 11.2k, False: 2.84M]
  ------------------
   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|  11.2k|    const __m128i sh =
   47|  11.2k|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   48|  11.2k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   49|  11.2k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   50|  11.2k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   51|  11.2k|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   52|  11.2k|    if (big_endian)
  ------------------
  |  Branch (52:9): [Folded, False: 11.2k]
  ------------------
   53|      0|      composed = _mm_shuffle_epi8(composed, swap);
   54|  11.2k|    _mm_storeu_si128((__m128i *)utf16_output, composed);
   55|  11.2k|    utf16_output += 8; // We wrote 16 bytes, 8 code points.
   56|  11.2k|    return 16;
   57|  11.2k|  }
   58|  2.84M|  if (input_utf8_end_of_code_point_mask == 0x924) {
  ------------------
  |  Branch (58:7): [True: 2.85k, False: 2.84M]
  ------------------
   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.85k|    const __m128i sh =
   63|  2.85k|        _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1);
   64|  2.85k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   65|  2.85k|    const __m128i ascii =
   66|  2.85k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   67|  2.85k|    const __m128i middlebyte =
   68|  2.85k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
   69|  2.85k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
   70|  2.85k|    const __m128i highbyte =
   71|  2.85k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
   72|  2.85k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
   73|  2.85k|    const __m128i composed =
   74|  2.85k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
   75|  2.85k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
   76|  2.85k|    if (big_endian)
  ------------------
  |  Branch (76:9): [Folded, False: 2.85k]
  ------------------
   77|      0|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
   78|  2.85k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
   79|  2.85k|    utf16_output += 4;
   80|  2.85k|    return 12;
   81|  2.85k|  }
   82|       |  /// We do not have a fast path available, so we fallback.
   83|       |
   84|  2.84M|  const uint8_t idx =
   85|  2.84M|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0];
   86|  2.84M|  const uint8_t consumed =
   87|  2.84M|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1];
   88|  2.84M|  if (idx < 64) {
  ------------------
  |  Branch (88:7): [True: 2.40M, False: 439k]
  ------------------
   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.40M|    const __m128i sh =
   96|  2.40M|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
   97|  2.40M|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   98|  2.40M|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   99|  2.40M|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
  100|  2.40M|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
  101|  2.40M|    if (big_endian)
  ------------------
  |  Branch (101:9): [Folded, False: 2.40M]
  ------------------
  102|      0|      composed = _mm_shuffle_epi8(composed, swap);
  103|  2.40M|    _mm_storeu_si128((__m128i *)utf16_output, composed);
  104|  2.40M|    utf16_output += 6; // We wrote 12 bytes, 6 code points.
  105|  2.40M|  } else if (idx < 145) {
  ------------------
  |  Branch (105:14): [True: 390k, False: 48.5k]
  ------------------
  106|       |    // FOUR (4) input code-code units
  107|   390k|    const __m128i sh =
  108|   390k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  109|   390k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  110|   390k|    const __m128i ascii =
  111|   390k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
  112|   390k|    const __m128i middlebyte =
  113|   390k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
  114|   390k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  115|   390k|    const __m128i highbyte =
  116|   390k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
  117|   390k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
  118|   390k|    const __m128i composed =
  119|   390k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
  120|   390k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
  121|   390k|    if (big_endian)
  ------------------
  |  Branch (121:9): [Folded, False: 390k]
  ------------------
  122|      0|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
  123|   390k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
  124|   390k|    utf16_output += 4;
  125|   390k|  } else if (idx < 209) {
  ------------------
  |  Branch (125:14): [True: 47.7k, False: 756]
  ------------------
  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|  47.7k|    const __m128i sh =
  137|  47.7k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  138|  47.7k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  139|  47.7k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f));
  140|  47.7k|    const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00));
  141|  47.7k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  142|  47.7k|    __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000));
  143|       |    // correct for spurious high bit
  144|  47.7k|    const __m128i correct =
  145|  47.7k|        _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1);
  146|  47.7k|    middlehighbyte = _mm_xor_si128(correct, middlehighbyte);
  147|  47.7k|    const __m128i middlehighbyte_shifted = _mm_srli_epi32(middlehighbyte, 4);
  148|       |    // We deliberately carry the leading four bits in highbyte if they are
  149|       |    // present, we remove them later when computing hightenbits.
  150|  47.7k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0xff000000));
  151|  47.7k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 6);
  152|       |    // When we need to generate a surrogate pair (leading byte > 0xF0), then
  153|       |    // the corresponding 32-bit value in 'composed'  will be greater than
  154|       |    // > (0xff00000>>6) or > 0x3c00000. This can be used later to identify the
  155|       |    // location of the surrogate pairs.
  156|  47.7k|    const __m128i composed =
  157|  47.7k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted),
  158|  47.7k|                     _mm_or_si128(highbyte_shifted, middlehighbyte_shifted));
  159|  47.7k|    const __m128i composedminus =
  160|  47.7k|        _mm_sub_epi32(composed, _mm_set1_epi32(0x10000));
  161|  47.7k|    const __m128i lowtenbits =
  162|  47.7k|        _mm_and_si128(composedminus, _mm_set1_epi32(0x3ff));
  163|       |    // Notice the 0x3ff mask:
  164|  47.7k|    const __m128i hightenbits =
  165|  47.7k|        _mm_and_si128(_mm_srli_epi32(composedminus, 10), _mm_set1_epi32(0x3ff));
  166|  47.7k|    const __m128i lowtenbitsadd =
  167|  47.7k|        _mm_add_epi32(lowtenbits, _mm_set1_epi32(0xDC00));
  168|  47.7k|    const __m128i hightenbitsadd =
  169|  47.7k|        _mm_add_epi32(hightenbits, _mm_set1_epi32(0xD800));
  170|  47.7k|    const __m128i lowtenbitsaddshifted = _mm_slli_epi32(lowtenbitsadd, 16);
  171|  47.7k|    __m128i surrogates = _mm_or_si128(hightenbitsadd, lowtenbitsaddshifted);
  172|  47.7k|    uint32_t basic_buffer[4];
  173|  47.7k|    uint32_t basic_buffer_swap[4];
  174|  47.7k|    if (big_endian) {
  ------------------
  |  Branch (174:9): [Folded, False: 47.7k]
  ------------------
  175|      0|      _mm_storeu_si128((__m128i *)basic_buffer_swap,
  176|      0|                       _mm_shuffle_epi8(composed, swap));
  177|      0|      surrogates = _mm_shuffle_epi8(surrogates, swap);
  178|      0|    }
  179|  47.7k|    _mm_storeu_si128((__m128i *)basic_buffer, composed);
  180|  47.7k|    uint32_t surrogate_buffer[4];
  181|  47.7k|    _mm_storeu_si128((__m128i *)surrogate_buffer, surrogates);
  182|   191k|    for (size_t i = 0; i < 3; i++) {
  ------------------
  |  Branch (182:24): [True: 143k, False: 47.7k]
  ------------------
  183|   143k|      if (basic_buffer[i] > 0x3c00000) {
  ------------------
  |  Branch (183:11): [True: 40.1k, False: 103k]
  ------------------
  184|  40.1k|        utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff);
  185|  40.1k|        utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16);
  186|  40.1k|        utf16_output += 2;
  187|   103k|      } else {
  188|   103k|        utf16_output[0] = big_endian ? uint16_t(basic_buffer_swap[i])
  ------------------
  |  Branch (188:27): [Folded, False: 103k]
  ------------------
  189|   103k|                                     : uint16_t(basic_buffer[i]);
  190|   103k|        utf16_output++;
  191|   103k|      }
  192|   143k|    }
  193|  47.7k|  } else {
  194|       |    // here we know that there is an error but we do not handle errors
  195|    756|  }
  196|  2.84M|  return consumed;
  197|  2.84M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_128convert_masked_utf8_to_utf16ILNS_10endiannessE1EEEmPKcmRPDs:
   10|  3.09M|                                    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.09M|  const __m128i swap =
   23|  3.09M|      _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   24|  3.09M|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   25|  3.09M|  const uint16_t input_utf8_end_of_code_point_mask =
   26|  3.09M|      utf8_end_of_code_point_mask & 0xfff;
   27|  3.09M|  if (utf8_end_of_code_point_mask == 0xfff) {
  ------------------
  |  Branch (27:7): [True: 8.76k, False: 3.09M]
  ------------------
   28|       |    // We process the data in chunks of 12 bytes.
   29|       |    // Note: using 16 bytes is unsafe, see issue_ossfuzz_71218
   30|  8.76k|    __m128i ascii_first = _mm_cvtepu8_epi16(in);
   31|  8.76k|    __m128i ascii_second = _mm_cvtepu8_epi16(_mm_srli_si128(in, 8));
   32|  8.76k|    if (big_endian) {
  ------------------
  |  Branch (32:9): [True: 8.76k, Folded]
  ------------------
   33|  8.76k|      ascii_first = _mm_shuffle_epi8(ascii_first, swap);
   34|  8.76k|      ascii_second = _mm_shuffle_epi8(ascii_second, swap);
   35|  8.76k|    }
   36|  8.76k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf16_output), ascii_first);
   37|  8.76k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf16_output + 8),
   38|  8.76k|                     ascii_second);
   39|  8.76k|    utf16_output += 12; // We wrote 12 16-bit characters.
   40|  8.76k|    return 12;          // We consumed 12 bytes.
   41|  8.76k|  }
   42|  3.09M|  if (((utf8_end_of_code_point_mask & 0xFFFF) == 0xaaaa)) {
  ------------------
  |  Branch (42:7): [True: 20.4k, False: 3.07M]
  ------------------
   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|  20.4k|    const __m128i sh =
   47|  20.4k|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   48|  20.4k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   49|  20.4k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   50|  20.4k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   51|  20.4k|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   52|  20.4k|    if (big_endian)
  ------------------
  |  Branch (52:9): [True: 20.4k, Folded]
  ------------------
   53|  20.4k|      composed = _mm_shuffle_epi8(composed, swap);
   54|  20.4k|    _mm_storeu_si128((__m128i *)utf16_output, composed);
   55|  20.4k|    utf16_output += 8; // We wrote 16 bytes, 8 code points.
   56|  20.4k|    return 16;
   57|  20.4k|  }
   58|  3.07M|  if (input_utf8_end_of_code_point_mask == 0x924) {
  ------------------
  |  Branch (58:7): [True: 4.37k, False: 3.06M]
  ------------------
   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|  4.37k|    const __m128i sh =
   63|  4.37k|        _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1);
   64|  4.37k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   65|  4.37k|    const __m128i ascii =
   66|  4.37k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   67|  4.37k|    const __m128i middlebyte =
   68|  4.37k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
   69|  4.37k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
   70|  4.37k|    const __m128i highbyte =
   71|  4.37k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
   72|  4.37k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
   73|  4.37k|    const __m128i composed =
   74|  4.37k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
   75|  4.37k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
   76|  4.37k|    if (big_endian)
  ------------------
  |  Branch (76:9): [True: 4.37k, Folded]
  ------------------
   77|  4.37k|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
   78|  4.37k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
   79|  4.37k|    utf16_output += 4;
   80|  4.37k|    return 12;
   81|  4.37k|  }
   82|       |  /// We do not have a fast path available, so we fallback.
   83|       |
   84|  3.06M|  const uint8_t idx =
   85|  3.06M|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0];
   86|  3.06M|  const uint8_t consumed =
   87|  3.06M|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1];
   88|  3.06M|  if (idx < 64) {
  ------------------
  |  Branch (88:7): [True: 2.75M, False: 306k]
  ------------------
   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.75M|    const __m128i sh =
   96|  2.75M|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
   97|  2.75M|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   98|  2.75M|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   99|  2.75M|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
  100|  2.75M|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
  101|  2.75M|    if (big_endian)
  ------------------
  |  Branch (101:9): [True: 2.75M, Folded]
  ------------------
  102|  2.75M|      composed = _mm_shuffle_epi8(composed, swap);
  103|  2.75M|    _mm_storeu_si128((__m128i *)utf16_output, composed);
  104|  2.75M|    utf16_output += 6; // We wrote 12 bytes, 6 code points.
  105|  2.75M|  } else if (idx < 145) {
  ------------------
  |  Branch (105:14): [True: 253k, False: 52.3k]
  ------------------
  106|       |    // FOUR (4) input code-code units
  107|   253k|    const __m128i sh =
  108|   253k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  109|   253k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  110|   253k|    const __m128i ascii =
  111|   253k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
  112|   253k|    const __m128i middlebyte =
  113|   253k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
  114|   253k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  115|   253k|    const __m128i highbyte =
  116|   253k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
  117|   253k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
  118|   253k|    const __m128i composed =
  119|   253k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
  120|   253k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
  121|   253k|    if (big_endian)
  ------------------
  |  Branch (121:9): [True: 253k, Folded]
  ------------------
  122|   253k|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
  123|   253k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
  124|   253k|    utf16_output += 4;
  125|   253k|  } else if (idx < 209) {
  ------------------
  |  Branch (125:14): [True: 51.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|  51.0k|    const __m128i sh =
  137|  51.0k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  138|  51.0k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  139|  51.0k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f));
  140|  51.0k|    const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00));
  141|  51.0k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  142|  51.0k|    __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000));
  143|       |    // correct for spurious high bit
  144|  51.0k|    const __m128i correct =
  145|  51.0k|        _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1);
  146|  51.0k|    middlehighbyte = _mm_xor_si128(correct, middlehighbyte);
  147|  51.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|  51.0k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0xff000000));
  151|  51.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|  51.0k|    const __m128i composed =
  157|  51.0k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted),
  158|  51.0k|                     _mm_or_si128(highbyte_shifted, middlehighbyte_shifted));
  159|  51.0k|    const __m128i composedminus =
  160|  51.0k|        _mm_sub_epi32(composed, _mm_set1_epi32(0x10000));
  161|  51.0k|    const __m128i lowtenbits =
  162|  51.0k|        _mm_and_si128(composedminus, _mm_set1_epi32(0x3ff));
  163|       |    // Notice the 0x3ff mask:
  164|  51.0k|    const __m128i hightenbits =
  165|  51.0k|        _mm_and_si128(_mm_srli_epi32(composedminus, 10), _mm_set1_epi32(0x3ff));
  166|  51.0k|    const __m128i lowtenbitsadd =
  167|  51.0k|        _mm_add_epi32(lowtenbits, _mm_set1_epi32(0xDC00));
  168|  51.0k|    const __m128i hightenbitsadd =
  169|  51.0k|        _mm_add_epi32(hightenbits, _mm_set1_epi32(0xD800));
  170|  51.0k|    const __m128i lowtenbitsaddshifted = _mm_slli_epi32(lowtenbitsadd, 16);
  171|  51.0k|    __m128i surrogates = _mm_or_si128(hightenbitsadd, lowtenbitsaddshifted);
  172|  51.0k|    uint32_t basic_buffer[4];
  173|  51.0k|    uint32_t basic_buffer_swap[4];
  174|  51.0k|    if (big_endian) {
  ------------------
  |  Branch (174:9): [True: 51.0k, Folded]
  ------------------
  175|  51.0k|      _mm_storeu_si128((__m128i *)basic_buffer_swap,
  176|  51.0k|                       _mm_shuffle_epi8(composed, swap));
  177|  51.0k|      surrogates = _mm_shuffle_epi8(surrogates, swap);
  178|  51.0k|    }
  179|  51.0k|    _mm_storeu_si128((__m128i *)basic_buffer, composed);
  180|  51.0k|    uint32_t surrogate_buffer[4];
  181|  51.0k|    _mm_storeu_si128((__m128i *)surrogate_buffer, surrogates);
  182|   204k|    for (size_t i = 0; i < 3; i++) {
  ------------------
  |  Branch (182:24): [True: 153k, False: 51.0k]
  ------------------
  183|   153k|      if (basic_buffer[i] > 0x3c00000) {
  ------------------
  |  Branch (183:11): [True: 42.9k, False: 110k]
  ------------------
  184|  42.9k|        utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff);
  185|  42.9k|        utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16);
  186|  42.9k|        utf16_output += 2;
  187|   110k|      } else {
  188|   110k|        utf16_output[0] = big_endian ? uint16_t(basic_buffer_swap[i])
  ------------------
  |  Branch (188:27): [True: 110k, Folded]
  ------------------
  189|   110k|                                     : uint16_t(basic_buffer[i]);
  190|   110k|        utf16_output++;
  191|   110k|      }
  192|   153k|    }
  193|  51.0k|  } else {
  194|       |    // here we know that there is an error but we do not handle errors
  195|  1.31k|  }
  196|  3.06M|  return consumed;
  197|  3.07M|}

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

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

