_Z18populate_functionsv:
  548|      1|const auto populate_functions() {
  549|      1|  using I = simdutf::implementation;
  550|      1|  using FuzzSignature = void (*)(std::span<const char>);
  551|       |
  552|      1|#define ADD(lenfunc, conversionfunc)                                           \
  553|      1|  FuzzSignature {                                                              \
  554|      1|    +[](std::span<const char> chardata) {                                      \
  555|      1|      const auto c =                                                           \
  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  562|      1|      c.fuzz(chardata);                                                        \
  563|      1|    }                                                                          \
  564|      1|  }
  565|       |
  566|      1|  return std::array{
  567|       |      // all these cases require valid input for invoking the convert function
  568|       |
  569|       |      // see #493
  570|       |      // IGNORE(latin1_length_from_utf16, convert_valid_utf16be_to_latin1),
  571|      1|      ADD(utf32_length_from_utf16be, convert_valid_utf16be_to_utf32),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  572|      1|      ADD(utf8_length_from_utf16be, convert_valid_utf16be_to_utf8),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  573|       |
  574|       |      //  see #493
  575|       |      // IGNORE(latin1_length_from_utf16, convert_valid_utf16le_to_latin1),
  576|      1|      ADD(utf32_length_from_utf16le, convert_valid_utf16le_to_utf32),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  577|      1|      ADD(utf8_length_from_utf16le, convert_valid_utf16le_to_utf8),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  578|       |
  579|       |      // see #493
  580|       |      // IGNORE(latin1_length_from_utf32, convert_valid_utf32_to_latin1),
  581|      1|      ADD(utf16_length_from_utf32, convert_valid_utf32_to_utf16be),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  582|      1|      ADD(utf16_length_from_utf32, convert_valid_utf32_to_utf16le),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  583|      1|      ADD(utf8_length_from_utf32, convert_valid_utf32_to_utf8),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  584|       |
  585|       |      // see #493
  586|       |      // IGNORE(latin1_length_from_utf8, convert_valid_utf8_to_latin1),
  587|      1|      ADD(utf16_length_from_utf8, convert_valid_utf8_to_utf16be),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  588|      1|      ADD(utf16_length_from_utf8, convert_valid_utf8_to_utf16le),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  589|      1|      ADD(utf32_length_from_utf8, convert_valid_utf8_to_utf32),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  590|       |
  591|       |      // all these cases operate on arbitrary data
  592|      1|      ADD(latin1_length_from_utf16, convert_utf16be_to_latin1),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  593|      1|      ADD(utf32_length_from_utf16be, convert_utf16be_to_utf32),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  594|      1|      ADD(utf8_length_from_utf16be, convert_utf16be_to_utf8),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  595|       |
  596|      1|      ADD(latin1_length_from_utf16, convert_utf16le_to_latin1),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  597|      1|      ADD(utf32_length_from_utf16le, convert_utf16le_to_utf32),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  598|      1|      ADD(utf8_length_from_utf16le, convert_utf16le_to_utf8),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  599|       |
  600|      1|      ADD(latin1_length_from_utf32, convert_utf32_to_latin1),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  601|      1|      ADD(utf16_length_from_utf32, convert_utf32_to_utf16be),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  602|      1|      ADD(utf16_length_from_utf32, convert_utf32_to_utf16le),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  603|      1|      ADD(utf8_length_from_utf32, convert_utf32_to_utf8),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  604|       |
  605|      1|      ADD(latin1_length_from_utf8, convert_utf8_to_latin1),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  606|      1|      ADD(utf16_length_from_utf8, convert_utf8_to_utf16be),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  607|      1|      ADD(utf16_length_from_utf8, convert_utf8_to_utf16le),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  608|      1|      ADD(utf32_length_from_utf8, convert_utf8_to_utf32),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  609|       |
  610|       |      // all these cases operate on arbitrary data and use the _with_errors
  611|       |      // variant
  612|      1|      ADD(latin1_length_from_utf16, convert_utf16be_to_latin1_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  613|      1|      ADD(utf32_length_from_utf16be, convert_utf16be_to_utf32_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  614|      1|      ADD(utf8_length_from_utf16be, convert_utf16be_to_utf8_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  615|       |
  616|      1|      ADD(latin1_length_from_utf16, convert_utf16le_to_latin1_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  617|      1|      ADD(utf32_length_from_utf16le, convert_utf16le_to_utf32_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  618|      1|      ADD(utf8_length_from_utf16le, convert_utf16le_to_utf8_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  619|       |
  620|      1|      ADD(latin1_length_from_utf32, convert_utf32_to_latin1_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  621|      1|      ADD(utf16_length_from_utf32, convert_utf32_to_utf16be_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  622|      1|      ADD(utf16_length_from_utf32, convert_utf32_to_utf16le_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  623|      1|      ADD(utf8_length_from_utf32, convert_utf32_to_utf8_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  624|       |
  625|      1|      ADD(latin1_length_from_utf8, convert_utf8_to_latin1_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  626|      1|      ADD(utf16_length_from_utf8, convert_utf8_to_utf16be_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  627|      1|      ADD(utf16_length_from_utf8, convert_utf8_to_utf16le_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  628|      1|      ADD(utf32_length_from_utf8, convert_utf8_to_utf32_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  629|       |
  630|       |      // these are a bit special since all input is valid
  631|      1|      ADD(utf32_length_from_latin1, convert_latin1_to_utf32),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  632|      1|      ADD(utf16_length_from_latin1, convert_latin1_to_utf16be),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  633|      1|      ADD(utf16_length_from_latin1, convert_latin1_to_utf16le),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  634|      1|      ADD(utf8_length_from_latin1, convert_latin1_to_utf8)};
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  635|       |
  636|      1|#undef ADD
  637|      1|}
LLVMFuzzerTestOneInput:
  639|  9.24k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  640|  9.24k|  static const auto fptrs = populate_functions();
  641|  9.24k|  constexpr std::size_t Ncases = fptrs.size();
  642|       |
  643|       |  // pick one of the function pointers, based on the fuzz data
  644|       |  // the first byte is which action to take. step forward
  645|       |  // several bytes so the input is aligned.
  646|  9.24k|  if (size < 4) {
  ------------------
  |  Branch (646:7): [True: 3, False: 9.24k]
  ------------------
  647|      3|    return 0;
  648|      3|  }
  649|       |
  650|  9.24k|  constexpr auto actionmask = std::bit_ceil(Ncases) - 1;
  651|  9.24k|  const auto action = data[0] & actionmask;
  652|  9.24k|  data += 4;
  653|  9.24k|  size -= 4;
  654|       |
  655|  9.24k|  if (action >= Ncases) {
  ------------------
  |  Branch (655:7): [True: 1, False: 9.24k]
  ------------------
  656|      1|    return 0;
  657|      1|  }
  658|       |
  659|  9.24k|  if constexpr (use_separate_allocation) {
  660|       |    // this is better at exercising null input and catch buffer underflows
  661|  9.24k|    const std::vector<char> separate{data, data + size};
  662|  9.24k|    fptrs[action](std::span(separate));
  663|       |  } else {
  664|       |    std::span<const char> chardata{(const char*)data, size};
  665|       |    fptrs[action](chardata);
  666|       |  }
  667|       |
  668|  9.24k|  return 0;
  669|  9.24k|}
conversion.cpp:_ZZ18populate_functionsvENK3$_0clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     99|    +[](std::span<const char> chardata) {                                      \
  555|     99|      const auto c =                                                           \
  556|     99|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     99|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     99|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     99|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     99|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     99|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     99|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     99|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     99|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     99|  constexpr auto _size = _name.size();                                \
  |  | 1183|     99|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     99|  return _nameof; }()
  ------------------
  561|     99|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     99|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     99|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     99|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     99|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     99|  constexpr auto _size = _name.size();                                \
  |  | 1183|     99|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     99|  return _nameof; }()
  ------------------
  562|     99|      c.fuzz(chardata);                                                        \
  563|     99|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    209|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    209|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    209|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    209|    static const bool do_print_testcase =
  181|    209|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    209|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 209]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    209|    do {
  189|       |      // step 0 - is the input valid?
  190|    209|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    209|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 209]
  |  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|    209|                    From == UtfEncodings::UTF8) {
  198|    209|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 209]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    209|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    209|      const auto [output_length, length_agree] =
  204|    209|          calculate_length(from, inputisvalid);
  205|    209|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 209]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    209|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 83, False: 126]
  |  Branch (208:28): [True: 13, False: 70]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     13|        return;
  211|     13|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    196|      const auto [written, outputs_agree] =
  215|    196|          do_conversion(from, output_length, inputisvalid);
  216|    196|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 196]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    196|      return;
  221|    196|    } 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|    209|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    209|  validation_result verify_valid_input(FromSpan src) const {
  231|    209|    validation_result ret{};
  232|       |
  233|    209|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    209|    const auto implementations = get_supported_implementations();
  235|    209|    std::vector<simdutf::result> results;
  236|    209|    results.reserve(implementations.size());
  237|       |
  238|    627|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 627, False: 209]
  ------------------
  239|    627|      results.push_back(
  240|    627|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    627|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    627|      const bool validation2 =
  245|    627|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    627|                      src.data(), src.size());
  247|    627|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 627]
  ------------------
  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|    627|    }
  258|       |
  259|    209|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    209|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 209]
  ------------------
  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|    209|    } else {
  273|    209|      ret.implementations_agree = true;
  274|    209|    }
  275|    209|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    209|      return r.error == simdutf::SUCCESS;
  277|    209|    });
  278|    209|    return ret;
  279|    209|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    418|    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|    461|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    461|      return r.error == simdutf::SUCCESS;
  277|    461|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    209|  bool count_the_input(FromSpan src) const {
  290|    209|    const auto implementations = get_supported_implementations();
  291|    209|    std::vector<std::size_t> results;
  292|    209|    results.reserve(implementations.size());
  293|       |
  294|    627|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 627, False: 209]
  ------------------
  295|    627|      std::size_t ret;
  296|    627|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    627|        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|    627|      results.push_back(ret);
  304|    627|    }
  305|    209|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    209|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 209]
  ------------------
  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|    209|    return true;
  321|    209|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    418|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    209|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    209|    length_result ret{};
  344|       |
  345|    209|    const auto implementations = get_supported_implementations();
  346|    209|    std::vector<std::size_t> results;
  347|    209|    results.reserve(implementations.size());
  348|       |
  349|    627|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 627, False: 209]
  ------------------
  350|    627|      const auto len = invoke_lengthcalc(impl, src);
  351|    627|      results.push_back(len);
  352|    627|      ret.length.push_back(len);
  353|    627|    }
  354|       |
  355|    209|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    209|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 209]
  ------------------
  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|    209|    } else {
  375|    209|      ret.implementations_agree = true;
  376|    209|    }
  377|    209|    return ret;
  378|    209|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    627|                                FromSpan src) const {
  331|    627|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    627|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    418|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    196|                                  const bool inputisvalid) const {
  383|    196|    conversion_result ret{};
  384|       |
  385|    196|    const auto implementations = get_supported_implementations();
  386|       |
  387|    196|    std::vector<result<ConversionResult>> results;
  388|    196|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    196|    std::vector<std::vector<ToType>> outputbuffers;
  393|    196|    outputbuffers.reserve(implementations.size());
  394|    784|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 588, False: 196]
  ------------------
  395|    588|      auto impl = implementations[i];
  396|    588|      const ToType canary1{42};
  397|    588|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    588|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    588|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    588|      const auto success = [](const ConversionResult& r) -> bool {
  402|    588|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    588|          return r != 0;
  404|    588|        } else {
  405|    588|          return r.error == simdutf::error_code::SUCCESS;
  406|    588|        }
  407|    588|      }(implret1);
  408|    588|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    588|      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|    588|        const ToType canary2{25};
  414|    588|        const auto outputbuffer_first_run = outputbuffer;
  415|    588|        std::ranges::fill(outputbuffer, canary2);
  416|    588|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    588|                                          src.size(), outputbuffer.data());
  418|       |
  419|    588|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 588]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    588|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 378, False: 210]
  |  Branch (423:29): [True: 366, False: 12]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    366|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    366|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 366]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    366|        }
  440|    588|      }
  441|    588|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 366, False: 222]
  ------------------
  442|    588|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    196|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 70, False: 126]
  ------------------
  447|    210|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 210, False: 70]
  ------------------
  448|    210|        e.outputhash.clear();
  449|    210|      }
  450|     70|    }
  451|       |
  452|    196|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    196|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 196]
  ------------------
  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|    196|    } else {
  474|    196|      ret.implementations_agree = true;
  475|    196|    }
  476|    196|    return ret;
  477|    196|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    588|      const auto success = [](const ConversionResult& r) -> bool {
  402|    588|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    588|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    588|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    392|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_1clENSt3__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|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    392|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    392|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    392|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    392|    static const bool do_print_testcase =
  181|    392|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    392|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 392]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    392|    do {
  189|       |      // step 0 - is the input valid?
  190|    392|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    392|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 392]
  |  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|    392|                    From == UtfEncodings::UTF8) {
  198|    392|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 392]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    392|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    392|      const auto [output_length, length_agree] =
  204|    392|          calculate_length(from, inputisvalid);
  205|    392|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 392]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    392|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 94, False: 298]
  |  Branch (208:28): [True: 17, False: 77]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     17|        return;
  211|     17|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    375|      const auto [written, outputs_agree] =
  215|    375|          do_conversion(from, output_length, inputisvalid);
  216|    375|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 375]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    375|      return;
  221|    375|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    392|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    392|  validation_result verify_valid_input(FromSpan src) const {
  231|    392|    validation_result ret{};
  232|       |
  233|    392|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    392|    const auto implementations = get_supported_implementations();
  235|    392|    std::vector<simdutf::result> results;
  236|    392|    results.reserve(implementations.size());
  237|       |
  238|  1.17k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.17k, False: 392]
  ------------------
  239|  1.17k|      results.push_back(
  240|  1.17k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.17k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.17k|      const bool validation2 =
  245|  1.17k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.17k|                      src.data(), src.size());
  247|  1.17k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.17k]
  ------------------
  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.17k|    }
  258|       |
  259|    392|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    392|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 392]
  ------------------
  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|    392|    } else {
  273|    392|      ret.implementations_agree = true;
  274|    392|    }
  275|    392|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    392|      return r.error == simdutf::SUCCESS;
  277|    392|    });
  278|    392|    return ret;
  279|    392|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    784|    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|    988|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    988|      return r.error == simdutf::SUCCESS;
  277|    988|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    392|  bool count_the_input(FromSpan src) const {
  290|    392|    const auto implementations = get_supported_implementations();
  291|    392|    std::vector<std::size_t> results;
  292|    392|    results.reserve(implementations.size());
  293|       |
  294|  1.17k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.17k, False: 392]
  ------------------
  295|  1.17k|      std::size_t ret;
  296|  1.17k|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|  1.17k|        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.17k|      results.push_back(ret);
  304|  1.17k|    }
  305|    392|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    392|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 392]
  ------------------
  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|    392|    return true;
  321|    392|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    784|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    392|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    392|    length_result ret{};
  344|       |
  345|    392|    const auto implementations = get_supported_implementations();
  346|    392|    std::vector<std::size_t> results;
  347|    392|    results.reserve(implementations.size());
  348|       |
  349|  1.17k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.17k, False: 392]
  ------------------
  350|  1.17k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.17k|      results.push_back(len);
  352|  1.17k|      ret.length.push_back(len);
  353|  1.17k|    }
  354|       |
  355|    392|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    392|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 392]
  ------------------
  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|    392|    } else {
  375|    392|      ret.implementations_agree = true;
  376|    392|    }
  377|    392|    return ret;
  378|    392|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.17k|                                FromSpan src) const {
  331|  1.17k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.17k|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    784|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    375|                                  const bool inputisvalid) const {
  383|    375|    conversion_result ret{};
  384|       |
  385|    375|    const auto implementations = get_supported_implementations();
  386|       |
  387|    375|    std::vector<result<ConversionResult>> results;
  388|    375|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    375|    std::vector<std::vector<ToType>> outputbuffers;
  393|    375|    outputbuffers.reserve(implementations.size());
  394|  1.50k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.12k, False: 375]
  ------------------
  395|  1.12k|      auto impl = implementations[i];
  396|  1.12k|      const ToType canary1{42};
  397|  1.12k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.12k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.12k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.12k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.12k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.12k|          return r != 0;
  404|  1.12k|        } else {
  405|  1.12k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.12k|        }
  407|  1.12k|      }(implret1);
  408|  1.12k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.12k|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|  1.12k|        const ToType canary2{25};
  414|  1.12k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.12k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.12k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.12k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.12k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.12k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.12k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 894, False: 231]
  |  Branch (423:29): [True: 885, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    885|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    885|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 885]
  ------------------
  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|    885|        }
  440|  1.12k|      }
  441|  1.12k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 885, False: 240]
  ------------------
  442|  1.12k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    375|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 77, False: 298]
  ------------------
  447|    231|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 231, False: 77]
  ------------------
  448|    231|        e.outputhash.clear();
  449|    231|      }
  450|     77|    }
  451|       |
  452|    375|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    375|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 375]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    375|    } else {
  474|    375|      ret.implementations_agree = true;
  475|    375|    }
  476|    375|    return ret;
  477|    375|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.12k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.12k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.12k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.12k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    750|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_2clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     58|    +[](std::span<const char> chardata) {                                      \
  555|     58|      const auto c =                                                           \
  556|     58|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     58|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     58|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     58|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     58|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     58|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     58|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     58|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     58|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     58|  constexpr auto _size = _name.size();                                \
  |  | 1183|     58|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     58|  return _nameof; }()
  ------------------
  561|     58|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     58|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     58|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     58|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     58|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     58|  constexpr auto _size = _name.size();                                \
  |  | 1183|     58|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     58|  return _nameof; }()
  ------------------
  562|     58|      c.fuzz(chardata);                                                        \
  563|     58|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    211|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    211|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    211|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    211|    static const bool do_print_testcase =
  181|    211|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    211|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 211]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    211|    do {
  189|       |      // step 0 - is the input valid?
  190|    211|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    211|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 211]
  |  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|    211|                    From == UtfEncodings::UTF8) {
  198|    211|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 211]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    211|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    211|      const auto [output_length, length_agree] =
  204|    211|          calculate_length(from, inputisvalid);
  205|    211|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 211]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    211|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 91, False: 120]
  |  Branch (208:28): [True: 5, False: 86]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      5|        return;
  211|      5|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    206|      const auto [written, outputs_agree] =
  215|    206|          do_conversion(from, output_length, inputisvalid);
  216|    206|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 206]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    206|      return;
  221|    206|    } 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|    211|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    211|  validation_result verify_valid_input(FromSpan src) const {
  231|    211|    validation_result ret{};
  232|       |
  233|    211|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    211|    const auto implementations = get_supported_implementations();
  235|    211|    std::vector<simdutf::result> results;
  236|    211|    results.reserve(implementations.size());
  237|       |
  238|    633|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 633, False: 211]
  ------------------
  239|    633|      results.push_back(
  240|    633|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    633|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    633|      const bool validation2 =
  245|    633|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    633|                      src.data(), src.size());
  247|    633|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 633]
  ------------------
  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|    633|    }
  258|       |
  259|    211|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    211|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 211]
  ------------------
  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|    211|    } else {
  273|    211|      ret.implementations_agree = true;
  274|    211|    }
  275|    211|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    211|      return r.error == simdutf::SUCCESS;
  277|    211|    });
  278|    211|    return ret;
  279|    211|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    422|    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|    451|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    451|      return r.error == simdutf::SUCCESS;
  277|    451|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    211|  bool count_the_input(FromSpan src) const {
  290|    211|    const auto implementations = get_supported_implementations();
  291|    211|    std::vector<std::size_t> results;
  292|    211|    results.reserve(implementations.size());
  293|       |
  294|    633|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 633, False: 211]
  ------------------
  295|    633|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    633|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    633|        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|    633|      results.push_back(ret);
  304|    633|    }
  305|    211|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    211|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 211]
  ------------------
  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|    211|    return true;
  321|    211|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    422|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    211|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    211|    length_result ret{};
  344|       |
  345|    211|    const auto implementations = get_supported_implementations();
  346|    211|    std::vector<std::size_t> results;
  347|    211|    results.reserve(implementations.size());
  348|       |
  349|    633|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 633, False: 211]
  ------------------
  350|    633|      const auto len = invoke_lengthcalc(impl, src);
  351|    633|      results.push_back(len);
  352|    633|      ret.length.push_back(len);
  353|    633|    }
  354|       |
  355|    211|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    211|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 211]
  ------------------
  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|    211|    } else {
  375|    211|      ret.implementations_agree = true;
  376|    211|    }
  377|    211|    return ret;
  378|    211|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    633|                                FromSpan src) const {
  331|    633|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    633|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    422|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    206|                                  const bool inputisvalid) const {
  383|    206|    conversion_result ret{};
  384|       |
  385|    206|    const auto implementations = get_supported_implementations();
  386|       |
  387|    206|    std::vector<result<ConversionResult>> results;
  388|    206|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    206|    std::vector<std::vector<ToType>> outputbuffers;
  393|    206|    outputbuffers.reserve(implementations.size());
  394|    824|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 618, False: 206]
  ------------------
  395|    618|      auto impl = implementations[i];
  396|    618|      const ToType canary1{42};
  397|    618|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    618|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    618|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    618|      const auto success = [](const ConversionResult& r) -> bool {
  402|    618|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    618|          return r != 0;
  404|    618|        } else {
  405|    618|          return r.error == simdutf::error_code::SUCCESS;
  406|    618|        }
  407|    618|      }(implret1);
  408|    618|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    618|      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|    618|        const ToType canary2{25};
  414|    618|        const auto outputbuffer_first_run = outputbuffer;
  415|    618|        std::ranges::fill(outputbuffer, canary2);
  416|    618|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    618|                                          src.size(), outputbuffer.data());
  418|       |
  419|    618|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 618]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    618|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 360, False: 258]
  |  Branch (423:29): [True: 348, False: 12]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    348|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    348|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 348]
  ------------------
  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|    348|        }
  440|    618|      }
  441|    618|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 348, False: 270]
  ------------------
  442|    618|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    206|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 86, False: 120]
  ------------------
  447|    258|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 258, False: 86]
  ------------------
  448|    258|        e.outputhash.clear();
  449|    258|      }
  450|     86|    }
  451|       |
  452|    206|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    206|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 206]
  ------------------
  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|    206|    } else {
  474|    206|      ret.implementations_agree = true;
  475|    206|    }
  476|    206|    return ret;
  477|    206|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    618|      const auto success = [](const ConversionResult& r) -> bool {
  402|    618|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    618|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    618|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    412|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_3clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    236|    +[](std::span<const char> chardata) {                                      \
  555|    236|      const auto c =                                                           \
  556|    236|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    236|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    236|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    236|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    236|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    236|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    236|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    236|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    236|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    236|  constexpr auto _size = _name.size();                                \
  |  | 1183|    236|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    236|  return _nameof; }()
  ------------------
  561|    236|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    236|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    236|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    236|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    236|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    236|  constexpr auto _size = _name.size();                                \
  |  | 1183|    236|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    236|  return _nameof; }()
  ------------------
  562|    236|      c.fuzz(chardata);                                                        \
  563|    236|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    444|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    444|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    444|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    444|    static const bool do_print_testcase =
  181|    444|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    444|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 444]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    444|    do {
  189|       |      // step 0 - is the input valid?
  190|    444|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    444|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 444]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    444|                    From == UtfEncodings::UTF8) {
  198|    444|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 444]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    444|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    444|      const auto [output_length, length_agree] =
  204|    444|          calculate_length(from, inputisvalid);
  205|    444|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 444]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    444|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 117, False: 327]
  |  Branch (208:28): [True: 16, False: 101]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     16|        return;
  211|     16|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    428|      const auto [written, outputs_agree] =
  215|    428|          do_conversion(from, output_length, inputisvalid);
  216|    428|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 428]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    428|      return;
  221|    428|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    444|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    444|  validation_result verify_valid_input(FromSpan src) const {
  231|    444|    validation_result ret{};
  232|       |
  233|    444|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    444|    const auto implementations = get_supported_implementations();
  235|    444|    std::vector<simdutf::result> results;
  236|    444|    results.reserve(implementations.size());
  237|       |
  238|  1.33k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.33k, False: 444]
  ------------------
  239|  1.33k|      results.push_back(
  240|  1.33k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.33k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.33k|      const bool validation2 =
  245|  1.33k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.33k|                      src.data(), src.size());
  247|  1.33k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.33k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  1.33k|    }
  258|       |
  259|    444|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    444|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 444]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    444|    } else {
  273|    444|      ret.implementations_agree = true;
  274|    444|    }
  275|    444|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    444|      return r.error == simdutf::SUCCESS;
  277|    444|    });
  278|    444|    return ret;
  279|    444|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    888|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKNS1_6resultEE_clESI_:
  275|  1.09k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.09k|      return r.error == simdutf::SUCCESS;
  277|  1.09k|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    444|  bool count_the_input(FromSpan src) const {
  290|    444|    const auto implementations = get_supported_implementations();
  291|    444|    std::vector<std::size_t> results;
  292|    444|    results.reserve(implementations.size());
  293|       |
  294|  1.33k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.33k, False: 444]
  ------------------
  295|  1.33k|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|  1.33k|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|  1.33k|        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.33k|      results.push_back(ret);
  304|  1.33k|    }
  305|    444|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    444|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 444]
  ------------------
  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|    444|    return true;
  321|    444|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    888|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    444|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    444|    length_result ret{};
  344|       |
  345|    444|    const auto implementations = get_supported_implementations();
  346|    444|    std::vector<std::size_t> results;
  347|    444|    results.reserve(implementations.size());
  348|       |
  349|  1.33k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.33k, False: 444]
  ------------------
  350|  1.33k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.33k|      results.push_back(len);
  352|  1.33k|      ret.length.push_back(len);
  353|  1.33k|    }
  354|       |
  355|    444|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    444|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 444]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    444|    } else {
  375|    444|      ret.implementations_agree = true;
  376|    444|    }
  377|    444|    return ret;
  378|    444|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.33k|                                FromSpan src) const {
  331|  1.33k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.33k|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    888|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    428|                                  const bool inputisvalid) const {
  383|    428|    conversion_result ret{};
  384|       |
  385|    428|    const auto implementations = get_supported_implementations();
  386|       |
  387|    428|    std::vector<result<ConversionResult>> results;
  388|    428|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    428|    std::vector<std::vector<ToType>> outputbuffers;
  393|    428|    outputbuffers.reserve(implementations.size());
  394|  1.71k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.28k, False: 428]
  ------------------
  395|  1.28k|      auto impl = implementations[i];
  396|  1.28k|      const ToType canary1{42};
  397|  1.28k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.28k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.28k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.28k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.28k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.28k|          return r != 0;
  404|  1.28k|        } else {
  405|  1.28k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.28k|        }
  407|  1.28k|      }(implret1);
  408|  1.28k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.28k|      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.28k|        const ToType canary2{25};
  414|  1.28k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.28k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.28k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.28k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.28k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.28k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.28k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 981, False: 303]
  |  Branch (423:29): [True: 969, False: 12]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    969|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    969|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 969]
  ------------------
  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|    969|        }
  440|  1.28k|      }
  441|  1.28k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 969, False: 315]
  ------------------
  442|  1.28k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    428|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 101, False: 327]
  ------------------
  447|    303|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 303, False: 101]
  ------------------
  448|    303|        e.outputhash.clear();
  449|    303|      }
  450|    101|    }
  451|       |
  452|    428|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    428|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 428]
  ------------------
  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|    428|    } else {
  474|    428|      ret.implementations_agree = true;
  475|    428|    }
  476|    428|    return ret;
  477|    428|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.28k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.28k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.28k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.28k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    856|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_4clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     66|    +[](std::span<const char> chardata) {                                      \
  555|     66|      const auto c =                                                           \
  556|     66|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     66|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     66|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     66|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     66|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     66|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     66|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     66|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     66|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     66|  constexpr auto _size = _name.size();                                \
  |  | 1183|     66|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     66|  return _nameof; }()
  ------------------
  561|     66|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     66|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     66|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     66|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     66|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     66|  constexpr auto _size = _name.size();                                \
  |  | 1183|     66|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     66|  return _nameof; }()
  ------------------
  562|     66|      c.fuzz(chardata);                                                        \
  563|     66|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    333|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    333|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    333|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    333|    static const bool do_print_testcase =
  181|    333|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    333|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 333]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    333|    do {
  189|       |      // step 0 - is the input valid?
  190|    333|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    333|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 333]
  |  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|    333|      const auto [output_length, length_agree] =
  204|    333|          calculate_length(from, inputisvalid);
  205|    333|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 333]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    333|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 190, False: 143]
  |  Branch (208:28): [True: 2, False: 188]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      2|        return;
  211|      2|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    331|      const auto [written, outputs_agree] =
  215|    331|          do_conversion(from, output_length, inputisvalid);
  216|    331|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 331]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    331|      return;
  221|    331|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    333|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    333|  validation_result verify_valid_input(FromSpan src) const {
  231|    333|    validation_result ret{};
  232|       |
  233|    333|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    333|    const auto implementations = get_supported_implementations();
  235|    333|    std::vector<simdutf::result> results;
  236|    333|    results.reserve(implementations.size());
  237|       |
  238|    999|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 999, False: 333]
  ------------------
  239|    999|      results.push_back(
  240|    999|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    999|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    999|      const bool validation2 =
  245|    999|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    999|                      src.data(), src.size());
  247|    999|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 999]
  ------------------
  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|    999|    }
  258|       |
  259|    333|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    333|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 333]
  ------------------
  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|    333|    } else {
  273|    333|      ret.implementations_agree = true;
  274|    333|    }
  275|    333|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    333|      return r.error == simdutf::SUCCESS;
  277|    333|    });
  278|    333|    return ret;
  279|    333|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    666|    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|    619|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    619|      return r.error == simdutf::SUCCESS;
  277|    619|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    333|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    333|    length_result ret{};
  344|       |
  345|    333|    const auto implementations = get_supported_implementations();
  346|    333|    std::vector<std::size_t> results;
  347|    333|    results.reserve(implementations.size());
  348|       |
  349|    999|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 999, False: 333]
  ------------------
  350|    999|      const auto len = invoke_lengthcalc(impl, src);
  351|    999|      results.push_back(len);
  352|    999|      ret.length.push_back(len);
  353|    999|    }
  354|       |
  355|    333|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    333|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 333]
  ------------------
  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|    333|    } else {
  375|    333|      ret.implementations_agree = true;
  376|    333|    }
  377|    333|    return ret;
  378|    333|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    999|                                FromSpan src) const {
  331|    999|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    999|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    666|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    331|                                  const bool inputisvalid) const {
  383|    331|    conversion_result ret{};
  384|       |
  385|    331|    const auto implementations = get_supported_implementations();
  386|       |
  387|    331|    std::vector<result<ConversionResult>> results;
  388|    331|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    331|    std::vector<std::vector<ToType>> outputbuffers;
  393|    331|    outputbuffers.reserve(implementations.size());
  394|  1.32k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 993, False: 331]
  ------------------
  395|    993|      auto impl = implementations[i];
  396|    993|      const ToType canary1{42};
  397|    993|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    993|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    993|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    993|      const auto success = [](const ConversionResult& r) -> bool {
  402|    993|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    993|          return r != 0;
  404|    993|        } else {
  405|    993|          return r.error == simdutf::error_code::SUCCESS;
  406|    993|        }
  407|    993|      }(implret1);
  408|    993|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    993|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    993|        const ToType canary2{25};
  414|    993|        const auto outputbuffer_first_run = outputbuffer;
  415|    993|        std::ranges::fill(outputbuffer, canary2);
  416|    993|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    993|                                          src.size(), outputbuffer.data());
  418|       |
  419|    993|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 993]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    993|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 429, False: 564]
  |  Branch (423:29): [True: 417, False: 12]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    417|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    417|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 417]
  ------------------
  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|    417|        }
  440|    993|      }
  441|    993|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 417, False: 576]
  ------------------
  442|    993|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    331|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 188, False: 143]
  ------------------
  447|    564|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 564, False: 188]
  ------------------
  448|    564|        e.outputhash.clear();
  449|    564|      }
  450|    188|    }
  451|       |
  452|    331|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    331|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 331]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    331|    } else {
  474|    331|      ret.implementations_agree = true;
  475|    331|    }
  476|    331|    return ret;
  477|    331|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    993|      const auto success = [](const ConversionResult& r) -> bool {
  402|    993|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    993|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    993|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    662|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_5clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    131|    +[](std::span<const char> chardata) {                                      \
  555|    131|      const auto c =                                                           \
  556|    131|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    131|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    131|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    131|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    131|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    131|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    131|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    131|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    131|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    131|  constexpr auto _size = _name.size();                                \
  |  | 1183|    131|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    131|  return _nameof; }()
  ------------------
  561|    131|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    131|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    131|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    131|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    131|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    131|  constexpr auto _size = _name.size();                                \
  |  | 1183|    131|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    131|  return _nameof; }()
  ------------------
  562|    131|      c.fuzz(chardata);                                                        \
  563|    131|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    394|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    394|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    394|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    394|    static const bool do_print_testcase =
  181|    394|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    394|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 394]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    394|    do {
  189|       |      // step 0 - is the input valid?
  190|    394|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    394|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 394]
  |  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|    394|      const auto [output_length, length_agree] =
  204|    394|          calculate_length(from, inputisvalid);
  205|    394|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 394]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    394|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 193, False: 201]
  |  Branch (208:28): [True: 7, False: 186]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      7|        return;
  211|      7|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    387|      const auto [written, outputs_agree] =
  215|    387|          do_conversion(from, output_length, inputisvalid);
  216|    387|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 387]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    387|      return;
  221|    387|    } 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|    394|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    394|  validation_result verify_valid_input(FromSpan src) const {
  231|    394|    validation_result ret{};
  232|       |
  233|    394|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    394|    const auto implementations = get_supported_implementations();
  235|    394|    std::vector<simdutf::result> results;
  236|    394|    results.reserve(implementations.size());
  237|       |
  238|  1.18k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.18k, False: 394]
  ------------------
  239|  1.18k|      results.push_back(
  240|  1.18k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.18k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.18k|      const bool validation2 =
  245|  1.18k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.18k|                      src.data(), src.size());
  247|  1.18k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.18k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  1.18k|    }
  258|       |
  259|    394|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    394|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 394]
  ------------------
  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|    394|    } else {
  273|    394|      ret.implementations_agree = true;
  274|    394|    }
  275|    394|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    394|      return r.error == simdutf::SUCCESS;
  277|    394|    });
  278|    394|    return ret;
  279|    394|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    788|    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|    796|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    796|      return r.error == simdutf::SUCCESS;
  277|    796|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    394|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    394|    length_result ret{};
  344|       |
  345|    394|    const auto implementations = get_supported_implementations();
  346|    394|    std::vector<std::size_t> results;
  347|    394|    results.reserve(implementations.size());
  348|       |
  349|  1.18k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.18k, False: 394]
  ------------------
  350|  1.18k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.18k|      results.push_back(len);
  352|  1.18k|      ret.length.push_back(len);
  353|  1.18k|    }
  354|       |
  355|    394|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    394|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 394]
  ------------------
  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|    394|    } else {
  375|    394|      ret.implementations_agree = true;
  376|    394|    }
  377|    394|    return ret;
  378|    394|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.18k|                                FromSpan src) const {
  331|  1.18k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.18k|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    788|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    387|                                  const bool inputisvalid) const {
  383|    387|    conversion_result ret{};
  384|       |
  385|    387|    const auto implementations = get_supported_implementations();
  386|       |
  387|    387|    std::vector<result<ConversionResult>> results;
  388|    387|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    387|    std::vector<std::vector<ToType>> outputbuffers;
  393|    387|    outputbuffers.reserve(implementations.size());
  394|  1.54k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.16k, False: 387]
  ------------------
  395|  1.16k|      auto impl = implementations[i];
  396|  1.16k|      const ToType canary1{42};
  397|  1.16k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.16k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.16k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.16k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.16k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.16k|          return r != 0;
  404|  1.16k|        } else {
  405|  1.16k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.16k|        }
  407|  1.16k|      }(implret1);
  408|  1.16k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.16k|      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.16k|        const ToType canary2{25};
  414|  1.16k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.16k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.16k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.16k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.16k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.16k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.16k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 603, False: 558]
  |  Branch (423:29): [True: 588, False: 15]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    588|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    588|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 588]
  ------------------
  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|    588|        }
  440|  1.16k|      }
  441|  1.16k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 588, False: 573]
  ------------------
  442|  1.16k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    387|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 186, False: 201]
  ------------------
  447|    558|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 558, False: 186]
  ------------------
  448|    558|        e.outputhash.clear();
  449|    558|      }
  450|    186|    }
  451|       |
  452|    387|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    387|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 387]
  ------------------
  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|    387|    } else {
  474|    387|      ret.implementations_agree = true;
  475|    387|    }
  476|    387|    return ret;
  477|    387|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.16k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.16k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.16k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.16k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    774|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_6clENSt3__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|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    470|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    470|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    470|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    470|    static const bool do_print_testcase =
  181|    470|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    470|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 470]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    470|    do {
  189|       |      // step 0 - is the input valid?
  190|    470|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    470|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 470]
  |  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|    470|      const auto [output_length, length_agree] =
  204|    470|          calculate_length(from, inputisvalid);
  205|    470|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 470]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    470|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 311, False: 159]
  |  Branch (208:28): [True: 12, False: 299]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     12|        return;
  211|     12|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    458|      const auto [written, outputs_agree] =
  215|    458|          do_conversion(from, output_length, inputisvalid);
  216|    458|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 458]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    458|      return;
  221|    458|    } 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|    470|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    470|  validation_result verify_valid_input(FromSpan src) const {
  231|    470|    validation_result ret{};
  232|       |
  233|    470|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    470|    const auto implementations = get_supported_implementations();
  235|    470|    std::vector<simdutf::result> results;
  236|    470|    results.reserve(implementations.size());
  237|       |
  238|  1.41k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.41k, False: 470]
  ------------------
  239|  1.41k|      results.push_back(
  240|  1.41k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.41k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.41k|      const bool validation2 =
  245|  1.41k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.41k|                      src.data(), src.size());
  247|  1.41k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.41k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  1.41k|    }
  258|       |
  259|    470|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    470|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 470]
  ------------------
  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|    470|    } else {
  273|    470|      ret.implementations_agree = true;
  274|    470|    }
  275|    470|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    470|      return r.error == simdutf::SUCCESS;
  277|    470|    });
  278|    470|    return ret;
  279|    470|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    940|    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|    788|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    788|      return r.error == simdutf::SUCCESS;
  277|    788|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    470|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    470|    length_result ret{};
  344|       |
  345|    470|    const auto implementations = get_supported_implementations();
  346|    470|    std::vector<std::size_t> results;
  347|    470|    results.reserve(implementations.size());
  348|       |
  349|  1.41k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.41k, False: 470]
  ------------------
  350|  1.41k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.41k|      results.push_back(len);
  352|  1.41k|      ret.length.push_back(len);
  353|  1.41k|    }
  354|       |
  355|    470|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    470|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 470]
  ------------------
  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|    470|    } else {
  375|    470|      ret.implementations_agree = true;
  376|    470|    }
  377|    470|    return ret;
  378|    470|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.41k|                                FromSpan src) const {
  331|  1.41k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.41k|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    940|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    458|                                  const bool inputisvalid) const {
  383|    458|    conversion_result ret{};
  384|       |
  385|    458|    const auto implementations = get_supported_implementations();
  386|       |
  387|    458|    std::vector<result<ConversionResult>> results;
  388|    458|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    458|    std::vector<std::vector<ToType>> outputbuffers;
  393|    458|    outputbuffers.reserve(implementations.size());
  394|  1.83k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.37k, False: 458]
  ------------------
  395|  1.37k|      auto impl = implementations[i];
  396|  1.37k|      const ToType canary1{42};
  397|  1.37k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.37k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.37k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.37k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.37k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.37k|          return r != 0;
  404|  1.37k|        } else {
  405|  1.37k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.37k|        }
  407|  1.37k|      }(implret1);
  408|  1.37k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.37k|      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.37k|        const ToType canary2{25};
  414|  1.37k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.37k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.37k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.37k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.37k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.37k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.37k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 477, False: 897]
  |  Branch (423:29): [True: 468, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    468|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    468|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 468]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    468|        }
  440|  1.37k|      }
  441|  1.37k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 468, False: 906]
  ------------------
  442|  1.37k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    458|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 299, False: 159]
  ------------------
  447|    897|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 897, False: 299]
  ------------------
  448|    897|        e.outputhash.clear();
  449|    897|      }
  450|    299|    }
  451|       |
  452|    458|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    458|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 458]
  ------------------
  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|    458|    } else {
  474|    458|      ret.implementations_agree = true;
  475|    458|    }
  476|    458|    return ret;
  477|    458|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.37k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.37k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.37k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.37k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    916|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_7clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    248|    +[](std::span<const char> chardata) {                                      \
  555|    248|      const auto c =                                                           \
  556|    248|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    248|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    248|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    248|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    248|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    248|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    248|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    248|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    248|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    248|  constexpr auto _size = _name.size();                                \
  |  | 1183|    248|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    248|  return _nameof; }()
  ------------------
  561|    248|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    248|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    248|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    248|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    248|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    248|  constexpr auto _size = _name.size();                                \
  |  | 1183|    248|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    248|  return _nameof; }()
  ------------------
  562|    248|      c.fuzz(chardata);                                                        \
  563|    248|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    626|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    626|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    626|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    626|    static const bool do_print_testcase =
  181|    626|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    626|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 626]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    626|    do {
  189|       |      // step 0 - is the input valid?
  190|    626|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    626|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 626]
  |  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|    626|                    From == UtfEncodings::UTF8) {
  198|    626|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 626]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    626|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    626|      const auto [output_length, length_agree] =
  204|    626|          calculate_length(from, inputisvalid);
  205|    626|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 626]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    626|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 289, False: 337]
  |  Branch (208:28): [True: 10, False: 279]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     10|        return;
  211|     10|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    616|      const auto [written, outputs_agree] =
  215|    616|          do_conversion(from, output_length, inputisvalid);
  216|    616|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 616]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    616|      return;
  221|    616|    } 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|    626|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    626|  validation_result verify_valid_input(FromSpan src) const {
  231|    626|    validation_result ret{};
  232|       |
  233|    626|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    626|    const auto implementations = get_supported_implementations();
  235|    626|    std::vector<simdutf::result> results;
  236|    626|    results.reserve(implementations.size());
  237|       |
  238|  1.87k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.87k, False: 626]
  ------------------
  239|  1.87k|      results.push_back(
  240|  1.87k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.87k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.87k|      const bool validation2 =
  245|  1.87k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.87k|                      src.data(), src.size());
  247|  1.87k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.87k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  1.87k|    }
  258|       |
  259|    626|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    626|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 626]
  ------------------
  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|    626|    } else {
  273|    626|      ret.implementations_agree = true;
  274|    626|    }
  275|    626|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    626|      return r.error == simdutf::SUCCESS;
  277|    626|    });
  278|    626|    return ret;
  279|    626|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|  1.25k|    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.30k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.30k|      return r.error == simdutf::SUCCESS;
  277|  1.30k|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    626|  bool count_the_input(FromSpan src) const {
  290|    626|    const auto implementations = get_supported_implementations();
  291|    626|    std::vector<std::size_t> results;
  292|    626|    results.reserve(implementations.size());
  293|       |
  294|  1.87k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.87k, False: 626]
  ------------------
  295|  1.87k|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|       |      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|       |        ret = impl->count_utf16le(src.data(), src.size());
  300|  1.87k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.87k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.87k|      }
  303|  1.87k|      results.push_back(ret);
  304|  1.87k|    }
  305|    626|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    626|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 626]
  ------------------
  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|    626|    return true;
  321|    626|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|  1.25k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    626|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    626|    length_result ret{};
  344|       |
  345|    626|    const auto implementations = get_supported_implementations();
  346|    626|    std::vector<std::size_t> results;
  347|    626|    results.reserve(implementations.size());
  348|       |
  349|  1.87k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.87k, False: 626]
  ------------------
  350|  1.87k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.87k|      results.push_back(len);
  352|  1.87k|      ret.length.push_back(len);
  353|  1.87k|    }
  354|       |
  355|    626|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    626|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 626]
  ------------------
  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|    626|    } else {
  375|    626|      ret.implementations_agree = true;
  376|    626|    }
  377|    626|    return ret;
  378|    626|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.87k|                                FromSpan src) const {
  331|  1.87k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.87k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|  1.25k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    616|                                  const bool inputisvalid) const {
  383|    616|    conversion_result ret{};
  384|       |
  385|    616|    const auto implementations = get_supported_implementations();
  386|       |
  387|    616|    std::vector<result<ConversionResult>> results;
  388|    616|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    616|    std::vector<std::vector<ToType>> outputbuffers;
  393|    616|    outputbuffers.reserve(implementations.size());
  394|  2.46k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.84k, False: 616]
  ------------------
  395|  1.84k|      auto impl = implementations[i];
  396|  1.84k|      const ToType canary1{42};
  397|  1.84k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.84k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.84k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.84k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.84k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.84k|          return r != 0;
  404|  1.84k|        } else {
  405|  1.84k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.84k|        }
  407|  1.84k|      }(implret1);
  408|  1.84k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.84k|      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.84k|        const ToType canary2{25};
  414|  1.84k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.84k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.84k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.84k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.84k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.84k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.84k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 1.01k, False: 837]
  |  Branch (423:29): [True: 1.00k, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|  1.00k|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|  1.00k|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 1.00k]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|  1.00k|        }
  440|  1.84k|      }
  441|  1.84k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 1.00k, False: 843]
  ------------------
  442|  1.84k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    616|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 279, False: 337]
  ------------------
  447|    837|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 837, False: 279]
  ------------------
  448|    837|        e.outputhash.clear();
  449|    837|      }
  450|    279|    }
  451|       |
  452|    616|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    616|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 616]
  ------------------
  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|    616|    } else {
  474|    616|      ret.implementations_agree = true;
  475|    616|    }
  476|    616|    return ret;
  477|    616|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.84k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.84k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.84k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.84k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|  1.23k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_8clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    239|    +[](std::span<const char> chardata) {                                      \
  555|    239|      const auto c =                                                           \
  556|    239|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    239|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    239|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    239|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    239|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    239|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    239|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    239|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    239|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    239|  constexpr auto _size = _name.size();                                \
  |  | 1183|    239|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    239|  return _nameof; }()
  ------------------
  561|    239|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    239|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    239|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    239|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    239|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    239|  constexpr auto _size = _name.size();                                \
  |  | 1183|    239|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    239|  return _nameof; }()
  ------------------
  562|    239|      c.fuzz(chardata);                                                        \
  563|    239|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    599|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    599|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    599|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    599|    static const bool do_print_testcase =
  181|    599|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    599|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 599]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    599|    do {
  189|       |      // step 0 - is the input valid?
  190|    599|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    599|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 599]
  |  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|    599|                    From == UtfEncodings::UTF8) {
  198|    599|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 599]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    599|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    599|      const auto [output_length, length_agree] =
  204|    599|          calculate_length(from, inputisvalid);
  205|    599|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 599]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    599|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 261, False: 338]
  |  Branch (208:28): [True: 17, False: 244]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     17|        return;
  211|     17|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    582|      const auto [written, outputs_agree] =
  215|    582|          do_conversion(from, output_length, inputisvalid);
  216|    582|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 582]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    582|      return;
  221|    582|    } 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|    599|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    599|  validation_result verify_valid_input(FromSpan src) const {
  231|    599|    validation_result ret{};
  232|       |
  233|    599|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    599|    const auto implementations = get_supported_implementations();
  235|    599|    std::vector<simdutf::result> results;
  236|    599|    results.reserve(implementations.size());
  237|       |
  238|  1.79k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.79k, False: 599]
  ------------------
  239|  1.79k|      results.push_back(
  240|  1.79k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.79k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.79k|      const bool validation2 =
  245|  1.79k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.79k|                      src.data(), src.size());
  247|  1.79k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.79k]
  ------------------
  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.79k|    }
  258|       |
  259|    599|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    599|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 599]
  ------------------
  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|    599|    } else {
  273|    599|      ret.implementations_agree = true;
  274|    599|    }
  275|    599|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    599|      return r.error == simdutf::SUCCESS;
  277|    599|    });
  278|    599|    return ret;
  279|    599|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|  1.19k|    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.27k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.27k|      return r.error == simdutf::SUCCESS;
  277|  1.27k|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    599|  bool count_the_input(FromSpan src) const {
  290|    599|    const auto implementations = get_supported_implementations();
  291|    599|    std::vector<std::size_t> results;
  292|    599|    results.reserve(implementations.size());
  293|       |
  294|  1.79k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.79k, False: 599]
  ------------------
  295|  1.79k|      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.79k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.79k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.79k|      }
  303|  1.79k|      results.push_back(ret);
  304|  1.79k|    }
  305|    599|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    599|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 599]
  ------------------
  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|    599|    return true;
  321|    599|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|  1.19k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    599|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    599|    length_result ret{};
  344|       |
  345|    599|    const auto implementations = get_supported_implementations();
  346|    599|    std::vector<std::size_t> results;
  347|    599|    results.reserve(implementations.size());
  348|       |
  349|  1.79k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.79k, False: 599]
  ------------------
  350|  1.79k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.79k|      results.push_back(len);
  352|  1.79k|      ret.length.push_back(len);
  353|  1.79k|    }
  354|       |
  355|    599|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    599|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 599]
  ------------------
  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|    599|    } else {
  375|    599|      ret.implementations_agree = true;
  376|    599|    }
  377|    599|    return ret;
  378|    599|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.79k|                                FromSpan src) const {
  331|  1.79k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.79k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|  1.19k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    582|                                  const bool inputisvalid) const {
  383|    582|    conversion_result ret{};
  384|       |
  385|    582|    const auto implementations = get_supported_implementations();
  386|       |
  387|    582|    std::vector<result<ConversionResult>> results;
  388|    582|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    582|    std::vector<std::vector<ToType>> outputbuffers;
  393|    582|    outputbuffers.reserve(implementations.size());
  394|  2.32k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.74k, False: 582]
  ------------------
  395|  1.74k|      auto impl = implementations[i];
  396|  1.74k|      const ToType canary1{42};
  397|  1.74k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.74k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.74k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.74k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.74k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.74k|          return r != 0;
  404|  1.74k|        } else {
  405|  1.74k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.74k|        }
  407|  1.74k|      }(implret1);
  408|  1.74k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.74k|      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.74k|        const ToType canary2{25};
  414|  1.74k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.74k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.74k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.74k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.74k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.74k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.74k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 1.01k, False: 732]
  |  Branch (423:29): [True: 1.00k, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|  1.00k|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|  1.00k|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 1.00k]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|  1.00k|        }
  440|  1.74k|      }
  441|  1.74k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 1.00k, False: 741]
  ------------------
  442|  1.74k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    582|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 244, False: 338]
  ------------------
  447|    732|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 732, False: 244]
  ------------------
  448|    732|        e.outputhash.clear();
  449|    732|      }
  450|    244|    }
  451|       |
  452|    582|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    582|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 582]
  ------------------
  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|    582|    } else {
  474|    582|      ret.implementations_agree = true;
  475|    582|    }
  476|    582|    return ret;
  477|    582|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.74k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.74k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.74k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.74k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|  1.16k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_9clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    229|    +[](std::span<const char> chardata) {                                      \
  555|    229|      const auto c =                                                           \
  556|    229|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    229|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    229|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    229|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    229|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    229|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    229|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    229|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    229|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    229|  constexpr auto _size = _name.size();                                \
  |  | 1183|    229|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    229|  return _nameof; }()
  ------------------
  561|    229|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    229|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    229|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    229|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    229|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    229|  constexpr auto _size = _name.size();                                \
  |  | 1183|    229|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    229|  return _nameof; }()
  ------------------
  562|    229|      c.fuzz(chardata);                                                        \
  563|    229|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    621|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    621|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    621|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    621|    static const bool do_print_testcase =
  181|    621|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    621|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 621]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    621|    do {
  189|       |      // step 0 - is the input valid?
  190|    621|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    621|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 621]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    621|                    From == UtfEncodings::UTF8) {
  198|    621|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 621]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    621|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    621|      const auto [output_length, length_agree] =
  204|    621|          calculate_length(from, inputisvalid);
  205|    621|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 621]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    621|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 268, False: 353]
  |  Branch (208:28): [True: 4, False: 264]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      4|        return;
  211|      4|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    617|      const auto [written, outputs_agree] =
  215|    617|          do_conversion(from, output_length, inputisvalid);
  216|    617|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 617]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    617|      return;
  221|    617|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    621|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    621|  validation_result verify_valid_input(FromSpan src) const {
  231|    621|    validation_result ret{};
  232|       |
  233|    621|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    621|    const auto implementations = get_supported_implementations();
  235|    621|    std::vector<simdutf::result> results;
  236|    621|    results.reserve(implementations.size());
  237|       |
  238|  1.86k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.86k, False: 621]
  ------------------
  239|  1.86k|      results.push_back(
  240|  1.86k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.86k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.86k|      const bool validation2 =
  245|  1.86k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.86k|                      src.data(), src.size());
  247|  1.86k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.86k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  1.86k|    }
  258|       |
  259|    621|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    621|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 621]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    621|    } else {
  273|    621|      ret.implementations_agree = true;
  274|    621|    }
  275|    621|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    621|      return r.error == simdutf::SUCCESS;
  277|    621|    });
  278|    621|    return ret;
  279|    621|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|  1.24k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKNS1_6resultEE_clESI_:
  275|  1.32k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.32k|      return r.error == simdutf::SUCCESS;
  277|  1.32k|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    621|  bool count_the_input(FromSpan src) const {
  290|    621|    const auto implementations = get_supported_implementations();
  291|    621|    std::vector<std::size_t> results;
  292|    621|    results.reserve(implementations.size());
  293|       |
  294|  1.86k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.86k, False: 621]
  ------------------
  295|  1.86k|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|       |      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|       |        ret = impl->count_utf16le(src.data(), src.size());
  300|  1.86k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.86k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.86k|      }
  303|  1.86k|      results.push_back(ret);
  304|  1.86k|    }
  305|    621|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    621|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 621]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    621|    return true;
  321|    621|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|  1.24k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    621|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    621|    length_result ret{};
  344|       |
  345|    621|    const auto implementations = get_supported_implementations();
  346|    621|    std::vector<std::size_t> results;
  347|    621|    results.reserve(implementations.size());
  348|       |
  349|  1.86k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.86k, False: 621]
  ------------------
  350|  1.86k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.86k|      results.push_back(len);
  352|  1.86k|      ret.length.push_back(len);
  353|  1.86k|    }
  354|       |
  355|    621|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    621|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 621]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    621|    } else {
  375|    621|      ret.implementations_agree = true;
  376|    621|    }
  377|    621|    return ret;
  378|    621|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.86k|                                FromSpan src) const {
  331|  1.86k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.86k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|  1.24k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    617|                                  const bool inputisvalid) const {
  383|    617|    conversion_result ret{};
  384|       |
  385|    617|    const auto implementations = get_supported_implementations();
  386|       |
  387|    617|    std::vector<result<ConversionResult>> results;
  388|    617|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    617|    std::vector<std::vector<ToType>> outputbuffers;
  393|    617|    outputbuffers.reserve(implementations.size());
  394|  2.46k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.85k, False: 617]
  ------------------
  395|  1.85k|      auto impl = implementations[i];
  396|  1.85k|      const ToType canary1{42};
  397|  1.85k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.85k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.85k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.85k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.85k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.85k|          return r != 0;
  404|  1.85k|        } else {
  405|  1.85k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.85k|        }
  407|  1.85k|      }(implret1);
  408|  1.85k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.85k|      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.85k|        const ToType canary2{25};
  414|  1.85k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.85k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.85k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.85k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.85k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.85k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.85k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 1.05k, False: 792]
  |  Branch (423:29): [True: 1.05k, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|  1.05k|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|  1.05k|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 1.05k]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|  1.05k|        }
  440|  1.85k|      }
  441|  1.85k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 1.05k, False: 801]
  ------------------
  442|  1.85k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    617|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 264, False: 353]
  ------------------
  447|    792|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 792, False: 264]
  ------------------
  448|    792|        e.outputhash.clear();
  449|    792|      }
  450|    264|    }
  451|       |
  452|    617|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    617|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 617]
  ------------------
  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|    617|    } else {
  474|    617|      ret.implementations_agree = true;
  475|    617|    }
  476|    617|    return ret;
  477|    617|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.85k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.85k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.85k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.85k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|  1.23k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_10clENSt3__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|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|     47|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     47|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     47|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     47|    static const bool do_print_testcase =
  181|     47|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     47|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 47]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     47|    do {
  189|       |      // step 0 - is the input valid?
  190|     47|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     47|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 47]
  |  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|     47|                    From == UtfEncodings::UTF8) {
  198|     47|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 47]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|     47|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|     47|      const auto [output_length, length_agree] =
  204|     47|          calculate_length(from, inputisvalid);
  205|     47|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 47]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     47|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 9, False: 38]
  |  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|     47|      const auto [written, outputs_agree] =
  215|     47|          do_conversion(from, output_length, inputisvalid);
  216|     47|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 47]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     47|      return;
  221|     47|    } 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|     47|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  230|     47|  validation_result verify_valid_input(FromSpan src) const {
  231|     47|    validation_result ret{};
  232|       |
  233|     47|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|     47|    const auto implementations = get_supported_implementations();
  235|     47|    std::vector<simdutf::result> results;
  236|     47|    results.reserve(implementations.size());
  237|       |
  238|    141|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 141, False: 47]
  ------------------
  239|    141|      results.push_back(
  240|    141|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    141|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    141|      const bool validation2 =
  245|    141|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    141|                      src.data(), src.size());
  247|    141|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 141]
  ------------------
  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|    141|    }
  258|       |
  259|     47|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|     47|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 47]
  ------------------
  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|     47|    } else {
  273|     47|      ret.implementations_agree = true;
  274|     47|    }
  275|     47|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|     47|      return r.error == simdutf::SUCCESS;
  277|     47|    });
  278|     47|    return ret;
  279|     47|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|     94|    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|    123|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    123|      return r.error == simdutf::SUCCESS;
  277|    123|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE15count_the_inputENSt3__14spanIS5_Lm18446744073709551615EEE:
  289|     47|  bool count_the_input(FromSpan src) const {
  290|     47|    const auto implementations = get_supported_implementations();
  291|     47|    std::vector<std::size_t> results;
  292|     47|    results.reserve(implementations.size());
  293|       |
  294|    141|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 141, False: 47]
  ------------------
  295|    141|      std::size_t ret;
  296|    141|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    141|        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|    141|      results.push_back(ret);
  304|    141|    }
  305|     47|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|     47|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 47]
  ------------------
  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|     47|    return true;
  321|     47|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE15count_the_inputENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|     94|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     47|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     47|    length_result ret{};
  344|       |
  345|     47|    const auto implementations = get_supported_implementations();
  346|     47|    std::vector<std::size_t> results;
  347|     47|    results.reserve(implementations.size());
  348|       |
  349|    141|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 141, False: 47]
  ------------------
  350|    141|      const auto len = invoke_lengthcalc(impl, src);
  351|    141|      results.push_back(len);
  352|    141|      ret.length.push_back(len);
  353|    141|    }
  354|       |
  355|     47|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     47|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 47]
  ------------------
  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|     47|    } else {
  375|     47|      ret.implementations_agree = true;
  376|     47|    }
  377|     47|    return ret;
  378|     47|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    141|                                FromSpan src) const {
  339|    141|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    141|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|     94|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     47|                                  const bool inputisvalid) const {
  383|     47|    conversion_result ret{};
  384|       |
  385|     47|    const auto implementations = get_supported_implementations();
  386|       |
  387|     47|    std::vector<result<ConversionResult>> results;
  388|     47|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     47|    std::vector<std::vector<ToType>> outputbuffers;
  393|     47|    outputbuffers.reserve(implementations.size());
  394|    188|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 141, False: 47]
  ------------------
  395|    141|      auto impl = implementations[i];
  396|    141|      const ToType canary1{42};
  397|    141|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    141|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    141|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    141|      const auto success = [](const ConversionResult& r) -> bool {
  402|    141|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    141|          return r != 0;
  404|    141|        } else {
  405|    141|          return r.error == simdutf::error_code::SUCCESS;
  406|    141|        }
  407|    141|      }(implret1);
  408|    141|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    141|      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|    141|        const ToType canary2{25};
  414|    141|        const auto outputbuffer_first_run = outputbuffer;
  415|    141|        std::ranges::fill(outputbuffer, canary2);
  416|    141|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    141|                                          src.size(), outputbuffer.data());
  418|       |
  419|    141|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 141]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    141|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 114, False: 27]
  |  Branch (423:29): [True: 60, False: 54]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|     60|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|     60|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 60]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|     60|        }
  440|    141|      }
  441|    141|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 60, False: 81]
  ------------------
  442|    141|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     47|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 9, False: 38]
  ------------------
  447|     27|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 27, False: 9]
  ------------------
  448|     27|        e.outputhash.clear();
  449|     27|      }
  450|      9|    }
  451|       |
  452|     47|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     47|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 47]
  ------------------
  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|     47|    } else {
  474|     47|      ret.implementations_agree = true;
  475|     47|    }
  476|     47|    return ret;
  477|     47|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    141|      const auto success = [](const ConversionResult& r) -> bool {
  402|    141|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    141|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    141|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|     94|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_11clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    110|    +[](std::span<const char> chardata) {                                      \
  555|    110|      const auto c =                                                           \
  556|    110|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    110|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    110|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    110|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    110|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    110|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    110|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    110|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    110|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    110|  constexpr auto _size = _name.size();                                \
  |  | 1183|    110|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    110|  return _nameof; }()
  ------------------
  561|    110|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    110|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    110|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    110|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    110|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    110|  constexpr auto _size = _name.size();                                \
  |  | 1183|    110|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    110|  return _nameof; }()
  ------------------
  562|    110|      c.fuzz(chardata);                                                        \
  563|    110|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_12clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    176|    +[](std::span<const char> chardata) {                                      \
  555|    176|      const auto c =                                                           \
  556|    176|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    176|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    176|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    176|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    176|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    176|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    176|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    176|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    176|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    176|  constexpr auto _size = _name.size();                                \
  |  | 1183|    176|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    176|  return _nameof; }()
  ------------------
  561|    176|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    176|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    176|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    176|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    176|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    176|  constexpr auto _size = _name.size();                                \
  |  | 1183|    176|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    176|  return _nameof; }()
  ------------------
  562|    176|      c.fuzz(chardata);                                                        \
  563|    176|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_13clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     67|    +[](std::span<const char> chardata) {                                      \
  555|     67|      const auto c =                                                           \
  556|     67|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     67|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     67|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     67|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     67|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     67|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     67|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     67|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     67|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     67|  constexpr auto _size = _name.size();                                \
  |  | 1183|     67|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     67|  return _nameof; }()
  ------------------
  561|     67|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     67|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     67|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     67|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     67|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     67|  constexpr auto _size = _name.size();                                \
  |  | 1183|     67|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     67|  return _nameof; }()
  ------------------
  562|     67|      c.fuzz(chardata);                                                        \
  563|     67|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|     67|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     67|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     67|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     67|    static const bool do_print_testcase =
  181|     67|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     67|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 67]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     67|    do {
  189|       |      // step 0 - is the input valid?
  190|     67|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     67|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 67]
  |  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|     67|                    From == UtfEncodings::UTF8) {
  198|     67|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 67]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|     67|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|     67|      const auto [output_length, length_agree] =
  204|     67|          calculate_length(from, inputisvalid);
  205|     67|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 67]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     67|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 19, False: 48]
  |  Branch (208:28): [True: 0, False: 19]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|     67|      const auto [written, outputs_agree] =
  215|     67|          do_conversion(from, output_length, inputisvalid);
  216|     67|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 67]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     67|      return;
  221|     67|    } 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|     67|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  230|     67|  validation_result verify_valid_input(FromSpan src) const {
  231|     67|    validation_result ret{};
  232|       |
  233|     67|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|     67|    const auto implementations = get_supported_implementations();
  235|     67|    std::vector<simdutf::result> results;
  236|     67|    results.reserve(implementations.size());
  237|       |
  238|    201|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 201, False: 67]
  ------------------
  239|    201|      results.push_back(
  240|    201|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    201|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    201|      const bool validation2 =
  245|    201|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    201|                      src.data(), src.size());
  247|    201|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 201]
  ------------------
  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|    201|    }
  258|       |
  259|     67|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|     67|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 67]
  ------------------
  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|     67|    } else {
  273|     67|      ret.implementations_agree = true;
  274|     67|    }
  275|     67|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|     67|      return r.error == simdutf::SUCCESS;
  277|     67|    });
  278|     67|    return ret;
  279|     67|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    134|    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|    163|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    163|      return r.error == simdutf::SUCCESS;
  277|    163|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE15count_the_inputENSt3__14spanIS5_Lm18446744073709551615EEE:
  289|     67|  bool count_the_input(FromSpan src) const {
  290|     67|    const auto implementations = get_supported_implementations();
  291|     67|    std::vector<std::size_t> results;
  292|     67|    results.reserve(implementations.size());
  293|       |
  294|    201|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 201, False: 67]
  ------------------
  295|    201|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    201|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    201|        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|    201|      results.push_back(ret);
  304|    201|    }
  305|     67|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|     67|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 67]
  ------------------
  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|     67|    return true;
  321|     67|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE15count_the_inputENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    134|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     67|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     67|    length_result ret{};
  344|       |
  345|     67|    const auto implementations = get_supported_implementations();
  346|     67|    std::vector<std::size_t> results;
  347|     67|    results.reserve(implementations.size());
  348|       |
  349|    201|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 201, False: 67]
  ------------------
  350|    201|      const auto len = invoke_lengthcalc(impl, src);
  351|    201|      results.push_back(len);
  352|    201|      ret.length.push_back(len);
  353|    201|    }
  354|       |
  355|     67|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     67|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 67]
  ------------------
  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|     67|    } else {
  375|     67|      ret.implementations_agree = true;
  376|     67|    }
  377|     67|    return ret;
  378|     67|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    201|                                FromSpan src) const {
  339|    201|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    201|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    134|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     67|                                  const bool inputisvalid) const {
  383|     67|    conversion_result ret{};
  384|       |
  385|     67|    const auto implementations = get_supported_implementations();
  386|       |
  387|     67|    std::vector<result<ConversionResult>> results;
  388|     67|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     67|    std::vector<std::vector<ToType>> outputbuffers;
  393|     67|    outputbuffers.reserve(implementations.size());
  394|    268|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 201, False: 67]
  ------------------
  395|    201|      auto impl = implementations[i];
  396|    201|      const ToType canary1{42};
  397|    201|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    201|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    201|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    201|      const auto success = [](const ConversionResult& r) -> bool {
  402|    201|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    201|          return r != 0;
  404|    201|        } else {
  405|    201|          return r.error == simdutf::error_code::SUCCESS;
  406|    201|        }
  407|    201|      }(implret1);
  408|    201|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    201|      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|    201|        const ToType canary2{25};
  414|    201|        const auto outputbuffer_first_run = outputbuffer;
  415|    201|        std::ranges::fill(outputbuffer, canary2);
  416|    201|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    201|                                          src.size(), outputbuffer.data());
  418|       |
  419|    201|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 201]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    201|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 144, False: 57]
  |  Branch (423:29): [True: 69, False: 75]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|     69|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|     69|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 69]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|     69|        }
  440|    201|      }
  441|    201|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 69, False: 132]
  ------------------
  442|    201|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     67|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 19, False: 48]
  ------------------
  447|     57|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 57, False: 19]
  ------------------
  448|     57|        e.outputhash.clear();
  449|     57|      }
  450|     19|    }
  451|       |
  452|     67|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     67|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 67]
  ------------------
  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|     67|    } else {
  474|     67|      ret.implementations_agree = true;
  475|     67|    }
  476|     67|    return ret;
  477|     67|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    201|      const auto success = [](const ConversionResult& r) -> bool {
  402|    201|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    201|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    201|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    134|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_14clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    153|    +[](std::span<const char> chardata) {                                      \
  555|    153|      const auto c =                                                           \
  556|    153|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    153|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    153|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    153|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    153|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    153|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    153|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    153|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    153|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    153|  constexpr auto _size = _name.size();                                \
  |  | 1183|    153|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    153|  return _nameof; }()
  ------------------
  561|    153|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    153|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    153|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    153|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    153|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    153|  constexpr auto _size = _name.size();                                \
  |  | 1183|    153|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    153|  return _nameof; }()
  ------------------
  562|    153|      c.fuzz(chardata);                                                        \
  563|    153|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_15clENSt3__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|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_16clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     86|    +[](std::span<const char> chardata) {                                      \
  555|     86|      const auto c =                                                           \
  556|     86|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     86|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     86|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     86|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     86|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     86|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     86|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     86|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     86|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     86|  constexpr auto _size = _name.size();                                \
  |  | 1183|     86|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     86|  return _nameof; }()
  ------------------
  561|     86|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     86|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     86|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     86|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     86|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     86|  constexpr auto _size = _name.size();                                \
  |  | 1183|     86|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     86|  return _nameof; }()
  ------------------
  562|     86|      c.fuzz(chardata);                                                        \
  563|     86|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|     86|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     86|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     86|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     86|    static const bool do_print_testcase =
  181|     86|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     86|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 86]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     86|    do {
  189|       |      // step 0 - is the input valid?
  190|     86|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     86|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 86]
  |  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|     86|      const auto [output_length, length_agree] =
  204|     86|          calculate_length(from, inputisvalid);
  205|     86|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 86]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     86|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 59, False: 27]
  |  Branch (208:28): [True: 0, False: 59]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|     86|      const auto [written, outputs_agree] =
  215|     86|          do_conversion(from, output_length, inputisvalid);
  216|     86|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 86]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     86|      return;
  221|     86|    } 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|     86|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  230|     86|  validation_result verify_valid_input(FromSpan src) const {
  231|     86|    validation_result ret{};
  232|       |
  233|     86|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|     86|    const auto implementations = get_supported_implementations();
  235|     86|    std::vector<simdutf::result> results;
  236|     86|    results.reserve(implementations.size());
  237|       |
  238|    258|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 258, False: 86]
  ------------------
  239|    258|      results.push_back(
  240|    258|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    258|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    258|      const bool validation2 =
  245|    258|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    258|                      src.data(), src.size());
  247|    258|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 258]
  ------------------
  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|    258|    }
  258|       |
  259|     86|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|     86|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 86]
  ------------------
  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|     86|    } else {
  273|     86|      ret.implementations_agree = true;
  274|     86|    }
  275|     86|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|     86|      return r.error == simdutf::SUCCESS;
  277|     86|    });
  278|     86|    return ret;
  279|     86|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    172|    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|    140|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    140|      return r.error == simdutf::SUCCESS;
  277|    140|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     86|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     86|    length_result ret{};
  344|       |
  345|     86|    const auto implementations = get_supported_implementations();
  346|     86|    std::vector<std::size_t> results;
  347|     86|    results.reserve(implementations.size());
  348|       |
  349|    258|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 258, False: 86]
  ------------------
  350|    258|      const auto len = invoke_lengthcalc(impl, src);
  351|    258|      results.push_back(len);
  352|    258|      ret.length.push_back(len);
  353|    258|    }
  354|       |
  355|     86|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     86|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 86]
  ------------------
  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|     86|    } else {
  375|     86|      ret.implementations_agree = true;
  376|     86|    }
  377|     86|    return ret;
  378|     86|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    258|                                FromSpan src) const {
  339|    258|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    258|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    172|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     86|                                  const bool inputisvalid) const {
  383|     86|    conversion_result ret{};
  384|       |
  385|     86|    const auto implementations = get_supported_implementations();
  386|       |
  387|     86|    std::vector<result<ConversionResult>> results;
  388|     86|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     86|    std::vector<std::vector<ToType>> outputbuffers;
  393|     86|    outputbuffers.reserve(implementations.size());
  394|    344|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 258, False: 86]
  ------------------
  395|    258|      auto impl = implementations[i];
  396|    258|      const ToType canary1{42};
  397|    258|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    258|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    258|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    258|      const auto success = [](const ConversionResult& r) -> bool {
  402|    258|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    258|          return r != 0;
  404|    258|        } else {
  405|    258|          return r.error == simdutf::error_code::SUCCESS;
  406|    258|        }
  407|    258|      }(implret1);
  408|    258|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    258|      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|    258|        const ToType canary2{25};
  414|    258|        const auto outputbuffer_first_run = outputbuffer;
  415|    258|        std::ranges::fill(outputbuffer, canary2);
  416|    258|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    258|                                          src.size(), outputbuffer.data());
  418|       |
  419|    258|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 258]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    258|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 81, False: 177]
  |  Branch (423:29): [True: 63, False: 18]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|     63|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|     63|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 63]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|     63|        }
  440|    258|      }
  441|    258|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 63, False: 195]
  ------------------
  442|    258|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     86|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 59, False: 27]
  ------------------
  447|    177|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 177, False: 59]
  ------------------
  448|    177|        e.outputhash.clear();
  449|    177|      }
  450|     59|    }
  451|       |
  452|     86|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     86|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 86]
  ------------------
  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|     86|    } else {
  474|     86|      ret.implementations_agree = true;
  475|     86|    }
  476|     86|    return ret;
  477|     86|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    258|      const auto success = [](const ConversionResult& r) -> bool {
  402|    258|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    258|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    258|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    172|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_17clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    267|    +[](std::span<const char> chardata) {                                      \
  555|    267|      const auto c =                                                           \
  556|    267|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    267|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    267|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    267|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    267|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    267|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    267|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    267|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    267|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    267|  constexpr auto _size = _name.size();                                \
  |  | 1183|    267|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    267|  return _nameof; }()
  ------------------
  561|    267|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    267|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    267|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    267|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    267|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    267|  constexpr auto _size = _name.size();                                \
  |  | 1183|    267|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    267|  return _nameof; }()
  ------------------
  562|    267|      c.fuzz(chardata);                                                        \
  563|    267|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_18clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    263|    +[](std::span<const char> chardata) {                                      \
  555|    263|      const auto c =                                                           \
  556|    263|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    263|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    263|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    263|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    263|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    263|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    263|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    263|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    263|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    263|  constexpr auto _size = _name.size();                                \
  |  | 1183|    263|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    263|  return _nameof; }()
  ------------------
  561|    263|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    263|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    263|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    263|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    263|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    263|  constexpr auto _size = _name.size();                                \
  |  | 1183|    263|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    263|  return _nameof; }()
  ------------------
  562|    263|      c.fuzz(chardata);                                                        \
  563|    263|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_19clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    355|    +[](std::span<const char> chardata) {                                      \
  555|    355|      const auto c =                                                           \
  556|    355|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    355|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    355|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    355|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    355|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    355|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    355|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    355|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    355|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    355|  constexpr auto _size = _name.size();                                \
  |  | 1183|    355|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    355|  return _nameof; }()
  ------------------
  561|    355|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    355|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    355|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    355|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    355|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    355|  constexpr auto _size = _name.size();                                \
  |  | 1183|    355|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    355|  return _nameof; }()
  ------------------
  562|    355|      c.fuzz(chardata);                                                        \
  563|    355|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_20clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    295|    +[](std::span<const char> chardata) {                                      \
  555|    295|      const auto c =                                                           \
  556|    295|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    295|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    295|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    295|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    295|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    295|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    295|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    295|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    295|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    295|  constexpr auto _size = _name.size();                                \
  |  | 1183|    295|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    295|  return _nameof; }()
  ------------------
  561|    295|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    295|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    295|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    295|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    295|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    295|  constexpr auto _size = _name.size();                                \
  |  | 1183|    295|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    295|  return _nameof; }()
  ------------------
  562|    295|      c.fuzz(chardata);                                                        \
  563|    295|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    295|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    295|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    295|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    295|    static const bool do_print_testcase =
  181|    295|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    295|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 295]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    295|    do {
  189|       |      // step 0 - is the input valid?
  190|    295|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    295|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 295]
  |  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|    295|                    From == UtfEncodings::UTF8) {
  198|    295|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 295]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    295|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    295|      const auto [output_length, length_agree] =
  204|    295|          calculate_length(from, inputisvalid);
  205|    295|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 295]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    295|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 196, False: 99]
  |  Branch (208:28): [True: 0, False: 196]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    295|      const auto [written, outputs_agree] =
  215|    295|          do_conversion(from, output_length, inputisvalid);
  216|    295|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 295]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    295|      return;
  221|    295|    } 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|    295|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    295|  validation_result verify_valid_input(FromSpan src) const {
  231|    295|    validation_result ret{};
  232|       |
  233|    295|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    295|    const auto implementations = get_supported_implementations();
  235|    295|    std::vector<simdutf::result> results;
  236|    295|    results.reserve(implementations.size());
  237|       |
  238|    885|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 885, False: 295]
  ------------------
  239|    885|      results.push_back(
  240|    885|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    885|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    885|      const bool validation2 =
  245|    885|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    885|                      src.data(), src.size());
  247|    885|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 885]
  ------------------
  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|    885|    }
  258|       |
  259|    295|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    295|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 295]
  ------------------
  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|    295|    } else {
  273|    295|      ret.implementations_agree = true;
  274|    295|    }
  275|    295|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    295|      return r.error == simdutf::SUCCESS;
  277|    295|    });
  278|    295|    return ret;
  279|    295|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    590|    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|    493|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    493|      return r.error == simdutf::SUCCESS;
  277|    493|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    295|  bool count_the_input(FromSpan src) const {
  290|    295|    const auto implementations = get_supported_implementations();
  291|    295|    std::vector<std::size_t> results;
  292|    295|    results.reserve(implementations.size());
  293|       |
  294|    885|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 885, False: 295]
  ------------------
  295|    885|      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|    885|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|    885|        ret = impl->count_utf8(src.data(), src.size());
  302|    885|      }
  303|    885|      results.push_back(ret);
  304|    885|    }
  305|    295|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    295|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 295]
  ------------------
  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|    295|    return true;
  321|    295|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    590|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    295|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    295|    length_result ret{};
  344|       |
  345|    295|    const auto implementations = get_supported_implementations();
  346|    295|    std::vector<std::size_t> results;
  347|    295|    results.reserve(implementations.size());
  348|       |
  349|    885|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 885, False: 295]
  ------------------
  350|    885|      const auto len = invoke_lengthcalc(impl, src);
  351|    885|      results.push_back(len);
  352|    885|      ret.length.push_back(len);
  353|    885|    }
  354|       |
  355|    295|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    295|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 295]
  ------------------
  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|    295|    } else {
  375|    295|      ret.implementations_agree = true;
  376|    295|    }
  377|    295|    return ret;
  378|    295|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    885|                                FromSpan src) const {
  331|    885|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    885|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    590|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    295|                                  const bool inputisvalid) const {
  383|    295|    conversion_result ret{};
  384|       |
  385|    295|    const auto implementations = get_supported_implementations();
  386|       |
  387|    295|    std::vector<result<ConversionResult>> results;
  388|    295|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    295|    std::vector<std::vector<ToType>> outputbuffers;
  393|    295|    outputbuffers.reserve(implementations.size());
  394|  1.18k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 885, False: 295]
  ------------------
  395|    885|      auto impl = implementations[i];
  396|    885|      const ToType canary1{42};
  397|    885|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    885|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    885|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    885|      const auto success = [](const ConversionResult& r) -> bool {
  402|    885|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    885|          return r != 0;
  404|    885|        } else {
  405|    885|          return r.error == simdutf::error_code::SUCCESS;
  406|    885|        }
  407|    885|      }(implret1);
  408|    885|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    885|      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|    885|        const ToType canary2{25};
  414|    885|        const auto outputbuffer_first_run = outputbuffer;
  415|    885|        std::ranges::fill(outputbuffer, canary2);
  416|    885|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    885|                                          src.size(), outputbuffer.data());
  418|       |
  419|    885|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 885]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    885|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 297, False: 588]
  |  Branch (423:29): [True: 267, False: 30]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    267|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    267|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 267]
  ------------------
  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|    267|        }
  440|    885|      }
  441|    885|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 267, False: 618]
  ------------------
  442|    885|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    295|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 196, False: 99]
  ------------------
  447|    588|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 588, False: 196]
  ------------------
  448|    588|        e.outputhash.clear();
  449|    588|      }
  450|    196|    }
  451|       |
  452|    295|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    295|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 295]
  ------------------
  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|    295|    } else {
  474|    295|      ret.implementations_agree = true;
  475|    295|    }
  476|    295|    return ret;
  477|    295|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    885|      const auto success = [](const ConversionResult& r) -> bool {
  402|    885|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    885|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    885|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    590|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_21clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    378|    +[](std::span<const char> chardata) {                                      \
  555|    378|      const auto c =                                                           \
  556|    378|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    378|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    378|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    378|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    378|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    378|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    378|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    378|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    378|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    378|  constexpr auto _size = _name.size();                                \
  |  | 1183|    378|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    378|  return _nameof; }()
  ------------------
  561|    378|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    378|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    378|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    378|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    378|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    378|  constexpr auto _size = _name.size();                                \
  |  | 1183|    378|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    378|  return _nameof; }()
  ------------------
  562|    378|      c.fuzz(chardata);                                                        \
  563|    378|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_22clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    360|    +[](std::span<const char> chardata) {                                      \
  555|    360|      const auto c =                                                           \
  556|    360|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    360|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    360|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    360|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    360|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    360|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    360|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    360|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    360|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    360|  constexpr auto _size = _name.size();                                \
  |  | 1183|    360|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    360|  return _nameof; }()
  ------------------
  561|    360|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    360|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    360|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    360|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    360|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    360|  constexpr auto _size = _name.size();                                \
  |  | 1183|    360|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    360|  return _nameof; }()
  ------------------
  562|    360|      c.fuzz(chardata);                                                        \
  563|    360|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_23clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    392|    +[](std::span<const char> chardata) {                                      \
  555|    392|      const auto c =                                                           \
  556|    392|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    392|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    392|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    392|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    392|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    392|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    392|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    392|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    392|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    392|  constexpr auto _size = _name.size();                                \
  |  | 1183|    392|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    392|  return _nameof; }()
  ------------------
  561|    392|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    392|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    392|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    392|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    392|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    392|  constexpr auto _size = _name.size();                                \
  |  | 1183|    392|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    392|  return _nameof; }()
  ------------------
  562|    392|      c.fuzz(chardata);                                                        \
  563|    392|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_24clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    125|    +[](std::span<const char> chardata) {                                      \
  555|    125|      const auto c =                                                           \
  556|    125|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    125|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    125|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    125|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    125|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    125|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    125|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    125|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    125|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    125|  constexpr auto _size = _name.size();                                \
  |  | 1183|    125|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    125|  return _nameof; }()
  ------------------
  561|    125|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    125|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    125|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    125|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    125|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    125|  constexpr auto _size = _name.size();                                \
  |  | 1183|    125|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    125|  return _nameof; }()
  ------------------
  562|    125|      c.fuzz(chardata);                                                        \
  563|    125|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    125|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    125|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    125|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    125|    static const bool do_print_testcase =
  181|    125|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    125|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 125]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    125|    do {
  189|       |      // step 0 - is the input valid?
  190|    125|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    125|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 125]
  |  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|    125|                    From == UtfEncodings::UTF8) {
  198|    125|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 125]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    125|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    125|      const auto [output_length, length_agree] =
  204|    125|          calculate_length(from, inputisvalid);
  205|    125|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 125]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    125|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 20, False: 105]
  |  Branch (208:28): [True: 0, False: 20]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    125|      const auto [written, outputs_agree] =
  215|    125|          do_conversion(from, output_length, inputisvalid);
  216|    125|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 125]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    125|      return;
  221|    125|    } 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|    125|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEE:
  230|    125|  validation_result verify_valid_input(FromSpan src) const {
  231|    125|    validation_result ret{};
  232|       |
  233|    125|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    125|    const auto implementations = get_supported_implementations();
  235|    125|    std::vector<simdutf::result> results;
  236|    125|    results.reserve(implementations.size());
  237|       |
  238|    375|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 375, False: 125]
  ------------------
  239|    375|      results.push_back(
  240|    375|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    375|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    375|      const bool validation2 =
  245|    375|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    375|                      src.data(), src.size());
  247|    375|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 375]
  ------------------
  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|    375|    }
  258|       |
  259|    125|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    125|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 125]
  ------------------
  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|    125|    } else {
  273|    125|      ret.implementations_agree = true;
  274|    125|    }
  275|    125|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    125|      return r.error == simdutf::SUCCESS;
  277|    125|    });
  278|    125|    return ret;
  279|    125|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS5_S5_EEDaSJ_SM_:
  259|    250|    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|    335|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    335|      return r.error == simdutf::SUCCESS;
  277|    335|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE15count_the_inputENSt3__14spanIS6_Lm18446744073709551615EEE:
  289|    125|  bool count_the_input(FromSpan src) const {
  290|    125|    const auto implementations = get_supported_implementations();
  291|    125|    std::vector<std::size_t> results;
  292|    125|    results.reserve(implementations.size());
  293|       |
  294|    375|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 375, False: 125]
  ------------------
  295|    375|      std::size_t ret;
  296|    375|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    375|        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|    375|      results.push_back(ret);
  304|    375|    }
  305|    125|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    125|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 125]
  ------------------
  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|    125|    return true;
  321|    125|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE15count_the_inputENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    250|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEb:
  342|    125|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    125|    length_result ret{};
  344|       |
  345|    125|    const auto implementations = get_supported_implementations();
  346|    125|    std::vector<std::size_t> results;
  347|    125|    results.reserve(implementations.size());
  348|       |
  349|    375|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 375, False: 125]
  ------------------
  350|    375|      const auto len = invoke_lengthcalc(impl, src);
  351|    375|      results.push_back(len);
  352|    375|      ret.length.push_back(len);
  353|    375|    }
  354|       |
  355|    125|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    125|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 125]
  ------------------
  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|    125|    } else {
  375|    125|      ret.implementations_agree = true;
  376|    125|    }
  377|    125|    return ret;
  378|    125|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSF_NSt3__14spanIS6_Lm18446744073709551615EEE:
  338|    375|                                FromSpan src) const {
  339|    375|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    375|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    250|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    125|                                  const bool inputisvalid) const {
  383|    125|    conversion_result ret{};
  384|       |
  385|    125|    const auto implementations = get_supported_implementations();
  386|       |
  387|    125|    std::vector<result<ConversionResult>> results;
  388|    125|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    125|    std::vector<std::vector<ToType>> outputbuffers;
  393|    125|    outputbuffers.reserve(implementations.size());
  394|    500|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 375, False: 125]
  ------------------
  395|    375|      auto impl = implementations[i];
  396|    375|      const ToType canary1{42};
  397|    375|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    375|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    375|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    375|      const auto success = [](const ConversionResult& r) -> bool {
  402|    375|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    375|          return r != 0;
  404|    375|        } else {
  405|    375|          return r.error == simdutf::error_code::SUCCESS;
  406|    375|        }
  407|    375|      }(implret1);
  408|    375|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    375|      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|    375|        const ToType canary2{25};
  414|    375|        const auto outputbuffer_first_run = outputbuffer;
  415|    375|        std::ranges::fill(outputbuffer, canary2);
  416|    375|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    375|                                          src.size(), outputbuffer.data());
  418|       |
  419|    375|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 375]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    375|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 315, False: 60]
  |  Branch (423:29): [True: 129, False: 186]
  ------------------
  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|    375|      }
  441|    375|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 129, False: 246]
  ------------------
  442|    375|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    125|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 20, False: 105]
  ------------------
  447|     60|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 60, False: 20]
  ------------------
  448|     60|        e.outputhash.clear();
  449|     60|      }
  450|     20|    }
  451|       |
  452|    125|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    125|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 125]
  ------------------
  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|    125|    } else {
  474|    125|      ret.implementations_agree = true;
  475|    125|    }
  476|    125|    return ret;
  477|    125|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS5_E_clESM_:
  401|    375|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    375|        } else {
  405|    375|          return r.error == simdutf::error_code::SUCCESS;
  406|    375|        }
  407|    375|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS5_ESU_EEDaSN_SQ_:
  452|    250|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_25clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    173|    +[](std::span<const char> chardata) {                                      \
  555|    173|      const auto c =                                                           \
  556|    173|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    173|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    173|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    173|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    173|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    173|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    173|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    173|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    173|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    173|  constexpr auto _size = _name.size();                                \
  |  | 1183|    173|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    173|  return _nameof; }()
  ------------------
  561|    173|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    173|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    173|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    173|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    173|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    173|  constexpr auto _size = _name.size();                                \
  |  | 1183|    173|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    173|  return _nameof; }()
  ------------------
  562|    173|      c.fuzz(chardata);                                                        \
  563|    173|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    173|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    173|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    173|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    173|    static const bool do_print_testcase =
  181|    173|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    173|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 173]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    173|    do {
  189|       |      // step 0 - is the input valid?
  190|    173|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    173|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 173]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    173|                    From == UtfEncodings::UTF8) {
  198|    173|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 173]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    173|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    173|      const auto [output_length, length_agree] =
  204|    173|          calculate_length(from, inputisvalid);
  205|    173|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 173]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    173|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 90, False: 83]
  |  Branch (208:28): [True: 0, False: 90]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    173|      const auto [written, outputs_agree] =
  215|    173|          do_conversion(from, output_length, inputisvalid);
  216|    173|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 173]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    173|      return;
  221|    173|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    173|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    173|  validation_result verify_valid_input(FromSpan src) const {
  231|    173|    validation_result ret{};
  232|       |
  233|    173|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    173|    const auto implementations = get_supported_implementations();
  235|    173|    std::vector<simdutf::result> results;
  236|    173|    results.reserve(implementations.size());
  237|       |
  238|    519|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 519, False: 173]
  ------------------
  239|    519|      results.push_back(
  240|    519|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    519|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    519|      const bool validation2 =
  245|    519|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    519|                      src.data(), src.size());
  247|    519|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 519]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    519|    }
  258|       |
  259|    173|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    173|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 173]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    173|    } else {
  273|    173|      ret.implementations_agree = true;
  274|    173|    }
  275|    173|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    173|      return r.error == simdutf::SUCCESS;
  277|    173|    });
  278|    173|    return ret;
  279|    173|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    346|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKS7_E_clESI_:
  275|    339|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    339|      return r.error == simdutf::SUCCESS;
  277|    339|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    173|  bool count_the_input(FromSpan src) const {
  290|    173|    const auto implementations = get_supported_implementations();
  291|    173|    std::vector<std::size_t> results;
  292|    173|    results.reserve(implementations.size());
  293|       |
  294|    519|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 519, False: 173]
  ------------------
  295|    519|      std::size_t ret;
  296|    519|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    519|        ret = impl->count_utf16be(src.data(), src.size());
  298|       |      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|       |        ret = impl->count_utf16le(src.data(), src.size());
  300|       |      } else if constexpr (From == UtfEncodings::UTF8) {
  301|       |        ret = impl->count_utf8(src.data(), src.size());
  302|       |      }
  303|    519|      results.push_back(ret);
  304|    519|    }
  305|    173|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    173|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 173]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    173|    return true;
  321|    173|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    346|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    173|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    173|    length_result ret{};
  344|       |
  345|    173|    const auto implementations = get_supported_implementations();
  346|    173|    std::vector<std::size_t> results;
  347|    173|    results.reserve(implementations.size());
  348|       |
  349|    519|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 519, False: 173]
  ------------------
  350|    519|      const auto len = invoke_lengthcalc(impl, src);
  351|    519|      results.push_back(len);
  352|    519|      ret.length.push_back(len);
  353|    519|    }
  354|       |
  355|    173|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    173|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 173]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    173|    } else {
  375|    173|      ret.implementations_agree = true;
  376|    173|    }
  377|    173|    return ret;
  378|    173|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    519|                                FromSpan src) const {
  331|    519|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    519|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    346|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    173|                                  const bool inputisvalid) const {
  383|    173|    conversion_result ret{};
  384|       |
  385|    173|    const auto implementations = get_supported_implementations();
  386|       |
  387|    173|    std::vector<result<ConversionResult>> results;
  388|    173|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    173|    std::vector<std::vector<ToType>> outputbuffers;
  393|    173|    outputbuffers.reserve(implementations.size());
  394|    692|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 519, False: 173]
  ------------------
  395|    519|      auto impl = implementations[i];
  396|    519|      const ToType canary1{42};
  397|    519|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    519|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    519|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    519|      const auto success = [](const ConversionResult& r) -> bool {
  402|    519|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    519|          return r != 0;
  404|    519|        } else {
  405|    519|          return r.error == simdutf::error_code::SUCCESS;
  406|    519|        }
  407|    519|      }(implret1);
  408|    519|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    519|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    519|        const ToType canary2{25};
  414|    519|        const auto outputbuffer_first_run = outputbuffer;
  415|    519|        std::ranges::fill(outputbuffer, canary2);
  416|    519|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    519|                                          src.size(), outputbuffer.data());
  418|       |
  419|    519|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 519]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    519|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 249, False: 270]
  |  Branch (423:29): [True: 249, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    249|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    249|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 249]
  ------------------
  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|    249|        }
  440|    519|      }
  441|    519|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 249, False: 270]
  ------------------
  442|    519|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    173|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 90, False: 83]
  ------------------
  447|    270|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 270, False: 90]
  ------------------
  448|    270|        e.outputhash.clear();
  449|    270|      }
  450|     90|    }
  451|       |
  452|    173|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    173|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 173]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    173|    } else {
  474|    173|      ret.implementations_agree = true;
  475|    173|    }
  476|    173|    return ret;
  477|    173|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    519|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    519|        } else {
  405|    519|          return r.error == simdutf::error_code::SUCCESS;
  406|    519|        }
  407|    519|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    346|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_26clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    364|    +[](std::span<const char> chardata) {                                      \
  555|    364|      const auto c =                                                           \
  556|    364|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    364|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    364|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    364|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    364|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    364|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    364|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    364|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    364|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    364|  constexpr auto _size = _name.size();                                \
  |  | 1183|    364|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    364|  return _nameof; }()
  ------------------
  561|    364|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    364|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    364|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    364|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    364|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    364|  constexpr auto _size = _name.size();                                \
  |  | 1183|    364|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    364|  return _nameof; }()
  ------------------
  562|    364|      c.fuzz(chardata);                                                        \
  563|    364|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    364|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    364|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    364|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    364|    static const bool do_print_testcase =
  181|    364|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    364|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 364]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    364|    do {
  189|       |      // step 0 - is the input valid?
  190|    364|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    364|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 364]
  |  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|    364|                    From == UtfEncodings::UTF8) {
  198|    364|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 364]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    364|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    364|      const auto [output_length, length_agree] =
  204|    364|          calculate_length(from, inputisvalid);
  205|    364|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 364]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    364|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 153, False: 211]
  |  Branch (208:28): [True: 0, False: 153]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    364|      const auto [written, outputs_agree] =
  215|    364|          do_conversion(from, output_length, inputisvalid);
  216|    364|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 364]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    364|      return;
  221|    364|    } 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|    364|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    364|  validation_result verify_valid_input(FromSpan src) const {
  231|    364|    validation_result ret{};
  232|       |
  233|    364|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    364|    const auto implementations = get_supported_implementations();
  235|    364|    std::vector<simdutf::result> results;
  236|    364|    results.reserve(implementations.size());
  237|       |
  238|  1.09k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.09k, False: 364]
  ------------------
  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|    364|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    364|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 364]
  ------------------
  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|    364|    } else {
  273|    364|      ret.implementations_agree = true;
  274|    364|    }
  275|    364|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    364|      return r.error == simdutf::SUCCESS;
  277|    364|    });
  278|    364|    return ret;
  279|    364|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    728|    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|    786|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    786|      return r.error == simdutf::SUCCESS;
  277|    786|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    364|  bool count_the_input(FromSpan src) const {
  290|    364|    const auto implementations = get_supported_implementations();
  291|    364|    std::vector<std::size_t> results;
  292|    364|    results.reserve(implementations.size());
  293|       |
  294|  1.09k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.09k, False: 364]
  ------------------
  295|  1.09k|      std::size_t ret;
  296|  1.09k|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|  1.09k|        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.09k|      results.push_back(ret);
  304|  1.09k|    }
  305|    364|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    364|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 364]
  ------------------
  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|    364|    return true;
  321|    364|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    728|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    364|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    364|    length_result ret{};
  344|       |
  345|    364|    const auto implementations = get_supported_implementations();
  346|    364|    std::vector<std::size_t> results;
  347|    364|    results.reserve(implementations.size());
  348|       |
  349|  1.09k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.09k, False: 364]
  ------------------
  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|    364|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    364|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 364]
  ------------------
  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|    364|    } else {
  375|    364|      ret.implementations_agree = true;
  376|    364|    }
  377|    364|    return ret;
  378|    364|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.09k|                                FromSpan src) const {
  331|  1.09k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.09k|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    728|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    364|                                  const bool inputisvalid) const {
  383|    364|    conversion_result ret{};
  384|       |
  385|    364|    const auto implementations = get_supported_implementations();
  386|       |
  387|    364|    std::vector<result<ConversionResult>> results;
  388|    364|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    364|    std::vector<std::vector<ToType>> outputbuffers;
  393|    364|    outputbuffers.reserve(implementations.size());
  394|  1.45k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.09k, False: 364]
  ------------------
  395|  1.09k|      auto impl = implementations[i];
  396|  1.09k|      const ToType canary1{42};
  397|  1.09k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.09k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.09k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.09k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.09k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.09k|          return r != 0;
  404|  1.09k|        } else {
  405|  1.09k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.09k|        }
  407|  1.09k|      }(implret1);
  408|  1.09k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.09k|      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.09k|        const ToType canary2{25};
  414|  1.09k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.09k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.09k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.09k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.09k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.09k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.09k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 633, False: 459]
  |  Branch (423:29): [True: 633, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    633|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    633|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 633]
  ------------------
  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|    633|        }
  440|  1.09k|      }
  441|  1.09k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 633, False: 459]
  ------------------
  442|  1.09k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    364|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 153, False: 211]
  ------------------
  447|    459|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 459, False: 153]
  ------------------
  448|    459|        e.outputhash.clear();
  449|    459|      }
  450|    153|    }
  451|       |
  452|    364|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    364|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 364]
  ------------------
  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|    364|    } else {
  474|    364|      ret.implementations_agree = true;
  475|    364|    }
  476|    364|    return ret;
  477|    364|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|  1.09k|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|  1.09k|        } else {
  405|  1.09k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.09k|        }
  407|  1.09k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    728|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_27clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    139|    +[](std::span<const char> chardata) {                                      \
  555|    139|      const auto c =                                                           \
  556|    139|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    139|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    139|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    139|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    139|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    139|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    139|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    139|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    139|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    139|  constexpr auto _size = _name.size();                                \
  |  | 1183|    139|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    139|  return _nameof; }()
  ------------------
  561|    139|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    139|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    139|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    139|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    139|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    139|  constexpr auto _size = _name.size();                                \
  |  | 1183|    139|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    139|  return _nameof; }()
  ------------------
  562|    139|      c.fuzz(chardata);                                                        \
  563|    139|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    139|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    139|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    139|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    139|    static const bool do_print_testcase =
  181|    139|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    139|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 139]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    139|    do {
  189|       |      // step 0 - is the input valid?
  190|    139|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    139|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 139]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    139|                    From == UtfEncodings::UTF8) {
  198|    139|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 139]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    139|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    139|      const auto [output_length, length_agree] =
  204|    139|          calculate_length(from, inputisvalid);
  205|    139|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 139]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    139|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 39, False: 100]
  |  Branch (208:28): [True: 0, False: 39]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    139|      const auto [written, outputs_agree] =
  215|    139|          do_conversion(from, output_length, inputisvalid);
  216|    139|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 139]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    139|      return;
  221|    139|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    139|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEE:
  230|    139|  validation_result verify_valid_input(FromSpan src) const {
  231|    139|    validation_result ret{};
  232|       |
  233|    139|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    139|    const auto implementations = get_supported_implementations();
  235|    139|    std::vector<simdutf::result> results;
  236|    139|    results.reserve(implementations.size());
  237|       |
  238|    417|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 417, False: 139]
  ------------------
  239|    417|      results.push_back(
  240|    417|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    417|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    417|      const bool validation2 =
  245|    417|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    417|                      src.data(), src.size());
  247|    417|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 417]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    417|    }
  258|       |
  259|    139|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    139|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 139]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    139|    } else {
  273|    139|      ret.implementations_agree = true;
  274|    139|    }
  275|    139|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    139|      return r.error == simdutf::SUCCESS;
  277|    139|    });
  278|    139|    return ret;
  279|    139|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS5_S5_EEDaSJ_SM_:
  259|    278|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKS5_E_clESI_:
  275|    339|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    339|      return r.error == simdutf::SUCCESS;
  277|    339|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE15count_the_inputENSt3__14spanIS6_Lm18446744073709551615EEE:
  289|    139|  bool count_the_input(FromSpan src) const {
  290|    139|    const auto implementations = get_supported_implementations();
  291|    139|    std::vector<std::size_t> results;
  292|    139|    results.reserve(implementations.size());
  293|       |
  294|    417|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 417, False: 139]
  ------------------
  295|    417|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    417|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    417|        ret = impl->count_utf16le(src.data(), src.size());
  300|       |      } else if constexpr (From == UtfEncodings::UTF8) {
  301|       |        ret = impl->count_utf8(src.data(), src.size());
  302|       |      }
  303|    417|      results.push_back(ret);
  304|    417|    }
  305|    139|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    139|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 139]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    139|    return true;
  321|    139|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE15count_the_inputENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    278|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEb:
  342|    139|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    139|    length_result ret{};
  344|       |
  345|    139|    const auto implementations = get_supported_implementations();
  346|    139|    std::vector<std::size_t> results;
  347|    139|    results.reserve(implementations.size());
  348|       |
  349|    417|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 417, False: 139]
  ------------------
  350|    417|      const auto len = invoke_lengthcalc(impl, src);
  351|    417|      results.push_back(len);
  352|    417|      ret.length.push_back(len);
  353|    417|    }
  354|       |
  355|    139|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    139|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 139]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    139|    } else {
  375|    139|      ret.implementations_agree = true;
  376|    139|    }
  377|    139|    return ret;
  378|    139|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSF_NSt3__14spanIS6_Lm18446744073709551615EEE:
  338|    417|                                FromSpan src) const {
  339|    417|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    417|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    278|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    139|                                  const bool inputisvalid) const {
  383|    139|    conversion_result ret{};
  384|       |
  385|    139|    const auto implementations = get_supported_implementations();
  386|       |
  387|    139|    std::vector<result<ConversionResult>> results;
  388|    139|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    139|    std::vector<std::vector<ToType>> outputbuffers;
  393|    139|    outputbuffers.reserve(implementations.size());
  394|    556|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 417, False: 139]
  ------------------
  395|    417|      auto impl = implementations[i];
  396|    417|      const ToType canary1{42};
  397|    417|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    417|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    417|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    417|      const auto success = [](const ConversionResult& r) -> bool {
  402|    417|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    417|          return r != 0;
  404|    417|        } else {
  405|    417|          return r.error == simdutf::error_code::SUCCESS;
  406|    417|        }
  407|    417|      }(implret1);
  408|    417|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    417|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    417|        const ToType canary2{25};
  414|    417|        const auto outputbuffer_first_run = outputbuffer;
  415|    417|        std::ranges::fill(outputbuffer, canary2);
  416|    417|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    417|                                          src.size(), outputbuffer.data());
  418|       |
  419|    417|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 417]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    417|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 300, False: 117]
  |  Branch (423:29): [True: 150, False: 150]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    150|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    150|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 150]
  ------------------
  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|    150|        }
  440|    417|      }
  441|    417|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 150, False: 267]
  ------------------
  442|    417|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    139|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 39, False: 100]
  ------------------
  447|    117|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 117, False: 39]
  ------------------
  448|    117|        e.outputhash.clear();
  449|    117|      }
  450|     39|    }
  451|       |
  452|    139|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    139|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 139]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    139|    } else {
  474|    139|      ret.implementations_agree = true;
  475|    139|    }
  476|    139|    return ret;
  477|    139|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS5_E_clESM_:
  401|    417|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    417|        } else {
  405|    417|          return r.error == simdutf::error_code::SUCCESS;
  406|    417|        }
  407|    417|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS5_ESU_EEDaSN_SQ_:
  452|    278|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_28clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    209|    +[](std::span<const char> chardata) {                                      \
  555|    209|      const auto c =                                                           \
  556|    209|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    209|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    209|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    209|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    209|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    209|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    209|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    209|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    209|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    209|  constexpr auto _size = _name.size();                                \
  |  | 1183|    209|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    209|  return _nameof; }()
  ------------------
  561|    209|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    209|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    209|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    209|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    209|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    209|  constexpr auto _size = _name.size();                                \
  |  | 1183|    209|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    209|  return _nameof; }()
  ------------------
  562|    209|      c.fuzz(chardata);                                                        \
  563|    209|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    209|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    209|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    209|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    209|    static const bool do_print_testcase =
  181|    209|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    209|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 209]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    209|    do {
  189|       |      // step 0 - is the input valid?
  190|    209|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    209|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 209]
  |  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|    209|                    From == UtfEncodings::UTF8) {
  198|    209|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 209]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    209|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    209|      const auto [output_length, length_agree] =
  204|    209|          calculate_length(from, inputisvalid);
  205|    209|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 209]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    209|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 118, False: 91]
  |  Branch (208:28): [True: 0, False: 118]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    209|      const auto [written, outputs_agree] =
  215|    209|          do_conversion(from, output_length, inputisvalid);
  216|    209|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 209]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    209|      return;
  221|    209|    } 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|    209|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    209|  validation_result verify_valid_input(FromSpan src) const {
  231|    209|    validation_result ret{};
  232|       |
  233|    209|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    209|    const auto implementations = get_supported_implementations();
  235|    209|    std::vector<simdutf::result> results;
  236|    209|    results.reserve(implementations.size());
  237|       |
  238|    627|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 627, False: 209]
  ------------------
  239|    627|      results.push_back(
  240|    627|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    627|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    627|      const bool validation2 =
  245|    627|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    627|                      src.data(), src.size());
  247|    627|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 627]
  ------------------
  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|    627|    }
  258|       |
  259|    209|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    209|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 209]
  ------------------
  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|    209|    } else {
  273|    209|      ret.implementations_agree = true;
  274|    209|    }
  275|    209|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    209|      return r.error == simdutf::SUCCESS;
  277|    209|    });
  278|    209|    return ret;
  279|    209|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    418|    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|    391|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    391|      return r.error == simdutf::SUCCESS;
  277|    391|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    209|  bool count_the_input(FromSpan src) const {
  290|    209|    const auto implementations = get_supported_implementations();
  291|    209|    std::vector<std::size_t> results;
  292|    209|    results.reserve(implementations.size());
  293|       |
  294|    627|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 627, False: 209]
  ------------------
  295|    627|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    627|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    627|        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|    627|      results.push_back(ret);
  304|    627|    }
  305|    209|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    209|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 209]
  ------------------
  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|    209|    return true;
  321|    209|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    418|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    209|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    209|    length_result ret{};
  344|       |
  345|    209|    const auto implementations = get_supported_implementations();
  346|    209|    std::vector<std::size_t> results;
  347|    209|    results.reserve(implementations.size());
  348|       |
  349|    627|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 627, False: 209]
  ------------------
  350|    627|      const auto len = invoke_lengthcalc(impl, src);
  351|    627|      results.push_back(len);
  352|    627|      ret.length.push_back(len);
  353|    627|    }
  354|       |
  355|    209|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    209|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 209]
  ------------------
  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|    209|    } else {
  375|    209|      ret.implementations_agree = true;
  376|    209|    }
  377|    209|    return ret;
  378|    209|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    627|                                FromSpan src) const {
  331|    627|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    627|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    418|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    209|                                  const bool inputisvalid) const {
  383|    209|    conversion_result ret{};
  384|       |
  385|    209|    const auto implementations = get_supported_implementations();
  386|       |
  387|    209|    std::vector<result<ConversionResult>> results;
  388|    209|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    209|    std::vector<std::vector<ToType>> outputbuffers;
  393|    209|    outputbuffers.reserve(implementations.size());
  394|    836|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 627, False: 209]
  ------------------
  395|    627|      auto impl = implementations[i];
  396|    627|      const ToType canary1{42};
  397|    627|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    627|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    627|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    627|      const auto success = [](const ConversionResult& r) -> bool {
  402|    627|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    627|          return r != 0;
  404|    627|        } else {
  405|    627|          return r.error == simdutf::error_code::SUCCESS;
  406|    627|        }
  407|    627|      }(implret1);
  408|    627|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    627|      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|    627|        const ToType canary2{25};
  414|    627|        const auto outputbuffer_first_run = outputbuffer;
  415|    627|        std::ranges::fill(outputbuffer, canary2);
  416|    627|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    627|                                          src.size(), outputbuffer.data());
  418|       |
  419|    627|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 627]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    627|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 273, False: 354]
  |  Branch (423:29): [True: 273, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    273|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    273|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 273]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    273|        }
  440|    627|      }
  441|    627|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 273, False: 354]
  ------------------
  442|    627|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    209|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 118, False: 91]
  ------------------
  447|    354|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 354, False: 118]
  ------------------
  448|    354|        e.outputhash.clear();
  449|    354|      }
  450|    118|    }
  451|       |
  452|    209|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    209|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 209]
  ------------------
  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|    209|    } else {
  474|    209|      ret.implementations_agree = true;
  475|    209|    }
  476|    209|    return ret;
  477|    209|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    627|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    627|        } else {
  405|    627|          return r.error == simdutf::error_code::SUCCESS;
  406|    627|        }
  407|    627|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    418|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_29clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    332|    +[](std::span<const char> chardata) {                                      \
  555|    332|      const auto c =                                                           \
  556|    332|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    332|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    332|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    332|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    332|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    332|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    332|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    332|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    332|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    332|  constexpr auto _size = _name.size();                                \
  |  | 1183|    332|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    332|  return _nameof; }()
  ------------------
  561|    332|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    332|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    332|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    332|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    332|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    332|  constexpr auto _size = _name.size();                                \
  |  | 1183|    332|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    332|  return _nameof; }()
  ------------------
  562|    332|      c.fuzz(chardata);                                                        \
  563|    332|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    332|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    332|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    332|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    332|    static const bool do_print_testcase =
  181|    332|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    332|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 332]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    332|    do {
  189|       |      // step 0 - is the input valid?
  190|    332|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    332|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 332]
  |  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|    332|                    From == UtfEncodings::UTF8) {
  198|    332|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 332]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    332|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    332|      const auto [output_length, length_agree] =
  204|    332|          calculate_length(from, inputisvalid);
  205|    332|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 332]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    332|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 135, False: 197]
  |  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|    332|      const auto [written, outputs_agree] =
  215|    332|          do_conversion(from, output_length, inputisvalid);
  216|    332|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 332]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    332|      return;
  221|    332|    } 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|    332|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    332|  validation_result verify_valid_input(FromSpan src) const {
  231|    332|    validation_result ret{};
  232|       |
  233|    332|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    332|    const auto implementations = get_supported_implementations();
  235|    332|    std::vector<simdutf::result> results;
  236|    332|    results.reserve(implementations.size());
  237|       |
  238|    996|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 996, False: 332]
  ------------------
  239|    996|      results.push_back(
  240|    996|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    996|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    996|      const bool validation2 =
  245|    996|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    996|                      src.data(), src.size());
  247|    996|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 996]
  ------------------
  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|    996|    }
  258|       |
  259|    332|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    332|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 332]
  ------------------
  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|    332|    } else {
  273|    332|      ret.implementations_agree = true;
  274|    332|    }
  275|    332|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    332|      return r.error == simdutf::SUCCESS;
  277|    332|    });
  278|    332|    return ret;
  279|    332|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    664|    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|    726|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    726|      return r.error == simdutf::SUCCESS;
  277|    726|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    332|  bool count_the_input(FromSpan src) const {
  290|    332|    const auto implementations = get_supported_implementations();
  291|    332|    std::vector<std::size_t> results;
  292|    332|    results.reserve(implementations.size());
  293|       |
  294|    996|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 996, False: 332]
  ------------------
  295|    996|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    996|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    996|        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|    996|      results.push_back(ret);
  304|    996|    }
  305|    332|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    332|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 332]
  ------------------
  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|    332|    return true;
  321|    332|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    664|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    332|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    332|    length_result ret{};
  344|       |
  345|    332|    const auto implementations = get_supported_implementations();
  346|    332|    std::vector<std::size_t> results;
  347|    332|    results.reserve(implementations.size());
  348|       |
  349|    996|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 996, False: 332]
  ------------------
  350|    996|      const auto len = invoke_lengthcalc(impl, src);
  351|    996|      results.push_back(len);
  352|    996|      ret.length.push_back(len);
  353|    996|    }
  354|       |
  355|    332|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    332|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 332]
  ------------------
  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|    332|    } else {
  375|    332|      ret.implementations_agree = true;
  376|    332|    }
  377|    332|    return ret;
  378|    332|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    996|                                FromSpan src) const {
  331|    996|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    996|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    664|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    332|                                  const bool inputisvalid) const {
  383|    332|    conversion_result ret{};
  384|       |
  385|    332|    const auto implementations = get_supported_implementations();
  386|       |
  387|    332|    std::vector<result<ConversionResult>> results;
  388|    332|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    332|    std::vector<std::vector<ToType>> outputbuffers;
  393|    332|    outputbuffers.reserve(implementations.size());
  394|  1.32k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 996, False: 332]
  ------------------
  395|    996|      auto impl = implementations[i];
  396|    996|      const ToType canary1{42};
  397|    996|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    996|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    996|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    996|      const auto success = [](const ConversionResult& r) -> bool {
  402|    996|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    996|          return r != 0;
  404|    996|        } else {
  405|    996|          return r.error == simdutf::error_code::SUCCESS;
  406|    996|        }
  407|    996|      }(implret1);
  408|    996|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    996|      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|    996|        const ToType canary2{25};
  414|    996|        const auto outputbuffer_first_run = outputbuffer;
  415|    996|        std::ranges::fill(outputbuffer, canary2);
  416|    996|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    996|                                          src.size(), outputbuffer.data());
  418|       |
  419|    996|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 996]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    996|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 591, False: 405]
  |  Branch (423:29): [True: 591, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    591|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    591|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 591]
  ------------------
  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|    591|        }
  440|    996|      }
  441|    996|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 591, False: 405]
  ------------------
  442|    996|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    332|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 135, False: 197]
  ------------------
  447|    405|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 405, False: 135]
  ------------------
  448|    405|        e.outputhash.clear();
  449|    405|      }
  450|    135|    }
  451|       |
  452|    332|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    332|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 332]
  ------------------
  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|    332|    } else {
  474|    332|      ret.implementations_agree = true;
  475|    332|    }
  476|    332|    return ret;
  477|    332|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    996|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    996|        } else {
  405|    996|          return r.error == simdutf::error_code::SUCCESS;
  406|    996|        }
  407|    996|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    664|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_30clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    204|    +[](std::span<const char> chardata) {                                      \
  555|    204|      const auto c =                                                           \
  556|    204|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    204|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    204|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    204|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    204|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    204|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    204|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    204|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    204|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    204|  constexpr auto _size = _name.size();                                \
  |  | 1183|    204|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    204|  return _nameof; }()
  ------------------
  561|    204|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    204|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    204|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    204|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    204|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    204|  constexpr auto _size = _name.size();                                \
  |  | 1183|    204|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    204|  return _nameof; }()
  ------------------
  562|    204|      c.fuzz(chardata);                                                        \
  563|    204|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    204|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    204|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    204|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    204|    static const bool do_print_testcase =
  181|    204|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    204|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 204]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    204|    do {
  189|       |      // step 0 - is the input valid?
  190|    204|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    204|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 204]
  |  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|    204|      const auto [output_length, length_agree] =
  204|    204|          calculate_length(from, inputisvalid);
  205|    204|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 204]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    204|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 173, False: 31]
  |  Branch (208:28): [True: 0, False: 173]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    204|      const auto [written, outputs_agree] =
  215|    204|          do_conversion(from, output_length, inputisvalid);
  216|    204|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 204]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    204|      return;
  221|    204|    } 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|    204|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEE:
  230|    204|  validation_result verify_valid_input(FromSpan src) const {
  231|    204|    validation_result ret{};
  232|       |
  233|    204|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    204|    const auto implementations = get_supported_implementations();
  235|    204|    std::vector<simdutf::result> results;
  236|    204|    results.reserve(implementations.size());
  237|       |
  238|    612|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 612, False: 204]
  ------------------
  239|    612|      results.push_back(
  240|    612|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    612|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    612|      const bool validation2 =
  245|    612|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    612|                      src.data(), src.size());
  247|    612|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 612]
  ------------------
  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|    612|    }
  258|       |
  259|    204|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    204|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 204]
  ------------------
  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|    204|    } else {
  273|    204|      ret.implementations_agree = true;
  274|    204|    }
  275|    204|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    204|      return r.error == simdutf::SUCCESS;
  277|    204|    });
  278|    204|    return ret;
  279|    204|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS5_S5_EEDaSJ_SM_:
  259|    408|    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|    266|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    266|      return r.error == simdutf::SUCCESS;
  277|    266|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEb:
  342|    204|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    204|    length_result ret{};
  344|       |
  345|    204|    const auto implementations = get_supported_implementations();
  346|    204|    std::vector<std::size_t> results;
  347|    204|    results.reserve(implementations.size());
  348|       |
  349|    612|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 612, False: 204]
  ------------------
  350|    612|      const auto len = invoke_lengthcalc(impl, src);
  351|    612|      results.push_back(len);
  352|    612|      ret.length.push_back(len);
  353|    612|    }
  354|       |
  355|    204|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    204|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 204]
  ------------------
  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|    204|    } else {
  375|    204|      ret.implementations_agree = true;
  376|    204|    }
  377|    204|    return ret;
  378|    204|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSF_NSt3__14spanIS6_Lm18446744073709551615EEE:
  338|    612|                                FromSpan src) const {
  339|    612|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    612|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    408|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    204|                                  const bool inputisvalid) const {
  383|    204|    conversion_result ret{};
  384|       |
  385|    204|    const auto implementations = get_supported_implementations();
  386|       |
  387|    204|    std::vector<result<ConversionResult>> results;
  388|    204|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    204|    std::vector<std::vector<ToType>> outputbuffers;
  393|    204|    outputbuffers.reserve(implementations.size());
  394|    816|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 612, False: 204]
  ------------------
  395|    612|      auto impl = implementations[i];
  396|    612|      const ToType canary1{42};
  397|    612|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    612|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    612|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    612|      const auto success = [](const ConversionResult& r) -> bool {
  402|    612|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    612|          return r != 0;
  404|    612|        } else {
  405|    612|          return r.error == simdutf::error_code::SUCCESS;
  406|    612|        }
  407|    612|      }(implret1);
  408|    612|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    612|      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|    612|        const ToType canary2{25};
  414|    612|        const auto outputbuffer_first_run = outputbuffer;
  415|    612|        std::ranges::fill(outputbuffer, canary2);
  416|    612|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    612|                                          src.size(), outputbuffer.data());
  418|       |
  419|    612|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 612]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    612|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 93, False: 519]
  |  Branch (423:29): [True: 69, False: 24]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|     69|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|     69|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 69]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|     69|        }
  440|    612|      }
  441|    612|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 69, False: 543]
  ------------------
  442|    612|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    204|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 173, False: 31]
  ------------------
  447|    519|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 519, False: 173]
  ------------------
  448|    519|        e.outputhash.clear();
  449|    519|      }
  450|    173|    }
  451|       |
  452|    204|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    204|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 204]
  ------------------
  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|    204|    } else {
  474|    204|      ret.implementations_agree = true;
  475|    204|    }
  476|    204|    return ret;
  477|    204|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS5_E_clESM_:
  401|    612|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    612|        } else {
  405|    612|          return r.error == simdutf::error_code::SUCCESS;
  406|    612|        }
  407|    612|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS5_ESU_EEDaSN_SQ_:
  452|    408|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_31clENSt3__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|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE4fuzzENSt3__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|       |                    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|    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: 229, False: 86]
  |  Branch (208:28): [True: 0, False: 229]
  ------------------
  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|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_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|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_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; };
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKS7_E_clESI_:
  275|    487|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    487|      return r.error == simdutf::SUCCESS;
  277|    487|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_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|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE17invoke_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|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    630|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_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: 258, False: 687]
  |  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|    945|      }
  441|    945|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 258, False: 687]
  ------------------
  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: 229, False: 86]
  ------------------
  447|    687|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 687, False: 229]
  ------------------
  448|    687|        e.outputhash.clear();
  449|    687|      }
  450|    229|    }
  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|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_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);
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_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$_32clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    342|    +[](std::span<const char> chardata) {                                      \
  555|    342|      const auto c =                                                           \
  556|    342|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    342|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    342|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    342|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    342|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    342|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    342|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    342|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    342|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    342|  constexpr auto _size = _name.size();                                \
  |  | 1183|    342|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    342|  return _nameof; }()
  ------------------
  561|    342|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    342|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    342|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    342|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    342|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    342|  constexpr auto _size = _name.size();                                \
  |  | 1183|    342|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    342|  return _nameof; }()
  ------------------
  562|    342|      c.fuzz(chardata);                                                        \
  563|    342|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    342|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    342|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    342|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    342|    static const bool do_print_testcase =
  181|    342|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    342|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 342]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    342|    do {
  189|       |      // step 0 - is the input valid?
  190|    342|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    342|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 342]
  |  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|    342|      const auto [output_length, length_agree] =
  204|    342|          calculate_length(from, inputisvalid);
  205|    342|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 342]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    342|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 252, False: 90]
  |  Branch (208:28): [True: 0, False: 252]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    342|      const auto [written, outputs_agree] =
  215|    342|          do_conversion(from, output_length, inputisvalid);
  216|    342|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 342]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    342|      return;
  221|    342|    } 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|    342|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    342|  validation_result verify_valid_input(FromSpan src) const {
  231|    342|    validation_result ret{};
  232|       |
  233|    342|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    342|    const auto implementations = get_supported_implementations();
  235|    342|    std::vector<simdutf::result> results;
  236|    342|    results.reserve(implementations.size());
  237|       |
  238|  1.02k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.02k, False: 342]
  ------------------
  239|  1.02k|      results.push_back(
  240|  1.02k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.02k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.02k|      const bool validation2 =
  245|  1.02k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.02k|                      src.data(), src.size());
  247|  1.02k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.02k]
  ------------------
  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.02k|    }
  258|       |
  259|    342|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    342|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 342]
  ------------------
  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|    342|    } else {
  273|    342|      ret.implementations_agree = true;
  274|    342|    }
  275|    342|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    342|      return r.error == simdutf::SUCCESS;
  277|    342|    });
  278|    342|    return ret;
  279|    342|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    684|    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|    522|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    522|      return r.error == simdutf::SUCCESS;
  277|    522|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    342|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    342|    length_result ret{};
  344|       |
  345|    342|    const auto implementations = get_supported_implementations();
  346|    342|    std::vector<std::size_t> results;
  347|    342|    results.reserve(implementations.size());
  348|       |
  349|  1.02k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.02k, False: 342]
  ------------------
  350|  1.02k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.02k|      results.push_back(len);
  352|  1.02k|      ret.length.push_back(len);
  353|  1.02k|    }
  354|       |
  355|    342|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    342|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 342]
  ------------------
  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|    342|    } else {
  375|    342|      ret.implementations_agree = true;
  376|    342|    }
  377|    342|    return ret;
  378|    342|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.02k|                                FromSpan src) const {
  331|  1.02k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.02k|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    684|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    342|                                  const bool inputisvalid) const {
  383|    342|    conversion_result ret{};
  384|       |
  385|    342|    const auto implementations = get_supported_implementations();
  386|       |
  387|    342|    std::vector<result<ConversionResult>> results;
  388|    342|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    342|    std::vector<std::vector<ToType>> outputbuffers;
  393|    342|    outputbuffers.reserve(implementations.size());
  394|  1.36k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.02k, False: 342]
  ------------------
  395|  1.02k|      auto impl = implementations[i];
  396|  1.02k|      const ToType canary1{42};
  397|  1.02k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.02k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.02k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.02k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.02k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.02k|          return r != 0;
  404|  1.02k|        } else {
  405|  1.02k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.02k|        }
  407|  1.02k|      }(implret1);
  408|  1.02k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.02k|      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.02k|        const ToType canary2{25};
  414|  1.02k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.02k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.02k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.02k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.02k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.02k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.02k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 270, False: 756]
  |  Branch (423:29): [True: 270, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    270|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    270|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 270]
  ------------------
  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|    270|        }
  440|  1.02k|      }
  441|  1.02k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 270, False: 756]
  ------------------
  442|  1.02k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    342|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 252, False: 90]
  ------------------
  447|    756|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 756, False: 252]
  ------------------
  448|    756|        e.outputhash.clear();
  449|    756|      }
  450|    252|    }
  451|       |
  452|    342|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    342|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 342]
  ------------------
  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|    342|    } else {
  474|    342|      ret.implementations_agree = true;
  475|    342|    }
  476|    342|    return ret;
  477|    342|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|  1.02k|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|  1.02k|        } else {
  405|  1.02k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.02k|        }
  407|  1.02k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    684|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_33clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    467|    +[](std::span<const char> chardata) {                                      \
  555|    467|      const auto c =                                                           \
  556|    467|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    467|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    467|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    467|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    467|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    467|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    467|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    467|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    467|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    467|  constexpr auto _size = _name.size();                                \
  |  | 1183|    467|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    467|  return _nameof; }()
  ------------------
  561|    467|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    467|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    467|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    467|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    467|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    467|  constexpr auto _size = _name.size();                                \
  |  | 1183|    467|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    467|  return _nameof; }()
  ------------------
  562|    467|      c.fuzz(chardata);                                                        \
  563|    467|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    467|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    467|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    467|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    467|    static const bool do_print_testcase =
  181|    467|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    467|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 467]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    467|    do {
  189|       |      // step 0 - is the input valid?
  190|    467|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    467|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 467]
  |  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|    467|      const auto [output_length, length_agree] =
  204|    467|          calculate_length(from, inputisvalid);
  205|    467|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 467]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    467|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 350, False: 117]
  |  Branch (208:28): [True: 0, False: 350]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    467|      const auto [written, outputs_agree] =
  215|    467|          do_conversion(from, output_length, inputisvalid);
  216|    467|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 467]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    467|      return;
  221|    467|    } 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|    467|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    467|  validation_result verify_valid_input(FromSpan src) const {
  231|    467|    validation_result ret{};
  232|       |
  233|    467|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    467|    const auto implementations = get_supported_implementations();
  235|    467|    std::vector<simdutf::result> results;
  236|    467|    results.reserve(implementations.size());
  237|       |
  238|  1.40k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.40k, False: 467]
  ------------------
  239|  1.40k|      results.push_back(
  240|  1.40k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.40k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.40k|      const bool validation2 =
  245|  1.40k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.40k|                      src.data(), src.size());
  247|  1.40k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.40k]
  ------------------
  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.40k|    }
  258|       |
  259|    467|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    467|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 467]
  ------------------
  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|    467|    } else {
  273|    467|      ret.implementations_agree = true;
  274|    467|    }
  275|    467|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    467|      return r.error == simdutf::SUCCESS;
  277|    467|    });
  278|    467|    return ret;
  279|    467|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    934|    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|    701|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    701|      return r.error == simdutf::SUCCESS;
  277|    701|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    467|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    467|    length_result ret{};
  344|       |
  345|    467|    const auto implementations = get_supported_implementations();
  346|    467|    std::vector<std::size_t> results;
  347|    467|    results.reserve(implementations.size());
  348|       |
  349|  1.40k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.40k, False: 467]
  ------------------
  350|  1.40k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.40k|      results.push_back(len);
  352|  1.40k|      ret.length.push_back(len);
  353|  1.40k|    }
  354|       |
  355|    467|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    467|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 467]
  ------------------
  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|    467|    } else {
  375|    467|      ret.implementations_agree = true;
  376|    467|    }
  377|    467|    return ret;
  378|    467|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.40k|                                FromSpan src) const {
  331|  1.40k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.40k|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    934|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    467|                                  const bool inputisvalid) const {
  383|    467|    conversion_result ret{};
  384|       |
  385|    467|    const auto implementations = get_supported_implementations();
  386|       |
  387|    467|    std::vector<result<ConversionResult>> results;
  388|    467|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    467|    std::vector<std::vector<ToType>> outputbuffers;
  393|    467|    outputbuffers.reserve(implementations.size());
  394|  1.86k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.40k, False: 467]
  ------------------
  395|  1.40k|      auto impl = implementations[i];
  396|  1.40k|      const ToType canary1{42};
  397|  1.40k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.40k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.40k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.40k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.40k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.40k|          return r != 0;
  404|  1.40k|        } else {
  405|  1.40k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.40k|        }
  407|  1.40k|      }(implret1);
  408|  1.40k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.40k|      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.40k|        const ToType canary2{25};
  414|  1.40k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.40k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.40k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.40k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.40k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.40k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.40k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 351, False: 1.05k]
  |  Branch (423:29): [True: 351, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    351|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    351|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 351]
  ------------------
  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|    351|        }
  440|  1.40k|      }
  441|  1.40k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 351, False: 1.05k]
  ------------------
  442|  1.40k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    467|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 350, False: 117]
  ------------------
  447|  1.05k|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 1.05k, False: 350]
  ------------------
  448|  1.05k|        e.outputhash.clear();
  449|  1.05k|      }
  450|    350|    }
  451|       |
  452|    467|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    467|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 467]
  ------------------
  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|    467|    } else {
  474|    467|      ret.implementations_agree = true;
  475|    467|    }
  476|    467|    return ret;
  477|    467|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|  1.40k|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|  1.40k|        } else {
  405|  1.40k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.40k|        }
  407|  1.40k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    934|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_34clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    251|    +[](std::span<const char> chardata) {                                      \
  555|    251|      const auto c =                                                           \
  556|    251|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    251|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    251|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    251|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    251|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    251|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    251|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    251|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    251|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    251|  constexpr auto _size = _name.size();                                \
  |  | 1183|    251|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    251|  return _nameof; }()
  ------------------
  561|    251|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    251|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    251|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    251|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    251|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    251|  constexpr auto _size = _name.size();                                \
  |  | 1183|    251|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    251|  return _nameof; }()
  ------------------
  562|    251|      c.fuzz(chardata);                                                        \
  563|    251|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    251|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    251|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    251|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    251|    static const bool do_print_testcase =
  181|    251|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    251|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 251]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    251|    do {
  189|       |      // step 0 - is the input valid?
  190|    251|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    251|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 251]
  |  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|    251|                    From == UtfEncodings::UTF8) {
  198|    251|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 251]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    251|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    251|      const auto [output_length, length_agree] =
  204|    251|          calculate_length(from, inputisvalid);
  205|    251|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 251]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    251|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 134, False: 117]
  |  Branch (208:28): [True: 0, False: 134]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    251|      const auto [written, outputs_agree] =
  215|    251|          do_conversion(from, output_length, inputisvalid);
  216|    251|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 251]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    251|      return;
  221|    251|    } 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|    251|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    251|  validation_result verify_valid_input(FromSpan src) const {
  231|    251|    validation_result ret{};
  232|       |
  233|    251|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    251|    const auto implementations = get_supported_implementations();
  235|    251|    std::vector<simdutf::result> results;
  236|    251|    results.reserve(implementations.size());
  237|       |
  238|    753|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 753, False: 251]
  ------------------
  239|    753|      results.push_back(
  240|    753|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    753|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    753|      const bool validation2 =
  245|    753|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    753|                      src.data(), src.size());
  247|    753|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 753]
  ------------------
  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|    753|    }
  258|       |
  259|    251|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    251|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 251]
  ------------------
  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|    251|    } else {
  273|    251|      ret.implementations_agree = true;
  274|    251|    }
  275|    251|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    251|      return r.error == simdutf::SUCCESS;
  277|    251|    });
  278|    251|    return ret;
  279|    251|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    502|    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|    485|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    485|      return r.error == simdutf::SUCCESS;
  277|    485|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    251|  bool count_the_input(FromSpan src) const {
  290|    251|    const auto implementations = get_supported_implementations();
  291|    251|    std::vector<std::size_t> results;
  292|    251|    results.reserve(implementations.size());
  293|       |
  294|    753|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 753, False: 251]
  ------------------
  295|    753|      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|    753|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|    753|        ret = impl->count_utf8(src.data(), src.size());
  302|    753|      }
  303|    753|      results.push_back(ret);
  304|    753|    }
  305|    251|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    251|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 251]
  ------------------
  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|    251|    return true;
  321|    251|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    502|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    251|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    251|    length_result ret{};
  344|       |
  345|    251|    const auto implementations = get_supported_implementations();
  346|    251|    std::vector<std::size_t> results;
  347|    251|    results.reserve(implementations.size());
  348|       |
  349|    753|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 753, False: 251]
  ------------------
  350|    753|      const auto len = invoke_lengthcalc(impl, src);
  351|    753|      results.push_back(len);
  352|    753|      ret.length.push_back(len);
  353|    753|    }
  354|       |
  355|    251|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    251|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 251]
  ------------------
  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|    251|    } else {
  375|    251|      ret.implementations_agree = true;
  376|    251|    }
  377|    251|    return ret;
  378|    251|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    753|                                FromSpan src) const {
  331|    753|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    753|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    502|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    251|                                  const bool inputisvalid) const {
  383|    251|    conversion_result ret{};
  384|       |
  385|    251|    const auto implementations = get_supported_implementations();
  386|       |
  387|    251|    std::vector<result<ConversionResult>> results;
  388|    251|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    251|    std::vector<std::vector<ToType>> outputbuffers;
  393|    251|    outputbuffers.reserve(implementations.size());
  394|  1.00k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 753, False: 251]
  ------------------
  395|    753|      auto impl = implementations[i];
  396|    753|      const ToType canary1{42};
  397|    753|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    753|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    753|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    753|      const auto success = [](const ConversionResult& r) -> bool {
  402|    753|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    753|          return r != 0;
  404|    753|        } else {
  405|    753|          return r.error == simdutf::error_code::SUCCESS;
  406|    753|        }
  407|    753|      }(implret1);
  408|    753|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    753|      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|    753|        const ToType canary2{25};
  414|    753|        const auto outputbuffer_first_run = outputbuffer;
  415|    753|        std::ranges::fill(outputbuffer, canary2);
  416|    753|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    753|                                          src.size(), outputbuffer.data());
  418|       |
  419|    753|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 753]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    753|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 351, False: 402]
  |  Branch (423:29): [True: 336, False: 15]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    336|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    336|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 336]
  ------------------
  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|    336|        }
  440|    753|      }
  441|    753|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 336, False: 417]
  ------------------
  442|    753|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    251|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 134, False: 117]
  ------------------
  447|    402|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 402, False: 134]
  ------------------
  448|    402|        e.outputhash.clear();
  449|    402|      }
  450|    134|    }
  451|       |
  452|    251|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    251|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 251]
  ------------------
  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|    251|    } else {
  474|    251|      ret.implementations_agree = true;
  475|    251|    }
  476|    251|    return ret;
  477|    251|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    753|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    753|        } else {
  405|    753|          return r.error == simdutf::error_code::SUCCESS;
  406|    753|        }
  407|    753|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    502|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_35clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    377|    +[](std::span<const char> chardata) {                                      \
  555|    377|      const auto c =                                                           \
  556|    377|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    377|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    377|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    377|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    377|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    377|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    377|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    377|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    377|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    377|  constexpr auto _size = _name.size();                                \
  |  | 1183|    377|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    377|  return _nameof; }()
  ------------------
  561|    377|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    377|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    377|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    377|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    377|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    377|  constexpr auto _size = _name.size();                                \
  |  | 1183|    377|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    377|  return _nameof; }()
  ------------------
  562|    377|      c.fuzz(chardata);                                                        \
  563|    377|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    377|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    377|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    377|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    377|    static const bool do_print_testcase =
  181|    377|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    377|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 377]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    377|    do {
  189|       |      // step 0 - is the input valid?
  190|    377|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    377|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 377]
  |  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|    377|                    From == UtfEncodings::UTF8) {
  198|    377|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 377]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    377|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    377|      const auto [output_length, length_agree] =
  204|    377|          calculate_length(from, inputisvalid);
  205|    377|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 377]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    377|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 214, False: 163]
  |  Branch (208:28): [True: 0, False: 214]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    377|      const auto [written, outputs_agree] =
  215|    377|          do_conversion(from, output_length, inputisvalid);
  216|    377|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 377]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    377|      return;
  221|    377|    } 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|    377|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    377|  validation_result verify_valid_input(FromSpan src) const {
  231|    377|    validation_result ret{};
  232|       |
  233|    377|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    377|    const auto implementations = get_supported_implementations();
  235|    377|    std::vector<simdutf::result> results;
  236|    377|    results.reserve(implementations.size());
  237|       |
  238|  1.13k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.13k, False: 377]
  ------------------
  239|  1.13k|      results.push_back(
  240|  1.13k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.13k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.13k|      const bool validation2 =
  245|  1.13k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.13k|                      src.data(), src.size());
  247|  1.13k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.13k]
  ------------------
  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.13k|    }
  258|       |
  259|    377|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    377|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 377]
  ------------------
  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|    377|    } else {
  273|    377|      ret.implementations_agree = true;
  274|    377|    }
  275|    377|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    377|      return r.error == simdutf::SUCCESS;
  277|    377|    });
  278|    377|    return ret;
  279|    377|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    754|    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|    703|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    703|      return r.error == simdutf::SUCCESS;
  277|    703|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    377|  bool count_the_input(FromSpan src) const {
  290|    377|    const auto implementations = get_supported_implementations();
  291|    377|    std::vector<std::size_t> results;
  292|    377|    results.reserve(implementations.size());
  293|       |
  294|  1.13k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.13k, False: 377]
  ------------------
  295|  1.13k|      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.13k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.13k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.13k|      }
  303|  1.13k|      results.push_back(ret);
  304|  1.13k|    }
  305|    377|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    377|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 377]
  ------------------
  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|    377|    return true;
  321|    377|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    754|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    377|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    377|    length_result ret{};
  344|       |
  345|    377|    const auto implementations = get_supported_implementations();
  346|    377|    std::vector<std::size_t> results;
  347|    377|    results.reserve(implementations.size());
  348|       |
  349|  1.13k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.13k, False: 377]
  ------------------
  350|  1.13k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.13k|      results.push_back(len);
  352|  1.13k|      ret.length.push_back(len);
  353|  1.13k|    }
  354|       |
  355|    377|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    377|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 377]
  ------------------
  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|    377|    } else {
  375|    377|      ret.implementations_agree = true;
  376|    377|    }
  377|    377|    return ret;
  378|    377|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.13k|                                FromSpan src) const {
  331|  1.13k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.13k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    754|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    377|                                  const bool inputisvalid) const {
  383|    377|    conversion_result ret{};
  384|       |
  385|    377|    const auto implementations = get_supported_implementations();
  386|       |
  387|    377|    std::vector<result<ConversionResult>> results;
  388|    377|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    377|    std::vector<std::vector<ToType>> outputbuffers;
  393|    377|    outputbuffers.reserve(implementations.size());
  394|  1.50k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.13k, False: 377]
  ------------------
  395|  1.13k|      auto impl = implementations[i];
  396|  1.13k|      const ToType canary1{42};
  397|  1.13k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.13k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.13k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.13k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.13k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.13k|          return r != 0;
  404|  1.13k|        } else {
  405|  1.13k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.13k|        }
  407|  1.13k|      }(implret1);
  408|  1.13k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.13k|      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.13k|        const ToType canary2{25};
  414|  1.13k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.13k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.13k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.13k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.13k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.13k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.13k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 489, False: 642]
  |  Branch (423:29): [True: 489, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    489|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    489|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 489]
  ------------------
  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|    489|        }
  440|  1.13k|      }
  441|  1.13k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 489, False: 642]
  ------------------
  442|  1.13k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    377|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 214, False: 163]
  ------------------
  447|    642|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 642, False: 214]
  ------------------
  448|    642|        e.outputhash.clear();
  449|    642|      }
  450|    214|    }
  451|       |
  452|    377|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    377|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 377]
  ------------------
  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|    377|    } else {
  474|    377|      ret.implementations_agree = true;
  475|    377|    }
  476|    377|    return ret;
  477|    377|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|  1.13k|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|  1.13k|        } else {
  405|  1.13k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.13k|        }
  407|  1.13k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    754|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_36clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    306|    +[](std::span<const char> chardata) {                                      \
  555|    306|      const auto c =                                                           \
  556|    306|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    306|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    306|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    306|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    306|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    306|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    306|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    306|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    306|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    306|  constexpr auto _size = _name.size();                                \
  |  | 1183|    306|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    306|  return _nameof; }()
  ------------------
  561|    306|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    306|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    306|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    306|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    306|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    306|  constexpr auto _size = _name.size();                                \
  |  | 1183|    306|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    306|  return _nameof; }()
  ------------------
  562|    306|      c.fuzz(chardata);                                                        \
  563|    306|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    306|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    306|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    306|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    306|    static const bool do_print_testcase =
  181|    306|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    306|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 306]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    306|    do {
  189|       |      // step 0 - is the input valid?
  190|    306|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    306|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 306]
  |  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|    306|                    From == UtfEncodings::UTF8) {
  198|    306|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 306]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    306|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    306|      const auto [output_length, length_agree] =
  204|    306|          calculate_length(from, inputisvalid);
  205|    306|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 306]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    306|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 177, False: 129]
  |  Branch (208:28): [True: 0, False: 177]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    306|      const auto [written, outputs_agree] =
  215|    306|          do_conversion(from, output_length, inputisvalid);
  216|    306|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 306]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    306|      return;
  221|    306|    } 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|    306|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    306|  validation_result verify_valid_input(FromSpan src) const {
  231|    306|    validation_result ret{};
  232|       |
  233|    306|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    306|    const auto implementations = get_supported_implementations();
  235|    306|    std::vector<simdutf::result> results;
  236|    306|    results.reserve(implementations.size());
  237|       |
  238|    918|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 918, False: 306]
  ------------------
  239|    918|      results.push_back(
  240|    918|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    918|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    918|      const bool validation2 =
  245|    918|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    918|                      src.data(), src.size());
  247|    918|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 918]
  ------------------
  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|    918|    }
  258|       |
  259|    306|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    306|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 306]
  ------------------
  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|    306|    } else {
  273|    306|      ret.implementations_agree = true;
  274|    306|    }
  275|    306|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    306|      return r.error == simdutf::SUCCESS;
  277|    306|    });
  278|    306|    return ret;
  279|    306|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    612|    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|    564|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    564|      return r.error == simdutf::SUCCESS;
  277|    564|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    306|  bool count_the_input(FromSpan src) const {
  290|    306|    const auto implementations = get_supported_implementations();
  291|    306|    std::vector<std::size_t> results;
  292|    306|    results.reserve(implementations.size());
  293|       |
  294|    918|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 918, False: 306]
  ------------------
  295|    918|      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|    918|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|    918|        ret = impl->count_utf8(src.data(), src.size());
  302|    918|      }
  303|    918|      results.push_back(ret);
  304|    918|    }
  305|    306|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    306|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 306]
  ------------------
  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|    306|    return true;
  321|    306|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    612|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    306|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    306|    length_result ret{};
  344|       |
  345|    306|    const auto implementations = get_supported_implementations();
  346|    306|    std::vector<std::size_t> results;
  347|    306|    results.reserve(implementations.size());
  348|       |
  349|    918|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 918, False: 306]
  ------------------
  350|    918|      const auto len = invoke_lengthcalc(impl, src);
  351|    918|      results.push_back(len);
  352|    918|      ret.length.push_back(len);
  353|    918|    }
  354|       |
  355|    306|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    306|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 306]
  ------------------
  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|    306|    } else {
  375|    306|      ret.implementations_agree = true;
  376|    306|    }
  377|    306|    return ret;
  378|    306|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    918|                                FromSpan src) const {
  331|    918|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    918|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    612|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    306|                                  const bool inputisvalid) const {
  383|    306|    conversion_result ret{};
  384|       |
  385|    306|    const auto implementations = get_supported_implementations();
  386|       |
  387|    306|    std::vector<result<ConversionResult>> results;
  388|    306|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    306|    std::vector<std::vector<ToType>> outputbuffers;
  393|    306|    outputbuffers.reserve(implementations.size());
  394|  1.22k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 918, False: 306]
  ------------------
  395|    918|      auto impl = implementations[i];
  396|    918|      const ToType canary1{42};
  397|    918|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    918|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    918|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    918|      const auto success = [](const ConversionResult& r) -> bool {
  402|    918|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    918|          return r != 0;
  404|    918|        } else {
  405|    918|          return r.error == simdutf::error_code::SUCCESS;
  406|    918|        }
  407|    918|      }(implret1);
  408|    918|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    918|      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|    918|        const ToType canary2{25};
  414|    918|        const auto outputbuffer_first_run = outputbuffer;
  415|    918|        std::ranges::fill(outputbuffer, canary2);
  416|    918|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    918|                                          src.size(), outputbuffer.data());
  418|       |
  419|    918|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 918]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    918|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 387, False: 531]
  |  Branch (423:29): [True: 387, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    387|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    387|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 387]
  ------------------
  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|    387|        }
  440|    918|      }
  441|    918|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 387, False: 531]
  ------------------
  442|    918|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    306|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 177, False: 129]
  ------------------
  447|    531|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 531, False: 177]
  ------------------
  448|    531|        e.outputhash.clear();
  449|    531|      }
  450|    177|    }
  451|       |
  452|    306|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    306|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 306]
  ------------------
  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|    306|    } else {
  474|    306|      ret.implementations_agree = true;
  475|    306|    }
  476|    306|    return ret;
  477|    306|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    918|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    918|        } else {
  405|    918|          return r.error == simdutf::error_code::SUCCESS;
  406|    918|        }
  407|    918|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    612|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_37clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    397|    +[](std::span<const char> chardata) {                                      \
  555|    397|      const auto c =                                                           \
  556|    397|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    397|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    397|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    397|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    397|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    397|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    397|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    397|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    397|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    397|  constexpr auto _size = _name.size();                                \
  |  | 1183|    397|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    397|  return _nameof; }()
  ------------------
  561|    397|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    397|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    397|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    397|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    397|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    397|  constexpr auto _size = _name.size();                                \
  |  | 1183|    397|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    397|  return _nameof; }()
  ------------------
  562|    397|      c.fuzz(chardata);                                                        \
  563|    397|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    397|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    397|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    397|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    397|    static const bool do_print_testcase =
  181|    397|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    397|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 397]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    397|    do {
  189|       |      // step 0 - is the input valid?
  190|    397|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    397|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 397]
  |  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|    397|                    From == UtfEncodings::UTF8) {
  198|    397|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 397]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    397|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    397|      const auto [output_length, length_agree] =
  204|    397|          calculate_length(from, inputisvalid);
  205|    397|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 397]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    397|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 217, False: 180]
  |  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|    397|      const auto [written, outputs_agree] =
  215|    397|          do_conversion(from, output_length, inputisvalid);
  216|    397|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 397]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    397|      return;
  221|    397|    } 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|    397|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    397|  validation_result verify_valid_input(FromSpan src) const {
  231|    397|    validation_result ret{};
  232|       |
  233|    397|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    397|    const auto implementations = get_supported_implementations();
  235|    397|    std::vector<simdutf::result> results;
  236|    397|    results.reserve(implementations.size());
  237|       |
  238|  1.19k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.19k, False: 397]
  ------------------
  239|  1.19k|      results.push_back(
  240|  1.19k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.19k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.19k|      const bool validation2 =
  245|  1.19k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.19k|                      src.data(), src.size());
  247|  1.19k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.19k]
  ------------------
  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.19k|    }
  258|       |
  259|    397|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    397|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 397]
  ------------------
  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|    397|    } else {
  273|    397|      ret.implementations_agree = true;
  274|    397|    }
  275|    397|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    397|      return r.error == simdutf::SUCCESS;
  277|    397|    });
  278|    397|    return ret;
  279|    397|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    794|    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|    757|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    757|      return r.error == simdutf::SUCCESS;
  277|    757|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    397|  bool count_the_input(FromSpan src) const {
  290|    397|    const auto implementations = get_supported_implementations();
  291|    397|    std::vector<std::size_t> results;
  292|    397|    results.reserve(implementations.size());
  293|       |
  294|  1.19k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.19k, False: 397]
  ------------------
  295|  1.19k|      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.19k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.19k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.19k|      }
  303|  1.19k|      results.push_back(ret);
  304|  1.19k|    }
  305|    397|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    397|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 397]
  ------------------
  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|    397|    return true;
  321|    397|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    794|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    397|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    397|    length_result ret{};
  344|       |
  345|    397|    const auto implementations = get_supported_implementations();
  346|    397|    std::vector<std::size_t> results;
  347|    397|    results.reserve(implementations.size());
  348|       |
  349|  1.19k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.19k, False: 397]
  ------------------
  350|  1.19k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.19k|      results.push_back(len);
  352|  1.19k|      ret.length.push_back(len);
  353|  1.19k|    }
  354|       |
  355|    397|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    397|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 397]
  ------------------
  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|    397|    } else {
  375|    397|      ret.implementations_agree = true;
  376|    397|    }
  377|    397|    return ret;
  378|    397|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.19k|                                FromSpan src) const {
  331|  1.19k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.19k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    794|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    397|                                  const bool inputisvalid) const {
  383|    397|    conversion_result ret{};
  384|       |
  385|    397|    const auto implementations = get_supported_implementations();
  386|       |
  387|    397|    std::vector<result<ConversionResult>> results;
  388|    397|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    397|    std::vector<std::vector<ToType>> outputbuffers;
  393|    397|    outputbuffers.reserve(implementations.size());
  394|  1.58k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.19k, False: 397]
  ------------------
  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: 540, False: 651]
  |  Branch (423:29): [True: 540, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    540|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    540|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 540]
  ------------------
  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|    540|        }
  440|  1.19k|      }
  441|  1.19k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 540, False: 651]
  ------------------
  442|  1.19k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    397|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 217, False: 180]
  ------------------
  447|    651|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 651, False: 217]
  ------------------
  448|    651|        e.outputhash.clear();
  449|    651|      }
  450|    217|    }
  451|       |
  452|    397|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    397|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 397]
  ------------------
  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|    397|    } else {
  474|    397|      ret.implementations_agree = true;
  475|    397|    }
  476|    397|    return ret;
  477|    397|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|  1.19k|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|  1.19k|        } else {
  405|  1.19k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.19k|        }
  407|  1.19k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    794|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_38clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     55|    +[](std::span<const char> chardata) {                                      \
  555|     55|      const auto c =                                                           \
  556|     55|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     55|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     55|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     55|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     55|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     55|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     55|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     55|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     55|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     55|  constexpr auto _size = _name.size();                                \
  |  | 1183|     55|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     55|  return _nameof; }()
  ------------------
  561|     55|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     55|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     55|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     55|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     55|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     55|  constexpr auto _size = _name.size();                                \
  |  | 1183|     55|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     55|  return _nameof; }()
  ------------------
  562|     55|      c.fuzz(chardata);                                                        \
  563|     55|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE4fuzzENSt3__14spanIS5_Lm18446744073709551615EEE:
  175|     55|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     55|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     55|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     55|    static const bool do_print_testcase =
  181|     55|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     55|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 55]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     55|    do {
  189|       |      // step 0 - is the input valid?
  190|     55|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     55|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 55]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|       |                    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|     55|      const auto [output_length, length_agree] =
  204|     55|          calculate_length(from, inputisvalid);
  205|     55|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 55]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     55|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 0, False: 55]
  |  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|     55|      const auto [written, outputs_agree] =
  215|     55|          do_conversion(from, output_length, inputisvalid);
  216|     55|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 55]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     55|      return;
  221|     55|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|     55|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE18verify_valid_inputIvQeqT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  283|     55|  validation_result verify_valid_input(FromSpan) const {
  284|       |    // all latin1 input is valid. there is no simdutf validation function for
  285|       |    // it.
  286|     55|    return validation_result{.valid = true, .implementations_agree = true};
  287|     55|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     55|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     55|    length_result ret{};
  344|       |
  345|     55|    const auto implementations = get_supported_implementations();
  346|     55|    std::vector<std::size_t> results;
  347|     55|    results.reserve(implementations.size());
  348|       |
  349|    165|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 165, False: 55]
  ------------------
  350|    165|      const auto len = invoke_lengthcalc(impl, src);
  351|    165|      results.push_back(len);
  352|    165|      ret.length.push_back(len);
  353|    165|    }
  354|       |
  355|     55|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     55|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 55]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|     55|    } else {
  375|     55|      ret.implementations_agree = true;
  376|     55|    }
  377|     55|    return ret;
  378|     55|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    165|                                FromSpan src) const {
  339|    165|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    165|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    110|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     55|                                  const bool inputisvalid) const {
  383|     55|    conversion_result ret{};
  384|       |
  385|     55|    const auto implementations = get_supported_implementations();
  386|       |
  387|     55|    std::vector<result<ConversionResult>> results;
  388|     55|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     55|    std::vector<std::vector<ToType>> outputbuffers;
  393|     55|    outputbuffers.reserve(implementations.size());
  394|    220|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 165, False: 55]
  ------------------
  395|    165|      auto impl = implementations[i];
  396|    165|      const ToType canary1{42};
  397|    165|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    165|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    165|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    165|      const auto success = [](const ConversionResult& r) -> bool {
  402|    165|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    165|          return r != 0;
  404|    165|        } else {
  405|    165|          return r.error == simdutf::error_code::SUCCESS;
  406|    165|        }
  407|    165|      }(implret1);
  408|    165|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    165|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    165|        const ToType canary2{25};
  414|    165|        const auto outputbuffer_first_run = outputbuffer;
  415|    165|        std::ranges::fill(outputbuffer, canary2);
  416|    165|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    165|                                          src.size(), outputbuffer.data());
  418|       |
  419|    165|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 165]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    165|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 165, False: 0]
  |  Branch (423:29): [True: 159, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    159|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    159|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 159]
  ------------------
  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|    159|        }
  440|    165|      }
  441|    165|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 159, False: 6]
  ------------------
  442|    165|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     55|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 0, False: 55]
  ------------------
  447|      0|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 0, False: 0]
  ------------------
  448|      0|        e.outputhash.clear();
  449|      0|      }
  450|      0|    }
  451|       |
  452|     55|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     55|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 55]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|     55|    } else {
  474|     55|      ret.implementations_agree = true;
  475|     55|    }
  476|     55|    return ret;
  477|     55|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    165|      const auto success = [](const ConversionResult& r) -> bool {
  402|    165|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    165|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    165|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    110|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_39clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     44|    +[](std::span<const char> chardata) {                                      \
  555|     44|      const auto c =                                                           \
  556|     44|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     44|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     44|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     44|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     44|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     44|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     44|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     44|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     44|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     44|  constexpr auto _size = _name.size();                                \
  |  | 1183|     44|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     44|  return _nameof; }()
  ------------------
  561|     44|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     44|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     44|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     44|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     44|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     44|  constexpr auto _size = _name.size();                                \
  |  | 1183|     44|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     44|  return _nameof; }()
  ------------------
  562|     44|      c.fuzz(chardata);                                                        \
  563|     44|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE4fuzzENSt3__14spanIS5_Lm18446744073709551615EEE:
  175|     44|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     44|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     44|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     44|    static const bool do_print_testcase =
  181|     44|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     44|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 44]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     44|    do {
  189|       |      // step 0 - is the input valid?
  190|     44|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     44|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 44]
  |  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|     44|      const auto [output_length, length_agree] =
  204|     44|          calculate_length(from, inputisvalid);
  205|     44|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 44]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     44|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 0, False: 44]
  |  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|     44|      const auto [written, outputs_agree] =
  215|     44|          do_conversion(from, output_length, inputisvalid);
  216|     44|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 44]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     44|      return;
  221|     44|    } 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|     44|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE18verify_valid_inputIvQeqT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  283|     44|  validation_result verify_valid_input(FromSpan) const {
  284|       |    // all latin1 input is valid. there is no simdutf validation function for
  285|       |    // it.
  286|     44|    return validation_result{.valid = true, .implementations_agree = true};
  287|     44|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     44|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     44|    length_result ret{};
  344|       |
  345|     44|    const auto implementations = get_supported_implementations();
  346|     44|    std::vector<std::size_t> results;
  347|     44|    results.reserve(implementations.size());
  348|       |
  349|    132|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 132, False: 44]
  ------------------
  350|    132|      const auto len = invoke_lengthcalc(impl, src);
  351|    132|      results.push_back(len);
  352|    132|      ret.length.push_back(len);
  353|    132|    }
  354|       |
  355|     44|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     44|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 44]
  ------------------
  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|     44|    } else {
  375|     44|      ret.implementations_agree = true;
  376|     44|    }
  377|     44|    return ret;
  378|     44|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    132|                                FromSpan src) const {
  339|    132|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    132|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|     88|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     44|                                  const bool inputisvalid) const {
  383|     44|    conversion_result ret{};
  384|       |
  385|     44|    const auto implementations = get_supported_implementations();
  386|       |
  387|     44|    std::vector<result<ConversionResult>> results;
  388|     44|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     44|    std::vector<std::vector<ToType>> outputbuffers;
  393|     44|    outputbuffers.reserve(implementations.size());
  394|    176|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 132, False: 44]
  ------------------
  395|    132|      auto impl = implementations[i];
  396|    132|      const ToType canary1{42};
  397|    132|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    132|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    132|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    132|      const auto success = [](const ConversionResult& r) -> bool {
  402|    132|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    132|          return r != 0;
  404|    132|        } else {
  405|    132|          return r.error == simdutf::error_code::SUCCESS;
  406|    132|        }
  407|    132|      }(implret1);
  408|    132|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    132|      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|    132|        const ToType canary2{25};
  414|    132|        const auto outputbuffer_first_run = outputbuffer;
  415|    132|        std::ranges::fill(outputbuffer, canary2);
  416|    132|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    132|                                          src.size(), outputbuffer.data());
  418|       |
  419|    132|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 132]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    132|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 132, False: 0]
  |  Branch (423:29): [True: 126, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    126|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    126|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 126]
  ------------------
  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|    126|        }
  440|    132|      }
  441|    132|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 126, False: 6]
  ------------------
  442|    132|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     44|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 0, False: 44]
  ------------------
  447|      0|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 0, False: 0]
  ------------------
  448|      0|        e.outputhash.clear();
  449|      0|      }
  450|      0|    }
  451|       |
  452|     44|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     44|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 44]
  ------------------
  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|     44|    } else {
  474|     44|      ret.implementations_agree = true;
  475|     44|    }
  476|     44|    return ret;
  477|     44|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    132|      const auto success = [](const ConversionResult& r) -> bool {
  402|    132|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    132|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    132|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|     88|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_40clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     43|    +[](std::span<const char> chardata) {                                      \
  555|     43|      const auto c =                                                           \
  556|     43|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     43|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     43|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     43|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     43|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     43|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     43|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     43|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     43|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     43|  constexpr auto _size = _name.size();                                \
  |  | 1183|     43|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     43|  return _nameof; }()
  ------------------
  561|     43|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     43|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     43|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     43|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     43|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     43|  constexpr auto _size = _name.size();                                \
  |  | 1183|     43|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     43|  return _nameof; }()
  ------------------
  562|     43|      c.fuzz(chardata);                                                        \
  563|     43|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE4fuzzENSt3__14spanIS5_Lm18446744073709551615EEE:
  175|     43|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     43|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     43|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     43|    static const bool do_print_testcase =
  181|     43|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     43|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 43]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     43|    do {
  189|       |      // step 0 - is the input valid?
  190|     43|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     43|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 43]
  |  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|     43|      const auto [output_length, length_agree] =
  204|     43|          calculate_length(from, inputisvalid);
  205|     43|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 43]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     43|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 0, False: 43]
  |  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|     43|      const auto [written, outputs_agree] =
  215|     43|          do_conversion(from, output_length, inputisvalid);
  216|     43|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 43]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     43|      return;
  221|     43|    } 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|     43|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE18verify_valid_inputIvQeqT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  283|     43|  validation_result verify_valid_input(FromSpan) const {
  284|       |    // all latin1 input is valid. there is no simdutf validation function for
  285|       |    // it.
  286|     43|    return validation_result{.valid = true, .implementations_agree = true};
  287|     43|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     43|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     43|    length_result ret{};
  344|       |
  345|     43|    const auto implementations = get_supported_implementations();
  346|     43|    std::vector<std::size_t> results;
  347|     43|    results.reserve(implementations.size());
  348|       |
  349|    129|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 129, False: 43]
  ------------------
  350|    129|      const auto len = invoke_lengthcalc(impl, src);
  351|    129|      results.push_back(len);
  352|    129|      ret.length.push_back(len);
  353|    129|    }
  354|       |
  355|     43|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     43|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 43]
  ------------------
  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|     43|    } else {
  375|     43|      ret.implementations_agree = true;
  376|     43|    }
  377|     43|    return ret;
  378|     43|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    129|                                FromSpan src) const {
  339|    129|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    129|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|     86|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     43|                                  const bool inputisvalid) const {
  383|     43|    conversion_result ret{};
  384|       |
  385|     43|    const auto implementations = get_supported_implementations();
  386|       |
  387|     43|    std::vector<result<ConversionResult>> results;
  388|     43|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     43|    std::vector<std::vector<ToType>> outputbuffers;
  393|     43|    outputbuffers.reserve(implementations.size());
  394|    172|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 129, False: 43]
  ------------------
  395|    129|      auto impl = implementations[i];
  396|    129|      const ToType canary1{42};
  397|    129|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    129|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    129|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    129|      const auto success = [](const ConversionResult& r) -> bool {
  402|    129|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    129|          return r != 0;
  404|    129|        } else {
  405|    129|          return r.error == simdutf::error_code::SUCCESS;
  406|    129|        }
  407|    129|      }(implret1);
  408|    129|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    129|      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|    129|        const ToType canary2{25};
  414|    129|        const auto outputbuffer_first_run = outputbuffer;
  415|    129|        std::ranges::fill(outputbuffer, canary2);
  416|    129|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    129|                                          src.size(), outputbuffer.data());
  418|       |
  419|    129|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 129]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    129|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 129, False: 0]
  |  Branch (423:29): [True: 123, False: 6]
  ------------------
  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|    129|      }
  441|    129|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 123, False: 6]
  ------------------
  442|    129|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     43|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 0, False: 43]
  ------------------
  447|      0|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 0, False: 0]
  ------------------
  448|      0|        e.outputhash.clear();
  449|      0|      }
  450|      0|    }
  451|       |
  452|     43|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     43|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 43]
  ------------------
  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|     43|    } else {
  474|     43|      ret.implementations_agree = true;
  475|     43|    }
  476|     43|    return ret;
  477|     43|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    129|      const auto success = [](const ConversionResult& r) -> bool {
  402|    129|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    129|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    129|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|     86|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_41clENSt3__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|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  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: 0, False: 303]
  |  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|    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|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQeqT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  283|    303|  validation_result verify_valid_input(FromSpan) const {
  284|       |    // all latin1 input is valid. there is no simdutf validation function for
  285|       |    // it.
  286|    303|    return validation_result{.valid = true, .implementations_agree = true};
  287|    303|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE16calculate_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|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    909|                                FromSpan src) const {
  331|    909|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    909|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    606|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_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: 909, False: 0]
  |  Branch (423:29): [True: 903, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    903|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    903|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 903]
  ------------------
  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|    903|        }
  440|    909|      }
  441|    909|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 903, False: 6]
  ------------------
  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: 0, False: 303]
  ------------------
  447|      0|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 0, False: 0]
  ------------------
  448|      0|        e.outputhash.clear();
  449|      0|      }
  450|      0|    }
  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|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  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|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    909|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    606|    auto neq = [](const auto& a, const auto& b) { return a != b; };

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

_ZNK23ValidationFunctionTraitIL12UtfEncodings0EE24ValidationWithErrorsNameMUlvE_clEv:
 1178|      2|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|      2|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|      2|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|      2|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|      2|  constexpr auto _size = _name.size();                                \
 1183|      2|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|      2|  return _nameof; }()
_ZNK6nameof7cstringILt28EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|      4|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt28EE4dataEv:
  233|      4|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt28EE4sizeEv:
  235|      4|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
_ZNK23ValidationFunctionTraitIL12UtfEncodings1EE24ValidationWithErrorsNameMUlvE_clEv:
 1178|      2|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|      2|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|      2|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|      2|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|      2|  constexpr auto _size = _name.size();                                \
 1183|      2|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|      2|  return _nameof; }()
_ZNK23ValidationFunctionTraitIL12UtfEncodings3EE24ValidationWithErrorsNameMUlvE_clEv:
 1178|      2|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|      2|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|      2|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|      2|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|      2|  constexpr auto _size = _name.size();                                \
 1183|      2|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|      2|  return _nameof; }()
_ZNK6nameof7cstringILt26EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|      2|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt26EE4dataEv:
  233|      2|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt26EE4sizeEv:
  235|      2|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
_ZNK23ValidationFunctionTraitIL12UtfEncodings2EE24ValidationWithErrorsNameMUlvE_clEv:
 1178|      2|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|      2|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|      2|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|      2|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|      2|  constexpr auto _size = _name.size();                                \
 1183|      2|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|      2|  return _nameof; }()
_ZNK6nameof7cstringILt25EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  1.00k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt25EE4dataEv:
  233|  1.00k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt25EE4sizeEv:
  235|  1.00k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_0clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     99|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     99|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     99|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     99|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     99|  constexpr auto _size = _name.size();                                \
 1183|     99|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     99|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_0clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     99|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     99|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     99|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     99|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     99|  constexpr auto _size = _name.size();                                \
 1183|     99|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     99|  return _nameof; }()
_ZNK6nameof7cstringILt30EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    354|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt30EE4dataEv:
  233|    354|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt30EE4sizeEv:
  235|    354|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_1clENSt3__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; }()
_ZNK6nameof7cstringILt24EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  3.13k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt24EE4dataEv:
  233|  3.13k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt24EE4sizeEv:
  235|  3.13k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_1clENSt3__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; }()
_ZNK6nameof7cstringILt29EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    939|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt29EE4dataEv:
  233|    939|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt29EE4sizeEv:
  235|    939|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_2clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     58|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     58|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     58|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     58|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     58|  constexpr auto _size = _name.size();                                \
 1183|     58|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     58|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_2clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     58|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     58|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     58|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     58|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     58|  constexpr auto _size = _name.size();                                \
 1183|     58|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     58|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_3clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    236|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    236|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    236|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    236|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    236|  constexpr auto _size = _name.size();                                \
 1183|    236|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    236|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_3clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    236|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    236|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    236|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    236|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    236|  constexpr auto _size = _name.size();                                \
 1183|    236|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    236|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_4clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     66|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     66|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     66|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     66|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     66|  constexpr auto _size = _name.size();                                \
 1183|     66|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     66|  return _nameof; }()
_ZNK6nameof7cstringILt23EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  3.49k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt23EE4dataEv:
  233|  3.49k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt23EE4sizeEv:
  235|  3.49k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_4clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     66|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     66|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     66|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     66|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     66|  constexpr auto _size = _name.size();                                \
 1183|     66|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     66|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_5clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    131|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    131|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    131|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    131|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    131|  constexpr auto _size = _name.size();                                \
 1183|    131|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    131|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_5clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    131|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    131|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    131|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    131|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    131|  constexpr auto _size = _name.size();                                \
 1183|    131|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    131|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_6clENSt3__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; }()
_ZNK6nameof7cstringILt22EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  4.46k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt22EE4dataEv:
  233|  4.46k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt22EE4sizeEv:
  235|  4.46k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_6clENSt3__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; }()
_ZNK6nameof7cstringILt27EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    344|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt27EE4dataEv:
  233|    344|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt27EE4sizeEv:
  235|    344|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_7clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    248|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    248|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    248|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    248|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    248|  constexpr auto _size = _name.size();                                \
 1183|    248|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    248|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_7clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    248|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    248|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    248|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    248|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    248|  constexpr auto _size = _name.size();                                \
 1183|    248|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    248|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_8clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    239|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    239|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    239|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    239|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    239|  constexpr auto _size = _name.size();                                \
 1183|    239|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    239|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_8clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    239|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    239|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    239|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    239|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    239|  constexpr auto _size = _name.size();                                \
 1183|    239|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    239|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_9clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    229|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    229|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    229|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    229|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    229|  constexpr auto _size = _name.size();                                \
 1183|    229|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    229|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_9clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    229|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    229|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    229|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    229|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    229|  constexpr auto _size = _name.size();                                \
 1183|    229|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    229|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_10clENSt3__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; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_10clENSt3__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_functionsvENK4$_11clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    110|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    110|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    110|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    110|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    110|  constexpr auto _size = _name.size();                                \
 1183|    110|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    110|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_11clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    110|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    110|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    110|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    110|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    110|  constexpr auto _size = _name.size();                                \
 1183|    110|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    110|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_12clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    176|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    176|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    176|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    176|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    176|  constexpr auto _size = _name.size();                                \
 1183|    176|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    176|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_12clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    176|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    176|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    176|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    176|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    176|  constexpr auto _size = _name.size();                                \
 1183|    176|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    176|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_13clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     67|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     67|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     67|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     67|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     67|  constexpr auto _size = _name.size();                                \
 1183|     67|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     67|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_13clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     67|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     67|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     67|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     67|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     67|  constexpr auto _size = _name.size();                                \
 1183|     67|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     67|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_14clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    153|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    153|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    153|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    153|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    153|  constexpr auto _size = _name.size();                                \
 1183|    153|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    153|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_14clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    153|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    153|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    153|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    153|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    153|  constexpr auto _size = _name.size();                                \
 1183|    153|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    153|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_15clENSt3__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_functionsvENK4$_15clENSt3__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$_16clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     86|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     86|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     86|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     86|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     86|  constexpr auto _size = _name.size();                                \
 1183|     86|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     86|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_16clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     86|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     86|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     86|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     86|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     86|  constexpr auto _size = _name.size();                                \
 1183|     86|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     86|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_17clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    267|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    267|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    267|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    267|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    267|  constexpr auto _size = _name.size();                                \
 1183|    267|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    267|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_17clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    267|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    267|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    267|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    267|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    267|  constexpr auto _size = _name.size();                                \
 1183|    267|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    267|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_18clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    263|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    263|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    263|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    263|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    263|  constexpr auto _size = _name.size();                                \
 1183|    263|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    263|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_18clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    263|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    263|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    263|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    263|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    263|  constexpr auto _size = _name.size();                                \
 1183|    263|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    263|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_19clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    355|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    355|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    355|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    355|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    355|  constexpr auto _size = _name.size();                                \
 1183|    355|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    355|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_19clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    355|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    355|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    355|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    355|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    355|  constexpr auto _size = _name.size();                                \
 1183|    355|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    355|  return _nameof; }()
_ZNK6nameof7cstringILt21EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    747|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt21EE4dataEv:
  233|    747|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt21EE4sizeEv:
  235|    747|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_20clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    295|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    295|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    295|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    295|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    295|  constexpr auto _size = _name.size();                                \
 1183|    295|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    295|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_20clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    295|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    295|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    295|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    295|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    295|  constexpr auto _size = _name.size();                                \
 1183|    295|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    295|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_21clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    378|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    378|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    378|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    378|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    378|  constexpr auto _size = _name.size();                                \
 1183|    378|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    378|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_21clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    378|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    378|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    378|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    378|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    378|  constexpr auto _size = _name.size();                                \
 1183|    378|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    378|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_22clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    360|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    360|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    360|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    360|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    360|  constexpr auto _size = _name.size();                                \
 1183|    360|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    360|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_22clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    360|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    360|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    360|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    360|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    360|  constexpr auto _size = _name.size();                                \
 1183|    360|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    360|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_23clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    392|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    392|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    392|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    392|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    392|  constexpr auto _size = _name.size();                                \
 1183|    392|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    392|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_23clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    392|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    392|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    392|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    392|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    392|  constexpr auto _size = _name.size();                                \
 1183|    392|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    392|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_24clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    125|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    125|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    125|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    125|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    125|  constexpr auto _size = _name.size();                                \
 1183|    125|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    125|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_24clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    125|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    125|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    125|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    125|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    125|  constexpr auto _size = _name.size();                                \
 1183|    125|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    125|  return _nameof; }()
_ZNK6nameof7cstringILt37EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    264|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt37EE4dataEv:
  233|    264|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt37EE4sizeEv:
  235|    264|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_25clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    173|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    173|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    173|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    173|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    173|  constexpr auto _size = _name.size();                                \
 1183|    173|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    173|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_25clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    173|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    173|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    173|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    173|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    173|  constexpr auto _size = _name.size();                                \
 1183|    173|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    173|  return _nameof; }()
_ZNK6nameof7cstringILt36EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  1.03k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt36EE4dataEv:
  233|  1.03k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt36EE4sizeEv:
  235|  1.03k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_26clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    364|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    364|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    364|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    364|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    364|  constexpr auto _size = _name.size();                                \
 1183|    364|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    364|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_26clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    364|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    364|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    364|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    364|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    364|  constexpr auto _size = _name.size();                                \
 1183|    364|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    364|  return _nameof; }()
_ZNK6nameof7cstringILt35EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  1.58k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt35EE4dataEv:
  233|  1.58k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt35EE4sizeEv:
  235|  1.58k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_27clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    139|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    139|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    139|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    139|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    139|  constexpr auto _size = _name.size();                                \
 1183|    139|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    139|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_27clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    139|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    139|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    139|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    139|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    139|  constexpr auto _size = _name.size();                                \
 1183|    139|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    139|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_28clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    209|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    209|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    209|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    209|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    209|  constexpr auto _size = _name.size();                                \
 1183|    209|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    209|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_28clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    209|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    209|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    209|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    209|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    209|  constexpr auto _size = _name.size();                                \
 1183|    209|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    209|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_29clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    332|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    332|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    332|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    332|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    332|  constexpr auto _size = _name.size();                                \
 1183|    332|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    332|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_29clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    332|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    332|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    332|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    332|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    332|  constexpr auto _size = _name.size();                                \
 1183|    332|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    332|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_30clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    204|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    204|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    204|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    204|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    204|  constexpr auto _size = _name.size();                                \
 1183|    204|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    204|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_30clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    204|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    204|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    204|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    204|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    204|  constexpr auto _size = _name.size();                                \
 1183|    204|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    204|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_31clENSt3__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$_31clENSt3__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$_32clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    342|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    342|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    342|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    342|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    342|  constexpr auto _size = _name.size();                                \
 1183|    342|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    342|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_32clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    342|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    342|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    342|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    342|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    342|  constexpr auto _size = _name.size();                                \
 1183|    342|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    342|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_33clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    467|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    467|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    467|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    467|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    467|  constexpr auto _size = _name.size();                                \
 1183|    467|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    467|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_33clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    467|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    467|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    467|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    467|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    467|  constexpr auto _size = _name.size();                                \
 1183|    467|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    467|  return _nameof; }()
_ZNK6nameof7cstringILt33EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    864|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt33EE4dataEv:
  233|    864|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt33EE4sizeEv:
  235|    864|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_34clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    251|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    251|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    251|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    251|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    251|  constexpr auto _size = _name.size();                                \
 1183|    251|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    251|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_34clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    251|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    251|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    251|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    251|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    251|  constexpr auto _size = _name.size();                                \
 1183|    251|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    251|  return _nameof; }()
_ZNK6nameof7cstringILt34EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    251|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt34EE4dataEv:
  233|    251|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt34EE4sizeEv:
  235|    251|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_35clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    377|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    377|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    377|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    377|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    377|  constexpr auto _size = _name.size();                                \
 1183|    377|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    377|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_35clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    377|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    377|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    377|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    377|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    377|  constexpr auto _size = _name.size();                                \
 1183|    377|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    377|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_36clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    306|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    306|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    306|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    306|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    306|  constexpr auto _size = _name.size();                                \
 1183|    306|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    306|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_36clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    306|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    306|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    306|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    306|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    306|  constexpr auto _size = _name.size();                                \
 1183|    306|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    306|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_37clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    397|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    397|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    397|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    397|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    397|  constexpr auto _size = _name.size();                                \
 1183|    397|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    397|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_37clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    397|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    397|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    397|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    397|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    397|  constexpr auto _size = _name.size();                                \
 1183|    397|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    397|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_38clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     55|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     55|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     55|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     55|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     55|  constexpr auto _size = _name.size();                                \
 1183|     55|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     55|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_38clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     55|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     55|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     55|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     55|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     55|  constexpr auto _size = _name.size();                                \
 1183|     55|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     55|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_39clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     44|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     44|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     44|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     44|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     44|  constexpr auto _size = _name.size();                                \
 1183|     44|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     44|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_39clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     44|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     44|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     44|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     44|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     44|  constexpr auto _size = _name.size();                                \
 1183|     44|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     44|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_40clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     43|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     43|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     43|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     43|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     43|  constexpr auto _size = _name.size();                                \
 1183|     43|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     43|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_40clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     43|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     43|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     43|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     43|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     43|  constexpr auto _size = _name.size();                                \
 1183|     43|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     43|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_41clENSt3__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$_41clENSt3__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; }()

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

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

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

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

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

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

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

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

_ZN7simdutf6scalar5utf168validateILNS_10endiannessE0EEEbPKDsm:
   22|  3.88k|validate(const char16_t *data, size_t len) noexcept {
   23|  3.88k|  uint64_t pos = 0;
   24|  21.4M|  while (pos < len) {
  ------------------
  |  Branch (24:10): [True: 21.4M, False: 2.61k]
  ------------------
   25|  21.4M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   26|  21.4M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (26:9): [True: 20.4k, False: 21.4M]
  ------------------
   27|  20.4k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 219, False: 20.2k]
  ------------------
   28|    219|        return false;
   29|    219|      }
   30|  20.2k|      char16_t diff = char16_t(word - 0xD800);
   31|  20.2k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (31:11): [True: 450, False: 19.8k]
  ------------------
   32|    450|        return false;
   33|    450|      }
   34|  19.8k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (34:28): [Folded, False: 19.8k]
  ------------------
   35|  19.8k|                               ? u16_swap_bytes(data[pos + 1])
   36|  19.8k|                               : data[pos + 1];
   37|  19.8k|      char16_t diff2 = char16_t(next_word - 0xDC00);
   38|  19.8k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (38:11): [True: 603, False: 19.2k]
  ------------------
   39|    603|        return false;
   40|    603|      }
   41|  19.2k|      pos += 2;
   42|  21.4M|    } else {
   43|  21.4M|      pos++;
   44|  21.4M|    }
   45|  21.4M|  }
   46|  2.61k|  return true;
   47|  3.88k|}
_ZN7simdutf6scalar5utf168validateILNS_10endiannessE1EEEbPKDsm:
   22|  3.68k|validate(const char16_t *data, size_t len) noexcept {
   23|  3.68k|  uint64_t pos = 0;
   24|  21.3M|  while (pos < len) {
  ------------------
  |  Branch (24:10): [True: 21.3M, False: 2.55k]
  ------------------
   25|  21.3M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   26|  21.3M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (26:9): [True: 24.9k, False: 21.3M]
  ------------------
   27|  24.9k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 222, False: 24.7k]
  ------------------
   28|    222|        return false;
   29|    222|      }
   30|  24.7k|      char16_t diff = char16_t(word - 0xD800);
   31|  24.7k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (31:11): [True: 419, False: 24.2k]
  ------------------
   32|    419|        return false;
   33|    419|      }
   34|  24.2k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (34:28): [True: 24.2k, Folded]
  ------------------
   35|  24.2k|                               ? u16_swap_bytes(data[pos + 1])
   36|  24.2k|                               : data[pos + 1];
   37|  24.2k|      char16_t diff2 = char16_t(next_word - 0xDC00);
   38|  24.2k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (38:11): [True: 493, False: 23.7k]
  ------------------
   39|    493|        return false;
   40|    493|      }
   41|  23.7k|      pos += 2;
   42|  21.3M|    } else {
   43|  21.3M|      pos++;
   44|  21.3M|    }
   45|  21.3M|  }
   46|  2.55k|  return true;
   47|  3.68k|}
_ZN7simdutf6scalar5utf1620validate_with_errorsILNS_10endiannessE0EEENS_6resultEPKDsm:
   51|  4.17k|validate_with_errors(const char16_t *data, size_t len) noexcept {
   52|  4.17k|  size_t pos = 0;
   53|  21.4M|  while (pos < len) {
  ------------------
  |  Branch (53:10): [True: 21.4M, False: 2.61k]
  ------------------
   54|  21.4M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   55|  21.4M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (55:9): [True: 20.8k, False: 21.4M]
  ------------------
   56|  20.8k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (56:11): [True: 219, False: 20.6k]
  ------------------
   57|    219|        return result(error_code::SURROGATE, pos);
   58|    219|      }
   59|  20.6k|      char16_t diff = char16_t(word - 0xD800);
   60|  20.6k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (60:11): [True: 585, False: 20.0k]
  ------------------
   61|    585|        return result(error_code::SURROGATE, pos);
   62|    585|      }
   63|  20.0k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (63:28): [Folded, False: 20.0k]
  ------------------
   64|  20.0k|                               ? u16_swap_bytes(data[pos + 1])
   65|  20.0k|                               : data[pos + 1];
   66|  20.0k|      char16_t diff2 = uint16_t(next_word - 0xDC00);
   67|  20.0k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (67:11): [True: 753, False: 19.2k]
  ------------------
   68|    753|        return result(error_code::SURROGATE, pos);
   69|    753|      }
   70|  19.2k|      pos += 2;
   71|  21.4M|    } else {
   72|  21.4M|      pos++;
   73|  21.4M|    }
   74|  21.4M|  }
   75|  2.61k|  return result(error_code::SUCCESS, pos);
   76|  4.17k|}
_ZN7simdutf6scalar5utf1620validate_with_errorsILNS_10endiannessE1EEENS_6resultEPKDsm:
   51|  3.89k|validate_with_errors(const char16_t *data, size_t len) noexcept {
   52|  3.89k|  size_t pos = 0;
   53|  21.3M|  while (pos < len) {
  ------------------
  |  Branch (53:10): [True: 21.3M, False: 2.55k]
  ------------------
   54|  21.3M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   55|  21.3M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (55:9): [True: 25.1k, False: 21.3M]
  ------------------
   56|  25.1k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (56:11): [True: 222, False: 24.9k]
  ------------------
   57|    222|        return result(error_code::SURROGATE, pos);
   58|    222|      }
   59|  24.9k|      char16_t diff = char16_t(word - 0xD800);
   60|  24.9k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (60:11): [True: 531, False: 24.4k]
  ------------------
   61|    531|        return result(error_code::SURROGATE, pos);
   62|    531|      }
   63|  24.4k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (63:28): [True: 24.4k, Folded]
  ------------------
   64|  24.4k|                               ? u16_swap_bytes(data[pos + 1])
   65|  24.4k|                               : data[pos + 1];
   66|  24.4k|      char16_t diff2 = uint16_t(next_word - 0xDC00);
   67|  24.4k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (67:11): [True: 594, False: 23.8k]
  ------------------
   68|    594|        return result(error_code::SURROGATE, pos);
   69|    594|      }
   70|  23.8k|      pos += 2;
   71|  21.3M|    } else {
   72|  21.3M|      pos++;
   73|  21.3M|    }
   74|  21.3M|  }
   75|  2.55k|  return result(error_code::SUCCESS, pos);
   76|  3.89k|}
_ZN7simdutf6scalar5utf1617count_code_pointsILNS_10endiannessE0EEEmPKDsm:
   79|  5.04k|simdutf_constexpr23 size_t count_code_points(const char16_t *p, size_t len) {
   80|       |  // We are not BOM aware.
   81|  5.04k|  size_t counter{0};
   82|  29.7M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (82:22): [True: 29.7M, False: 5.04k]
  ------------------
   83|  29.7M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
   84|  29.7M|    counter += ((word & 0xFC00) != 0xDC00);
   85|  29.7M|  }
   86|  5.04k|  return counter;
   87|  5.04k|}
_ZN7simdutf6scalar5utf1617count_code_pointsILNS_10endiannessE1EEEmPKDsm:
   79|  4.69k|simdutf_constexpr23 size_t count_code_points(const char16_t *p, size_t len) {
   80|       |  // We are not BOM aware.
   81|  4.69k|  size_t counter{0};
   82|  27.1M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (82:22): [True: 27.1M, False: 4.69k]
  ------------------
   83|  27.1M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
   84|  27.1M|    counter += ((word & 0xFC00) != 0xDC00);
   85|  27.1M|  }
   86|  4.69k|  return counter;
   87|  4.69k|}
_ZN7simdutf6scalar5utf1622utf8_length_from_utf16ILNS_10endiannessE0EEEmPKDsm:
   91|  2.32k|                                                  size_t len) {
   92|       |  // We are not BOM aware.
   93|  2.32k|  size_t counter{0};
   94|  17.2M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (94:22): [True: 17.2M, False: 2.32k]
  ------------------
   95|  17.2M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
   96|  17.2M|    counter++; // ASCII
   97|  17.2M|    counter += static_cast<size_t>(
   98|  17.2M|        word >
   99|  17.2M|        0x7F); // non-ASCII is at least 2 bytes, surrogates are 2*2 == 4 bytes
  100|  17.2M|    counter += static_cast<size_t>((word > 0x7FF && word <= 0xD7FF) ||
  ------------------
  |  Branch (100:37): [True: 3.15M, False: 14.0M]
  |  Branch (100:53): [True: 2.85M, False: 297k]
  ------------------
  101|  14.3M|                                   (word >= 0xE000)); // three-byte
  ------------------
  |  Branch (101:36): [True: 235k, False: 14.1M]
  ------------------
  102|  17.2M|  }
  103|  2.32k|  return counter;
  104|  2.32k|}
_ZN7simdutf6scalar5utf1622utf8_length_from_utf16ILNS_10endiannessE1EEEmPKDsm:
   91|  2.26k|                                                  size_t len) {
   92|       |  // We are not BOM aware.
   93|  2.26k|  size_t counter{0};
   94|  16.5M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (94:22): [True: 16.5M, False: 2.26k]
  ------------------
   95|  16.5M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
   96|  16.5M|    counter++; // ASCII
   97|  16.5M|    counter += static_cast<size_t>(
   98|  16.5M|        word >
   99|  16.5M|        0x7F); // non-ASCII is at least 2 bytes, surrogates are 2*2 == 4 bytes
  100|  16.5M|    counter += static_cast<size_t>((word > 0x7FF && word <= 0xD7FF) ||
  ------------------
  |  Branch (100:37): [True: 3.10M, False: 13.4M]
  |  Branch (100:53): [True: 2.86M, False: 241k]
  ------------------
  101|  13.6M|                                   (word >= 0xE000)); // three-byte
  ------------------
  |  Branch (101:36): [True: 201k, False: 13.4M]
  ------------------
  102|  16.5M|  }
  103|  2.26k|  return counter;
  104|  2.26k|}
_ZN7simdutf6scalar5utf1623utf32_length_from_utf16ILNS_10endiannessE0EEEmPKDsm:
  108|    420|                                                   size_t len) {
  109|       |  // We are not BOM aware.
  110|    420|  size_t counter{0};
  111|  5.29M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (111:22): [True: 5.29M, False: 420]
  ------------------
  112|  5.29M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
  113|  5.29M|    counter += ((word & 0xFC00) != 0xDC00);
  114|  5.29M|  }
  115|    420|  return counter;
  116|    420|}
_ZN7simdutf6scalar5utf1623utf32_length_from_utf16ILNS_10endiannessE1EEEmPKDsm:
  108|    382|                                                   size_t len) {
  109|       |  // We are not BOM aware.
  110|    382|  size_t counter{0};
  111|  4.91M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (111:22): [True: 4.91M, False: 382]
  ------------------
  112|  4.91M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
  113|  4.91M|    counter += ((word & 0xFC00) != 0xDC00);
  114|  4.91M|  }
  115|    382|  return counter;
  116|    382|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf16_to_latin17convertILNS_10endiannessE0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEEmS8_mS9_:
   17|    266|                                   OutputPtr latin_output) {
   18|    266|  if (len == 0) {
  ------------------
  |  Branch (18:7): [True: 6, False: 260]
  ------------------
   19|      6|    return 0;
   20|      6|  }
   21|    260|  size_t pos = 0;
   22|    260|  const auto latin_output_start = latin_output;
   23|    260|  uint16_t word = 0;
   24|    260|  uint16_t too_large = 0;
   25|       |
   26|  4.20M|  while (pos < len) {
  ------------------
  |  Branch (26:10): [True: 4.20M, False: 260]
  ------------------
   27|  4.20M|    word = !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (27:12): [Folded, False: 4.20M]
  ------------------
   28|  4.20M|    too_large |= word;
   29|  4.20M|    *latin_output++ = char(word & 0xFF);
   30|  4.20M|    pos++;
   31|  4.20M|  }
   32|    260|  if ((too_large & 0xFF00) != 0) {
  ------------------
  |  Branch (32:7): [True: 150, False: 110]
  ------------------
   33|    150|    return 0;
   34|    150|  }
   35|       |
   36|    110|  return latin_output - latin_output_start;
   37|    260|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf16_to_latin17convertILNS_10endiannessE1EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEEmS8_mS9_:
   17|    202|                                   OutputPtr latin_output) {
   18|    202|  if (len == 0) {
  ------------------
  |  Branch (18:7): [True: 6, False: 196]
  ------------------
   19|      6|    return 0;
   20|      6|  }
   21|    196|  size_t pos = 0;
   22|    196|  const auto latin_output_start = latin_output;
   23|    196|  uint16_t word = 0;
   24|    196|  uint16_t too_large = 0;
   25|       |
   26|   617k|  while (pos < len) {
  ------------------
  |  Branch (26:10): [True: 617k, False: 196]
  ------------------
   27|   617k|    word = !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (27:12): [True: 617k, Folded]
  ------------------
   28|   617k|    too_large |= word;
   29|   617k|    *latin_output++ = char(word & 0xFF);
   30|   617k|    pos++;
   31|   617k|  }
   32|    196|  if ((too_large & 0xFF00) != 0) {
  ------------------
  |  Branch (32:7): [True: 104, False: 92]
  ------------------
   33|    104|    return 0;
   34|    104|  }
   35|       |
   36|     92|  return latin_output - latin_output_start;
   37|    196|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf16_to_latin119convert_with_errorsILNS_10endiannessE0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEENS_6resultES8_mS9_:
   45|    476|                                               OutputPtr latin_output) {
   46|    476|  if (len == 0) {
  ------------------
  |  Branch (46:7): [True: 4, False: 472]
  ------------------
   47|      4|    return result(error_code::SUCCESS, 0);
   48|      4|  }
   49|    472|  size_t pos = 0;
   50|    472|  auto start = latin_output;
   51|    472|  uint16_t word;
   52|       |
   53|   413k|  while (pos < len) {
  ------------------
  |  Branch (53:10): [True: 413k, False: 202]
  ------------------
   54|       |#if SIMDUTF_CPLUSPLUS23
   55|       |    if !consteval
   56|       |#endif
   57|   413k|    {
   58|   413k|      if (pos + 16 <= len) { // if it is safe to read 32 more bytes, check that
  ------------------
  |  Branch (58:11): [True: 411k, False: 1.68k]
  ------------------
   59|       |                             // they are Latin1
   60|   411k|        uint64_t v1, v2, v3, v4;
   61|   411k|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   62|   411k|        ::memcpy(&v2, data + pos + 4, sizeof(uint64_t));
   63|   411k|        ::memcpy(&v3, data + pos + 8, sizeof(uint64_t));
   64|   411k|        ::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|   411k|        if (((v1 | v2 | v3 | v4) & 0xFF00FF00FF00FF00) == 0) {
  ------------------
  |  Branch (79:13): [True: 411k, False: 346]
  ------------------
   80|   411k|          size_t final_pos = pos + 16;
   81|  6.99M|          while (pos < final_pos) {
  ------------------
  |  Branch (81:18): [True: 6.58M, False: 411k]
  ------------------
   82|  6.58M|            *latin_output++ = !match_system(big_endian)
  ------------------
  |  Branch (82:31): [Folded, False: 6.58M]
  ------------------
   83|  6.58M|                                  ? char(u16_swap_bytes(data[pos]))
   84|  6.58M|                                  : char(data[pos]);
   85|  6.58M|            pos++;
   86|  6.58M|          }
   87|   411k|          continue;
   88|   411k|        }
   89|   411k|      }
   90|   413k|    }
   91|       |
   92|  2.02k|    word = !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (92:12): [Folded, False: 2.02k]
  ------------------
   93|  2.02k|    if ((word & 0xFF00) == 0) {
  ------------------
  |  Branch (93:9): [True: 1.75k, False: 270]
  ------------------
   94|  1.75k|      *latin_output++ = char(word & 0xFF);
   95|  1.75k|      pos++;
   96|  1.75k|    } else {
   97|    270|      return result(error_code::TOO_LARGE, pos);
   98|    270|    }
   99|  2.02k|  }
  100|    202|  return result(error_code::SUCCESS, latin_output - start);
  101|    472|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf16_to_latin119convert_with_errorsILNS_10endiannessE1EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEENS_6resultES8_mS9_:
   45|    432|                                               OutputPtr latin_output) {
   46|    432|  if (len == 0) {
  ------------------
  |  Branch (46:7): [True: 4, False: 428]
  ------------------
   47|      4|    return result(error_code::SUCCESS, 0);
   48|      4|  }
   49|    428|  size_t pos = 0;
   50|    428|  auto start = latin_output;
   51|    428|  uint16_t word;
   52|       |
   53|   465k|  while (pos < len) {
  ------------------
  |  Branch (53:10): [True: 465k, False: 182]
  ------------------
   54|       |#if SIMDUTF_CPLUSPLUS23
   55|       |    if !consteval
   56|       |#endif
   57|   465k|    {
   58|   465k|      if (pos + 16 <= len) { // if it is safe to read 32 more bytes, check that
  ------------------
  |  Branch (58:11): [True: 463k, False: 1.37k]
  ------------------
   59|       |                             // they are Latin1
   60|   463k|        uint64_t v1, v2, v3, v4;
   61|   463k|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   62|   463k|        ::memcpy(&v2, data + pos + 4, sizeof(uint64_t));
   63|   463k|        ::memcpy(&v3, data + pos + 8, sizeof(uint64_t));
   64|   463k|        ::memcpy(&v4, data + pos + 12, sizeof(uint64_t));
   65|       |
   66|   463k|        if constexpr (!match_system(big_endian)) {
   67|   463k|          v1 = (v1 >> 8) | (v1 << (64 - 8));
   68|   463k|        }
   69|   463k|        if constexpr (!match_system(big_endian)) {
   70|   463k|          v2 = (v2 >> 8) | (v2 << (64 - 8));
   71|   463k|        }
   72|   463k|        if constexpr (!match_system(big_endian)) {
   73|   463k|          v3 = (v3 >> 8) | (v3 << (64 - 8));
   74|   463k|        }
   75|   463k|        if constexpr (!match_system(big_endian)) {
   76|   463k|          v4 = (v4 >> 8) | (v4 << (64 - 8));
   77|   463k|        }
   78|       |
   79|   463k|        if (((v1 | v2 | v3 | v4) & 0xFF00FF00FF00FF00) == 0) {
  ------------------
  |  Branch (79:13): [True: 463k, False: 390]
  ------------------
   80|   463k|          size_t final_pos = pos + 16;
   81|  7.87M|          while (pos < final_pos) {
  ------------------
  |  Branch (81:18): [True: 7.41M, False: 463k]
  ------------------
   82|  7.41M|            *latin_output++ = !match_system(big_endian)
  ------------------
  |  Branch (82:31): [True: 7.41M, Folded]
  ------------------
   83|  7.41M|                                  ? char(u16_swap_bytes(data[pos]))
   84|  7.41M|                                  : char(data[pos]);
   85|  7.41M|            pos++;
   86|  7.41M|          }
   87|   463k|          continue;
   88|   463k|        }
   89|   463k|      }
   90|   465k|    }
   91|       |
   92|  1.76k|    word = !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (92:12): [True: 1.76k, Folded]
  ------------------
   93|  1.76k|    if ((word & 0xFF00) == 0) {
  ------------------
  |  Branch (93:9): [True: 1.51k, False: 246]
  ------------------
   94|  1.51k|      *latin_output++ = char(word & 0xFF);
   95|  1.51k|      pos++;
   96|  1.51k|    } else {
   97|    246|      return result(error_code::TOO_LARGE, pos);
   98|    246|    }
   99|  1.76k|  }
  100|    182|  return result(error_code::SUCCESS, latin_output - start);
  101|    428|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf327convertILNS_10endiannessE0EEEmPKDsmPDi:
   11|    774|                                   char32_t *utf32_output) {
   12|    774|  size_t pos = 0;
   13|    774|  char32_t *start{utf32_output};
   14|  1.23M|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 1.23M, False: 476]
  ------------------
   15|  1.23M|    uint16_t word =
   16|  1.23M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (16:9): [Folded, False: 1.23M]
  ------------------
   17|  1.23M|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (17:9): [True: 1.22M, False: 2.94k]
  ------------------
   18|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   19|  1.22M|      *utf32_output++ = char32_t(word);
   20|  1.22M|      pos++;
   21|  1.22M|    } else {
   22|       |      // must be a surrogate pair
   23|  2.94k|      uint16_t diff = uint16_t(word - 0xD800);
   24|  2.94k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (24:11): [True: 112, False: 2.82k]
  ------------------
   25|    112|        return 0;
   26|    112|      }
   27|  2.82k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 78, False: 2.75k]
  ------------------
   28|     78|        return 0;
   29|     78|      } // minimal bound checking
   30|  2.75k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (30:28): [Folded, False: 2.75k]
  ------------------
   31|  2.75k|                               ? u16_swap_bytes(data[pos + 1])
   32|  2.75k|                               : data[pos + 1];
   33|  2.75k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   34|  2.75k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (34:11): [True: 108, False: 2.64k]
  ------------------
   35|    108|        return 0;
   36|    108|      }
   37|  2.64k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   38|  2.64k|      *utf32_output++ = char32_t(value);
   39|  2.64k|      pos += 2;
   40|  2.64k|    }
   41|  1.23M|  }
   42|    476|  return utf32_output - start;
   43|    774|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf327convertILNS_10endiannessE1EEEmPKDsmPDi:
   11|    762|                                   char32_t *utf32_output) {
   12|    762|  size_t pos = 0;
   13|    762|  char32_t *start{utf32_output};
   14|  1.20M|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 1.20M, False: 474]
  ------------------
   15|  1.20M|    uint16_t word =
   16|  1.20M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (16:9): [True: 1.20M, Folded]
  ------------------
   17|  1.20M|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (17:9): [True: 1.20M, False: 1.57k]
  ------------------
   18|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   19|  1.20M|      *utf32_output++ = char32_t(word);
   20|  1.20M|      pos++;
   21|  1.20M|    } else {
   22|       |      // must be a surrogate pair
   23|  1.57k|      uint16_t diff = uint16_t(word - 0xD800);
   24|  1.57k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (24:11): [True: 84, False: 1.49k]
  ------------------
   25|     84|        return 0;
   26|     84|      }
   27|  1.49k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 108, False: 1.38k]
  ------------------
   28|    108|        return 0;
   29|    108|      } // minimal bound checking
   30|  1.38k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (30:28): [True: 1.38k, Folded]
  ------------------
   31|  1.38k|                               ? u16_swap_bytes(data[pos + 1])
   32|  1.38k|                               : data[pos + 1];
   33|  1.38k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   34|  1.38k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (34:11): [True: 96, False: 1.28k]
  ------------------
   35|     96|        return 0;
   36|     96|      }
   37|  1.28k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   38|  1.28k|      *utf32_output++ = char32_t(value);
   39|  1.28k|      pos += 2;
   40|  1.28k|    }
   41|  1.20M|  }
   42|    474|  return utf32_output - start;
   43|    762|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf3219convert_with_errorsILNS_10endiannessE0EEENS_6resultEPKDsmPDi:
   47|    858|                                               char32_t *utf32_output) {
   48|    858|  size_t pos = 0;
   49|    858|  char32_t *start{utf32_output};
   50|  4.29M|  while (pos < len) {
  ------------------
  |  Branch (50:10): [True: 4.29M, False: 464]
  ------------------
   51|  4.29M|    uint16_t word =
   52|  4.29M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (52:9): [Folded, False: 4.29M]
  ------------------
   53|  4.29M|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (53:9): [True: 4.27M, False: 15.1k]
  ------------------
   54|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   55|  4.27M|      *utf32_output++ = char32_t(word);
   56|  4.27M|      pos++;
   57|  4.27M|    } else {
   58|       |      // must be a surrogate pair
   59|  15.1k|      uint16_t diff = uint16_t(word - 0xD800);
   60|  15.1k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (60:11): [True: 122, False: 15.0k]
  ------------------
   61|    122|        return result(error_code::SURROGATE, pos);
   62|    122|      }
   63|  15.0k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (63:11): [True: 96, False: 14.9k]
  ------------------
   64|     96|        return result(error_code::SURROGATE, pos);
   65|     96|      } // minimal bound checking
   66|  14.9k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (66:28): [Folded, False: 14.9k]
  ------------------
   67|  14.9k|                               ? u16_swap_bytes(data[pos + 1])
   68|  14.9k|                               : data[pos + 1];
   69|  14.9k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   70|  14.9k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (70:11): [True: 176, False: 14.7k]
  ------------------
   71|    176|        return result(error_code::SURROGATE, pos);
   72|    176|      }
   73|  14.7k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   74|  14.7k|      *utf32_output++ = char32_t(value);
   75|  14.7k|      pos += 2;
   76|  14.7k|    }
   77|  4.29M|  }
   78|    464|  return result(error_code::SUCCESS, utf32_output - start);
   79|    858|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf3219convert_with_errorsILNS_10endiannessE1EEENS_6resultEPKDsmPDi:
   47|    780|                                               char32_t *utf32_output) {
   48|    780|  size_t pos = 0;
   49|    780|  char32_t *start{utf32_output};
   50|  2.52M|  while (pos < len) {
  ------------------
  |  Branch (50:10): [True: 2.52M, False: 424]
  ------------------
   51|  2.52M|    uint16_t word =
   52|  2.52M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (52:9): [True: 2.52M, Folded]
  ------------------
   53|  2.52M|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (53:9): [True: 2.51M, False: 10.8k]
  ------------------
   54|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   55|  2.51M|      *utf32_output++ = char32_t(word);
   56|  2.51M|      pos++;
   57|  2.51M|    } else {
   58|       |      // must be a surrogate pair
   59|  10.8k|      uint16_t diff = uint16_t(word - 0xD800);
   60|  10.8k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (60:11): [True: 106, False: 10.7k]
  ------------------
   61|    106|        return result(error_code::SURROGATE, pos);
   62|    106|      }
   63|  10.7k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (63:11): [True: 96, False: 10.6k]
  ------------------
   64|     96|        return result(error_code::SURROGATE, pos);
   65|     96|      } // minimal bound checking
   66|  10.6k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (66:28): [True: 10.6k, Folded]
  ------------------
   67|  10.6k|                               ? u16_swap_bytes(data[pos + 1])
   68|  10.6k|                               : data[pos + 1];
   69|  10.6k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   70|  10.6k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (70:11): [True: 154, False: 10.4k]
  ------------------
   71|    154|        return result(error_code::SURROGATE, pos);
   72|    154|      }
   73|  10.4k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   74|  10.4k|      *utf32_output++ = char32_t(value);
   75|  10.4k|      pos += 2;
   76|  10.4k|    }
   77|  2.52M|  }
   78|    424|  return result(error_code::SUCCESS, utf32_output - start);
   79|    780|}

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

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf87convertILNS_10endiannessE0EPKDsPcQsr7simdutf6detailE18indexes_into_utf16IT0_EEEmS8_mT1_:
   17|  1.86k|                                   OutputPtr utf8_output) {
   18|  1.86k|  size_t pos = 0;
   19|  1.86k|  const auto start = utf8_output;
   20|  4.80M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 4.80M, False: 1.50k]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  4.80M|    {
   25|       |      // try to convert the next block of 8 bytes
   26|  4.80M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (26:11): [True: 4.80M, False: 3.41k]
  ------------------
   27|       |                            // they are ascii
   28|  4.80M|        uint64_t v;
   29|  4.80M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   30|       |        if constexpr (!match_system(big_endian)) {
   31|       |          v = (v >> 8) | (v << (64 - 8));
   32|       |        }
   33|  4.80M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (33:13): [True: 1.27M, False: 3.52M]
  ------------------
   34|  1.27M|          size_t final_pos = pos + 4;
   35|  6.39M|          while (pos < final_pos) {
  ------------------
  |  Branch (35:18): [True: 5.11M, False: 1.27M]
  ------------------
   36|  5.11M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (36:30): [Folded, False: 5.11M]
  ------------------
   37|  5.11M|                                 ? char(u16_swap_bytes(data[pos]))
   38|  5.11M|                                 : char(data[pos]);
   39|  5.11M|            pos++;
   40|  5.11M|          }
   41|  1.27M|          continue;
   42|  1.27M|        }
   43|  4.80M|      }
   44|  4.80M|    }
   45|  3.52M|    uint16_t word =
   46|  3.52M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (46:9): [Folded, False: 3.52M]
  ------------------
   47|  3.52M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (47:9): [True: 122k, False: 3.40M]
  ------------------
   48|       |      // will generate one UTF-8 bytes
   49|   122k|      *utf8_output++ = char(word);
   50|   122k|      pos++;
   51|  3.40M|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (51:16): [True: 3.20M, False: 204k]
  ------------------
   52|       |      // will generate two UTF-8 bytes
   53|       |      // we have 0b110XXXXX 0b10XXXXXX
   54|  3.20M|      *utf8_output++ = char((word >> 6) | 0b11000000);
   55|  3.20M|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   56|  3.20M|      pos++;
   57|  3.20M|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (57:16): [True: 199k, False: 5.12k]
  ------------------
   58|       |      // will generate three UTF-8 bytes
   59|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   60|   199k|      *utf8_output++ = char((word >> 12) | 0b11100000);
   61|   199k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   62|   199k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   63|   199k|      pos++;
   64|   199k|    } else {
   65|       |      // must be a surrogate pair
   66|  5.12k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (66:11): [True: 54, False: 5.06k]
  ------------------
   67|     54|        return 0;
   68|     54|      }
   69|  5.06k|      uint16_t diff = uint16_t(word - 0xD800);
   70|  5.06k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (70:11): [True: 150, False: 4.91k]
  ------------------
   71|    150|        return 0;
   72|    150|      }
   73|  4.91k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (73:28): [Folded, False: 4.91k]
  ------------------
   74|  4.91k|                               ? u16_swap_bytes(data[pos + 1])
   75|  4.91k|                               : data[pos + 1];
   76|  4.91k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   77|  4.91k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (77:11): [True: 154, False: 4.76k]
  ------------------
   78|    154|        return 0;
   79|    154|      }
   80|  4.76k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   81|       |      // will generate four UTF-8 bytes
   82|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   83|  4.76k|      *utf8_output++ = char((value >> 18) | 0b11110000);
   84|  4.76k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
   85|  4.76k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
   86|  4.76k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
   87|  4.76k|      pos += 2;
   88|  4.76k|    }
   89|  3.52M|  }
   90|  1.50k|  return utf8_output - start;
   91|  1.86k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf87convertILNS_10endiannessE1EPKDsPcQsr7simdutf6detailE18indexes_into_utf16IT0_EEEmS8_mT1_:
   17|  1.64k|                                   OutputPtr utf8_output) {
   18|  1.64k|  size_t pos = 0;
   19|  1.64k|  const auto start = utf8_output;
   20|  3.57M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 3.57M, False: 1.37k]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  3.57M|    {
   25|       |      // try to convert the next block of 8 bytes
   26|  3.57M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (26:11): [True: 3.56M, False: 2.91k]
  ------------------
   27|       |                            // they are ascii
   28|  3.56M|        uint64_t v;
   29|  3.56M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   30|  3.56M|        if constexpr (!match_system(big_endian)) {
   31|  3.56M|          v = (v >> 8) | (v << (64 - 8));
   32|  3.56M|        }
   33|  3.56M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (33:13): [True: 1.37M, False: 2.19M]
  ------------------
   34|  1.37M|          size_t final_pos = pos + 4;
   35|  6.85M|          while (pos < final_pos) {
  ------------------
  |  Branch (35:18): [True: 5.48M, False: 1.37M]
  ------------------
   36|  5.48M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (36:30): [True: 5.48M, Folded]
  ------------------
   37|  5.48M|                                 ? char(u16_swap_bytes(data[pos]))
   38|  5.48M|                                 : char(data[pos]);
   39|  5.48M|            pos++;
   40|  5.48M|          }
   41|  1.37M|          continue;
   42|  1.37M|        }
   43|  3.56M|      }
   44|  3.57M|    }
   45|  2.20M|    uint16_t word =
   46|  2.20M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (46:9): [True: 2.20M, Folded]
  ------------------
   47|  2.20M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (47:9): [True: 116k, False: 2.08M]
  ------------------
   48|       |      // will generate one UTF-8 bytes
   49|   116k|      *utf8_output++ = char(word);
   50|   116k|      pos++;
   51|  2.08M|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (51:16): [True: 36.6k, False: 2.04M]
  ------------------
   52|       |      // will generate two UTF-8 bytes
   53|       |      // we have 0b110XXXXX 0b10XXXXXX
   54|  36.6k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   55|  36.6k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   56|  36.6k|      pos++;
   57|  2.04M|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (57:16): [True: 2.04M, False: 3.98k]
  ------------------
   58|       |      // will generate three UTF-8 bytes
   59|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   60|  2.04M|      *utf8_output++ = char((word >> 12) | 0b11100000);
   61|  2.04M|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   62|  2.04M|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   63|  2.04M|      pos++;
   64|  2.04M|    } else {
   65|       |      // must be a surrogate pair
   66|  3.98k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (66:11): [True: 30, False: 3.95k]
  ------------------
   67|     30|        return 0;
   68|     30|      }
   69|  3.95k|      uint16_t diff = uint16_t(word - 0xD800);
   70|  3.95k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (70:11): [True: 126, False: 3.83k]
  ------------------
   71|    126|        return 0;
   72|    126|      }
   73|  3.83k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (73:28): [True: 3.83k, Folded]
  ------------------
   74|  3.83k|                               ? u16_swap_bytes(data[pos + 1])
   75|  3.83k|                               : data[pos + 1];
   76|  3.83k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   77|  3.83k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (77:11): [True: 114, False: 3.71k]
  ------------------
   78|    114|        return 0;
   79|    114|      }
   80|  3.71k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   81|       |      // will generate four UTF-8 bytes
   82|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   83|  3.71k|      *utf8_output++ = char((value >> 18) | 0b11110000);
   84|  3.71k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
   85|  3.71k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
   86|  3.71k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
   87|  3.71k|      pos += 2;
   88|  3.71k|    }
   89|  2.20M|  }
   90|  1.37k|  return utf8_output - start;
   91|  1.64k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf819convert_with_errorsILNS_10endiannessE0ELb0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT1_Esr7simdutf6detailE26index_assignable_from_charIT2_EEENS_11full_resultES8_mS9_m:
  101|  1.67k|                                                    size_t utf8_len = 0) {
  102|  1.67k|  if (check_output && utf8_len == 0) {
  ------------------
  |  Branch (102:7): [Folded, False: 1.67k]
  |  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.67k|  size_t pos = 0;
  107|  1.67k|  auto start = utf8_output;
  108|  1.67k|  auto end = utf8_output + utf8_len;
  109|       |
  110|  5.47M|  while (pos < len) {
  ------------------
  |  Branch (110:10): [True: 5.47M, False: 1.17k]
  ------------------
  111|       |#if SIMDUTF_CPLUSPLUS23
  112|       |    if !consteval
  113|       |#endif
  114|  5.47M|    {
  115|       |      // try to convert the next block of 8 bytes
  116|  5.47M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (116:11): [True: 5.47M, False: 2.69k]
  ------------------
  117|       |                            // they are ascii
  118|  5.47M|        uint64_t v;
  119|  5.47M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
  120|       |        if constexpr (!match_system(big_endian))
  121|       |          v = (v >> 8) | (v << (64 - 8));
  122|  5.47M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (122:13): [True: 1.11M, False: 4.36M]
  ------------------
  123|  1.11M|          size_t final_pos = pos + 4;
  124|  5.57M|          while (pos < final_pos) {
  ------------------
  |  Branch (124:18): [True: 4.46M, False: 1.11M]
  ------------------
  125|  4.46M|            if (check_output && size_t(end - utf8_output) < 1) {
  ------------------
  |  Branch (125:17): [Folded, False: 4.46M]
  |  Branch (125:33): [True: 0, False: 0]
  ------------------
  126|      0|              return full_result(error_code::OUTPUT_BUFFER_TOO_SMALL, pos,
  127|      0|                                 utf8_output - start);
  128|      0|            }
  129|  4.46M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (129:30): [Folded, False: 4.46M]
  ------------------
  130|  4.46M|                                 ? char(u16_swap_bytes(data[pos]))
  131|  4.46M|                                 : char(data[pos]);
  132|  4.46M|            pos++;
  133|  4.46M|          }
  134|  1.11M|          continue;
  135|  1.11M|        }
  136|  5.47M|      }
  137|  5.47M|    }
  138|       |
  139|  4.36M|    uint16_t word =
  140|  4.36M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (140:9): [Folded, False: 4.36M]
  ------------------
  141|  4.36M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (141:9): [True: 209k, False: 4.15M]
  ------------------
  142|       |      // will generate one UTF-8 bytes
  143|   209k|      if (check_output && size_t(end - utf8_output) < 1) {
  ------------------
  |  Branch (143:11): [Folded, False: 209k]
  |  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|   209k|      *utf8_output++ = char(word);
  148|   209k|      pos++;
  149|  4.15M|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (149:16): [True: 1.38M, False: 2.77M]
  ------------------
  150|       |      // will generate two UTF-8 bytes
  151|       |      // we have 0b110XXXXX 0b10XXXXXX
  152|  1.38M|      if (check_output && size_t(end - utf8_output) < 2) {
  ------------------
  |  Branch (152:11): [Folded, False: 1.38M]
  |  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.38M|      *utf8_output++ = char((word >> 6) | 0b11000000);
  157|  1.38M|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  158|  1.38M|      pos++;
  159|       |
  160|  2.77M|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (160:16): [True: 2.76M, False: 3.21k]
  ------------------
  161|       |      // will generate three UTF-8 bytes
  162|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
  163|  2.76M|      if (check_output && size_t(end - utf8_output) < 3) {
  ------------------
  |  Branch (163:11): [Folded, False: 2.76M]
  |  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.76M|      *utf8_output++ = char((word >> 12) | 0b11100000);
  168|  2.76M|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  169|  2.76M|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  170|  2.76M|      pos++;
  171|  2.76M|    } else {
  172|       |
  173|  3.21k|      if (check_output && size_t(end - utf8_output) < 4) {
  ------------------
  |  Branch (173:11): [Folded, False: 3.21k]
  |  Branch (173:27): [True: 0, False: 0]
  ------------------
  174|      0|        return full_result(error_code::OUTPUT_BUFFER_TOO_SMALL, pos,
  175|      0|                           utf8_output - start);
  176|      0|      }
  177|       |      // must be a surrogate pair
  178|  3.21k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (178:11): [True: 60, False: 3.15k]
  ------------------
  179|     60|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  180|     60|      }
  181|  3.15k|      uint16_t diff = uint16_t(word - 0xD800);
  182|  3.15k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (182:11): [True: 162, False: 2.98k]
  ------------------
  183|    162|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  184|    162|      }
  185|  2.98k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (185:28): [Folded, False: 2.98k]
  ------------------
  186|  2.98k|                               ? u16_swap_bytes(data[pos + 1])
  187|  2.98k|                               : data[pos + 1];
  188|  2.98k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
  189|  2.98k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (189:11): [True: 274, False: 2.71k]
  ------------------
  190|    274|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  191|    274|      }
  192|  2.71k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
  193|       |      // will generate four UTF-8 bytes
  194|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
  195|  2.71k|      *utf8_output++ = char((value >> 18) | 0b11110000);
  196|  2.71k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  197|  2.71k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  198|  2.71k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
  199|  2.71k|      pos += 2;
  200|  2.71k|    }
  201|  4.36M|  }
  202|  1.17k|  return full_result(error_code::SUCCESS, pos, utf8_output - start);
  203|  1.67k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf819convert_with_errorsILNS_10endiannessE1ELb0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT1_Esr7simdutf6detailE26index_assignable_from_charIT2_EEENS_11full_resultES8_mS9_m:
  101|  1.80k|                                                    size_t utf8_len = 0) {
  102|  1.80k|  if (check_output && utf8_len == 0) {
  ------------------
  |  Branch (102:7): [Folded, False: 1.80k]
  |  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.80k|  size_t pos = 0;
  107|  1.80k|  auto start = utf8_output;
  108|  1.80k|  auto end = utf8_output + utf8_len;
  109|       |
  110|  4.39M|  while (pos < len) {
  ------------------
  |  Branch (110:10): [True: 4.39M, False: 1.25k]
  ------------------
  111|       |#if SIMDUTF_CPLUSPLUS23
  112|       |    if !consteval
  113|       |#endif
  114|  4.39M|    {
  115|       |      // try to convert the next block of 8 bytes
  116|  4.39M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (116:11): [True: 4.39M, False: 2.79k]
  ------------------
  117|       |                            // they are ascii
  118|  4.39M|        uint64_t v;
  119|  4.39M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
  120|       |        if constexpr (!match_system(big_endian))
  121|  4.39M|          v = (v >> 8) | (v << (64 - 8));
  122|  4.39M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (122:13): [True: 2.21M, False: 2.18M]
  ------------------
  123|  2.21M|          size_t final_pos = pos + 4;
  124|  11.0M|          while (pos < final_pos) {
  ------------------
  |  Branch (124:18): [True: 8.84M, False: 2.21M]
  ------------------
  125|  8.84M|            if (check_output && size_t(end - utf8_output) < 1) {
  ------------------
  |  Branch (125:17): [Folded, False: 8.84M]
  |  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|  8.84M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (129:30): [True: 8.84M, Folded]
  ------------------
  130|  8.84M|                                 ? char(u16_swap_bytes(data[pos]))
  131|  8.84M|                                 : char(data[pos]);
  132|  8.84M|            pos++;
  133|  8.84M|          }
  134|  2.21M|          continue;
  135|  2.21M|        }
  136|  4.39M|      }
  137|  4.39M|    }
  138|       |
  139|  2.18M|    uint16_t word =
  140|  2.18M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (140:9): [True: 2.18M, Folded]
  ------------------
  141|  2.18M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (141:9): [True: 749k, False: 1.43M]
  ------------------
  142|       |      // will generate one UTF-8 bytes
  143|   749k|      if (check_output && size_t(end - utf8_output) < 1) {
  ------------------
  |  Branch (143:11): [Folded, False: 749k]
  |  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|   749k|      *utf8_output++ = char(word);
  148|   749k|      pos++;
  149|  1.43M|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (149:16): [True: 317k, False: 1.11M]
  ------------------
  150|       |      // will generate two UTF-8 bytes
  151|       |      // we have 0b110XXXXX 0b10XXXXXX
  152|   317k|      if (check_output && size_t(end - utf8_output) < 2) {
  ------------------
  |  Branch (152:11): [Folded, False: 317k]
  |  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|   317k|      *utf8_output++ = char((word >> 6) | 0b11000000);
  157|   317k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  158|   317k|      pos++;
  159|       |
  160|  1.11M|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (160:16): [True: 1.09M, False: 26.5k]
  ------------------
  161|       |      // will generate three UTF-8 bytes
  162|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
  163|  1.09M|      if (check_output && size_t(end - utf8_output) < 3) {
  ------------------
  |  Branch (163:11): [Folded, False: 1.09M]
  |  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|  1.09M|      *utf8_output++ = char((word >> 12) | 0b11100000);
  168|  1.09M|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  169|  1.09M|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  170|  1.09M|      pos++;
  171|  1.09M|    } else {
  172|       |
  173|  26.5k|      if (check_output && size_t(end - utf8_output) < 4) {
  ------------------
  |  Branch (173:11): [Folded, False: 26.5k]
  |  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|  26.5k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (178:11): [True: 72, False: 26.4k]
  ------------------
  179|     72|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  180|     72|      }
  181|  26.4k|      uint16_t diff = uint16_t(word - 0xD800);
  182|  26.4k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (182:11): [True: 172, False: 26.2k]
  ------------------
  183|    172|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  184|    172|      }
  185|  26.2k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (185:28): [True: 26.2k, Folded]
  ------------------
  186|  26.2k|                               ? u16_swap_bytes(data[pos + 1])
  187|  26.2k|                               : data[pos + 1];
  188|  26.2k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
  189|  26.2k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (189:11): [True: 300, False: 25.9k]
  ------------------
  190|    300|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  191|    300|      }
  192|  25.9k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
  193|       |      // will generate four UTF-8 bytes
  194|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
  195|  25.9k|      *utf8_output++ = char((value >> 18) | 0b11110000);
  196|  25.9k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  197|  25.9k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  198|  25.9k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
  199|  25.9k|      pos += 2;
  200|  25.9k|    }
  201|  2.18M|  }
  202|  1.25k|  return full_result(error_code::SUCCESS, pos, utf8_output - start);
  203|  1.80k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf813convert_validILNS_10endiannessE0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEEmS8_mS9_:
   17|    440|                                         OutputPtr utf8_output) {
   18|    440|  size_t pos = 0;
   19|    440|  auto start = utf8_output;
   20|  2.66M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 2.66M, False: 440]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  2.66M|    {
   25|       |      // try to convert the next block of 4 ASCII characters
   26|  2.66M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (26:11): [True: 2.65M, False: 938]
  ------------------
   27|       |                            // they are ascii
   28|  2.65M|        uint64_t v;
   29|  2.65M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   30|       |        if constexpr (!match_system(big_endian)) {
   31|       |          v = (v >> 8) | (v << (64 - 8));
   32|       |        }
   33|  2.65M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (33:13): [True: 1.63M, False: 1.02M]
  ------------------
   34|  1.63M|          size_t final_pos = pos + 4;
   35|  8.17M|          while (pos < final_pos) {
  ------------------
  |  Branch (35:18): [True: 6.54M, False: 1.63M]
  ------------------
   36|  6.54M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (36:30): [Folded, False: 6.54M]
  ------------------
   37|  6.54M|                                 ? char(u16_swap_bytes(data[pos]))
   38|  6.54M|                                 : char(data[pos]);
   39|  6.54M|            pos++;
   40|  6.54M|          }
   41|  1.63M|          continue;
   42|  1.63M|        }
   43|  2.65M|      }
   44|  2.66M|    }
   45|       |
   46|  1.02M|    uint16_t word =
   47|  1.02M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (47:9): [Folded, False: 1.02M]
  ------------------
   48|  1.02M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (48:9): [True: 429k, False: 594k]
  ------------------
   49|       |      // will generate one UTF-8 bytes
   50|   429k|      *utf8_output++ = char(word);
   51|   429k|      pos++;
   52|   594k|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (52:16): [True: 224k, False: 370k]
  ------------------
   53|       |      // will generate two UTF-8 bytes
   54|       |      // we have 0b110XXXXX 0b10XXXXXX
   55|   224k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   56|   224k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   57|   224k|      pos++;
   58|   370k|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (58:16): [True: 363k, False: 6.83k]
  ------------------
   59|       |      // will generate three UTF-8 bytes
   60|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   61|   363k|      *utf8_output++ = char((word >> 12) | 0b11100000);
   62|   363k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   63|   363k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   64|   363k|      pos++;
   65|   363k|    } else {
   66|       |      // must be a surrogate pair
   67|  6.83k|      uint16_t diff = uint16_t(word - 0xD800);
   68|  6.83k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (68:11): [True: 0, False: 6.83k]
  ------------------
   69|      0|        return 0;
   70|      0|      } // minimal bound checking
   71|  6.83k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (71:28): [Folded, False: 6.83k]
  ------------------
   72|  6.83k|                               ? u16_swap_bytes(data[pos + 1])
   73|  6.83k|                               : data[pos + 1];
   74|  6.83k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   75|  6.83k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   76|       |      // will generate four UTF-8 bytes
   77|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   78|  6.83k|      *utf8_output++ = char((value >> 18) | 0b11110000);
   79|  6.83k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
   80|  6.83k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
   81|  6.83k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
   82|  6.83k|      pos += 2;
   83|  6.83k|    }
   84|  1.02M|  }
   85|    440|  return utf8_output - start;
   86|    440|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf813convert_validILNS_10endiannessE1EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEEmS8_mS9_:
   17|    398|                                         OutputPtr utf8_output) {
   18|    398|  size_t pos = 0;
   19|    398|  auto start = utf8_output;
   20|  2.40M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 2.40M, False: 398]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  2.40M|    {
   25|       |      // try to convert the next block of 4 ASCII characters
   26|  2.40M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (26:11): [True: 2.40M, False: 774]
  ------------------
   27|       |                            // they are ascii
   28|  2.40M|        uint64_t v;
   29|  2.40M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   30|  2.40M|        if constexpr (!match_system(big_endian)) {
   31|  2.40M|          v = (v >> 8) | (v << (64 - 8));
   32|  2.40M|        }
   33|  2.40M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (33:13): [True: 1.55M, False: 851k]
  ------------------
   34|  1.55M|          size_t final_pos = pos + 4;
   35|  7.75M|          while (pos < final_pos) {
  ------------------
  |  Branch (35:18): [True: 6.20M, False: 1.55M]
  ------------------
   36|  6.20M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (36:30): [True: 6.20M, Folded]
  ------------------
   37|  6.20M|                                 ? char(u16_swap_bytes(data[pos]))
   38|  6.20M|                                 : char(data[pos]);
   39|  6.20M|            pos++;
   40|  6.20M|          }
   41|  1.55M|          continue;
   42|  1.55M|        }
   43|  2.40M|      }
   44|  2.40M|    }
   45|       |
   46|   852k|    uint16_t word =
   47|   852k|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (47:9): [True: 852k, Folded]
  ------------------
   48|   852k|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (48:9): [True: 241k, False: 610k]
  ------------------
   49|       |      // will generate one UTF-8 bytes
   50|   241k|      *utf8_output++ = char(word);
   51|   241k|      pos++;
   52|   610k|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (52:16): [True: 72.5k, False: 537k]
  ------------------
   53|       |      // will generate two UTF-8 bytes
   54|       |      // we have 0b110XXXXX 0b10XXXXXX
   55|  72.5k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   56|  72.5k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   57|  72.5k|      pos++;
   58|   537k|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (58:16): [True: 535k, False: 1.98k]
  ------------------
   59|       |      // will generate three UTF-8 bytes
   60|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   61|   535k|      *utf8_output++ = char((word >> 12) | 0b11100000);
   62|   535k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   63|   535k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   64|   535k|      pos++;
   65|   535k|    } else {
   66|       |      // must be a surrogate pair
   67|  1.98k|      uint16_t diff = uint16_t(word - 0xD800);
   68|  1.98k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (68:11): [True: 0, False: 1.98k]
  ------------------
   69|      0|        return 0;
   70|      0|      } // minimal bound checking
   71|  1.98k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (71:28): [True: 1.98k, Folded]
  ------------------
   72|  1.98k|                               ? u16_swap_bytes(data[pos + 1])
   73|  1.98k|                               : data[pos + 1];
   74|  1.98k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   75|  1.98k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   76|       |      // will generate four UTF-8 bytes
   77|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   78|  1.98k|      *utf8_output++ = char((value >> 18) | 0b11110000);
   79|  1.98k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
   80|  1.98k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
   81|  1.98k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
   82|  1.98k|      pos += 2;
   83|  1.98k|    }
   84|   852k|  }
   85|    398|  return utf8_output - start;
   86|    398|}

_ZN7simdutf6scalar5utf328validateEPKDim:
   25|  5.68k|                                                        size_t len) noexcept {
   26|  5.68k|  return validate(reinterpret_cast<const uint32_t *>(buf), len);
   27|  5.68k|}
_ZN7simdutf6scalar5utf3220validate_with_errorsEPKDim:
   49|  7.78k|validate_with_errors(const char32_t *buf, size_t len) noexcept {
   50|  7.78k|  return validate_with_errors(reinterpret_cast<const uint32_t *>(buf), len);
   51|  7.78k|}
_ZN7simdutf6scalar5utf3222utf8_length_from_utf32EPKDim:
   54|  2.81k|                                                         size_t len) {
   55|       |  // We are not BOM aware.
   56|  2.81k|  size_t counter{0};
   57|  2.41M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (57:22): [True: 2.41M, False: 2.81k]
  ------------------
   58|       |    // credit: @ttsugriy  for the vectorizable approach
   59|  2.41M|    counter++;                                     // ASCII
   60|  2.41M|    counter += static_cast<size_t>(p[i] > 0x7F);   // two-byte
   61|  2.41M|    counter += static_cast<size_t>(p[i] > 0x7FF);  // three-byte
   62|  2.41M|    counter += static_cast<size_t>(p[i] > 0xFFFF); // four-bytes
   63|  2.41M|  }
   64|  2.81k|  return counter;
   65|  2.81k|}
_ZN7simdutf6scalar5utf3223utf16_length_from_utf32EPKDim:
   68|  4.15k|utf16_length_from_utf32(const char32_t *p, size_t len) {
   69|       |  // We are not BOM aware.
   70|  4.15k|  size_t counter{0};
   71|  6.11M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (71:22): [True: 6.11M, False: 4.15k]
  ------------------
   72|  6.11M|    counter++;                                     // non-surrogate word
   73|  6.11M|    counter += static_cast<size_t>(p[i] > 0xFFFF); // surrogate pair
   74|  6.11M|  }
   75|  4.15k|  return counter;
   76|  4.15k|}
_ZN7simdutf6scalar5utf328validateIPKjQsr7simdutf6detailE19indexes_into_uint32IT_EEEbS5_m:
   13|  5.68k|                                                      size_t len) noexcept {
   14|  5.68k|  uint64_t pos = 0;
   15|  1.74M|  for (; pos < len; pos++) {
  ------------------
  |  Branch (15:10): [True: 1.74M, False: 2.51k]
  ------------------
   16|  1.74M|    uint32_t word = data[pos];
   17|  1.74M|    if (word > 0x10FFFF || (word >= 0xD800 && word <= 0xDFFF)) {
  ------------------
  |  Branch (17:9): [True: 2.67k, False: 1.74M]
  |  Branch (17:29): [True: 40.1k, False: 1.70M]
  |  Branch (17:47): [True: 495, False: 39.6k]
  ------------------
   18|  3.17k|      return false;
   19|  3.17k|    }
   20|  1.74M|  }
   21|  2.51k|  return true;
   22|  5.68k|}
_ZN7simdutf6scalar5utf3220validate_with_errorsIPKjQsr7simdutf6detailE19indexes_into_uint32IT_EEENS_6resultES5_m:
   34|  7.78k|validate_with_errors(InputPtr data, size_t len) noexcept {
   35|  7.78k|  size_t pos = 0;
   36|  1.75M|  for (; pos < len; pos++) {
  ------------------
  |  Branch (36:10): [True: 1.75M, False: 2.51k]
  ------------------
   37|  1.75M|    uint32_t word = data[pos];
   38|  1.75M|    if (word > 0x10FFFF) {
  ------------------
  |  Branch (38:9): [True: 4.37k, False: 1.74M]
  ------------------
   39|  4.37k|      return result(error_code::TOO_LARGE, pos);
   40|  4.37k|    }
   41|  1.74M|    if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (41:9): [True: 41.5k, False: 1.70M]
  |  Branch (41:27): [True: 894, False: 40.6k]
  ------------------
   42|    894|      return result(error_code::SURROGATE, pos);
   43|    894|    }
   44|  1.74M|  }
   45|  2.51k|  return result(error_code::SUCCESS, pos);
   46|  7.78k|}

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

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf167convertILNS_10endiannessE0EEEmPKDimPDs:
   11|  1.82k|                                   char16_t *utf16_output) {
   12|  1.82k|  size_t pos = 0;
   13|  1.82k|  char16_t *start{utf16_output};
   14|   538k|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 537k, False: 938]
  ------------------
   15|   537k|    uint32_t word = data[pos];
   16|   537k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (16:9): [True: 534k, False: 3.35k]
  ------------------
   17|   534k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (17:11): [True: 1.75k, False: 532k]
  |  Branch (17:29): [True: 192, False: 1.55k]
  ------------------
   18|    192|        return 0;
   19|    192|      }
   20|       |      // will not generate a surrogate pair
   21|   534k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (21:25): [Folded, False: 534k]
  ------------------
   22|   534k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   23|   534k|                            : char16_t(word);
   24|   534k|    } else {
   25|       |      // will generate a surrogate pair
   26|  3.35k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (26:11): [True: 690, False: 2.66k]
  ------------------
   27|    690|        return 0;
   28|    690|      }
   29|  2.66k|      word -= 0x10000;
   30|  2.66k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   31|  2.66k|      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.66k|      *utf16_output++ = char16_t(high_surrogate);
   37|  2.66k|      *utf16_output++ = char16_t(low_surrogate);
   38|  2.66k|    }
   39|   536k|    pos++;
   40|   536k|  }
   41|    938|  return utf16_output - start;
   42|  1.82k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf167convertILNS_10endiannessE1EEEmPKDimPDs:
   11|  1.53k|                                   char16_t *utf16_output) {
   12|  1.53k|  size_t pos = 0;
   13|  1.53k|  char16_t *start{utf16_output};
   14|   176k|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 176k, False: 714]
  ------------------
   15|   176k|    uint32_t word = data[pos];
   16|   176k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (16:9): [True: 173k, False: 2.83k]
  ------------------
   17|   173k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (17:11): [True: 1.18k, False: 171k]
  |  Branch (17:29): [True: 166, False: 1.01k]
  ------------------
   18|    166|        return 0;
   19|    166|      }
   20|       |      // will not generate a surrogate pair
   21|   173k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (21:25): [True: 173k, Folded]
  ------------------
   22|   173k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   23|   173k|                            : char16_t(word);
   24|   173k|    } else {
   25|       |      // will generate a surrogate pair
   26|  2.83k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (26:11): [True: 656, False: 2.18k]
  ------------------
   27|    656|        return 0;
   28|    656|      }
   29|  2.18k|      word -= 0x10000;
   30|  2.18k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   31|  2.18k|      uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   32|  2.18k|      if constexpr (!match_system(big_endian)) {
   33|  2.18k|        high_surrogate = u16_swap_bytes(high_surrogate);
   34|  2.18k|        low_surrogate = u16_swap_bytes(low_surrogate);
   35|  2.18k|      }
   36|  2.18k|      *utf16_output++ = char16_t(high_surrogate);
   37|  2.18k|      *utf16_output++ = char16_t(low_surrogate);
   38|  2.18k|    }
   39|   175k|    pos++;
   40|   175k|  }
   41|    714|  return utf16_output - start;
   42|  1.53k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf1619convert_with_errorsILNS_10endiannessE0EEENS_6resultEPKDimPDs:
   46|  2.02k|                                               char16_t *utf16_output) {
   47|  2.02k|  size_t pos = 0;
   48|  2.02k|  char16_t *start{utf16_output};
   49|   445k|  while (pos < len) {
  ------------------
  |  Branch (49:10): [True: 445k, False: 512]
  ------------------
   50|   445k|    uint32_t word = data[pos];
   51|   445k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (51:9): [True: 436k, False: 8.99k]
  ------------------
   52|   436k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (52:11): [True: 1.61k, False: 434k]
  |  Branch (52:29): [True: 300, False: 1.31k]
  ------------------
   53|    300|        return result(error_code::SURROGATE, pos);
   54|    300|      }
   55|       |      // will not generate a surrogate pair
   56|   436k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (56:25): [Folded, False: 436k]
  ------------------
   57|   436k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   58|   436k|                            : char16_t(word);
   59|   436k|    } else {
   60|       |      // will generate a surrogate pair
   61|  8.99k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (61:11): [True: 1.21k, False: 7.77k]
  ------------------
   62|  1.21k|        return result(error_code::TOO_LARGE, pos);
   63|  1.21k|      }
   64|  7.77k|      word -= 0x10000;
   65|  7.77k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   66|  7.77k|      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|  7.77k|      *utf16_output++ = char16_t(high_surrogate);
   72|  7.77k|      *utf16_output++ = char16_t(low_surrogate);
   73|  7.77k|    }
   74|   443k|    pos++;
   75|   443k|  }
   76|    512|  return result(error_code::SUCCESS, utf16_output - start);
   77|  2.02k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf1619convert_with_errorsILNS_10endiannessE1EEENS_6resultEPKDimPDs:
   46|  1.86k|                                               char16_t *utf16_output) {
   47|  1.86k|  size_t pos = 0;
   48|  1.86k|  char16_t *start{utf16_output};
   49|  28.3k|  while (pos < len) {
  ------------------
  |  Branch (49:10): [True: 27.8k, False: 490]
  ------------------
   50|  27.8k|    uint32_t word = data[pos];
   51|  27.8k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (51:9): [True: 23.6k, False: 4.17k]
  ------------------
   52|  23.6k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (52:11): [True: 1.53k, False: 22.1k]
  |  Branch (52:29): [True: 192, False: 1.34k]
  ------------------
   53|    192|        return result(error_code::SURROGATE, pos);
   54|    192|      }
   55|       |      // will not generate a surrogate pair
   56|  23.4k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (56:25): [True: 23.4k, Folded]
  ------------------
   57|  23.4k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   58|  23.4k|                            : char16_t(word);
   59|  23.4k|    } else {
   60|       |      // will generate a surrogate pair
   61|  4.17k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (61:11): [True: 1.18k, False: 2.99k]
  ------------------
   62|  1.18k|        return result(error_code::TOO_LARGE, pos);
   63|  1.18k|      }
   64|  2.99k|      word -= 0x10000;
   65|  2.99k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   66|  2.99k|      uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   67|  2.99k|      if constexpr (!match_system(big_endian)) {
   68|  2.99k|        high_surrogate = u16_swap_bytes(high_surrogate);
   69|  2.99k|        low_surrogate = u16_swap_bytes(low_surrogate);
   70|  2.99k|      }
   71|  2.99k|      *utf16_output++ = char16_t(high_surrogate);
   72|  2.99k|      *utf16_output++ = char16_t(low_surrogate);
   73|  2.99k|    }
   74|  26.4k|    pos++;
   75|  26.4k|  }
   76|    490|  return result(error_code::SUCCESS, utf16_output - start);
   77|  1.86k|}

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

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf32_to_utf87convertIPKDiPcQaasr7simdutf6detailE18indexes_into_utf32IT_Esr7simdutf6detailE26index_assignable_from_charIT0_EEEmS7_mS8_:
   17|  1.89k|                                   OutputPtr utf8_output) {
   18|  1.89k|  size_t pos = 0;
   19|  1.89k|  auto start = utf8_output;
   20|   242k|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 242k, False: 736]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|   242k|    { // try to convert the next block of 2 ASCII characters
   25|   242k|      if (pos + 2 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 241k, False: 1.02k]
  ------------------
   26|       |                            // they are ascii
   27|   241k|        uint64_t v;
   28|   241k|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   29|   241k|        if ((v & 0xFFFFFF80FFFFFF80) == 0) {
  ------------------
  |  Branch (29:13): [True: 218k, False: 22.1k]
  ------------------
   30|   218k|          *utf8_output++ = char(data[pos]);
   31|   218k|          *utf8_output++ = char(data[pos + 1]);
   32|   218k|          pos += 2;
   33|   218k|          continue;
   34|   218k|        }
   35|   241k|      }
   36|   242k|    }
   37|       |
   38|  23.1k|    uint32_t word = data[pos];
   39|  23.1k|    if ((word & 0xFFFFFF80) == 0) {
  ------------------
  |  Branch (39:9): [True: 3.76k, False: 19.4k]
  ------------------
   40|       |      // will generate one UTF-8 bytes
   41|  3.76k|      *utf8_output++ = char(word);
   42|  3.76k|      pos++;
   43|  19.4k|    } else if ((word & 0xFFFFF800) == 0) {
  ------------------
  |  Branch (43:16): [True: 3.88k, False: 15.5k]
  ------------------
   44|       |      // will generate two UTF-8 bytes
   45|       |      // we have 0b110XXXXX 0b10XXXXXX
   46|  3.88k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   47|  3.88k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   48|  3.88k|      pos++;
   49|  15.5k|    } else if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (49:16): [True: 9.83k, False: 5.70k]
  ------------------
   50|       |      // will generate three UTF-8 bytes
   51|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   52|  9.83k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (52:11): [True: 7.03k, False: 2.80k]
  |  Branch (52:29): [True: 228, False: 6.80k]
  ------------------
   53|    228|        return 0;
   54|    228|      }
   55|  9.60k|      *utf8_output++ = char((word >> 12) | 0b11100000);
   56|  9.60k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   57|  9.60k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   58|  9.60k|      pos++;
   59|  9.60k|    } else {
   60|       |      // will generate four UTF-8 bytes
   61|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   62|  5.70k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (62:11): [True: 930, False: 4.77k]
  ------------------
   63|    930|        return 0;
   64|    930|      }
   65|  4.77k|      *utf8_output++ = char((word >> 18) | 0b11110000);
   66|  4.77k|      *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000);
   67|  4.77k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   68|  4.77k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   69|  4.77k|      pos++;
   70|  4.77k|    }
   71|  23.1k|  }
   72|    736|  return utf8_output - start;
   73|  1.89k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf32_to_utf819convert_with_errorsIPKDiPcQaasr7simdutf6detailE18indexes_into_utf32IT_Esr7simdutf6detailE26index_assignable_from_charIT0_EEENS_6resultES7_mS8_:
   81|  2.79k|                                               OutputPtr utf8_output) {
   82|  2.79k|  size_t pos = 0;
   83|  2.79k|  auto start = utf8_output;
   84|   424k|  while (pos < len) {
  ------------------
  |  Branch (84:10): [True: 424k, False: 694]
  ------------------
   85|       |#if SIMDUTF_CPLUSPLUS23
   86|       |    if !consteval
   87|       |#endif
   88|   424k|    { // try to convert the next block of 2 ASCII characters
   89|   424k|      if (pos + 2 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (89:11): [True: 423k, False: 1.13k]
  ------------------
   90|       |                            // they are ascii
   91|   423k|        uint64_t v;
   92|   423k|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   93|   423k|        if ((v & 0xFFFFFF80FFFFFF80) == 0) {
  ------------------
  |  Branch (93:13): [True: 368k, False: 54.2k]
  ------------------
   94|   368k|          *utf8_output++ = char(data[pos]);
   95|   368k|          *utf8_output++ = char(data[pos + 1]);
   96|   368k|          pos += 2;
   97|   368k|          continue;
   98|   368k|        }
   99|   423k|      }
  100|   424k|    }
  101|       |
  102|  55.4k|    uint32_t word = data[pos];
  103|  55.4k|    if ((word & 0xFFFFFF80) == 0) {
  ------------------
  |  Branch (103:9): [True: 7.62k, False: 47.7k]
  ------------------
  104|       |      // will generate one UTF-8 bytes
  105|  7.62k|      *utf8_output++ = char(word);
  106|  7.62k|      pos++;
  107|  47.7k|    } else if ((word & 0xFFFFF800) == 0) {
  ------------------
  |  Branch (107:16): [True: 22.8k, False: 24.9k]
  ------------------
  108|       |      // will generate two UTF-8 bytes
  109|       |      // we have 0b110XXXXX 0b10XXXXXX
  110|  22.8k|      *utf8_output++ = char((word >> 6) | 0b11000000);
  111|  22.8k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  112|  22.8k|      pos++;
  113|  24.9k|    } else if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (113:16): [True: 16.5k, False: 8.45k]
  ------------------
  114|       |      // will generate three UTF-8 bytes
  115|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
  116|  16.5k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (116:11): [True: 11.8k, False: 4.64k]
  |  Branch (116:29): [True: 342, False: 11.5k]
  ------------------
  117|    342|        return result(error_code::SURROGATE, pos);
  118|    342|      }
  119|  16.1k|      *utf8_output++ = char((word >> 12) | 0b11100000);
  120|  16.1k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  121|  16.1k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  122|  16.1k|      pos++;
  123|  16.1k|    } else {
  124|       |      // will generate four UTF-8 bytes
  125|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
  126|  8.45k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (126:11): [True: 1.75k, False: 6.69k]
  ------------------
  127|  1.75k|        return result(error_code::TOO_LARGE, pos);
  128|  1.75k|      }
  129|  6.69k|      *utf8_output++ = char((word >> 18) | 0b11110000);
  130|  6.69k|      *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000);
  131|  6.69k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  132|  6.69k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  133|  6.69k|      pos++;
  134|  6.69k|    }
  135|  55.4k|  }
  136|    694|  return result(error_code::SUCCESS, utf8_output - start);
  137|  2.79k|}

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

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf88validateEPKcm:
  113|  3.47k|                                                        size_t len) noexcept {
  114|  3.47k|  return validate(reinterpret_cast<const uint8_t *>(buf), len);
  115|  3.47k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf88validateIPKhEEbT_m:
   14|  3.47k|                                                      size_t len) noexcept {
   15|  3.47k|  static_assert(
   16|  3.47k|      std::is_same<typename std::decay<decltype(*data)>::type, uint8_t>::value,
   17|  3.47k|      "dereferencing the data pointer must result in a uint8_t");
   18|  3.47k|  uint64_t pos = 0;
   19|  3.47k|  uint32_t code_point = 0;
   20|  8.61M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 8.61M, False: 631]
  ------------------
   21|  8.61M|    uint64_t next_pos;
   22|       |#if SIMDUTF_CPLUSPLUS23
   23|       |    if !consteval
   24|       |#endif
   25|  8.61M|    { // check if the next 16 bytes are ascii.
   26|  8.61M|      next_pos = pos + 16;
   27|  8.61M|      if (next_pos <= len) { // if it is safe to read 16 more bytes, check
  ------------------
  |  Branch (27:11): [True: 8.61M, False: 3.38k]
  ------------------
   28|       |                             // that they are ascii
   29|  8.61M|        uint64_t v1{};
   30|  8.61M|        std::memcpy(&v1, data + pos, sizeof(uint64_t));
   31|  8.61M|        uint64_t v2{};
   32|  8.61M|        std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   33|  8.61M|        uint64_t v{v1 | v2};
   34|  8.61M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (34:13): [True: 7.41M, False: 1.20M]
  ------------------
   35|  7.41M|          pos = next_pos;
   36|  7.41M|          continue;
   37|  7.41M|        }
   38|  8.61M|      }
   39|  8.61M|    }
   40|       |
   41|  1.20M|    unsigned char byte = data[pos];
   42|       |
   43|  5.71M|    while (byte < 0b10000000) {
  ------------------
  |  Branch (43:12): [True: 4.51M, False: 1.20M]
  ------------------
   44|  4.51M|      if (++pos == len) {
  ------------------
  |  Branch (44:11): [True: 1.08k, False: 4.51M]
  ------------------
   45|  1.08k|        return true;
   46|  1.08k|      }
   47|  4.51M|      byte = data[pos];
   48|  4.51M|    }
   49|       |
   50|  1.20M|    if ((byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (50:9): [True: 829k, False: 372k]
  ------------------
   51|   829k|      next_pos = pos + 2;
   52|   829k|      if (next_pos > len) {
  ------------------
  |  Branch (52:11): [True: 69, False: 829k]
  ------------------
   53|     69|        return false;
   54|     69|      }
   55|   829k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (55:11): [True: 244, False: 829k]
  ------------------
   56|    244|        return false;
   57|    244|      }
   58|       |      // range check
   59|   829k|      code_point = (byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
   60|   829k|      if (code_point < 0x80) {
  ------------------
  |  Branch (60:11): [True: 38, False: 829k]
  ------------------
   61|     38|        return false;
   62|     38|      }
   63|   829k|    } else if ((byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (63:16): [True: 283k, False: 89.2k]
  ------------------
   64|   283k|      next_pos = pos + 3;
   65|   283k|      if (next_pos > len) {
  ------------------
  |  Branch (65:11): [True: 52, False: 283k]
  ------------------
   66|     52|        return false;
   67|     52|      }
   68|   283k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (68:11): [True: 119, False: 283k]
  ------------------
   69|    119|        return false;
   70|    119|      }
   71|   283k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (71:11): [True: 52, False: 283k]
  ------------------
   72|     52|        return false;
   73|     52|      }
   74|       |      // range check
   75|   283k|      code_point = (byte & 0b00001111) << 12 |
   76|   283k|                   (data[pos + 1] & 0b00111111) << 6 |
   77|   283k|                   (data[pos + 2] & 0b00111111);
   78|   283k|      if ((code_point < 0x800) ||
  ------------------
  |  Branch (78:11): [True: 43, False: 283k]
  ------------------
   79|   283k|          (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (79:12): [True: 8.29k, False: 275k]
  |  Branch (79:35): [True: 18, False: 8.27k]
  ------------------
   80|     61|        return false;
   81|     61|      }
   82|   283k|    } else if ((byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (82:16): [True: 88.3k, False: 826]
  ------------------
   83|  88.3k|      next_pos = pos + 4;
   84|  88.3k|      if (next_pos > len) {
  ------------------
  |  Branch (84:11): [True: 41, False: 88.3k]
  ------------------
   85|     41|        return false;
   86|     41|      }
   87|  88.3k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (87:11): [True: 97, False: 88.2k]
  ------------------
   88|     97|        return false;
   89|     97|      }
   90|  88.2k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (90:11): [True: 43, False: 88.2k]
  ------------------
   91|     43|        return false;
   92|     43|      }
   93|  88.2k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (93:11): [True: 41, False: 88.1k]
  ------------------
   94|     41|        return false;
   95|     41|      }
   96|       |      // range check
   97|  88.1k|      code_point =
   98|  88.1k|          (byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 |
   99|  88.1k|          (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111);
  100|  88.1k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (100:11): [True: 38, False: 88.1k]
  |  Branch (100:35): [True: 35, False: 88.1k]
  ------------------
  101|     73|        return false;
  102|     73|      }
  103|  88.1k|    } else {
  104|       |      // we may have a continuation
  105|    826|      return false;
  106|    826|    }
  107|  1.20M|    pos = next_pos;
  108|  1.20M|  }
  109|    631|  return true;
  110|  3.47k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf820validate_with_errorsEPKcm:
  221|  6.71k|validate_with_errors(const char *buf, size_t len) noexcept {
  222|  6.71k|  return validate_with_errors(reinterpret_cast<const uint8_t *>(buf), len);
  223|  6.71k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf820validate_with_errorsIPKhEENS_6resultET_m:
  119|  6.71k|validate_with_errors(BytePtr data, size_t len) noexcept {
  120|  6.71k|  static_assert(
  121|  6.71k|      std::is_same<typename std::decay<decltype(*data)>::type, uint8_t>::value,
  122|  6.71k|      "dereferencing the data pointer must result in a uint8_t");
  123|  6.71k|  size_t pos = 0;
  124|  6.71k|  uint32_t code_point = 0;
  125|  8.62M|  while (pos < len) {
  ------------------
  |  Branch (125:10): [True: 8.62M, False: 631]
  ------------------
  126|       |    // check of the next 16 bytes are ascii.
  127|  8.62M|    size_t next_pos = pos + 16;
  128|  8.62M|    if (next_pos <=
  ------------------
  |  Branch (128:9): [True: 8.61M, False: 5.17k]
  ------------------
  129|  8.62M|        len) { // if it is safe to read 16 more bytes, check that they are ascii
  130|  8.61M|      uint64_t v1;
  131|  8.61M|      std::memcpy(&v1, data + pos, sizeof(uint64_t));
  132|  8.61M|      uint64_t v2;
  133|  8.61M|      std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  134|  8.61M|      uint64_t v{v1 | v2};
  135|  8.61M|      if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (135:11): [True: 7.41M, False: 1.20M]
  ------------------
  136|  7.41M|        pos = next_pos;
  137|  7.41M|        continue;
  138|  7.41M|      }
  139|  8.61M|    }
  140|  1.21M|    unsigned char byte = data[pos];
  141|       |
  142|  5.73M|    while (byte < 0b10000000) {
  ------------------
  |  Branch (142:12): [True: 4.53M, False: 1.20M]
  ------------------
  143|  4.53M|      if (++pos == len) {
  ------------------
  |  Branch (143:11): [True: 1.08k, False: 4.52M]
  ------------------
  144|  1.08k|        return result(error_code::SUCCESS, len);
  145|  1.08k|      }
  146|  4.52M|      byte = data[pos];
  147|  4.52M|    }
  148|       |
  149|  1.20M|    if ((byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (149:9): [True: 832k, False: 376k]
  ------------------
  150|   832k|      next_pos = pos + 2;
  151|   832k|      if (next_pos > len) {
  ------------------
  |  Branch (151:11): [True: 207, False: 832k]
  ------------------
  152|    207|        return result(error_code::TOO_SHORT, pos);
  153|    207|      }
  154|   832k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (154:11): [True: 732, False: 831k]
  ------------------
  155|    732|        return result(error_code::TOO_SHORT, pos);
  156|    732|      }
  157|       |      // range check
  158|   831k|      code_point = (byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
  159|   831k|      if (code_point < 0x80) {
  ------------------
  |  Branch (159:11): [True: 114, False: 831k]
  ------------------
  160|    114|        return result(error_code::OVERLONG, pos);
  161|    114|      }
  162|   831k|    } else if ((byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (162:16): [True: 285k, False: 91.6k]
  ------------------
  163|   285k|      next_pos = pos + 3;
  164|   285k|      if (next_pos > len) {
  ------------------
  |  Branch (164:11): [True: 156, False: 284k]
  ------------------
  165|    156|        return result(error_code::TOO_SHORT, pos);
  166|    156|      }
  167|   284k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (167:11): [True: 357, False: 284k]
  ------------------
  168|    357|        return result(error_code::TOO_SHORT, pos);
  169|    357|      }
  170|   284k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (170:11): [True: 156, False: 284k]
  ------------------
  171|    156|        return result(error_code::TOO_SHORT, pos);
  172|    156|      }
  173|       |      // range check
  174|   284k|      code_point = (byte & 0b00001111) << 12 |
  175|   284k|                   (data[pos + 1] & 0b00111111) << 6 |
  176|   284k|                   (data[pos + 2] & 0b00111111);
  177|   284k|      if (code_point < 0x800) {
  ------------------
  |  Branch (177:11): [True: 129, False: 284k]
  ------------------
  178|    129|        return result(error_code::OVERLONG, pos);
  179|    129|      }
  180|   284k|      if (0xd7ff < code_point && code_point < 0xe000) {
  ------------------
  |  Branch (180:11): [True: 8.91k, False: 275k]
  |  Branch (180:34): [True: 54, False: 8.86k]
  ------------------
  181|     54|        return result(error_code::SURROGATE, pos);
  182|     54|      }
  183|   284k|    } else if ((byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (183:16): [True: 89.4k, False: 2.21k]
  ------------------
  184|  89.4k|      next_pos = pos + 4;
  185|  89.4k|      if (next_pos > len) {
  ------------------
  |  Branch (185:11): [True: 123, False: 89.2k]
  ------------------
  186|    123|        return result(error_code::TOO_SHORT, pos);
  187|    123|      }
  188|  89.2k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (188:11): [True: 291, False: 89.0k]
  ------------------
  189|    291|        return result(error_code::TOO_SHORT, pos);
  190|    291|      }
  191|  89.0k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (191:11): [True: 129, False: 88.8k]
  ------------------
  192|    129|        return result(error_code::TOO_SHORT, pos);
  193|    129|      }
  194|  88.8k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (194:11): [True: 123, False: 88.7k]
  ------------------
  195|    123|        return result(error_code::TOO_SHORT, pos);
  196|    123|      }
  197|       |      // range check
  198|  88.7k|      code_point =
  199|  88.7k|          (byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 |
  200|  88.7k|          (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111);
  201|  88.7k|      if (code_point <= 0xffff) {
  ------------------
  |  Branch (201:11): [True: 114, False: 88.6k]
  ------------------
  202|    114|        return result(error_code::OVERLONG, pos);
  203|    114|      }
  204|  88.6k|      if (0x10ffff < code_point) {
  ------------------
  |  Branch (204:11): [True: 105, False: 88.5k]
  ------------------
  205|    105|        return result(error_code::TOO_LARGE, pos);
  206|    105|      }
  207|  88.6k|    } else {
  208|       |      // we either have too many continuation bytes or an invalid leading byte
  209|  2.21k|      if ((byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (209:11): [True: 1.15k, False: 1.05k]
  ------------------
  210|  1.15k|        return result(error_code::TOO_LONG, pos);
  211|  1.15k|      } else {
  212|  1.05k|        return result(error_code::HEADER_BITS, pos);
  213|  1.05k|      }
  214|  2.21k|    }
  215|  1.20M|    pos = next_pos;
  216|  1.20M|  }
  217|    631|  return result(error_code::SUCCESS, len);
  218|  6.71k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf831rewind_and_validate_with_errorsEPKcS4_m:
  232|  3.51k|    const char *start, const char *buf, size_t len) noexcept {
  233|       |  // First check that we start with a leading byte
  234|  3.51k|  if ((*start & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (234:7): [True: 266, False: 3.24k]
  ------------------
  235|    266|    return result(error_code::TOO_LONG, 0);
  236|    266|  }
  237|  3.24k|  size_t extra_len{0};
  238|       |  // A leading byte cannot be further than 4 bytes away
  239|  3.43k|  for (int i = 0; i < 5; i++) {
  ------------------
  |  Branch (239:19): [True: 3.43k, False: 0]
  ------------------
  240|  3.43k|    unsigned char byte = *buf;
  241|  3.43k|    if ((byte & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (241:9): [True: 3.24k, False: 192]
  ------------------
  242|  3.24k|      break;
  243|  3.24k|    } else {
  244|    192|      buf--;
  245|    192|      extra_len++;
  246|    192|    }
  247|  3.43k|  }
  248|       |
  249|  3.24k|  result res = validate_with_errors(buf, len + extra_len);
  250|  3.24k|  res.count -= extra_len; // Might underflow
  251|  3.24k|  return res;
  252|  3.51k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf817count_code_pointsIPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEEmS6_m:
  258|  15.1k|simdutf_constexpr23 size_t count_code_points(InputPtr data, size_t len) {
  259|  15.1k|  size_t counter{0};
  260|   256M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (260:22): [True: 256M, False: 15.1k]
  ------------------
  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: 3.21M]
  ------------------
  264|   253M|      counter++;
  265|   253M|    }
  266|   256M|  }
  267|  15.1k|  return counter;
  268|  15.1k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf822utf16_length_from_utf8IPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEEmS6_m:
  274|  5.72k|simdutf_constexpr23 size_t utf16_length_from_utf8(InputPtr data, size_t len) {
  275|  5.72k|  size_t counter{0};
  276|  90.5M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (276:22): [True: 90.5M, False: 5.72k]
  ------------------
  277|  90.5M|    if (int8_t(data[i]) > -65) {
  ------------------
  |  Branch (277:9): [True: 89.0M, False: 1.51M]
  ------------------
  278|  89.0M|      counter++;
  279|  89.0M|    }
  280|  90.5M|    if (uint8_t(data[i]) >= 240) {
  ------------------
  |  Branch (280:9): [True: 141k, False: 90.4M]
  ------------------
  281|   141k|      counter++;
  282|   141k|    }
  283|  90.5M|  }
  284|  5.72k|  return counter;
  285|  5.72k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf8_to_latin130rewind_and_convert_with_errorsEmPKcmPc:
  176|    996|                                             char *latin1_output) {
  177|    996|  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|    996|  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|    996|  bool found_leading_bytes{false};
  185|       |  // important: it is i <= how_far_back and not 'i < how_far_back'.
  186|  1.06k|  for (size_t i = 0; i <= how_far_back; i++) {
  ------------------
  |  Branch (186:22): [True: 1.00k, False: 60]
  ------------------
  187|  1.00k|    unsigned char byte = buf[-static_cast<std::ptrdiff_t>(i)];
  188|  1.00k|    found_leading_bytes = ((byte & 0b11000000) != 0b10000000);
  189|  1.00k|    if (found_leading_bytes) {
  ------------------
  |  Branch (189:9): [True: 936, False: 64]
  ------------------
  190|    936|      if (i > 0 && byte < 128) {
  ------------------
  |  Branch (190:11): [True: 4, False: 932]
  |  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|    932|      buf -= i;
  196|    932|      extra_len = i;
  197|    932|      break;
  198|    936|    }
  199|  1.00k|  }
  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|    992|  if (!found_leading_bytes) {
  ------------------
  |  Branch (208:7): [True: 60, False: 932]
  ------------------
  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|     60|    return result(error_code::TOO_LONG, 0 - how_far_back);
  214|     60|  }
  215|    932|  result res = convert_with_errors(buf, len + extra_len, latin1_output);
  216|    932|  if (res.error) {
  ------------------
  |  Branch (216:7): [True: 492, False: 440]
  ------------------
  217|    492|    res.count -= extra_len;
  218|    492|  }
  219|    932|  return res;
  220|    992|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf8_to_latin119convert_with_errorsIPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEENS_6resultES6_mPc:
   92|  1.43k|                                               char *latin_output) {
   93|  1.43k|  size_t pos = 0;
   94|  1.43k|  char *start{latin_output};
   95|       |
   96|  1.45M|  while (pos < len) {
  ------------------
  |  Branch (96:10): [True: 1.45M, False: 664]
  ------------------
   97|       |#if SIMDUTF_CPLUSPLUS23
   98|       |    if !consteval
   99|       |#endif
  100|  1.45M|    {
  101|       |      // try to convert the next block of 16 ASCII bytes
  102|  1.45M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (102:11): [True: 1.44M, False: 7.40k]
  ------------------
  103|       |                             // they are ascii
  104|  1.44M|        uint64_t v1;
  105|  1.44M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
  106|  1.44M|        uint64_t v2;
  107|  1.44M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  108|  1.44M|        uint64_t v{v1 | v2}; // We are only interested in these bits: 1000 1000
  109|       |                             // 1000 1000...etc
  110|  1.44M|        if ((v & 0x8080808080808080) ==
  ------------------
  |  Branch (110:13): [True: 1.20M, False: 238k]
  ------------------
  111|  1.44M|            0) { // if NONE of these are set, e.g. all of them are zero, then
  112|       |                 // everything is ASCII
  113|  1.20M|          size_t final_pos = pos + 16;
  114|  20.5M|          while (pos < final_pos) {
  ------------------
  |  Branch (114:18): [True: 19.3M, False: 1.20M]
  ------------------
  115|  19.3M|            *latin_output++ = char(data[pos]);
  116|  19.3M|            pos++;
  117|  19.3M|          }
  118|  1.20M|          continue;
  119|  1.20M|        }
  120|  1.44M|      }
  121|  1.45M|    }
  122|       |    // suppose it is not an all ASCII byte sequence
  123|   245k|    uint8_t leading_byte = data[pos]; // leading byte
  124|   245k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (124:9): [True: 213k, False: 32.4k]
  ------------------
  125|       |      // converting one ASCII byte !!!
  126|   213k|      *latin_output++ = char(leading_byte);
  127|   213k|      pos++;
  128|   213k|    } else if ((leading_byte & 0b11100000) ==
  ------------------
  |  Branch (128:16): [True: 31.9k, False: 470]
  ------------------
  129|  32.4k|               0b11000000) { // the first three bits indicate:
  130|       |      // We have a two-byte UTF-8
  131|  31.9k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (131:11): [True: 66, False: 31.8k]
  ------------------
  132|     66|        return result(error_code::TOO_SHORT, pos);
  133|     66|      } // minimal bound checking
  134|  31.8k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (134:11): [True: 180, False: 31.7k]
  ------------------
  135|    180|        return result(error_code::TOO_SHORT, pos);
  136|    180|      } // checks if the next byte is a valid continuation byte in UTF-8. A
  137|       |        // valid continuation byte starts with 10.
  138|       |      // range check -
  139|  31.7k|      uint32_t code_point =
  140|  31.7k|          (leading_byte & 0b00011111) << 6 |
  141|  31.7k|          (data[pos + 1] &
  142|  31.7k|           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|  31.7k|      if (code_point < 0x80) {
  ------------------
  |  Branch (147:11): [True: 12, False: 31.6k]
  ------------------
  148|     12|        return result(error_code::OVERLONG, pos);
  149|     12|      }
  150|  31.6k|      if (0xFF < code_point) {
  ------------------
  |  Branch (150:11): [True: 42, False: 31.6k]
  ------------------
  151|     42|        return result(error_code::TOO_LARGE, pos);
  152|     42|      } // We only care about the range 129-255 which is Non-ASCII latin1
  153|       |        // characters
  154|  31.6k|      *latin_output++ = char(code_point);
  155|  31.6k|      pos += 2;
  156|  31.6k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (156:16): [True: 60, False: 410]
  ------------------
  157|       |      // We have a three-byte UTF-8
  158|     60|      return result(error_code::TOO_LARGE, pos);
  159|    410|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (159:16): [True: 54, False: 356]
  ------------------
  160|       |      // we have a 4-byte UTF-8 word.
  161|     54|      return result(error_code::TOO_LARGE, pos);
  162|    356|    } else {
  163|       |      // we either have too many continuation bytes or an invalid leading byte
  164|    356|      if ((leading_byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (164:11): [True: 158, False: 198]
  ------------------
  165|    158|        return result(error_code::TOO_LONG, pos);
  166|    158|      }
  167|       |
  168|    198|      return result(error_code::HEADER_BITS, pos);
  169|    356|    }
  170|   245k|  }
  171|    664|  return result(error_code::SUCCESS, latin_output - start);
  172|  1.43k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf8_to_latin17convertIPKcPcQaasr7simdutf6detailE22indexes_into_byte_likeIT_Esr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mS8_:
   17|  1.25k|                                   OutputPtr latin_output) {
   18|  1.25k|  size_t pos = 0;
   19|  1.25k|  auto start = latin_output;
   20|       |
   21|  1.50M|  while (pos < len) {
  ------------------
  |  Branch (21:10): [True: 1.50M, False: 538]
  ------------------
   22|       |#if SIMDUTF_CPLUSPLUS23
   23|       |    if !consteval
   24|       |#endif
   25|  1.50M|    {
   26|       |      // try to convert the next block of 16 ASCII bytes
   27|  1.50M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (27:11): [True: 1.50M, False: 4.11k]
  ------------------
   28|       |                             // they are ascii
   29|  1.50M|        uint64_t v1;
   30|  1.50M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   31|  1.50M|        uint64_t v2;
   32|  1.50M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   33|  1.50M|        uint64_t v{v1 | v2}; // We are only interested in these bits: 1000 1000
   34|       |                             // 1000 1000 .... etc
   35|  1.50M|        if ((v & 0x8080808080808080) ==
  ------------------
  |  Branch (35:13): [True: 1.35M, False: 147k]
  ------------------
   36|  1.50M|            0) { // if NONE of these are set, e.g. all of them are zero, then
   37|       |                 // everything is ASCII
   38|  1.35M|          size_t final_pos = pos + 16;
   39|  23.0M|          while (pos < final_pos) {
  ------------------
  |  Branch (39:18): [True: 21.7M, False: 1.35M]
  ------------------
   40|  21.7M|            *latin_output++ = char(data[pos]);
   41|  21.7M|            pos++;
   42|  21.7M|          }
   43|  1.35M|          continue;
   44|  1.35M|        }
   45|  1.50M|      }
   46|  1.50M|    }
   47|       |
   48|       |    // suppose it is not an all ASCII byte sequence
   49|   151k|    uint8_t leading_byte = data[pos]; // leading byte
   50|   151k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (50:9): [True: 133k, False: 18.1k]
  ------------------
   51|       |      // converting one ASCII byte !!!
   52|   133k|      *latin_output++ = char(leading_byte);
   53|   133k|      pos++;
   54|   133k|    } else if ((leading_byte & 0b11100000) ==
  ------------------
  |  Branch (54:16): [True: 17.6k, False: 452]
  ------------------
   55|  18.1k|               0b11000000) { // the first three bits indicate:
   56|       |      // We have a two-byte UTF-8
   57|  17.6k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (57:11): [True: 42, False: 17.6k]
  ------------------
   58|     42|        return 0;
   59|     42|      } // minimal bound checking
   60|  17.6k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (60:11): [True: 150, False: 17.4k]
  ------------------
   61|    150|        return 0;
   62|    150|      } // 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.4k|      uint32_t code_point =
   66|  17.4k|          (leading_byte & 0b00011111) << 6 |
   67|  17.4k|          (data[pos + 1] &
   68|  17.4k|           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.4k|      if (code_point < 0x80 || 0xFF < code_point) {
  ------------------
  |  Branch (73:11): [True: 18, False: 17.4k]
  |  Branch (73:32): [True: 54, False: 17.3k]
  ------------------
   74|     72|        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|     72|      }
   78|  17.3k|      *latin_output++ = char(code_point);
   79|  17.3k|      pos += 2;
   80|  17.3k|    } else {
   81|    452|      return 0;
   82|    452|    }
   83|   151k|  }
   84|    538|  return latin_output - start;
   85|  1.25k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf167convertILNS_10endiannessE0EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mPDs:
   16|  1.56k|                                   char16_t *utf16_output) {
   17|  1.56k|  size_t pos = 0;
   18|  1.56k|  char16_t *start{utf16_output};
   19|  1.63M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 1.63M, False: 692]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|       |    // try to convert the next block of 16 ASCII bytes
   24|  1.63M|    {
   25|  1.63M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 1.63M, False: 4.83k]
  ------------------
   26|       |                             // they are ascii
   27|  1.63M|        uint64_t v1;
   28|  1.63M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   29|  1.63M|        uint64_t v2;
   30|  1.63M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   31|  1.63M|        uint64_t v{v1 | v2};
   32|  1.63M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (32:13): [True: 949k, False: 680k]
  ------------------
   33|   949k|          size_t final_pos = pos + 16;
   34|  16.1M|          while (pos < final_pos) {
  ------------------
  |  Branch (34:18): [True: 15.1M, False: 949k]
  ------------------
   35|  15.1M|            *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (35:31): [Folded, False: 15.1M]
  ------------------
   36|  15.1M|                                  ? char16_t(u16_swap_bytes(data[pos]))
   37|  15.1M|                                  : char16_t(data[pos]);
   38|  15.1M|            pos++;
   39|  15.1M|          }
   40|   949k|          continue;
   41|   949k|        }
   42|  1.63M|      }
   43|  1.63M|    }
   44|       |
   45|   685k|    uint8_t leading_byte = data[pos]; // leading byte
   46|   685k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (46:9): [True: 534k, False: 150k]
  ------------------
   47|       |      // converting one ASCII byte !!!
   48|   534k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (48:25): [Folded, False: 534k]
  ------------------
   49|   534k|                            ? char16_t(u16_swap_bytes(leading_byte))
   50|   534k|                            : char16_t(leading_byte);
   51|   534k|      pos++;
   52|   534k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (52:16): [True: 104k, False: 46.4k]
  ------------------
   53|       |      // We have a two-byte UTF-8, it should become
   54|       |      // a single UTF-16 word.
   55|   104k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (55:11): [True: 36, False: 104k]
  ------------------
   56|     36|        return 0;
   57|     36|      } // minimal bound checking
   58|   104k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (58:11): [True: 90, False: 104k]
  ------------------
   59|     90|        return 0;
   60|     90|      }
   61|       |      // range check
   62|   104k|      uint32_t code_point =
   63|   104k|          (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
   64|   104k|      if (code_point < 0x80) {
  ------------------
  |  Branch (64:11): [True: 20, False: 104k]
  ------------------
   65|     20|        return 0;
   66|     20|      }
   67|       |      if constexpr (!match_system(big_endian)) {
   68|       |        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
   69|       |      }
   70|   104k|      *utf16_output++ = char16_t(code_point);
   71|   104k|      pos += 2;
   72|   104k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (72:16): [True: 34.8k, False: 11.6k]
  ------------------
   73|       |      // We have a three-byte UTF-8, it should become
   74|       |      // a single UTF-16 word.
   75|  34.8k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (75:11): [True: 42, False: 34.7k]
  ------------------
   76|     42|        return 0;
   77|     42|      } // minimal bound checking
   78|       |
   79|  34.7k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (79:11): [True: 50, False: 34.7k]
  ------------------
   80|     50|        return 0;
   81|     50|      }
   82|  34.7k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (82:11): [True: 44, False: 34.6k]
  ------------------
   83|     44|        return 0;
   84|     44|      }
   85|       |      // range check
   86|  34.6k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
   87|  34.6k|                            (data[pos + 1] & 0b00111111) << 6 |
   88|  34.6k|                            (data[pos + 2] & 0b00111111);
   89|  34.6k|      if (code_point < 0x800 || (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (89:11): [True: 44, False: 34.6k]
  |  Branch (89:34): [True: 966, False: 33.6k]
  |  Branch (89:57): [True: 14, False: 952]
  ------------------
   90|     58|        return 0;
   91|     58|      }
   92|       |      if constexpr (!match_system(big_endian)) {
   93|       |        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
   94|       |      }
   95|  34.6k|      *utf16_output++ = char16_t(code_point);
   96|  34.6k|      pos += 3;
   97|  34.6k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (97:16): [True: 11.2k, False: 326]
  ------------------
   98|       |      // we have a 4-byte UTF-8 word.
   99|  11.2k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (99:11): [True: 42, False: 11.2k]
  ------------------
  100|     42|        return 0;
  101|     42|      } // minimal bound checking
  102|  11.2k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (102:11): [True: 62, False: 11.1k]
  ------------------
  103|     62|        return 0;
  104|     62|      }
  105|  11.1k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (105:11): [True: 20, False: 11.1k]
  ------------------
  106|     20|        return 0;
  107|     20|      }
  108|  11.1k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (108:11): [True: 26, False: 11.1k]
  ------------------
  109|     26|        return 0;
  110|     26|      }
  111|       |
  112|       |      // range check
  113|  11.1k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  114|  11.1k|                            (data[pos + 1] & 0b00111111) << 12 |
  115|  11.1k|                            (data[pos + 2] & 0b00111111) << 6 |
  116|  11.1k|                            (data[pos + 3] & 0b00111111);
  117|  11.1k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (117:11): [True: 10, False: 11.1k]
  |  Branch (117:35): [True: 42, False: 11.0k]
  ------------------
  118|     52|        return 0;
  119|     52|      }
  120|  11.0k|      code_point -= 0x10000;
  121|  11.0k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
  122|  11.0k|      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|  11.0k|      *utf16_output++ = char16_t(high_surrogate);
  128|  11.0k|      *utf16_output++ = char16_t(low_surrogate);
  129|  11.0k|      pos += 4;
  130|  11.0k|    } else {
  131|    326|      return 0;
  132|    326|    }
  133|   685k|  }
  134|    692|  return utf16_output - start;
  135|  1.56k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf167convertILNS_10endiannessE1EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mPDs:
   16|  1.54k|                                   char16_t *utf16_output) {
   17|  1.54k|  size_t pos = 0;
   18|  1.54k|  char16_t *start{utf16_output};
   19|  1.33M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 1.33M, False: 590]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|       |    // try to convert the next block of 16 ASCII bytes
   24|  1.33M|    {
   25|  1.33M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 1.33M, False: 3.69k]
  ------------------
   26|       |                             // they are ascii
   27|  1.33M|        uint64_t v1;
   28|  1.33M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   29|  1.33M|        uint64_t v2;
   30|  1.33M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   31|  1.33M|        uint64_t v{v1 | v2};
   32|  1.33M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (32:13): [True: 840k, False: 491k]
  ------------------
   33|   840k|          size_t final_pos = pos + 16;
   34|  14.2M|          while (pos < final_pos) {
  ------------------
  |  Branch (34:18): [True: 13.4M, False: 840k]
  ------------------
   35|  13.4M|            *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (35:31): [True: 13.4M, Folded]
  ------------------
   36|  13.4M|                                  ? char16_t(u16_swap_bytes(data[pos]))
   37|  13.4M|                                  : char16_t(data[pos]);
   38|  13.4M|            pos++;
   39|  13.4M|          }
   40|   840k|          continue;
   41|   840k|        }
   42|  1.33M|      }
   43|  1.33M|    }
   44|       |
   45|   495k|    uint8_t leading_byte = data[pos]; // leading byte
   46|   495k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (46:9): [True: 397k, False: 98.0k]
  ------------------
   47|       |      // converting one ASCII byte !!!
   48|   397k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (48:25): [True: 397k, Folded]
  ------------------
   49|   397k|                            ? char16_t(u16_swap_bytes(leading_byte))
   50|   397k|                            : char16_t(leading_byte);
   51|   397k|      pos++;
   52|   397k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (52:16): [True: 62.0k, False: 35.9k]
  ------------------
   53|       |      // We have a two-byte UTF-8, it should become
   54|       |      // a single UTF-16 word.
   55|  62.0k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (55:11): [True: 30, False: 62.0k]
  ------------------
   56|     30|        return 0;
   57|     30|      } // minimal bound checking
   58|  62.0k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (58:11): [True: 84, False: 61.9k]
  ------------------
   59|     84|        return 0;
   60|     84|      }
   61|       |      // range check
   62|  61.9k|      uint32_t code_point =
   63|  61.9k|          (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
   64|  61.9k|      if (code_point < 0x80) {
  ------------------
  |  Branch (64:11): [True: 22, False: 61.9k]
  ------------------
   65|     22|        return 0;
   66|     22|      }
   67|  61.9k|      if constexpr (!match_system(big_endian)) {
   68|  61.9k|        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
   69|  61.9k|      }
   70|  61.9k|      *utf16_output++ = char16_t(code_point);
   71|  61.9k|      pos += 2;
   72|  61.9k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (72:16): [True: 27.1k, False: 8.82k]
  ------------------
   73|       |      // We have a three-byte UTF-8, it should become
   74|       |      // a single UTF-16 word.
   75|  27.1k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (75:11): [True: 18, False: 27.0k]
  ------------------
   76|     18|        return 0;
   77|     18|      } // minimal bound checking
   78|       |
   79|  27.0k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (79:11): [True: 64, False: 27.0k]
  ------------------
   80|     64|        return 0;
   81|     64|      }
   82|  27.0k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (82:11): [True: 46, False: 26.9k]
  ------------------
   83|     46|        return 0;
   84|     46|      }
   85|       |      // range check
   86|  26.9k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
   87|  26.9k|                            (data[pos + 1] & 0b00111111) << 6 |
   88|  26.9k|                            (data[pos + 2] & 0b00111111);
   89|  26.9k|      if (code_point < 0x800 || (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (89:11): [True: 54, False: 26.9k]
  |  Branch (89:34): [True: 948, False: 25.9k]
  |  Branch (89:57): [True: 12, False: 936]
  ------------------
   90|     66|        return 0;
   91|     66|      }
   92|  26.9k|      if constexpr (!match_system(big_endian)) {
   93|  26.9k|        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
   94|  26.9k|      }
   95|  26.9k|      *utf16_output++ = char16_t(code_point);
   96|  26.9k|      pos += 3;
   97|  26.9k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (97:16): [True: 8.41k, False: 410]
  ------------------
   98|       |      // we have a 4-byte UTF-8 word.
   99|  8.41k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (99:11): [True: 30, False: 8.38k]
  ------------------
  100|     30|        return 0;
  101|     30|      } // minimal bound checking
  102|  8.38k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (102:11): [True: 62, False: 8.32k]
  ------------------
  103|     62|        return 0;
  104|     62|      }
  105|  8.32k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (105:11): [True: 22, False: 8.30k]
  ------------------
  106|     22|        return 0;
  107|     22|      }
  108|  8.30k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (108:11): [True: 42, False: 8.26k]
  ------------------
  109|     42|        return 0;
  110|     42|      }
  111|       |
  112|       |      // range check
  113|  8.26k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  114|  8.26k|                            (data[pos + 1] & 0b00111111) << 12 |
  115|  8.26k|                            (data[pos + 2] & 0b00111111) << 6 |
  116|  8.26k|                            (data[pos + 3] & 0b00111111);
  117|  8.26k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (117:11): [True: 36, False: 8.22k]
  |  Branch (117:35): [True: 26, False: 8.20k]
  ------------------
  118|     62|        return 0;
  119|     62|      }
  120|  8.20k|      code_point -= 0x10000;
  121|  8.20k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
  122|  8.20k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
  123|  8.20k|      if constexpr (!match_system(big_endian)) {
  124|  8.20k|        high_surrogate = u16_swap_bytes(high_surrogate);
  125|  8.20k|        low_surrogate = u16_swap_bytes(low_surrogate);
  126|  8.20k|      }
  127|  8.20k|      *utf16_output++ = char16_t(high_surrogate);
  128|  8.20k|      *utf16_output++ = char16_t(low_surrogate);
  129|  8.20k|      pos += 4;
  130|  8.20k|    } else {
  131|    410|      return 0;
  132|    410|    }
  133|   495k|  }
  134|    590|  return utf16_output - start;
  135|  1.54k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1619convert_with_errorsILNS_10endiannessE0EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEENS_6resultES7_mPDs:
  142|  1.76k|                                               char16_t *utf16_output) {
  143|  1.76k|  size_t pos = 0;
  144|  1.76k|  char16_t *start{utf16_output};
  145|  2.97M|  while (pos < len) {
  ------------------
  |  Branch (145:10): [True: 2.97M, False: 766]
  ------------------
  146|       |#if SIMDUTF_CPLUSPLUS23
  147|       |    if !consteval
  148|       |#endif
  149|  2.97M|    {
  150|       |      // try to convert the next block of 16 ASCII bytes
  151|  2.97M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (151:11): [True: 2.97M, False: 6.11k]
  ------------------
  152|       |                             // they are ascii
  153|  2.97M|        uint64_t v1;
  154|  2.97M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
  155|  2.97M|        uint64_t v2;
  156|  2.97M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  157|  2.97M|        uint64_t v{v1 | v2};
  158|  2.97M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (158:13): [True: 1.37M, False: 1.59M]
  ------------------
  159|  1.37M|          size_t final_pos = pos + 16;
  160|  23.4M|          while (pos < final_pos) {
  ------------------
  |  Branch (160:18): [True: 22.0M, False: 1.37M]
  ------------------
  161|  22.0M|            const char16_t byte = uint8_t(data[pos]);
  162|  22.0M|            *utf16_output++ =
  163|  22.0M|                !match_system(big_endian) ? u16_swap_bytes(byte) : byte;
  ------------------
  |  Branch (163:17): [Folded, False: 22.0M]
  ------------------
  164|  22.0M|            pos++;
  165|  22.0M|          }
  166|  1.37M|          continue;
  167|  1.37M|        }
  168|  2.97M|      }
  169|  2.97M|    }
  170|       |
  171|  1.59M|    auto leading_byte = uint8_t(data[pos]); // leading byte
  172|  1.59M|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (172:9): [True: 1.32M, False: 276k]
  ------------------
  173|       |      // converting one ASCII byte !!!
  174|  1.32M|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (174:25): [Folded, False: 1.32M]
  ------------------
  175|  1.32M|                            ? char16_t(u16_swap_bytes(leading_byte))
  176|  1.32M|                            : char16_t(leading_byte);
  177|  1.32M|      pos++;
  178|  1.32M|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (178:16): [True: 179k, False: 96.8k]
  ------------------
  179|       |      // We have a two-byte UTF-8, it should become
  180|       |      // a single UTF-16 word.
  181|   179k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (181:11): [True: 48, False: 179k]
  ------------------
  182|     48|        return result(error_code::TOO_SHORT, pos);
  183|     48|      } // minimal bound checking
  184|   179k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (184:11): [True: 90, False: 179k]
  ------------------
  185|     90|        return result(error_code::TOO_SHORT, pos);
  186|     90|      }
  187|       |      // range check
  188|   179k|      uint32_t code_point = (leading_byte & 0b00011111) << 6 |
  189|   179k|                            (uint8_t(data[pos + 1]) & 0b00111111);
  190|   179k|      if (code_point < 0x80) {
  ------------------
  |  Branch (190:11): [True: 24, False: 179k]
  ------------------
  191|     24|        return result(error_code::OVERLONG, pos);
  192|     24|      }
  193|       |      if constexpr (!match_system(big_endian)) {
  194|       |        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
  195|       |      }
  196|   179k|      *utf16_output++ = char16_t(code_point);
  197|   179k|      pos += 2;
  198|   179k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (198:16): [True: 72.7k, False: 24.0k]
  ------------------
  199|       |      // We have a three-byte UTF-8, it should become
  200|       |      // a single UTF-16 word.
  201|  72.7k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (201:11): [True: 42, False: 72.7k]
  ------------------
  202|     42|        return result(error_code::TOO_SHORT, pos);
  203|     42|      } // minimal bound checking
  204|       |
  205|  72.7k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (205:11): [True: 66, False: 72.6k]
  ------------------
  206|     66|        return result(error_code::TOO_SHORT, pos);
  207|     66|      }
  208|  72.6k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (208:11): [True: 18, False: 72.6k]
  ------------------
  209|     18|        return result(error_code::TOO_SHORT, pos);
  210|     18|      }
  211|       |      // range check
  212|  72.6k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
  213|  72.6k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 6 |
  214|  72.6k|                            (uint8_t(data[pos + 2]) & 0b00111111);
  215|  72.6k|      if (code_point < 0x800) {
  ------------------
  |  Branch (215:11): [True: 36, False: 72.6k]
  ------------------
  216|     36|        return result(error_code::OVERLONG, pos);
  217|     36|      }
  218|  72.6k|      if (0xd7ff < code_point && code_point < 0xe000) {
  ------------------
  |  Branch (218:11): [True: 1.53k, False: 71.0k]
  |  Branch (218:34): [True: 18, False: 1.52k]
  ------------------
  219|     18|        return result(error_code::SURROGATE, pos);
  220|     18|      }
  221|       |      if constexpr (!match_system(big_endian)) {
  222|       |        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
  223|       |      }
  224|  72.5k|      *utf16_output++ = char16_t(code_point);
  225|  72.5k|      pos += 3;
  226|  72.5k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (226:16): [True: 23.6k, False: 440]
  ------------------
  227|       |      // we have a 4-byte UTF-8 word.
  228|  23.6k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (228:11): [True: 42, False: 23.5k]
  ------------------
  229|     42|        return result(error_code::TOO_SHORT, pos);
  230|     42|      } // minimal bound checking
  231|  23.5k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (231:11): [True: 60, False: 23.5k]
  ------------------
  232|     60|        return result(error_code::TOO_SHORT, pos);
  233|     60|      }
  234|  23.5k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (234:11): [True: 18, False: 23.5k]
  ------------------
  235|     18|        return result(error_code::TOO_SHORT, pos);
  236|     18|      }
  237|  23.5k|      if ((uint8_t(data[pos + 3]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (237:11): [True: 18, False: 23.4k]
  ------------------
  238|     18|        return result(error_code::TOO_SHORT, pos);
  239|     18|      }
  240|       |
  241|       |      // range check
  242|  23.4k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  243|  23.4k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 12 |
  244|  23.4k|                            (uint8_t(data[pos + 2]) & 0b00111111) << 6 |
  245|  23.4k|                            (uint8_t(data[pos + 3]) & 0b00111111);
  246|  23.4k|      if (code_point <= 0xffff) {
  ------------------
  |  Branch (246:11): [True: 42, False: 23.4k]
  ------------------
  247|     42|        return result(error_code::OVERLONG, pos);
  248|     42|      }
  249|  23.4k|      if (0x10ffff < code_point) {
  ------------------
  |  Branch (249:11): [True: 36, False: 23.4k]
  ------------------
  250|     36|        return result(error_code::TOO_LARGE, pos);
  251|     36|      }
  252|  23.4k|      code_point -= 0x10000;
  253|  23.4k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
  254|  23.4k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
  255|       |      if constexpr (!match_system(big_endian)) {
  256|       |        high_surrogate = u16_swap_bytes(high_surrogate);
  257|       |        low_surrogate = u16_swap_bytes(low_surrogate);
  258|       |      }
  259|  23.4k|      *utf16_output++ = char16_t(high_surrogate);
  260|  23.4k|      *utf16_output++ = char16_t(low_surrogate);
  261|  23.4k|      pos += 4;
  262|  23.4k|    } else {
  263|       |      // we either have too many continuation bytes or an invalid leading byte
  264|    440|      if ((leading_byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (264:11): [True: 182, False: 258]
  ------------------
  265|    182|        return result(error_code::TOO_LONG, pos);
  266|    258|      } else {
  267|    258|        return result(error_code::HEADER_BITS, pos);
  268|    258|      }
  269|    440|    }
  270|  1.59M|  }
  271|    766|  return result(error_code::SUCCESS, utf16_output - start);
  272|  1.76k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1619convert_with_errorsILNS_10endiannessE1EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEENS_6resultES7_mPDs:
  142|  2.15k|                                               char16_t *utf16_output) {
  143|  2.15k|  size_t pos = 0;
  144|  2.15k|  char16_t *start{utf16_output};
  145|  3.05M|  while (pos < len) {
  ------------------
  |  Branch (145:10): [True: 3.05M, False: 970]
  ------------------
  146|       |#if SIMDUTF_CPLUSPLUS23
  147|       |    if !consteval
  148|       |#endif
  149|  3.05M|    {
  150|       |      // try to convert the next block of 16 ASCII bytes
  151|  3.05M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (151:11): [True: 3.04M, False: 9.04k]
  ------------------
  152|       |                             // they are ascii
  153|  3.04M|        uint64_t v1;
  154|  3.04M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
  155|  3.04M|        uint64_t v2;
  156|  3.04M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  157|  3.04M|        uint64_t v{v1 | v2};
  158|  3.04M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (158:13): [True: 1.54M, False: 1.49M]
  ------------------
  159|  1.54M|          size_t final_pos = pos + 16;
  160|  26.2M|          while (pos < final_pos) {
  ------------------
  |  Branch (160:18): [True: 24.6M, False: 1.54M]
  ------------------
  161|  24.6M|            const char16_t byte = uint8_t(data[pos]);
  162|  24.6M|            *utf16_output++ =
  163|  24.6M|                !match_system(big_endian) ? u16_swap_bytes(byte) : byte;
  ------------------
  |  Branch (163:17): [True: 24.6M, Folded]
  ------------------
  164|  24.6M|            pos++;
  165|  24.6M|          }
  166|  1.54M|          continue;
  167|  1.54M|        }
  168|  3.04M|      }
  169|  3.05M|    }
  170|       |
  171|  1.50M|    auto leading_byte = uint8_t(data[pos]); // leading byte
  172|  1.50M|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (172:9): [True: 1.15M, False: 356k]
  ------------------
  173|       |      // converting one ASCII byte !!!
  174|  1.15M|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (174:25): [True: 1.15M, Folded]
  ------------------
  175|  1.15M|                            ? char16_t(u16_swap_bytes(leading_byte))
  176|  1.15M|                            : char16_t(leading_byte);
  177|  1.15M|      pos++;
  178|  1.15M|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (178:16): [True: 251k, False: 105k]
  ------------------
  179|       |      // We have a two-byte UTF-8, it should become
  180|       |      // a single UTF-16 word.
  181|   251k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (181:11): [True: 36, False: 250k]
  ------------------
  182|     36|        return result(error_code::TOO_SHORT, pos);
  183|     36|      } // minimal bound checking
  184|   250k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (184:11): [True: 162, False: 250k]
  ------------------
  185|    162|        return result(error_code::TOO_SHORT, pos);
  186|    162|      }
  187|       |      // range check
  188|   250k|      uint32_t code_point = (leading_byte & 0b00011111) << 6 |
  189|   250k|                            (uint8_t(data[pos + 1]) & 0b00111111);
  190|   250k|      if (code_point < 0x80) {
  ------------------
  |  Branch (190:11): [True: 18, False: 250k]
  ------------------
  191|     18|        return result(error_code::OVERLONG, pos);
  192|     18|      }
  193|   250k|      if constexpr (!match_system(big_endian)) {
  194|   250k|        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
  195|   250k|      }
  196|   250k|      *utf16_output++ = char16_t(code_point);
  197|   250k|      pos += 2;
  198|   250k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (198:16): [True: 74.9k, False: 30.2k]
  ------------------
  199|       |      // We have a three-byte UTF-8, it should become
  200|       |      // a single UTF-16 word.
  201|  74.9k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (201:11): [True: 36, False: 74.8k]
  ------------------
  202|     36|        return result(error_code::TOO_SHORT, pos);
  203|     36|      } // minimal bound checking
  204|       |
  205|  74.8k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (205:11): [True: 120, False: 74.7k]
  ------------------
  206|    120|        return result(error_code::TOO_SHORT, pos);
  207|    120|      }
  208|  74.7k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (208:11): [True: 60, False: 74.7k]
  ------------------
  209|     60|        return result(error_code::TOO_SHORT, pos);
  210|     60|      }
  211|       |      // range check
  212|  74.7k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
  213|  74.7k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 6 |
  214|  74.7k|                            (uint8_t(data[pos + 2]) & 0b00111111);
  215|  74.7k|      if (code_point < 0x800) {
  ------------------
  |  Branch (215:11): [True: 42, False: 74.6k]
  ------------------
  216|     42|        return result(error_code::OVERLONG, pos);
  217|     42|      }
  218|  74.6k|      if (0xd7ff < code_point && code_point < 0xe000) {
  ------------------
  |  Branch (218:11): [True: 2.89k, False: 71.7k]
  |  Branch (218:34): [True: 6, False: 2.88k]
  ------------------
  219|      6|        return result(error_code::SURROGATE, pos);
  220|      6|      }
  221|  74.6k|      if constexpr (!match_system(big_endian)) {
  222|  74.6k|        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
  223|  74.6k|      }
  224|  74.6k|      *utf16_output++ = char16_t(code_point);
  225|  74.6k|      pos += 3;
  226|  74.6k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (226:16): [True: 29.7k, False: 484]
  ------------------
  227|       |      // we have a 4-byte UTF-8 word.
  228|  29.7k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (228:11): [True: 48, False: 29.7k]
  ------------------
  229|     48|        return result(error_code::TOO_SHORT, pos);
  230|     48|      } // minimal bound checking
  231|  29.7k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (231:11): [True: 42, False: 29.7k]
  ------------------
  232|     42|        return result(error_code::TOO_SHORT, pos);
  233|     42|      }
  234|  29.7k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (234:11): [True: 54, False: 29.6k]
  ------------------
  235|     54|        return result(error_code::TOO_SHORT, pos);
  236|     54|      }
  237|  29.6k|      if ((uint8_t(data[pos + 3]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (237:11): [True: 54, False: 29.5k]
  ------------------
  238|     54|        return result(error_code::TOO_SHORT, pos);
  239|     54|      }
  240|       |
  241|       |      // range check
  242|  29.5k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  243|  29.5k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 12 |
  244|  29.5k|                            (uint8_t(data[pos + 2]) & 0b00111111) << 6 |
  245|  29.5k|                            (uint8_t(data[pos + 3]) & 0b00111111);
  246|  29.5k|      if (code_point <= 0xffff) {
  ------------------
  |  Branch (246:11): [True: 6, False: 29.5k]
  ------------------
  247|      6|        return result(error_code::OVERLONG, pos);
  248|      6|      }
  249|  29.5k|      if (0x10ffff < code_point) {
  ------------------
  |  Branch (249:11): [True: 12, False: 29.5k]
  ------------------
  250|     12|        return result(error_code::TOO_LARGE, pos);
  251|     12|      }
  252|  29.5k|      code_point -= 0x10000;
  253|  29.5k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
  254|  29.5k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
  255|  29.5k|      if constexpr (!match_system(big_endian)) {
  256|  29.5k|        high_surrogate = u16_swap_bytes(high_surrogate);
  257|  29.5k|        low_surrogate = u16_swap_bytes(low_surrogate);
  258|  29.5k|      }
  259|  29.5k|      *utf16_output++ = char16_t(high_surrogate);
  260|  29.5k|      *utf16_output++ = char16_t(low_surrogate);
  261|  29.5k|      pos += 4;
  262|  29.5k|    } else {
  263|       |      // we either have too many continuation bytes or an invalid leading byte
  264|    484|      if ((leading_byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (264:11): [True: 232, False: 252]
  ------------------
  265|    232|        return result(error_code::TOO_LONG, pos);
  266|    252|      } else {
  267|    252|        return result(error_code::HEADER_BITS, pos);
  268|    252|      }
  269|    484|    }
  270|  1.50M|  }
  271|    970|  return result(error_code::SUCCESS, utf16_output - start);
  272|  2.15k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1630rewind_and_convert_with_errorsILNS_10endiannessE0EEENS_6resultEmPKcmPDs:
  292|  1.21k|                                             char16_t *utf16_output) {
  293|  1.21k|  size_t extra_len{0};
  294|       |  // We potentially need to go back in time and find a leading byte.
  295|       |  // In theory '3' would be sufficient, but sometimes the error can go back
  296|       |  // quite far.
  297|  1.21k|  size_t how_far_back = prior_bytes;
  298|       |  // size_t how_far_back = 3; // 3 bytes in the past + current position
  299|       |  // if(how_far_back >= prior_bytes) { how_far_back = prior_bytes; }
  300|  1.21k|  bool found_leading_bytes{false};
  301|       |  // important: it is i <= how_far_back and not 'i < how_far_back'.
  302|  1.28k|  for (size_t i = 0; i <= how_far_back; i++) {
  ------------------
  |  Branch (302:22): [True: 1.22k, False: 52]
  ------------------
  303|  1.22k|    unsigned char byte = buf[-static_cast<std::ptrdiff_t>(i)];
  304|  1.22k|    found_leading_bytes = ((byte & 0b11000000) != 0b10000000);
  305|  1.22k|    if (found_leading_bytes) {
  ------------------
  |  Branch (305:9): [True: 1.16k, False: 64]
  ------------------
  306|  1.16k|      if (i > 0 && byte < 128) {
  ------------------
  |  Branch (306:11): [True: 12, False: 1.15k]
  |  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.15k|      buf -= i;
  312|  1.15k|      extra_len = i;
  313|  1.15k|      break;
  314|  1.16k|    }
  315|  1.22k|  }
  316|       |  //
  317|       |  // It is possible for this function to return a negative count in its result.
  318|       |  // C++ Standard Section 18.1 defines size_t is in <cstddef> which is described
  319|       |  // in C Standard as <stddef.h>. C Standard Section 4.1.5 defines size_t as an
  320|       |  // unsigned integral type of the result of the sizeof operator
  321|       |  //
  322|       |  // An unsigned type will simply wrap round arithmetically (well defined).
  323|       |  //
  324|  1.20k|  if (!found_leading_bytes) {
  ------------------
  |  Branch (324:7): [True: 52, False: 1.15k]
  ------------------
  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|     52|    return result(error_code::TOO_LONG, 0 - how_far_back);
  330|     52|  }
  331|  1.15k|  result res = convert_with_errors<endian>(buf, len + extra_len, utf16_output);
  332|  1.15k|  if (res.error) {
  ------------------
  |  Branch (332:7): [True: 644, False: 508]
  ------------------
  333|    644|    res.count -= extra_len;
  334|    644|  }
  335|  1.15k|  return res;
  336|  1.20k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1630rewind_and_convert_with_errorsILNS_10endiannessE1EEENS_6resultEmPKcmPDs:
  292|  1.50k|                                             char16_t *utf16_output) {
  293|  1.50k|  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.50k|  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.50k|  bool found_leading_bytes{false};
  301|       |  // important: it is i <= how_far_back and not 'i < how_far_back'.
  302|  1.60k|  for (size_t i = 0; i <= how_far_back; i++) {
  ------------------
  |  Branch (302:22): [True: 1.52k, False: 76]
  ------------------
  303|  1.52k|    unsigned char byte = buf[-static_cast<std::ptrdiff_t>(i)];
  304|  1.52k|    found_leading_bytes = ((byte & 0b11000000) != 0b10000000);
  305|  1.52k|    if (found_leading_bytes) {
  ------------------
  |  Branch (305:9): [True: 1.42k, False: 104]
  ------------------
  306|  1.42k|      if (i > 0 && byte < 128) {
  ------------------
  |  Branch (306:11): [True: 28, False: 1.39k]
  |  Branch (306:20): [True: 28, False: 0]
  ------------------
  307|       |        // If we had to go back and the leading byte is ascii
  308|       |        // then we can stop right away.
  309|     28|        return result(error_code::TOO_LONG, 0 - i + 1);
  310|     28|      }
  311|  1.39k|      buf -= i;
  312|  1.39k|      extra_len = i;
  313|  1.39k|      break;
  314|  1.42k|    }
  315|  1.52k|  }
  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.47k|  if (!found_leading_bytes) {
  ------------------
  |  Branch (324:7): [True: 76, False: 1.39k]
  ------------------
  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|     76|    return result(error_code::TOO_LONG, 0 - how_far_back);
  330|     76|  }
  331|  1.39k|  result res = convert_with_errors<endian>(buf, len + extra_len, utf16_output);
  332|  1.39k|  if (res.error) {
  ------------------
  |  Branch (332:7): [True: 752, False: 644]
  ------------------
  333|    752|    res.count -= extra_len;
  334|    752|  }
  335|  1.39k|  return res;
  336|  1.47k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1613convert_validILNS_10endiannessE0EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mPDs:
   16|  1.33k|                                         char16_t *utf16_output) {
   17|  1.33k|  size_t pos = 0;
   18|  1.33k|  char16_t *start{utf16_output};
   19|  4.31M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 4.30M, False: 1.33k]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|  4.30M|    {                       // try to convert the next block of 8 ASCII bytes
   24|  4.30M|      if (pos + 8 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (24:11): [True: 4.30M, False: 4.44k]
  ------------------
   25|       |                            // they are ascii
   26|  4.30M|        uint64_t v;
   27|  4.30M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   28|  4.30M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (28:13): [True: 2.82M, False: 1.47M]
  ------------------
   29|  2.82M|          size_t final_pos = pos + 8;
   30|  25.4M|          while (pos < final_pos) {
  ------------------
  |  Branch (30:18): [True: 22.6M, False: 2.82M]
  ------------------
   31|  22.6M|            const char16_t byte = uint8_t(data[pos]);
   32|  22.6M|            *utf16_output++ =
   33|  22.6M|                !match_system(big_endian) ? u16_swap_bytes(byte) : byte;
  ------------------
  |  Branch (33:17): [Folded, False: 22.6M]
  ------------------
   34|  22.6M|            pos++;
   35|  22.6M|          }
   36|  2.82M|          continue;
   37|  2.82M|        }
   38|  4.30M|      }
   39|  4.30M|    }
   40|       |
   41|  1.48M|    auto leading_byte = uint8_t(data[pos]); // leading byte
   42|  1.48M|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (42:9): [True: 1.00M, False: 481k]
  ------------------
   43|       |      // converting one ASCII byte !!!
   44|  1.00M|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (44:25): [Folded, False: 1.00M]
  ------------------
   45|  1.00M|                            ? char16_t(u16_swap_bytes(leading_byte))
   46|  1.00M|                            : char16_t(leading_byte);
   47|  1.00M|      pos++;
   48|  1.00M|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (48:16): [True: 277k, False: 203k]
  ------------------
   49|       |      // We have a two-byte UTF-8, it should become
   50|       |      // a single UTF-16 word.
   51|   277k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (51:11): [True: 0, False: 277k]
  ------------------
   52|      0|        break;
   53|      0|      } // minimal bound checking
   54|   277k|      uint16_t code_point = uint16_t(((leading_byte & 0b00011111) << 6) |
   55|   277k|                                     (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|   277k|      *utf16_output++ = char16_t(code_point);
   60|   277k|      pos += 2;
   61|   277k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (61:16): [True: 185k, False: 18.1k]
  ------------------
   62|       |      // We have a three-byte UTF-8, it should become
   63|       |      // a single UTF-16 word.
   64|   185k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (64:11): [True: 0, False: 185k]
  ------------------
   65|      0|        break;
   66|      0|      } // minimal bound checking
   67|   185k|      uint16_t code_point =
   68|   185k|          uint16_t(((leading_byte & 0b00001111) << 12) |
   69|   185k|                   ((uint8_t(data[pos + 1]) & 0b00111111) << 6) |
   70|   185k|                   (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|   185k|      *utf16_output++ = char16_t(code_point);
   75|   185k|      pos += 3;
   76|   185k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (76:16): [True: 18.1k, False: 0]
  ------------------
   77|       |      // we have a 4-byte UTF-8 word.
   78|  18.1k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (78:11): [True: 0, False: 18.1k]
  ------------------
   79|      0|        break;
   80|      0|      } // minimal bound checking
   81|  18.1k|      uint32_t code_point = ((leading_byte & 0b00000111) << 18) |
   82|  18.1k|                            ((uint8_t(data[pos + 1]) & 0b00111111) << 12) |
   83|  18.1k|                            ((uint8_t(data[pos + 2]) & 0b00111111) << 6) |
   84|  18.1k|                            (uint8_t(data[pos + 3]) & 0b00111111);
   85|  18.1k|      code_point -= 0x10000;
   86|  18.1k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
   87|  18.1k|      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|  18.1k|      *utf16_output++ = char16_t(high_surrogate);
   93|  18.1k|      *utf16_output++ = char16_t(low_surrogate);
   94|  18.1k|      pos += 4;
   95|  18.1k|    } else {
   96|       |      // we may have a continuation but we do not do error checking
   97|      0|      return 0;
   98|      0|    }
   99|  1.48M|  }
  100|  1.33k|  return utf16_output - start;
  101|  1.33k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1613convert_validILNS_10endiannessE1EPKcQsr7simdutf6detailE22indexes_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|  4.23M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 4.23M, False: 1.42k]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|  4.23M|    {                       // try to convert the next block of 8 ASCII bytes
   24|  4.23M|      if (pos + 8 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (24:11): [True: 4.23M, False: 4.23k]
  ------------------
   25|       |                            // they are ascii
   26|  4.23M|        uint64_t v;
   27|  4.23M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   28|  4.23M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (28:13): [True: 3.63M, False: 598k]
  ------------------
   29|  3.63M|          size_t final_pos = pos + 8;
   30|  32.7M|          while (pos < final_pos) {
  ------------------
  |  Branch (30:18): [True: 29.0M, False: 3.63M]
  ------------------
   31|  29.0M|            const char16_t byte = uint8_t(data[pos]);
   32|  29.0M|            *utf16_output++ =
   33|  29.0M|                !match_system(big_endian) ? u16_swap_bytes(byte) : byte;
  ------------------
  |  Branch (33:17): [True: 29.0M, Folded]
  ------------------
   34|  29.0M|            pos++;
   35|  29.0M|          }
   36|  3.63M|          continue;
   37|  3.63M|        }
   38|  4.23M|      }
   39|  4.23M|    }
   40|       |
   41|   603k|    auto leading_byte = uint8_t(data[pos]); // leading byte
   42|   603k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (42:9): [True: 332k, False: 270k]
  ------------------
   43|       |      // converting one ASCII byte !!!
   44|   332k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (44:25): [True: 332k, Folded]
  ------------------
   45|   332k|                            ? char16_t(u16_swap_bytes(leading_byte))
   46|   332k|                            : char16_t(leading_byte);
   47|   332k|      pos++;
   48|   332k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (48:16): [True: 215k, False: 55.1k]
  ------------------
   49|       |      // We have a two-byte UTF-8, it should become
   50|       |      // a single UTF-16 word.
   51|   215k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (51:11): [True: 0, False: 215k]
  ------------------
   52|      0|        break;
   53|      0|      } // minimal bound checking
   54|   215k|      uint16_t code_point = uint16_t(((leading_byte & 0b00011111) << 6) |
   55|   215k|                                     (uint8_t(data[pos + 1]) & 0b00111111));
   56|   215k|      if constexpr (!match_system(big_endian)) {
   57|   215k|        code_point = u16_swap_bytes(uint16_t(code_point));
   58|   215k|      }
   59|   215k|      *utf16_output++ = char16_t(code_point);
   60|   215k|      pos += 2;
   61|   215k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (61:16): [True: 31.6k, False: 23.4k]
  ------------------
   62|       |      // We have a three-byte UTF-8, it should become
   63|       |      // a single UTF-16 word.
   64|  31.6k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (64:11): [True: 0, False: 31.6k]
  ------------------
   65|      0|        break;
   66|      0|      } // minimal bound checking
   67|  31.6k|      uint16_t code_point =
   68|  31.6k|          uint16_t(((leading_byte & 0b00001111) << 12) |
   69|  31.6k|                   ((uint8_t(data[pos + 1]) & 0b00111111) << 6) |
   70|  31.6k|                   (uint8_t(data[pos + 2]) & 0b00111111));
   71|  31.6k|      if constexpr (!match_system(big_endian)) {
   72|  31.6k|        code_point = u16_swap_bytes(uint16_t(code_point));
   73|  31.6k|      }
   74|  31.6k|      *utf16_output++ = char16_t(code_point);
   75|  31.6k|      pos += 3;
   76|  31.6k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (76:16): [True: 23.4k, False: 0]
  ------------------
   77|       |      // we have a 4-byte UTF-8 word.
   78|  23.4k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (78:11): [True: 0, False: 23.4k]
  ------------------
   79|      0|        break;
   80|      0|      } // minimal bound checking
   81|  23.4k|      uint32_t code_point = ((leading_byte & 0b00000111) << 18) |
   82|  23.4k|                            ((uint8_t(data[pos + 1]) & 0b00111111) << 12) |
   83|  23.4k|                            ((uint8_t(data[pos + 2]) & 0b00111111) << 6) |
   84|  23.4k|                            (uint8_t(data[pos + 3]) & 0b00111111);
   85|  23.4k|      code_point -= 0x10000;
   86|  23.4k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
   87|  23.4k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
   88|  23.4k|      if constexpr (!match_system(big_endian)) {
   89|  23.4k|        high_surrogate = u16_swap_bytes(high_surrogate);
   90|  23.4k|        low_surrogate = u16_swap_bytes(low_surrogate);
   91|  23.4k|      }
   92|  23.4k|      *utf16_output++ = char16_t(high_surrogate);
   93|  23.4k|      *utf16_output++ = char16_t(low_surrogate);
   94|  23.4k|      pos += 4;
   95|  23.4k|    } else {
   96|       |      // we may have a continuation but we do not do error checking
   97|      0|      return 0;
   98|      0|    }
   99|   603k|  }
  100|  1.42k|  return utf16_output - start;
  101|  1.42k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf3230rewind_and_convert_with_errorsEmPKcmPDi:
  249|  1.58k|                                             char32_t *utf32_output) {
  250|  1.58k|  size_t extra_len{0};
  251|       |  // We potentially need to go back in time and find a leading byte.
  252|  1.58k|  size_t how_far_back = 3; // 3 bytes in the past + current position
  253|  1.58k|  if (how_far_back > prior_bytes) {
  ------------------
  |  Branch (253:7): [True: 836, False: 744]
  ------------------
  254|    836|    how_far_back = prior_bytes;
  255|    836|  }
  256|  1.58k|  bool found_leading_bytes{false};
  257|       |  // important: it is i <= how_far_back and not 'i < how_far_back'.
  258|  1.67k|  for (size_t i = 0; i <= how_far_back; i++) {
  ------------------
  |  Branch (258:22): [True: 1.59k, False: 80]
  ------------------
  259|  1.59k|    unsigned char byte = buf[-static_cast<std::ptrdiff_t>(i)];
  260|  1.59k|    found_leading_bytes = ((byte & 0b11000000) != 0b10000000);
  261|  1.59k|    if (found_leading_bytes) {
  ------------------
  |  Branch (261:9): [True: 1.50k, False: 92]
  ------------------
  262|  1.50k|      if (i > 0 && byte < 128) {
  ------------------
  |  Branch (262:11): [True: 12, False: 1.48k]
  |  Branch (262:20): [True: 12, False: 0]
  ------------------
  263|       |        // If we had to go back and the leading byte is ascii
  264|       |        // then we can stop right away.
  265|     12|        return result(error_code::TOO_LONG, 0 - i + 1);
  266|     12|      }
  267|  1.48k|      buf -= i;
  268|  1.48k|      extra_len = i;
  269|  1.48k|      break;
  270|  1.50k|    }
  271|  1.59k|  }
  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.56k|  if (!found_leading_bytes) {
  ------------------
  |  Branch (280:7): [True: 80, False: 1.48k]
  ------------------
  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|     80|    return result(error_code::TOO_LONG, 0 - how_far_back);
  286|     80|  }
  287|       |
  288|  1.48k|  result res = convert_with_errors(buf, len + extra_len, utf32_output);
  289|  1.48k|  if (res.error) {
  ------------------
  |  Branch (289:7): [True: 776, False: 712]
  ------------------
  290|    776|    res.count -= extra_len;
  291|    776|  }
  292|  1.48k|  return res;
  293|  1.56k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf3219convert_with_errorsIPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEENS_6resultES6_mPDi:
  121|  2.28k|                                               char32_t *utf32_output) {
  122|  2.28k|  size_t pos = 0;
  123|  2.28k|  char32_t *start{utf32_output};
  124|  3.11M|  while (pos < len) {
  ------------------
  |  Branch (124:10): [True: 3.11M, False: 1.07k]
  ------------------
  125|       |#if SIMDUTF_CPLUSPLUS23
  126|       |    if !consteval
  127|       |#endif
  128|  3.11M|    {
  129|       |      // try to convert the next block of 16 ASCII bytes
  130|  3.11M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (130:11): [True: 3.10M, False: 8.95k]
  ------------------
  131|       |                             // they are ascii
  132|  3.10M|        uint64_t v1;
  133|  3.10M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
  134|  3.10M|        uint64_t v2;
  135|  3.10M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  136|  3.10M|        uint64_t v{v1 | v2};
  137|  3.10M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (137:13): [True: 1.67M, False: 1.43M]
  ------------------
  138|  1.67M|          size_t final_pos = pos + 16;
  139|  28.4M|          while (pos < final_pos) {
  ------------------
  |  Branch (139:18): [True: 26.7M, False: 1.67M]
  ------------------
  140|  26.7M|            *utf32_output++ = uint8_t(data[pos]);
  141|  26.7M|            pos++;
  142|  26.7M|          }
  143|  1.67M|          continue;
  144|  1.67M|        }
  145|  3.10M|      }
  146|  3.11M|    }
  147|  1.44M|    auto leading_byte = uint8_t(data[pos]); // leading byte
  148|  1.44M|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (148:9): [True: 1.10M, False: 332k]
  ------------------
  149|       |      // converting one ASCII byte !!!
  150|  1.10M|      *utf32_output++ = char32_t(leading_byte);
  151|  1.10M|      pos++;
  152|  1.10M|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (152:16): [True: 235k, False: 97.0k]
  ------------------
  153|       |      // We have a two-byte UTF-8
  154|   235k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (154:11): [True: 60, False: 235k]
  ------------------
  155|     60|        return result(error_code::TOO_SHORT, pos);
  156|     60|      } // minimal bound checking
  157|   235k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (157:11): [True: 180, False: 234k]
  ------------------
  158|    180|        return result(error_code::TOO_SHORT, pos);
  159|    180|      }
  160|       |      // range check
  161|   234k|      uint32_t code_point = (leading_byte & 0b00011111) << 6 |
  162|   234k|                            (uint8_t(data[pos + 1]) & 0b00111111);
  163|   234k|      if (code_point < 0x80) {
  ------------------
  |  Branch (163:11): [True: 30, False: 234k]
  ------------------
  164|     30|        return result(error_code::OVERLONG, pos);
  165|     30|      }
  166|   234k|      *utf32_output++ = char32_t(code_point);
  167|   234k|      pos += 2;
  168|   234k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (168:16): [True: 72.2k, False: 24.7k]
  ------------------
  169|       |      // We have a three-byte UTF-8
  170|  72.2k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (170:11): [True: 48, False: 72.2k]
  ------------------
  171|     48|        return result(error_code::TOO_SHORT, pos);
  172|     48|      } // minimal bound checking
  173|       |
  174|  72.2k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (174:11): [True: 114, False: 72.1k]
  ------------------
  175|    114|        return result(error_code::TOO_SHORT, pos);
  176|    114|      }
  177|  72.1k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (177:11): [True: 36, False: 72.0k]
  ------------------
  178|     36|        return result(error_code::TOO_SHORT, pos);
  179|     36|      }
  180|       |      // range check
  181|  72.0k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
  182|  72.0k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 6 |
  183|  72.0k|                            (uint8_t(data[pos + 2]) & 0b00111111);
  184|  72.0k|      if (code_point < 0x800) {
  ------------------
  |  Branch (184:11): [True: 36, False: 72.0k]
  ------------------
  185|     36|        return result(error_code::OVERLONG, pos);
  186|     36|      }
  187|  72.0k|      if (0xd7ff < code_point && code_point < 0xe000) {
  ------------------
  |  Branch (187:11): [True: 2.69k, False: 69.3k]
  |  Branch (187:34): [True: 6, False: 2.69k]
  ------------------
  188|      6|        return result(error_code::SURROGATE, pos);
  189|      6|      }
  190|  72.0k|      *utf32_output++ = char32_t(code_point);
  191|  72.0k|      pos += 3;
  192|  72.0k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (192:16): [True: 24.2k, False: 472]
  ------------------
  193|       |      // we have a 4-byte UTF-8 word.
  194|  24.2k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (194:11): [True: 30, False: 24.2k]
  ------------------
  195|     30|        return result(error_code::TOO_SHORT, pos);
  196|     30|      } // minimal bound checking
  197|  24.2k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (197:11): [True: 84, False: 24.1k]
  ------------------
  198|     84|        return result(error_code::TOO_SHORT, pos);
  199|     84|      }
  200|  24.1k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (200:11): [True: 36, False: 24.1k]
  ------------------
  201|     36|        return result(error_code::TOO_SHORT, pos);
  202|     36|      }
  203|  24.1k|      if ((uint8_t(data[pos + 3]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (203:11): [True: 18, False: 24.1k]
  ------------------
  204|     18|        return result(error_code::TOO_SHORT, pos);
  205|     18|      }
  206|       |
  207|       |      // range check
  208|  24.1k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  209|  24.1k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 12 |
  210|  24.1k|                            (uint8_t(data[pos + 2]) & 0b00111111) << 6 |
  211|  24.1k|                            (uint8_t(data[pos + 3]) & 0b00111111);
  212|  24.1k|      if (code_point <= 0xffff) {
  ------------------
  |  Branch (212:11): [True: 30, False: 24.0k]
  ------------------
  213|     30|        return result(error_code::OVERLONG, pos);
  214|     30|      }
  215|  24.0k|      if (0x10ffff < code_point) {
  ------------------
  |  Branch (215:11): [True: 30, False: 24.0k]
  ------------------
  216|     30|        return result(error_code::TOO_LARGE, pos);
  217|     30|      }
  218|  24.0k|      *utf32_output++ = char32_t(code_point);
  219|  24.0k|      pos += 4;
  220|  24.0k|    } else {
  221|       |      // we either have too many continuation bytes or an invalid leading byte
  222|    472|      if ((leading_byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (222:11): [True: 244, False: 228]
  ------------------
  223|    244|        return result(error_code::TOO_LONG, pos);
  224|    244|      } else {
  225|    228|        return result(error_code::HEADER_BITS, pos);
  226|    228|      }
  227|    472|    }
  228|  1.44M|  }
  229|  1.07k|  return result(error_code::SUCCESS, utf32_output - start);
  230|  2.28k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf327convertIPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEEmS6_mPDi:
   16|  1.73k|                                   char32_t *utf32_output) {
   17|  1.73k|  size_t pos = 0;
   18|  1.73k|  char32_t *start{utf32_output};
   19|  1.95M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 1.95M, False: 764]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|  1.95M|    {
   24|       |      // try to convert the next block of 16 ASCII bytes
   25|  1.95M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 1.94M, False: 5.83k]
  ------------------
   26|       |                             // they are ascii
   27|  1.94M|        uint64_t v1;
   28|  1.94M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   29|  1.94M|        uint64_t v2;
   30|  1.94M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   31|  1.94M|        uint64_t v{v1 | v2};
   32|  1.94M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (32:13): [True: 1.16M, False: 782k]
  ------------------
   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|            *utf32_output++ = uint8_t(data[pos]);
   36|  18.6M|            pos++;
   37|  18.6M|          }
   38|  1.16M|          continue;
   39|  1.16M|        }
   40|  1.94M|      }
   41|  1.95M|    }
   42|   788k|    auto leading_byte = uint8_t(data[pos]); // leading byte
   43|   788k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (43:9): [True: 639k, False: 148k]
  ------------------
   44|       |      // converting one ASCII byte !!!
   45|   639k|      *utf32_output++ = char32_t(leading_byte);
   46|   639k|      pos++;
   47|   639k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (47:16): [True: 91.7k, False: 56.5k]
  ------------------
   48|       |      // We have a two-byte UTF-8
   49|  91.7k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (49:11): [True: 60, False: 91.7k]
  ------------------
   50|     60|        return 0;
   51|     60|      } // minimal bound checking
   52|  91.7k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (52:11): [True: 86, False: 91.6k]
  ------------------
   53|     86|        return 0;
   54|     86|      }
   55|       |      // range check
   56|  91.6k|      uint32_t code_point = (leading_byte & 0b00011111) << 6 |
   57|  91.6k|                            (uint8_t(data[pos + 1]) & 0b00111111);
   58|  91.6k|      if (code_point < 0x80) {
  ------------------
  |  Branch (58:11): [True: 36, False: 91.6k]
  ------------------
   59|     36|        return 0;
   60|     36|      }
   61|  91.6k|      *utf32_output++ = char32_t(code_point);
   62|  91.6k|      pos += 2;
   63|  91.6k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (63:16): [True: 49.7k, False: 6.74k]
  ------------------
   64|       |      // We have a three-byte UTF-8
   65|  49.7k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (65:11): [True: 54, False: 49.7k]
  ------------------
   66|     54|        return 0;
   67|     54|      } // minimal bound checking
   68|       |
   69|  49.7k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (69:11): [True: 68, False: 49.6k]
  ------------------
   70|     68|        return 0;
   71|     68|      }
   72|  49.6k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (72:11): [True: 42, False: 49.6k]
  ------------------
   73|     42|        return 0;
   74|     42|      }
   75|       |      // range check
   76|  49.6k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
   77|  49.6k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 6 |
   78|  49.6k|                            (uint8_t(data[pos + 2]) & 0b00111111);
   79|  49.6k|      if (code_point < 0x800 || (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (79:11): [True: 26, False: 49.5k]
  |  Branch (79:34): [True: 746, False: 48.8k]
  |  Branch (79:57): [True: 16, False: 730]
  ------------------
   80|     42|        return 0;
   81|     42|      }
   82|  49.5k|      *utf32_output++ = char32_t(code_point);
   83|  49.5k|      pos += 3;
   84|  49.5k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (84:16): [True: 6.37k, False: 370]
  ------------------
   85|       |      // we have a 4-byte UTF-8 word.
   86|  6.37k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (86:11): [True: 30, False: 6.34k]
  ------------------
   87|     30|        return 0;
   88|     30|      } // minimal bound checking
   89|  6.34k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (89:11): [True: 50, False: 6.29k]
  ------------------
   90|     50|        return 0;
   91|     50|      }
   92|  6.29k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (92:11): [True: 38, False: 6.25k]
  ------------------
   93|     38|        return 0;
   94|     38|      }
   95|  6.25k|      if ((uint8_t(data[pos + 3]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (95:11): [True: 16, False: 6.23k]
  ------------------
   96|     16|        return 0;
   97|     16|      }
   98|       |
   99|       |      // range check
  100|  6.23k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  101|  6.23k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 12 |
  102|  6.23k|                            (uint8_t(data[pos + 2]) & 0b00111111) << 6 |
  103|  6.23k|                            (uint8_t(data[pos + 3]) & 0b00111111);
  104|  6.23k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (104:11): [True: 56, False: 6.18k]
  |  Branch (104:35): [True: 24, False: 6.15k]
  ------------------
  105|     80|        return 0;
  106|     80|      }
  107|  6.15k|      *utf32_output++ = char32_t(code_point);
  108|  6.15k|      pos += 4;
  109|  6.15k|    } else {
  110|    370|      return 0;
  111|    370|    }
  112|   788k|  }
  113|    764|  return utf32_output - start;
  114|  1.73k|}

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

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

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

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

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

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

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

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

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoderC2Ev:
  114|  2.84k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoderC2Ev:
  114|  2.84k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder7convertILNS_10endiannessE0EEEmPKcmPDs:
  130|    720|                                       char16_t *utf16_output) {
  131|    720|    size_t pos = 0;
  132|    720|    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|    720|    size_t leading_byte = 0;
  140|    720|    size_t margin = size;
  141|  6.58k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (141:12): [True: 6.35k, False: 232]
  |  Branch (141:26): [True: 5.86k, False: 488]
  ------------------
  142|  5.86k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  143|  5.86k|    }
  144|       |    // If the input is long enough, then we have that margin-1 is the eight last
  145|       |    // leading byte.
  146|    720|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  147|   488k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (147:12): [True: 487k, False: 704]
  ------------------
  148|   487k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  149|   487k|      if (input.is_ascii()) {
  ------------------
  |  Branch (149:11): [True: 412k, False: 74.8k]
  ------------------
  150|   412k|        input.store_ascii_as_utf16<endian>(utf16_output);
  151|   412k|        utf16_output += 64;
  152|   412k|        pos += 64;
  153|   412k|      } else {
  154|       |        // you might think that a for-loop would work, but under Visual Studio,
  155|       |        // it is not good enough.
  156|  74.8k|        static_assert(
  157|  74.8k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  158|  74.8k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  159|  74.8k|            "We support either two or four chunks per 64-byte block.");
  160|  74.8k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  161|  74.8k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  162|  74.8k|          this->check_utf8_bytes(input.chunks[0], zero);
  163|  74.8k|          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|  74.8k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  171|  74.8k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (171:13): [True: 16, False: 74.8k]
  ------------------
  172|     16|          return 0; // error
  173|     16|        }
  174|  74.8k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  175|  74.8k|        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|  74.8k|        size_t max_starting_point = (pos + 64) - 12;
  180|       |        // Next loop is going to run at least five times.
  181|   730k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (181:16): [True: 655k, False: 74.8k]
  ------------------
  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|   655k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  192|   655k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  193|   655k|          pos += consumed;
  194|   655k|          utf8_end_of_code_point_mask >>= consumed;
  195|   655k|        }
  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|  74.8k|      }
  201|   487k|    }
  202|    704|    if (errors()) {
  ------------------
  |  Branch (202:9): [True: 282, False: 422]
  ------------------
  203|    282|      return 0;
  204|    282|    }
  205|    422|    if (pos < size) {
  ------------------
  |  Branch (205:9): [True: 420, False: 2]
  ------------------
  206|    420|      size_t howmany = scalar::utf8_to_utf16::convert<endian>(
  207|    420|          in + pos, size - pos, utf16_output);
  208|    420|      if (howmany == 0) {
  ------------------
  |  Branch (208:11): [True: 190, False: 230]
  ------------------
  209|    190|        return 0;
  210|    190|      }
  211|    230|      utf16_output += howmany;
  212|    230|    }
  213|    232|    return utf16_output - start;
  214|    422|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  119|   920k|                                              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|   920k|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  124|   920k|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  125|   920k|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  126|   920k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1619check_special_casesENS1_4simd5simd8IhEES5_:
    8|   920k|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|   920k|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   16|       |                                               // 11______ 11______
   17|   920k|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   18|   920k|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   19|   920k|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   20|   920k|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   21|   920k|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   22|   920k|  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|   920k|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   31|       |  // 11110101 1000____
   32|       |  // 1111011_ 1000____
   33|       |  // 11111___ 1000____
   34|   920k|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   35|       |
   36|   920k|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   37|       |      // 0_______ ________ <ASCII in byte 1>
   38|   920k|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   39|   920k|      TOO_LONG,
   40|       |      // 10______ ________ <continuation in byte 1>
   41|   920k|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   42|       |      // 1100____ ________ <two byte lead in byte 1>
   43|   920k|      TOO_SHORT | OVERLONG_2,
   44|       |      // 1101____ ________ <two byte lead in byte 1>
   45|   920k|      TOO_SHORT,
   46|       |      // 1110____ ________ <three byte lead in byte 1>
   47|   920k|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   48|       |      // 1111____ ________ <four+ byte lead in byte 1>
   49|   920k|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   50|   920k|  constexpr const uint8_t CARRY =
   51|   920k|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   52|   920k|  const simd8<uint8_t> byte_1_low =
   53|   920k|      (prev1 & 0x0F)
   54|   920k|          .lookup_16<uint8_t>(
   55|       |              // ____0000 ________
   56|   920k|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   57|       |              // ____0001 ________
   58|   920k|              CARRY | OVERLONG_2,
   59|       |              // ____001_ ________
   60|   920k|              CARRY, CARRY,
   61|       |
   62|       |              // ____0100 ________
   63|   920k|              CARRY | TOO_LARGE,
   64|       |              // ____0101 ________
   65|   920k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   66|       |              // ____011_ ________
   67|   920k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   68|   920k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|       |
   70|       |              // ____1___ ________
   71|   920k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   72|   920k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|   920k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|   920k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|   920k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|       |              // ____1101 ________
   77|   920k|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   78|   920k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   79|   920k|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   80|   920k|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   81|       |      // ________ 0_______ <ASCII in byte 2>
   82|   920k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   83|   920k|      TOO_SHORT, TOO_SHORT,
   84|       |
   85|       |      // ________ 1000____
   86|   920k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   87|   920k|          OVERLONG_4,
   88|       |      // ________ 1001____
   89|   920k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   90|       |      // ________ 101_____
   91|   920k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   92|   920k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|       |
   94|       |      // ________ 11______
   95|   920k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   96|   920k|  return (byte_1_high & byte_1_low & byte_2_high);
   97|   920k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1623check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  101|   920k|                        const simd8<uint8_t> sc) {
  102|   920k|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  103|   920k|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  104|   920k|  simd8<uint8_t> must23 =
  105|   920k|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  106|   920k|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  107|   920k|  return must23_80 ^ sc;
  108|   920k|}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder6errorsEv:
  324|   190k|  simdutf_really_inline bool errors() const {
  325|   190k|    return this->error.any_bits_set_anywhere();
  326|   190k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder7convertILNS_10endiannessE1EEEmPKcmPDs:
  130|    756|                                       char16_t *utf16_output) {
  131|    756|    size_t pos = 0;
  132|    756|    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|    756|    size_t leading_byte = 0;
  140|    756|    size_t margin = size;
  141|  7.21k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (141:12): [True: 6.96k, False: 252]
  |  Branch (141:26): [True: 6.45k, False: 504]
  ------------------
  142|  6.45k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  143|  6.45k|    }
  144|       |    // If the input is long enough, then we have that margin-1 is the eight last
  145|       |    // leading byte.
  146|    756|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  147|   544k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (147:12): [True: 544k, False: 738]
  ------------------
  148|   544k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  149|   544k|      if (input.is_ascii()) {
  ------------------
  |  Branch (149:11): [True: 346k, False: 197k]
  ------------------
  150|   346k|        input.store_ascii_as_utf16<endian>(utf16_output);
  151|   346k|        utf16_output += 64;
  152|   346k|        pos += 64;
  153|   346k|      } else {
  154|       |        // you might think that a for-loop would work, but under Visual Studio,
  155|       |        // it is not good enough.
  156|   197k|        static_assert(
  157|   197k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  158|   197k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  159|   197k|            "We support either two or four chunks per 64-byte block.");
  160|   197k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  161|   197k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  162|   197k|          this->check_utf8_bytes(input.chunks[0], zero);
  163|   197k|          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|   197k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  171|   197k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (171:13): [True: 18, False: 197k]
  ------------------
  172|     18|          return 0; // error
  173|     18|        }
  174|   197k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  175|   197k|        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|   197k|        size_t max_starting_point = (pos + 64) - 12;
  180|       |        // Next loop is going to run at least five times.
  181|  1.95M|        while (pos < max_starting_point) {
  ------------------
  |  Branch (181:16): [True: 1.76M, False: 197k]
  ------------------
  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.76M|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  192|  1.76M|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  193|  1.76M|          pos += consumed;
  194|  1.76M|          utf8_end_of_code_point_mask >>= consumed;
  195|  1.76M|        }
  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|   197k|      }
  201|   544k|    }
  202|    738|    if (errors()) {
  ------------------
  |  Branch (202:9): [True: 340, False: 398]
  ------------------
  203|    340|      return 0;
  204|    340|    }
  205|    398|    if (pos < size) {
  ------------------
  |  Branch (205:9): [True: 396, False: 2]
  ------------------
  206|    396|      size_t howmany = scalar::utf8_to_utf16::convert<endian>(
  207|    396|          in + pos, size - pos, utf16_output);
  208|    396|      if (howmany == 0) {
  ------------------
  |  Branch (208:11): [True: 200, False: 196]
  ------------------
  209|    200|        return 0;
  210|    200|      }
  211|    196|      utf16_output += howmany;
  212|    196|    }
  213|    198|    return utf16_output - start;
  214|    398|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder19convert_with_errorsILNS_10endiannessE0EEENS_6resultEPKcmPDs:
  218|    612|                                                   char16_t *utf16_output) {
  219|    612|    size_t pos = 0;
  220|    612|    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|    612|    size_t leading_byte = 0;
  228|    612|    size_t margin = size;
  229|  5.26k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (229:12): [True: 5.02k, False: 244]
  |  Branch (229:26): [True: 4.65k, False: 368]
  ------------------
  230|  4.65k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  231|  4.65k|    }
  232|       |    // If the input is long enough, then we have that margin-1 is the eight last
  233|       |    // leading byte.
  234|    612|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  235|   389k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (235:12): [True: 388k, False: 518]
  ------------------
  236|   388k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  237|   388k|      if (input.is_ascii()) {
  ------------------
  |  Branch (237:11): [True: 294k, False: 93.9k]
  ------------------
  238|   294k|        input.store_ascii_as_utf16<endian>(utf16_output);
  239|   294k|        utf16_output += 64;
  240|   294k|        pos += 64;
  241|   294k|      } else {
  242|       |        // you might think that a for-loop would work, but under Visual Studio,
  243|       |        // it is not good enough.
  244|  93.9k|        static_assert(
  245|  93.9k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  246|  93.9k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  247|  93.9k|            "We support either two or four chunks per 64-byte block.");
  248|  93.9k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  249|  93.9k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  250|  93.9k|          this->check_utf8_bytes(input.chunks[0], zero);
  251|  93.9k|          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|  93.9k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  259|  93.9k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (259:13): [True: 94, False: 93.8k]
  |  Branch (259:25): [True: 0, False: 93.8k]
  ------------------
  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|     94|          result res =
  264|     94|              scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  265|     94|                  pos, in + pos, size - pos, utf16_output);
  266|     94|          res.count += pos;
  267|     94|          return res;
  268|     94|        }
  269|  93.8k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  270|  93.8k|        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|  93.8k|        size_t max_starting_point = (pos + 64) - 12;
  275|       |        // Next loop is going to run at least five times.
  276|   926k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (276:16): [True: 832k, False: 93.8k]
  ------------------
  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|   832k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  287|   832k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  288|   832k|          pos += consumed;
  289|   832k|          utf8_end_of_code_point_mask >>= consumed;
  290|   832k|        }
  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|  93.8k|      }
  296|   388k|    }
  297|    518|    if (errors()) {
  ------------------
  |  Branch (297:9): [True: 0, False: 518]
  ------------------
  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|    518|    if (pos < size) {
  ------------------
  |  Branch (307:9): [True: 514, 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|    514|      result res =
  312|    514|          scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  313|    514|              pos, in + pos, size - pos, utf16_output);
  314|    514|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (314:11): [True: 260, False: 254]
  ------------------
  315|    260|        res.count += pos;
  316|    260|        return res;
  317|    260|      } else { // In case of success, we want the number of word written
  318|    254|        utf16_output += res.count;
  319|    254|      }
  320|    514|    }
  321|    258|    return result(error_code::SUCCESS, utf16_output - start);
  322|    518|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder19convert_with_errorsILNS_10endiannessE1EEENS_6resultEPKcmPDs:
  218|    754|                                                   char16_t *utf16_output) {
  219|    754|    size_t pos = 0;
  220|    754|    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|    754|    size_t leading_byte = 0;
  228|    754|    size_t margin = size;
  229|  6.69k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (229:12): [True: 6.44k, False: 248]
  |  Branch (229:26): [True: 5.94k, False: 506]
  ------------------
  230|  5.94k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  231|  5.94k|    }
  232|       |    // If the input is long enough, then we have that margin-1 is the eight last
  233|       |    // leading byte.
  234|    754|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  235|   429k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (235:12): [True: 429k, False: 662]
  ------------------
  236|   429k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  237|   429k|      if (input.is_ascii()) {
  ------------------
  |  Branch (237:11): [True: 335k, False: 94.0k]
  ------------------
  238|   335k|        input.store_ascii_as_utf16<endian>(utf16_output);
  239|   335k|        utf16_output += 64;
  240|   335k|        pos += 64;
  241|   335k|      } else {
  242|       |        // you might think that a for-loop would work, but under Visual Studio,
  243|       |        // it is not good enough.
  244|  94.0k|        static_assert(
  245|  94.0k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  246|  94.0k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  247|  94.0k|            "We support either two or four chunks per 64-byte block.");
  248|  94.0k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  249|  94.0k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  250|  94.0k|          this->check_utf8_bytes(input.chunks[0], zero);
  251|  94.0k|          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|  94.0k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  259|  94.0k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (259:13): [True: 92, False: 93.9k]
  |  Branch (259:25): [True: 0, False: 93.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|     92|          result res =
  264|     92|              scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  265|     92|                  pos, in + pos, size - pos, utf16_output);
  266|     92|          res.count += pos;
  267|     92|          return res;
  268|     92|        }
  269|  93.9k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  270|  93.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|  93.9k|        size_t max_starting_point = (pos + 64) - 12;
  275|       |        // Next loop is going to run at least five times.
  276|   912k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (276:16): [True: 818k, False: 93.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|   818k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  287|   818k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  288|   818k|          pos += consumed;
  289|   818k|          utf8_end_of_code_point_mask >>= consumed;
  290|   818k|        }
  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|  93.9k|      }
  296|   429k|    }
  297|    662|    if (errors()) {
  ------------------
  |  Branch (297:9): [True: 0, False: 662]
  ------------------
  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|    662|    if (pos < size) {
  ------------------
  |  Branch (307:9): [True: 658, 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|    658|      result res =
  312|    658|          scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  313|    658|              pos, in + pos, size - pos, utf16_output);
  314|    658|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (314:11): [True: 336, False: 322]
  ------------------
  315|    336|        res.count += pos;
  316|    336|        return res;
  317|    336|      } else { // In case of success, we want the number of word written
  318|    322|        utf16_output += res.count;
  319|    322|      }
  320|    658|    }
  321|    326|    return result(error_code::SUCCESS, utf16_output - start);
  322|    662|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder7convertILNS_10endiannessE0EEEmPKcmPDs:
  130|    720|                                       char16_t *utf16_output) {
  131|    720|    size_t pos = 0;
  132|    720|    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|    720|    size_t leading_byte = 0;
  140|    720|    size_t margin = size;
  141|  6.58k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (141:12): [True: 6.35k, False: 232]
  |  Branch (141:26): [True: 5.86k, False: 488]
  ------------------
  142|  5.86k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  143|  5.86k|    }
  144|       |    // If the input is long enough, then we have that margin-1 is the eight last
  145|       |    // leading byte.
  146|    720|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  147|   488k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (147:12): [True: 487k, False: 704]
  ------------------
  148|   487k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  149|   487k|      if (input.is_ascii()) {
  ------------------
  |  Branch (149:11): [True: 412k, False: 74.8k]
  ------------------
  150|   412k|        input.store_ascii_as_utf16<endian>(utf16_output);
  151|   412k|        utf16_output += 64;
  152|   412k|        pos += 64;
  153|   412k|      } else {
  154|       |        // you might think that a for-loop would work, but under Visual Studio,
  155|       |        // it is not good enough.
  156|  74.8k|        static_assert(
  157|  74.8k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  158|  74.8k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  159|  74.8k|            "We support either two or four chunks per 64-byte block.");
  160|  74.8k|        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|  74.8k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  165|  74.8k|          this->check_utf8_bytes(input.chunks[0], zero);
  166|  74.8k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  167|  74.8k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  168|  74.8k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  169|  74.8k|        }
  170|  74.8k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  171|  74.8k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (171:13): [True: 16, False: 74.8k]
  ------------------
  172|     16|          return 0; // error
  173|     16|        }
  174|  74.8k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  175|  74.8k|        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|  74.8k|        size_t max_starting_point = (pos + 64) - 12;
  180|       |        // Next loop is going to run at least five times.
  181|   730k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (181:16): [True: 655k, False: 74.8k]
  ------------------
  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|   655k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  192|   655k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  193|   655k|          pos += consumed;
  194|   655k|          utf8_end_of_code_point_mask >>= consumed;
  195|   655k|        }
  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|  74.8k|      }
  201|   487k|    }
  202|    704|    if (errors()) {
  ------------------
  |  Branch (202:9): [True: 282, False: 422]
  ------------------
  203|    282|      return 0;
  204|    282|    }
  205|    422|    if (pos < size) {
  ------------------
  |  Branch (205:9): [True: 420, False: 2]
  ------------------
  206|    420|      size_t howmany = scalar::utf8_to_utf16::convert<endian>(
  207|    420|          in + pos, size - pos, utf16_output);
  208|    420|      if (howmany == 0) {
  ------------------
  |  Branch (208:11): [True: 190, False: 230]
  ------------------
  209|    190|        return 0;
  210|    190|      }
  211|    230|      utf16_output += howmany;
  212|    230|    }
  213|    232|    return utf16_output - start;
  214|    422|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  119|  1.84M|                                              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.84M|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  124|  1.84M|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  125|  1.84M|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  126|  1.84M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1619check_special_casesENS1_4simd5simd8IhEES5_:
    8|  1.84M|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.84M|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   16|       |                                               // 11______ 11______
   17|  1.84M|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   18|  1.84M|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   19|  1.84M|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   20|  1.84M|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   21|  1.84M|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   22|  1.84M|  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.84M|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   31|       |  // 11110101 1000____
   32|       |  // 1111011_ 1000____
   33|       |  // 11111___ 1000____
   34|  1.84M|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   35|       |
   36|  1.84M|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   37|       |      // 0_______ ________ <ASCII in byte 1>
   38|  1.84M|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   39|  1.84M|      TOO_LONG,
   40|       |      // 10______ ________ <continuation in byte 1>
   41|  1.84M|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   42|       |      // 1100____ ________ <two byte lead in byte 1>
   43|  1.84M|      TOO_SHORT | OVERLONG_2,
   44|       |      // 1101____ ________ <two byte lead in byte 1>
   45|  1.84M|      TOO_SHORT,
   46|       |      // 1110____ ________ <three byte lead in byte 1>
   47|  1.84M|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   48|       |      // 1111____ ________ <four+ byte lead in byte 1>
   49|  1.84M|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   50|  1.84M|  constexpr const uint8_t CARRY =
   51|  1.84M|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   52|  1.84M|  const simd8<uint8_t> byte_1_low =
   53|  1.84M|      (prev1 & 0x0F)
   54|  1.84M|          .lookup_16<uint8_t>(
   55|       |              // ____0000 ________
   56|  1.84M|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   57|       |              // ____0001 ________
   58|  1.84M|              CARRY | OVERLONG_2,
   59|       |              // ____001_ ________
   60|  1.84M|              CARRY, CARRY,
   61|       |
   62|       |              // ____0100 ________
   63|  1.84M|              CARRY | TOO_LARGE,
   64|       |              // ____0101 ________
   65|  1.84M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   66|       |              // ____011_ ________
   67|  1.84M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   68|  1.84M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|       |
   70|       |              // ____1___ ________
   71|  1.84M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   72|  1.84M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|  1.84M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|  1.84M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|  1.84M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|       |              // ____1101 ________
   77|  1.84M|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   78|  1.84M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   79|  1.84M|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   80|  1.84M|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   81|       |      // ________ 0_______ <ASCII in byte 2>
   82|  1.84M|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   83|  1.84M|      TOO_SHORT, TOO_SHORT,
   84|       |
   85|       |      // ________ 1000____
   86|  1.84M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   87|  1.84M|          OVERLONG_4,
   88|       |      // ________ 1001____
   89|  1.84M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   90|       |      // ________ 101_____
   91|  1.84M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   92|  1.84M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|       |
   94|       |      // ________ 11______
   95|  1.84M|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   96|  1.84M|  return (byte_1_high & byte_1_low & byte_2_high);
   97|  1.84M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1623check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  101|  1.84M|                        const simd8<uint8_t> sc) {
  102|  1.84M|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  103|  1.84M|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  104|  1.84M|  simd8<uint8_t> must23 =
  105|  1.84M|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  106|  1.84M|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  107|  1.84M|  return must23_80 ^ sc;
  108|  1.84M|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder6errorsEv:
  324|   190k|  simdutf_really_inline bool errors() const {
  325|   190k|    return this->error.any_bits_set_anywhere();
  326|   190k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder7convertILNS_10endiannessE1EEEmPKcmPDs:
  130|    756|                                       char16_t *utf16_output) {
  131|    756|    size_t pos = 0;
  132|    756|    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|    756|    size_t leading_byte = 0;
  140|    756|    size_t margin = size;
  141|  7.21k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (141:12): [True: 6.96k, False: 252]
  |  Branch (141:26): [True: 6.45k, False: 504]
  ------------------
  142|  6.45k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  143|  6.45k|    }
  144|       |    // If the input is long enough, then we have that margin-1 is the eight last
  145|       |    // leading byte.
  146|    756|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  147|   544k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (147:12): [True: 544k, False: 738]
  ------------------
  148|   544k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  149|   544k|      if (input.is_ascii()) {
  ------------------
  |  Branch (149:11): [True: 346k, False: 197k]
  ------------------
  150|   346k|        input.store_ascii_as_utf16<endian>(utf16_output);
  151|   346k|        utf16_output += 64;
  152|   346k|        pos += 64;
  153|   346k|      } else {
  154|       |        // you might think that a for-loop would work, but under Visual Studio,
  155|       |        // it is not good enough.
  156|   197k|        static_assert(
  157|   197k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  158|   197k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  159|   197k|            "We support either two or four chunks per 64-byte block.");
  160|   197k|        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|   197k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  165|   197k|          this->check_utf8_bytes(input.chunks[0], zero);
  166|   197k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  167|   197k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  168|   197k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  169|   197k|        }
  170|   197k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  171|   197k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (171:13): [True: 18, False: 197k]
  ------------------
  172|     18|          return 0; // error
  173|     18|        }
  174|   197k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  175|   197k|        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|   197k|        size_t max_starting_point = (pos + 64) - 12;
  180|       |        // Next loop is going to run at least five times.
  181|  1.95M|        while (pos < max_starting_point) {
  ------------------
  |  Branch (181:16): [True: 1.76M, False: 197k]
  ------------------
  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.76M|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  192|  1.76M|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  193|  1.76M|          pos += consumed;
  194|  1.76M|          utf8_end_of_code_point_mask >>= consumed;
  195|  1.76M|        }
  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|   197k|      }
  201|   544k|    }
  202|    738|    if (errors()) {
  ------------------
  |  Branch (202:9): [True: 340, False: 398]
  ------------------
  203|    340|      return 0;
  204|    340|    }
  205|    398|    if (pos < size) {
  ------------------
  |  Branch (205:9): [True: 396, False: 2]
  ------------------
  206|    396|      size_t howmany = scalar::utf8_to_utf16::convert<endian>(
  207|    396|          in + pos, size - pos, utf16_output);
  208|    396|      if (howmany == 0) {
  ------------------
  |  Branch (208:11): [True: 200, False: 196]
  ------------------
  209|    200|        return 0;
  210|    200|      }
  211|    196|      utf16_output += howmany;
  212|    196|    }
  213|    198|    return utf16_output - start;
  214|    398|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder19convert_with_errorsILNS_10endiannessE0EEENS_6resultEPKcmPDs:
  218|    612|                                                   char16_t *utf16_output) {
  219|    612|    size_t pos = 0;
  220|    612|    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|    612|    size_t leading_byte = 0;
  228|    612|    size_t margin = size;
  229|  5.26k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (229:12): [True: 5.02k, False: 244]
  |  Branch (229:26): [True: 4.65k, False: 368]
  ------------------
  230|  4.65k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  231|  4.65k|    }
  232|       |    // If the input is long enough, then we have that margin-1 is the eight last
  233|       |    // leading byte.
  234|    612|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  235|   389k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (235:12): [True: 388k, False: 518]
  ------------------
  236|   388k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  237|   388k|      if (input.is_ascii()) {
  ------------------
  |  Branch (237:11): [True: 294k, False: 93.9k]
  ------------------
  238|   294k|        input.store_ascii_as_utf16<endian>(utf16_output);
  239|   294k|        utf16_output += 64;
  240|   294k|        pos += 64;
  241|   294k|      } else {
  242|       |        // you might think that a for-loop would work, but under Visual Studio,
  243|       |        // it is not good enough.
  244|  93.9k|        static_assert(
  245|  93.9k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  246|  93.9k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  247|  93.9k|            "We support either two or four chunks per 64-byte block.");
  248|  93.9k|        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|  93.9k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  253|  93.9k|          this->check_utf8_bytes(input.chunks[0], zero);
  254|  93.9k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  255|  93.9k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  256|  93.9k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  257|  93.9k|        }
  258|  93.9k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  259|  93.9k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (259:13): [True: 94, False: 93.8k]
  |  Branch (259:25): [True: 0, False: 93.8k]
  ------------------
  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|     94|          result res =
  264|     94|              scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  265|     94|                  pos, in + pos, size - pos, utf16_output);
  266|     94|          res.count += pos;
  267|     94|          return res;
  268|     94|        }
  269|  93.8k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  270|  93.8k|        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|  93.8k|        size_t max_starting_point = (pos + 64) - 12;
  275|       |        // Next loop is going to run at least five times.
  276|   926k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (276:16): [True: 832k, False: 93.8k]
  ------------------
  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|   832k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  287|   832k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  288|   832k|          pos += consumed;
  289|   832k|          utf8_end_of_code_point_mask >>= consumed;
  290|   832k|        }
  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|  93.8k|      }
  296|   388k|    }
  297|    518|    if (errors()) {
  ------------------
  |  Branch (297:9): [True: 0, False: 518]
  ------------------
  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|    518|    if (pos < size) {
  ------------------
  |  Branch (307:9): [True: 514, 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|    514|      result res =
  312|    514|          scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  313|    514|              pos, in + pos, size - pos, utf16_output);
  314|    514|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (314:11): [True: 260, False: 254]
  ------------------
  315|    260|        res.count += pos;
  316|    260|        return res;
  317|    260|      } else { // In case of success, we want the number of word written
  318|    254|        utf16_output += res.count;
  319|    254|      }
  320|    514|    }
  321|    258|    return result(error_code::SUCCESS, utf16_output - start);
  322|    518|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder19convert_with_errorsILNS_10endiannessE1EEENS_6resultEPKcmPDs:
  218|    754|                                                   char16_t *utf16_output) {
  219|    754|    size_t pos = 0;
  220|    754|    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|    754|    size_t leading_byte = 0;
  228|    754|    size_t margin = size;
  229|  6.69k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (229:12): [True: 6.44k, False: 248]
  |  Branch (229:26): [True: 5.94k, False: 506]
  ------------------
  230|  5.94k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  231|  5.94k|    }
  232|       |    // If the input is long enough, then we have that margin-1 is the eight last
  233|       |    // leading byte.
  234|    754|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  235|   429k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (235:12): [True: 429k, False: 662]
  ------------------
  236|   429k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  237|   429k|      if (input.is_ascii()) {
  ------------------
  |  Branch (237:11): [True: 335k, False: 94.0k]
  ------------------
  238|   335k|        input.store_ascii_as_utf16<endian>(utf16_output);
  239|   335k|        utf16_output += 64;
  240|   335k|        pos += 64;
  241|   335k|      } else {
  242|       |        // you might think that a for-loop would work, but under Visual Studio,
  243|       |        // it is not good enough.
  244|  94.0k|        static_assert(
  245|  94.0k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  246|  94.0k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  247|  94.0k|            "We support either two or four chunks per 64-byte block.");
  248|  94.0k|        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|  94.0k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  253|  94.0k|          this->check_utf8_bytes(input.chunks[0], zero);
  254|  94.0k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  255|  94.0k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  256|  94.0k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  257|  94.0k|        }
  258|  94.0k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  259|  94.0k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (259:13): [True: 92, False: 93.9k]
  |  Branch (259:25): [True: 0, False: 93.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|     92|          result res =
  264|     92|              scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  265|     92|                  pos, in + pos, size - pos, utf16_output);
  266|     92|          res.count += pos;
  267|     92|          return res;
  268|     92|        }
  269|  93.9k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  270|  93.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|  93.9k|        size_t max_starting_point = (pos + 64) - 12;
  275|       |        // Next loop is going to run at least five times.
  276|   912k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (276:16): [True: 818k, False: 93.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|   818k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  287|   818k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  288|   818k|          pos += consumed;
  289|   818k|          utf8_end_of_code_point_mask >>= consumed;
  290|   818k|        }
  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|  93.9k|      }
  296|   429k|    }
  297|    662|    if (errors()) {
  ------------------
  |  Branch (297:9): [True: 0, False: 662]
  ------------------
  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|    662|    if (pos < size) {
  ------------------
  |  Branch (307:9): [True: 658, 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|    658|      result res =
  312|    658|          scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  313|    658|              pos, in + pos, size - pos, utf16_output);
  314|    658|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (314:11): [True: 336, False: 322]
  ------------------
  315|    336|        res.count += pos;
  316|    336|        return res;
  317|    336|      } else { // In case of success, we want the number of word written
  318|    322|        utf16_output += res.count;
  319|    322|      }
  320|    658|    }
  321|    326|    return result(error_code::SUCCESS, utf16_output - start);
  322|    662|  }

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

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

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

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

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE0EEEKNS_6resultEPKDsm:
   49|  2.78k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  2.78k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.78k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 17, False: 2.77k]
  |  |  ------------------
  ------------------
   51|     17|    return result(error_code::SUCCESS, 0);
   52|     17|  }
   53|       |
   54|  2.77k|  const char16_t *start = input;
   55|  2.77k|  const char16_t *end = input + size;
   56|       |
   57|  2.77k|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|  2.77k|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|  2.77k|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|  2.77k|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|  2.67M|  while (input + simd16<uint16_t>::SIZE * 2 < end) {
  ------------------
  |  Branch (62:10): [True: 2.67M, False: 2.53k]
  ------------------
   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.67M|    auto in0 = simd16<uint16_t>(input);
   67|  2.67M|    auto in1 =
   68|  2.67M|        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.67M|    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.67M|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   76|  2.67M|    const uint16_t surrogates_bitmask =
   77|  2.67M|        static_cast<uint16_t>(surrogates_wordmask.to_bitmask());
   78|  2.67M|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (78:9): [True: 2.64M, False: 25.9k]
  ------------------
   79|  2.64M|      input += 16;
   80|  2.64M|    } 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|  25.9k|      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|  25.9k|      const auto vH = (in & v_fc) == v_dc;
   93|  25.9k|      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|  25.9k|      const uint16_t L = static_cast<uint16_t>(~H & surrogates_bitmask);
   98|       |
   99|  25.9k|      const uint16_t a = static_cast<uint16_t>(
  100|  25.9k|          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|  25.9k|      const uint16_t b = static_cast<uint16_t>(
  104|  25.9k|          a << 1); // Just mark that the opinput - startite fact is hold,
  105|       |                   // thanks to that we have only two masks for valid case.
  106|  25.9k|      const uint16_t c = static_cast<uint16_t>(
  107|  25.9k|          V | a | b); // Combine all the masks into the final one.
  108|       |
  109|  25.9k|      if (c == 0xffff) {
  ------------------
  |  Branch (109:11): [True: 19.0k, False: 6.88k]
  ------------------
  110|       |        // The whole input register contains valid UTF-16, i.e.,
  111|       |        // either single code units or proper surrogate pairs.
  112|  19.0k|        input += 16;
  113|  19.0k|      } else if (c == 0x7fff) {
  ------------------
  |  Branch (113:18): [True: 6.64k, False: 240]
  ------------------
  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|  6.64k|        input += 15;
  119|  6.64k|      } else {
  120|    240|        return result(error_code::SURROGATE, input - start);
  121|    240|      }
  122|  25.9k|    }
  123|  2.67M|  }
  124|       |
  125|  2.53k|  return result(error_code::SUCCESS, input - start);
  126|  2.77k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE1EEEKNS_6resultEPKDsm:
   49|  2.60k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  2.60k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.60k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 16, False: 2.58k]
  |  |  ------------------
  ------------------
   51|     16|    return result(error_code::SUCCESS, 0);
   52|     16|  }
   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.67M|  while (input + simd16<uint16_t>::SIZE * 2 < end) {
  ------------------
  |  Branch (62:10): [True: 2.66M, False: 2.40k]
  ------------------
   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.66M|    auto in0 = simd16<uint16_t>(input);
   67|  2.66M|    auto in1 =
   68|  2.66M|        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.66M|    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.66M|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   76|  2.66M|    const uint16_t surrogates_bitmask =
   77|  2.66M|        static_cast<uint16_t>(surrogates_wordmask.to_bitmask());
   78|  2.66M|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (78:9): [True: 2.63M, False: 36.8k]
  ------------------
   79|  2.63M|      input += 16;
   80|  2.63M|    } 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|  36.8k|      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|  36.8k|      const auto vH = (in & v_fc) == v_dc;
   93|  36.8k|      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|  36.8k|      const uint16_t L = static_cast<uint16_t>(~H & surrogates_bitmask);
   98|       |
   99|  36.8k|      const uint16_t a = static_cast<uint16_t>(
  100|  36.8k|          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|  36.8k|      const uint16_t b = static_cast<uint16_t>(
  104|  36.8k|          a << 1); // Just mark that the opinput - startite fact is hold,
  105|       |                   // thanks to that we have only two masks for valid case.
  106|  36.8k|      const uint16_t c = static_cast<uint16_t>(
  107|  36.8k|          V | a | b); // Combine all the masks into the final one.
  108|       |
  109|  36.8k|      if (c == 0xffff) {
  ------------------
  |  Branch (109:11): [True: 31.0k, False: 5.85k]
  ------------------
  110|       |        // The whole input register contains valid UTF-16, i.e.,
  111|       |        // either single code units or proper surrogate pairs.
  112|  31.0k|        input += 16;
  113|  31.0k|      } else if (c == 0x7fff) {
  ------------------
  |  Branch (113:18): [True: 5.66k, False: 188]
  ------------------
  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.66k|        input += 15;
  119|  5.66k|      } else {
  120|    188|        return result(error_code::SURROGATE, input - start);
  121|    188|      }
  122|  36.8k|    }
  123|  2.66M|  }
  124|       |
  125|  2.40k|  return result(error_code::SUCCESS, input - start);
  126|  2.58k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE0EEEKNS_6resultEPKDsm:
   49|  2.78k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  2.78k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.78k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 17, False: 2.77k]
  |  |  ------------------
  ------------------
   51|     17|    return result(error_code::SUCCESS, 0);
   52|     17|  }
   53|       |
   54|  2.77k|  const char16_t *start = input;
   55|  2.77k|  const char16_t *end = input + size;
   56|       |
   57|  2.77k|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|  2.77k|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|  2.77k|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|  2.77k|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|  2.67M|  while (input + simd16<uint16_t>::SIZE * 2 < end) {
  ------------------
  |  Branch (62:10): [True: 2.67M, False: 2.44k]
  ------------------
   63|       |    // 0. Load data: since the validation takes into account only higher
   64|       |    //    byte of each word, we compress the two vectors into one which
   65|       |    //    consists only the higher bytes.
   66|  2.67M|    auto in0 = simd16<uint16_t>(input);
   67|  2.67M|    auto in1 =
   68|  2.67M|        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.67M|    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.67M|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   76|  2.67M|    const uint16_t surrogates_bitmask =
   77|  2.67M|        static_cast<uint16_t>(surrogates_wordmask.to_bitmask());
   78|  2.67M|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (78:9): [True: 2.64M, False: 26.4k]
  ------------------
   79|  2.64M|      input += 16;
   80|  2.64M|    } 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|  26.4k|      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|  26.4k|      const auto vH = (in & v_fc) == v_dc;
   93|  26.4k|      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|  26.4k|      const uint16_t L = static_cast<uint16_t>(~H & surrogates_bitmask);
   98|       |
   99|  26.4k|      const uint16_t a = static_cast<uint16_t>(
  100|  26.4k|          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|  26.4k|      const uint16_t b = static_cast<uint16_t>(
  104|  26.4k|          a << 1); // Just mark that the opinput - startite fact is hold,
  105|       |                   // thanks to that we have only two masks for valid case.
  106|  26.4k|      const uint16_t c = static_cast<uint16_t>(
  107|  26.4k|          V | a | b); // Combine all the masks into the final one.
  108|       |
  109|  26.4k|      if (c == 0xffff) {
  ------------------
  |  Branch (109:11): [True: 19.3k, False: 7.05k]
  ------------------
  110|       |        // The whole input register contains valid UTF-16, i.e.,
  111|       |        // either single code units or proper surrogate pairs.
  112|  19.3k|        input += 16;
  113|  19.3k|      } else if (c == 0x7fff) {
  ------------------
  |  Branch (113:18): [True: 6.72k, False: 330]
  ------------------
  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|  6.72k|        input += 15;
  119|  6.72k|      } else {
  120|    330|        return result(error_code::SURROGATE, input - start);
  121|    330|      }
  122|  26.4k|    }
  123|  2.67M|  }
  124|       |
  125|  2.44k|  return result(error_code::SUCCESS, input - start);
  126|  2.77k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE1EEEKNS_6resultEPKDsm:
   49|  2.60k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  2.60k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.60k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 16, False: 2.58k]
  |  |  ------------------
  ------------------
   51|     16|    return result(error_code::SUCCESS, 0);
   52|     16|  }
   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.67M|  while (input + simd16<uint16_t>::SIZE * 2 < end) {
  ------------------
  |  Branch (62:10): [True: 2.67M, False: 2.35k]
  ------------------
   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.67M|    auto in0 = simd16<uint16_t>(input);
   67|  2.67M|    auto in1 =
   68|  2.67M|        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.67M|    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.67M|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   76|  2.67M|    const uint16_t surrogates_bitmask =
   77|  2.67M|        static_cast<uint16_t>(surrogates_wordmask.to_bitmask());
   78|  2.67M|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (78:9): [True: 2.63M, False: 37.2k]
  ------------------
   79|  2.63M|      input += 16;
   80|  2.63M|    } 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|  37.2k|      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|  37.2k|      const auto vH = (in & v_fc) == v_dc;
   93|  37.2k|      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|  37.2k|      const uint16_t L = static_cast<uint16_t>(~H & surrogates_bitmask);
   98|       |
   99|  37.2k|      const uint16_t a = static_cast<uint16_t>(
  100|  37.2k|          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|  37.2k|      const uint16_t b = static_cast<uint16_t>(
  104|  37.2k|          a << 1); // Just mark that the opinput - startite fact is hold,
  105|       |                   // thanks to that we have only two masks for valid case.
  106|  37.2k|      const uint16_t c = static_cast<uint16_t>(
  107|  37.2k|          V | a | b); // Combine all the masks into the final one.
  108|       |
  109|  37.2k|      if (c == 0xffff) {
  ------------------
  |  Branch (109:11): [True: 31.2k, False: 6.00k]
  ------------------
  110|       |        // The whole input register contains valid UTF-16, i.e.,
  111|       |        // either single code units or proper surrogate pairs.
  112|  31.2k|        input += 16;
  113|  31.2k|      } else if (c == 0x7fff) {
  ------------------
  |  Branch (113:18): [True: 5.76k, False: 238]
  ------------------
  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.76k|        input += 15;
  119|  5.76k|      } else {
  120|    238|        return result(error_code::SURROGATE, input - start);
  121|    238|      }
  122|  37.2k|    }
  123|  2.67M|  }
  124|       |
  125|  2.35k|  return result(error_code::SUCCESS, input - start);
  126|  2.58k|}

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

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

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

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

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_127avx2_convert_utf16_to_utf32ILNS_10endiannessE0EEENSt3__14pairIPKDsPDiEES7_mS8_:
   57|    412|                            char32_t *utf32_output) {
   58|    412|  const char16_t *end = buf + len;
   59|    412|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
   60|    412|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
   61|       |
   62|   146k|  while (end - buf >= 16) {
  ------------------
  |  Branch (62:10): [True: 146k, False: 310]
  ------------------
   63|   146k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
   64|   146k|    if (big_endian) {
  ------------------
  |  Branch (64:9): [Folded, False: 146k]
  ------------------
   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|   146k|    const __m256i surrogates_bytemask =
   75|   146k|        _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|   146k|    const uint32_t surrogates_bitmask =
   80|   146k|        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|   146k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (83:9): [True: 142k, False: 4.45k]
  ------------------
   84|       |      // case: we extend all sixteen 16-bit code units to sixteen 32-bit code
   85|       |      // units
   86|   142k|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
   87|   142k|                          _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in)));
   88|   142k|      _mm256_storeu_si256(
   89|   142k|          reinterpret_cast<__m256i *>(utf32_output + 8),
   90|   142k|          _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1)));
   91|   142k|      utf32_output += 16;
   92|   142k|      buf += 16;
   93|       |      // surrogate pair(s) in a register
   94|   142k|    } else {
   95|       |      // Let us do a scalar fallback.
   96|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
   97|       |      // in the presence of surrogate pairs may require non-trivial tables.
   98|  4.45k|      size_t forward = 15;
   99|  4.45k|      size_t k = 0;
  100|  4.45k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (100:11): [True: 0, False: 4.45k]
  ------------------
  101|      0|        forward = size_t(end - buf - 1);
  102|      0|      }
  103|  65.1k|      for (; k < forward; k++) {
  ------------------
  |  Branch (103:14): [True: 60.7k, False: 4.34k]
  ------------------
  104|  60.7k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  105|  60.7k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (105:13): [True: 55.3k, False: 5.39k]
  ------------------
  106|       |          // No surrogate pair
  107|  55.3k|          *utf32_output++ = char32_t(word);
  108|  55.3k|        } else {
  109|       |          // must be a surrogate pair
  110|  5.39k|          uint16_t diff = uint16_t(word - 0xD800);
  111|  5.39k|          uint16_t next_word =
  112|  5.39k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  113|  5.39k|          k++;
  114|  5.39k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  115|  5.39k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (115:15): [True: 102, False: 5.29k]
  ------------------
  116|    102|            return std::make_pair(nullptr, utf32_output);
  117|    102|          }
  118|  5.29k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  119|  5.29k|          *utf32_output++ = char32_t(value);
  120|  5.29k|        }
  121|  60.7k|      }
  122|  4.34k|      buf += k;
  123|  4.34k|    }
  124|   146k|  } // while
  125|    310|  return std::make_pair(buf, utf32_output);
  126|    412|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_127avx2_convert_utf16_to_utf32ILNS_10endiannessE1EEENSt3__14pairIPKDsPDiEES7_mS8_:
   57|    392|                            char32_t *utf32_output) {
   58|    392|  const char16_t *end = buf + len;
   59|    392|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
   60|    392|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
   61|       |
   62|   312k|  while (end - buf >= 16) {
  ------------------
  |  Branch (62:10): [True: 311k, False: 338]
  ------------------
   63|   311k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
   64|   311k|    if (big_endian) {
  ------------------
  |  Branch (64:9): [True: 311k, Folded]
  ------------------
   65|   311k|      const __m256i swap = _mm256_setr_epi8(
   66|   311k|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   67|   311k|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   68|   311k|      in = _mm256_shuffle_epi8(in, swap);
   69|   311k|    }
   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|   311k|    const __m256i surrogates_bytemask =
   75|   311k|        _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|   311k|    const uint32_t surrogates_bitmask =
   80|   311k|        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|   311k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (83:9): [True: 310k, False: 1.68k]
  ------------------
   84|       |      // case: we extend all sixteen 16-bit code units to sixteen 32-bit code
   85|       |      // units
   86|   310k|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
   87|   310k|                          _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in)));
   88|   310k|      _mm256_storeu_si256(
   89|   310k|          reinterpret_cast<__m256i *>(utf32_output + 8),
   90|   310k|          _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1)));
   91|   310k|      utf32_output += 16;
   92|   310k|      buf += 16;
   93|       |      // surrogate pair(s) in a register
   94|   310k|    } 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.68k|      size_t forward = 15;
   99|  1.68k|      size_t k = 0;
  100|  1.68k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (100:11): [True: 0, False: 1.68k]
  ------------------
  101|      0|        forward = size_t(end - buf - 1);
  102|      0|      }
  103|  24.2k|      for (; k < forward; k++) {
  ------------------
  |  Branch (103:14): [True: 22.6k, False: 1.62k]
  ------------------
  104|  22.6k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  105|  22.6k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (105:13): [True: 20.3k, False: 2.27k]
  ------------------
  106|       |          // No surrogate pair
  107|  20.3k|          *utf32_output++ = char32_t(word);
  108|  20.3k|        } else {
  109|       |          // must be a surrogate pair
  110|  2.27k|          uint16_t diff = uint16_t(word - 0xD800);
  111|  2.27k|          uint16_t next_word =
  112|  2.27k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  113|  2.27k|          k++;
  114|  2.27k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  115|  2.27k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (115:15): [True: 54, False: 2.22k]
  ------------------
  116|     54|            return std::make_pair(nullptr, utf32_output);
  117|     54|          }
  118|  2.22k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  119|  2.22k|          *utf32_output++ = char32_t(value);
  120|  2.22k|        }
  121|  22.6k|      }
  122|  1.62k|      buf += k;
  123|  1.62k|    }
  124|   311k|  } // while
  125|    338|  return std::make_pair(buf, utf32_output);
  126|    392|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_139avx2_convert_utf16_to_utf32_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPDiEEPKDsmS7_:
  138|    418|                                        char32_t *utf32_output) {
  139|    418|  const char16_t *start = buf;
  140|    418|  const char16_t *end = buf + len;
  141|    418|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
  142|    418|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
  143|       |
  144|   269k|  while (end - buf >= 16) {
  ------------------
  |  Branch (144:10): [True: 269k, False: 272]
  ------------------
  145|   269k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
  146|   269k|    if (big_endian) {
  ------------------
  |  Branch (146:9): [Folded, False: 269k]
  ------------------
  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|   269k|    const __m256i surrogates_bytemask =
  157|   269k|        _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|   269k|    const uint32_t surrogates_bitmask =
  162|   269k|        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|   269k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (165:9): [True: 259k, False: 9.65k]
  ------------------
  166|       |      // case: we extend all sixteen 16-bit code units to sixteen 32-bit code
  167|       |      // units
  168|   259k|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
  169|   259k|                          _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in)));
  170|   259k|      _mm256_storeu_si256(
  171|   259k|          reinterpret_cast<__m256i *>(utf32_output + 8),
  172|   259k|          _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1)));
  173|   259k|      utf32_output += 16;
  174|   259k|      buf += 16;
  175|       |      // surrogate pair(s) in a register
  176|   259k|    } 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|  9.65k|      size_t forward = 15;
  181|  9.65k|      size_t k = 0;
  182|  9.65k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (182:11): [True: 0, False: 9.65k]
  ------------------
  183|      0|        forward = size_t(end - buf - 1);
  184|      0|      }
  185|   139k|      for (; k < forward; k++) {
  ------------------
  |  Branch (185:14): [True: 129k, False: 9.50k]
  ------------------
  186|   129k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  187|   129k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (187:13): [True: 115k, False: 14.7k]
  ------------------
  188|       |          // No surrogate pair
  189|   115k|          *utf32_output++ = char32_t(word);
  190|   115k|        } else {
  191|       |          // must be a surrogate pair
  192|  14.7k|          uint16_t diff = uint16_t(word - 0xD800);
  193|  14.7k|          uint16_t next_word =
  194|  14.7k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  195|  14.7k|          k++;
  196|  14.7k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  197|  14.7k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (197:15): [True: 146, False: 14.5k]
  ------------------
  198|    146|            return std::make_pair(
  199|    146|                result(error_code::SURROGATE, buf - start + k - 1),
  200|    146|                utf32_output);
  201|    146|          }
  202|  14.5k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  203|  14.5k|          *utf32_output++ = char32_t(value);
  204|  14.5k|        }
  205|   129k|      }
  206|  9.50k|      buf += k;
  207|  9.50k|    }
  208|   269k|  } // while
  209|    272|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output);
  210|    418|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_139avx2_convert_utf16_to_utf32_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPDiEEPKDsmS7_:
  138|    346|                                        char32_t *utf32_output) {
  139|    346|  const char16_t *start = buf;
  140|    346|  const char16_t *end = buf + len;
  141|    346|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
  142|    346|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
  143|       |
  144|   158k|  while (end - buf >= 16) {
  ------------------
  |  Branch (144:10): [True: 158k, False: 270]
  ------------------
  145|   158k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
  146|   158k|    if (big_endian) {
  ------------------
  |  Branch (146:9): [True: 158k, Folded]
  ------------------
  147|   158k|      const __m256i swap = _mm256_setr_epi8(
  148|   158k|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
  149|   158k|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
  150|   158k|      in = _mm256_shuffle_epi8(in, swap);
  151|   158k|    }
  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|   158k|    const __m256i surrogates_bytemask =
  157|   158k|        _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|   158k|    const uint32_t surrogates_bitmask =
  162|   158k|        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|   158k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (165:9): [True: 152k, False: 5.85k]
  ------------------
  166|       |      // case: we extend all sixteen 16-bit code units to sixteen 32-bit code
  167|       |      // units
  168|   152k|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
  169|   152k|                          _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in)));
  170|   152k|      _mm256_storeu_si256(
  171|   152k|          reinterpret_cast<__m256i *>(utf32_output + 8),
  172|   152k|          _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1)));
  173|   152k|      utf32_output += 16;
  174|   152k|      buf += 16;
  175|       |      // surrogate pair(s) in a register
  176|   152k|    } else {
  177|       |      // Let us do a scalar fallback.
  178|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
  179|       |      // in the presence of surrogate pairs may require non-trivial tables.
  180|  5.85k|      size_t forward = 15;
  181|  5.85k|      size_t k = 0;
  182|  5.85k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (182:11): [True: 0, False: 5.85k]
  ------------------
  183|      0|        forward = size_t(end - buf - 1);
  184|      0|      }
  185|  83.5k|      for (; k < forward; k++) {
  ------------------
  |  Branch (185:14): [True: 77.7k, False: 5.78k]
  ------------------
  186|  77.7k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  187|  77.7k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (187:13): [True: 67.4k, False: 10.2k]
  ------------------
  188|       |          // No surrogate pair
  189|  67.4k|          *utf32_output++ = char32_t(word);
  190|  67.4k|        } else {
  191|       |          // must be a surrogate pair
  192|  10.2k|          uint16_t diff = uint16_t(word - 0xD800);
  193|  10.2k|          uint16_t next_word =
  194|  10.2k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  195|  10.2k|          k++;
  196|  10.2k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  197|  10.2k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (197:15): [True: 76, False: 10.2k]
  ------------------
  198|     76|            return std::make_pair(
  199|     76|                result(error_code::SURROGATE, buf - start + k - 1),
  200|     76|                utf32_output);
  201|     76|          }
  202|  10.2k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  203|  10.2k|          *utf32_output++ = char32_t(value);
  204|  10.2k|        }
  205|  77.7k|      }
  206|  5.78k|      buf += k;
  207|  5.78k|    }
  208|   158k|  } // while
  209|    270|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output);
  210|    346|}

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

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_127avx2_convert_utf32_to_utf16ILNS_10endiannessE0EEENSt3__14pairIPKDiPDsEES7_mS8_:
    4|    774|                            char16_t *utf16_output) {
    5|    774|  const char32_t *end = buf + len;
    6|       |
    7|    774|  const size_t safety_margin =
    8|    774|      12; // to avoid overruns, see issue
    9|       |          // https://github.com/simdutf/simdutf/issues/92
   10|    774|  __m256i forbidden_bytemask = _mm256_setzero_si256();
   11|       |
   12|    774|  const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000);
   13|    774|  const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800);
   14|    774|  const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800);
   15|       |
   16|   133k|  while (end - buf >= std::ptrdiff_t(8 + safety_margin)) {
  ------------------
  |  Branch (16:10): [True: 132k, False: 624]
  ------------------
   17|   132k|    const __m256i in = _mm256_loadu_si256((__m256i *)buf);
   18|       |
   19|   132k|    if (simdutf_likely(_mm256_testz_si256(in, v_ffff0000))) {
  ------------------
  |  |   90|   132k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 130k, False: 2.72k]
  |  |  ------------------
  ------------------
   20|       |      // no bits set above 16th bit <=> can pack to UTF16
   21|       |      // without surrogate pairs
   22|   130k|      forbidden_bytemask = _mm256_or_si256(
   23|   130k|          forbidden_bytemask,
   24|   130k|          _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800));
   25|       |
   26|   130k|      __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),
   27|   130k|                                              _mm256_extractf128_si256(in, 1));
   28|   130k|      if (big_endian) {
  ------------------
  |  Branch (28:11): [Folded, False: 130k]
  ------------------
   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|   130k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
   34|   130k|      utf16_output += 8;
   35|   130k|      buf += 8;
   36|   130k|    } else {
   37|  2.72k|      size_t forward = 7;
   38|  2.72k|      size_t k = 0;
   39|  2.72k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (39:11): [True: 0, False: 2.72k]
  ------------------
   40|      0|        forward = size_t(end - buf - 1);
   41|      0|      }
   42|  21.0k|      for (; k < forward; k++) {
  ------------------
  |  Branch (42:14): [True: 18.4k, False: 2.57k]
  ------------------
   43|  18.4k|        uint32_t word = buf[k];
   44|  18.4k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (44:13): [True: 6.09k, False: 12.3k]
  ------------------
   45|       |          // will not generate a surrogate pair
   46|  6.09k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (46:15): [True: 814, False: 5.28k]
  |  Branch (46:33): [True: 26, False: 788]
  ------------------
   47|     26|            return std::make_pair(nullptr, utf16_output);
   48|     26|          }
   49|  6.07k|          *utf16_output++ =
   50|  6.07k|              big_endian
  ------------------
  |  Branch (50:15): [Folded, False: 6.07k]
  ------------------
   51|  6.07k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
   52|  6.07k|                  : char16_t(word);
   53|  12.3k|        } else {
   54|       |          // will generate a surrogate pair
   55|  12.3k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (55:15): [True: 124, False: 12.2k]
  ------------------
   56|    124|            return std::make_pair(nullptr, utf16_output);
   57|    124|          }
   58|  12.2k|          word -= 0x10000;
   59|  12.2k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   60|  12.2k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   61|  12.2k|          if (big_endian) {
  ------------------
  |  Branch (61:15): [Folded, False: 12.2k]
  ------------------
   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|  12.2k|          *utf16_output++ = char16_t(high_surrogate);
   68|  12.2k|          *utf16_output++ = char16_t(low_surrogate);
   69|  12.2k|        }
   70|  18.4k|      }
   71|  2.57k|      buf += k;
   72|  2.57k|    }
   73|   132k|  }
   74|       |
   75|       |  // check for invalid input
   76|    624|  if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (76:7): [True: 42, False: 582]
  ------------------
   77|     42|    return std::make_pair(nullptr, utf16_output);
   78|     42|  }
   79|       |
   80|    582|  return std::make_pair(buf, utf16_output);
   81|    624|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_127avx2_convert_utf32_to_utf16ILNS_10endiannessE1EEENSt3__14pairIPKDiPDsEES7_mS8_:
    4|    662|                            char16_t *utf16_output) {
    5|    662|  const char32_t *end = buf + len;
    6|       |
    7|    662|  const size_t safety_margin =
    8|    662|      12; // to avoid overruns, see issue
    9|       |          // https://github.com/simdutf/simdutf/issues/92
   10|    662|  __m256i forbidden_bytemask = _mm256_setzero_si256();
   11|       |
   12|    662|  const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000);
   13|    662|  const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800);
   14|    662|  const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800);
   15|       |
   16|  26.1k|  while (end - buf >= std::ptrdiff_t(8 + safety_margin)) {
  ------------------
  |  Branch (16:10): [True: 25.6k, False: 482]
  ------------------
   17|  25.6k|    const __m256i in = _mm256_loadu_si256((__m256i *)buf);
   18|       |
   19|  25.6k|    if (simdutf_likely(_mm256_testz_si256(in, v_ffff0000))) {
  ------------------
  |  |   90|  25.6k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 22.4k, False: 3.23k]
  |  |  ------------------
  ------------------
   20|       |      // no bits set above 16th bit <=> can pack to UTF16
   21|       |      // without surrogate pairs
   22|  22.4k|      forbidden_bytemask = _mm256_or_si256(
   23|  22.4k|          forbidden_bytemask,
   24|  22.4k|          _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800));
   25|       |
   26|  22.4k|      __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),
   27|  22.4k|                                              _mm256_extractf128_si256(in, 1));
   28|  22.4k|      if (big_endian) {
  ------------------
  |  Branch (28:11): [True: 22.4k, Folded]
  ------------------
   29|  22.4k|        const __m128i swap =
   30|  22.4k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   31|  22.4k|        utf16_packed = _mm_shuffle_epi8(utf16_packed, swap);
   32|  22.4k|      }
   33|  22.4k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
   34|  22.4k|      utf16_output += 8;
   35|  22.4k|      buf += 8;
   36|  22.4k|    } else {
   37|  3.23k|      size_t forward = 7;
   38|  3.23k|      size_t k = 0;
   39|  3.23k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (39:11): [True: 0, False: 3.23k]
  ------------------
   40|      0|        forward = size_t(end - buf - 1);
   41|      0|      }
   42|  24.9k|      for (; k < forward; k++) {
  ------------------
  |  Branch (42:14): [True: 21.8k, False: 3.05k]
  ------------------
   43|  21.8k|        uint32_t word = buf[k];
   44|  21.8k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (44:13): [True: 2.70k, False: 19.1k]
  ------------------
   45|       |          // will not generate a surrogate pair
   46|  2.70k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (46:15): [True: 446, False: 2.25k]
  |  Branch (46:33): [True: 20, False: 426]
  ------------------
   47|     20|            return std::make_pair(nullptr, utf16_output);
   48|     20|          }
   49|  2.68k|          *utf16_output++ =
   50|  2.68k|              big_endian
  ------------------
  |  Branch (50:15): [True: 2.68k, Folded]
  ------------------
   51|  2.68k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
   52|  2.68k|                  : char16_t(word);
   53|  19.1k|        } else {
   54|       |          // will generate a surrogate pair
   55|  19.1k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (55:15): [True: 160, False: 19.0k]
  ------------------
   56|    160|            return std::make_pair(nullptr, utf16_output);
   57|    160|          }
   58|  19.0k|          word -= 0x10000;
   59|  19.0k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   60|  19.0k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   61|  19.0k|          if (big_endian) {
  ------------------
  |  Branch (61:15): [True: 19.0k, Folded]
  ------------------
   62|  19.0k|            high_surrogate =
   63|  19.0k|                uint16_t((high_surrogate >> 8) | (high_surrogate << 8));
   64|  19.0k|            low_surrogate =
   65|  19.0k|                uint16_t((low_surrogate >> 8) | (low_surrogate << 8));
   66|  19.0k|          }
   67|  19.0k|          *utf16_output++ = char16_t(high_surrogate);
   68|  19.0k|          *utf16_output++ = char16_t(low_surrogate);
   69|  19.0k|        }
   70|  21.8k|      }
   71|  3.05k|      buf += k;
   72|  3.05k|    }
   73|  25.6k|  }
   74|       |
   75|       |  // check for invalid input
   76|    482|  if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (76:7): [True: 26, False: 456]
  ------------------
   77|     26|    return std::make_pair(nullptr, utf16_output);
   78|     26|  }
   79|       |
   80|    456|  return std::make_pair(buf, utf16_output);
   81|    482|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_139avx2_convert_utf32_to_utf16_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPDsEEPKDimS7_:
   86|    684|                                        char16_t *utf16_output) {
   87|    684|  const char32_t *start = buf;
   88|    684|  const char32_t *end = buf + len;
   89|       |
   90|    684|  const size_t safety_margin =
   91|    684|      12; // to avoid overruns, see issue
   92|       |          // https://github.com/simdutf/simdutf/issues/92
   93|       |
   94|    684|  const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000);
   95|    684|  const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800);
   96|    684|  const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800);
   97|       |
   98|  55.8k|  while (end - buf >= std::ptrdiff_t(8 + safety_margin)) {
  ------------------
  |  Branch (98:10): [True: 55.3k, False: 514]
  ------------------
   99|  55.3k|    const __m256i in = _mm256_loadu_si256((__m256i *)buf);
  100|       |
  101|  55.3k|    if (simdutf_likely(_mm256_testz_si256(in, v_ffff0000))) {
  ------------------
  |  |   90|  55.3k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 53.4k, False: 1.92k]
  |  |  ------------------
  ------------------
  102|       |      // no bits set above 16th bit <=> can pack to UTF16 without surrogate
  103|       |      // pairs
  104|  53.4k|      const __m256i forbidden_bytemask =
  105|  53.4k|          _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800);
  106|  53.4k|      if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) !=
  ------------------
  |  Branch (106:11): [True: 30, False: 53.3k]
  ------------------
  107|  53.4k|          0x0) {
  108|     30|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  109|     30|                              utf16_output);
  110|     30|      }
  111|       |
  112|  53.3k|      __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),
  113|  53.3k|                                              _mm256_extractf128_si256(in, 1));
  114|  53.3k|      if (big_endian) {
  ------------------
  |  Branch (114:11): [Folded, False: 53.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|  53.3k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
  120|  53.3k|      utf16_output += 8;
  121|  53.3k|      buf += 8;
  122|  53.3k|    } else {
  123|  1.92k|      size_t forward = 7;
  124|  1.92k|      size_t k = 0;
  125|  1.92k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (125:11): [True: 0, False: 1.92k]
  ------------------
  126|      0|        forward = size_t(end - buf - 1);
  127|      0|      }
  128|  14.6k|      for (; k < forward; k++) {
  ------------------
  |  Branch (128:14): [True: 12.9k, False: 1.78k]
  ------------------
  129|  12.9k|        uint32_t word = buf[k];
  130|  12.9k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (130:13): [True: 5.98k, False: 6.92k]
  ------------------
  131|       |          // will not generate a surrogate pair
  132|  5.98k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (132:15): [True: 542, False: 5.44k]
  |  Branch (132:33): [True: 4, False: 538]
  ------------------
  133|      4|            return std::make_pair(
  134|      4|                result(error_code::SURROGATE, buf - start + k), utf16_output);
  135|      4|          }
  136|  5.98k|          *utf16_output++ =
  137|  5.98k|              big_endian
  ------------------
  |  Branch (137:15): [Folded, False: 5.98k]
  ------------------
  138|  5.98k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
  139|  5.98k|                  : char16_t(word);
  140|  6.92k|        } else {
  141|       |          // will generate a surrogate pair
  142|  6.92k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (142:15): [True: 136, False: 6.79k]
  ------------------
  143|    136|            return std::make_pair(
  144|    136|                result(error_code::TOO_LARGE, buf - start + k), utf16_output);
  145|    136|          }
  146|  6.79k|          word -= 0x10000;
  147|  6.79k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
  148|  6.79k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
  149|  6.79k|          if (big_endian) {
  ------------------
  |  Branch (149:15): [Folded, False: 6.79k]
  ------------------
  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|  6.79k|          *utf16_output++ = char16_t(high_surrogate);
  156|  6.79k|          *utf16_output++ = char16_t(low_surrogate);
  157|  6.79k|        }
  158|  12.9k|      }
  159|  1.78k|      buf += k;
  160|  1.78k|    }
  161|  55.3k|  }
  162|       |
  163|    514|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output);
  164|    684|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_139avx2_convert_utf32_to_utf16_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPDsEEPKDimS7_:
   86|    630|                                        char16_t *utf16_output) {
   87|    630|  const char32_t *start = buf;
   88|    630|  const char32_t *end = buf + len;
   89|       |
   90|    630|  const size_t safety_margin =
   91|    630|      12; // to avoid overruns, see issue
   92|       |          // https://github.com/simdutf/simdutf/issues/92
   93|       |
   94|    630|  const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000);
   95|    630|  const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800);
   96|    630|  const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800);
   97|       |
   98|  3.55k|  while (end - buf >= std::ptrdiff_t(8 + safety_margin)) {
  ------------------
  |  Branch (98:10): [True: 3.05k, False: 500]
  ------------------
   99|  3.05k|    const __m256i in = _mm256_loadu_si256((__m256i *)buf);
  100|       |
  101|  3.05k|    if (simdutf_likely(_mm256_testz_si256(in, v_ffff0000))) {
  ------------------
  |  |   90|  3.05k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 2.31k, False: 734]
  |  |  ------------------
  ------------------
  102|       |      // no bits set above 16th bit <=> can pack to UTF16 without surrogate
  103|       |      // pairs
  104|  2.31k|      const __m256i forbidden_bytemask =
  105|  2.31k|          _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800);
  106|  2.31k|      if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) !=
  ------------------
  |  Branch (106:11): [True: 6, False: 2.31k]
  ------------------
  107|  2.31k|          0x0) {
  108|      6|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  109|      6|                              utf16_output);
  110|      6|      }
  111|       |
  112|  2.31k|      __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),
  113|  2.31k|                                              _mm256_extractf128_si256(in, 1));
  114|  2.31k|      if (big_endian) {
  ------------------
  |  Branch (114:11): [True: 2.31k, Folded]
  ------------------
  115|  2.31k|        const __m128i swap =
  116|  2.31k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  117|  2.31k|        utf16_packed = _mm_shuffle_epi8(utf16_packed, swap);
  118|  2.31k|      }
  119|  2.31k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
  120|  2.31k|      utf16_output += 8;
  121|  2.31k|      buf += 8;
  122|  2.31k|    } else {
  123|    734|      size_t forward = 7;
  124|    734|      size_t k = 0;
  125|    734|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (125:11): [True: 0, False: 734]
  ------------------
  126|      0|        forward = size_t(end - buf - 1);
  127|      0|      }
  128|  5.25k|      for (; k < forward; k++) {
  ------------------
  |  Branch (128:14): [True: 4.64k, False: 610]
  ------------------
  129|  4.64k|        uint32_t word = buf[k];
  130|  4.64k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (130:13): [True: 2.31k, False: 2.33k]
  ------------------
  131|       |          // will not generate a surrogate pair
  132|  2.31k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (132:15): [True: 554, False: 1.75k]
  |  Branch (132:33): [True: 6, False: 548]
  ------------------
  133|      6|            return std::make_pair(
  134|      6|                result(error_code::SURROGATE, buf - start + k), utf16_output);
  135|      6|          }
  136|  2.30k|          *utf16_output++ =
  137|  2.30k|              big_endian
  ------------------
  |  Branch (137:15): [True: 2.30k, Folded]
  ------------------
  138|  2.30k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
  139|  2.30k|                  : char16_t(word);
  140|  2.33k|        } else {
  141|       |          // will generate a surrogate pair
  142|  2.33k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (142:15): [True: 118, False: 2.21k]
  ------------------
  143|    118|            return std::make_pair(
  144|    118|                result(error_code::TOO_LARGE, buf - start + k), utf16_output);
  145|    118|          }
  146|  2.21k|          word -= 0x10000;
  147|  2.21k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
  148|  2.21k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
  149|  2.21k|          if (big_endian) {
  ------------------
  |  Branch (149:15): [True: 2.21k, Folded]
  ------------------
  150|  2.21k|            high_surrogate =
  151|  2.21k|                uint16_t((high_surrogate >> 8) | (high_surrogate << 8));
  152|  2.21k|            low_surrogate =
  153|  2.21k|                uint16_t((low_surrogate >> 8) | (low_surrogate << 8));
  154|  2.21k|          }
  155|  2.21k|          *utf16_output++ = char16_t(high_surrogate);
  156|  2.21k|          *utf16_output++ = char16_t(low_surrogate);
  157|  2.21k|        }
  158|  4.64k|      }
  159|    610|      buf += k;
  160|    610|    }
  161|  3.05k|  }
  162|       |
  163|    500|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output);
  164|    630|}

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

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_128convert_masked_utf8_to_utf16ILNS_10endiannessE0EEEmPKcmRPDs:
   10|  3.02M|                                    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.02M|  const __m128i swap =
   23|  3.02M|      _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   24|  3.02M|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   25|  3.02M|  const uint16_t input_utf8_end_of_code_point_mask =
   26|  3.02M|      utf8_end_of_code_point_mask & 0xfff;
   27|  3.02M|  if (utf8_end_of_code_point_mask == 0xfff) {
  ------------------
  |  Branch (27:7): [True: 10.8k, False: 3.01M]
  ------------------
   28|       |    // We process the data in chunks of 12 bytes.
   29|  10.8k|    __m256i ascii = _mm256_cvtepu8_epi16(in);
   30|  10.8k|    if (big_endian) {
  ------------------
  |  Branch (30:9): [Folded, False: 10.8k]
  ------------------
   31|      0|      const __m256i swap256 = _mm256_setr_epi8(
   32|      0|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   33|      0|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   34|      0|      ascii = _mm256_shuffle_epi8(ascii, swap256);
   35|      0|    }
   36|  10.8k|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf16_output), ascii);
   37|  10.8k|    utf16_output += 12; // We wrote 12 16-bit characters.
   38|  10.8k|    return 12;          // We consumed 12 bytes.
   39|  10.8k|  }
   40|  3.01M|  if (((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa)) {
  ------------------
  |  Branch (40:7): [True: 14.8k, False: 2.99M]
  ------------------
   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|  14.8k|    const __m128i sh =
   45|  14.8k|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   46|  14.8k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   47|  14.8k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   48|  14.8k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   49|  14.8k|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   50|  14.8k|    if (big_endian)
  ------------------
  |  Branch (50:9): [Folded, False: 14.8k]
  ------------------
   51|      0|      composed = _mm_shuffle_epi8(composed, swap);
   52|  14.8k|    _mm_storeu_si128((__m128i *)utf16_output, composed);
   53|  14.8k|    utf16_output += 8; // We wrote 16 bytes, 8 code points.
   54|  14.8k|    return 16;
   55|  14.8k|  }
   56|  2.99M|  if (input_utf8_end_of_code_point_mask == 0x924) {
  ------------------
  |  Branch (56:7): [True: 2.78k, False: 2.99M]
  ------------------
   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.78k|    const __m128i sh =
   61|  2.78k|        _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1);
   62|  2.78k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   63|  2.78k|    const __m128i ascii =
   64|  2.78k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   65|  2.78k|    const __m128i middlebyte =
   66|  2.78k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
   67|  2.78k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
   68|  2.78k|    const __m128i highbyte =
   69|  2.78k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
   70|  2.78k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
   71|  2.78k|    const __m128i composed =
   72|  2.78k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
   73|  2.78k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
   74|  2.78k|    if (big_endian)
  ------------------
  |  Branch (74:9): [Folded, False: 2.78k]
  ------------------
   75|      0|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
   76|  2.78k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
   77|  2.78k|    utf16_output += 4;
   78|  2.78k|    return 12;
   79|  2.78k|  }
   80|       |
   81|  2.99M|  const uint8_t idx = simdutf::tables::utf8_to_utf16::utf8bigindex
   82|  2.99M|      [input_utf8_end_of_code_point_mask][0];
   83|  2.99M|  const uint8_t consumed = simdutf::tables::utf8_to_utf16::utf8bigindex
   84|  2.99M|      [input_utf8_end_of_code_point_mask][1];
   85|  2.99M|  if (idx < 64) {
  ------------------
  |  Branch (85:7): [True: 2.54M, False: 443k]
  ------------------
   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.54M|    const __m128i sh = _mm_loadu_si128(
   93|  2.54M|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
   94|  2.54M|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   95|  2.54M|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   96|  2.54M|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   97|  2.54M|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   98|  2.54M|    if (big_endian)
  ------------------
  |  Branch (98:9): [Folded, False: 2.54M]
  ------------------
   99|      0|      composed = _mm_shuffle_epi8(composed, swap);
  100|  2.54M|    _mm_storeu_si128((__m128i *)utf16_output, composed);
  101|  2.54M|    utf16_output += 6; // We wrote 12 bytes, 6 code points. There is a potential
  102|       |                       // overflow of 4 bytes.
  103|  2.54M|  } else if (idx < 145) {
  ------------------
  |  Branch (103:14): [True: 369k, False: 73.8k]
  ------------------
  104|       |    // FOUR (4) input code-code units
  105|   369k|    const __m128i sh = _mm_loadu_si128(
  106|   369k|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
  107|   369k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  108|   369k|    const __m128i ascii =
  109|   369k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
  110|   369k|    const __m128i middlebyte =
  111|   369k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
  112|   369k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  113|   369k|    const __m128i highbyte =
  114|   369k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
  115|   369k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
  116|   369k|    const __m128i composed =
  117|   369k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
  118|   369k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
  119|   369k|    if (big_endian)
  ------------------
  |  Branch (119:9): [Folded, False: 369k]
  ------------------
  120|      0|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
  121|   369k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
  122|   369k|    utf16_output += 4; // Here we overflow by 8 bytes.
  123|   369k|  } else if (idx < 209) {
  ------------------
  |  Branch (123:14): [True: 72.5k, False: 1.29k]
  ------------------
  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|  72.5k|    const __m128i sh = _mm_loadu_si128(
  135|  72.5k|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
  136|  72.5k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  137|  72.5k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f));
  138|  72.5k|    const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00));
  139|  72.5k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  140|  72.5k|    __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000));
  141|       |    // correct for spurious high bit
  142|  72.5k|    const __m128i correct =
  143|  72.5k|        _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1);
  144|  72.5k|    middlehighbyte = _mm_xor_si128(correct, middlehighbyte);
  145|  72.5k|    const __m128i middlehighbyte_shifted = _mm_srli_epi32(middlehighbyte, 4);
  146|       |    // We deliberately carry the leading four bits in highbyte if they are
  147|       |    // present, we remove them later when computing hightenbits.
  148|  72.5k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0xff000000));
  149|  72.5k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 6);
  150|       |    // When we need to generate a surrogate pair (leading byte > 0xF0), then
  151|       |    // the corresponding 32-bit value in 'composed'  will be greater than
  152|       |    // > (0xff00000>>6) or > 0x3c00000. This can be used later to identify the
  153|       |    // location of the surrogate pairs.
  154|  72.5k|    const __m128i composed =
  155|  72.5k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted),
  156|  72.5k|                     _mm_or_si128(highbyte_shifted, middlehighbyte_shifted));
  157|  72.5k|    const __m128i composedminus =
  158|  72.5k|        _mm_sub_epi32(composed, _mm_set1_epi32(0x10000));
  159|  72.5k|    const __m128i lowtenbits =
  160|  72.5k|        _mm_and_si128(composedminus, _mm_set1_epi32(0x3ff));
  161|       |    // Notice the 0x3ff mask:
  162|  72.5k|    const __m128i hightenbits =
  163|  72.5k|        _mm_and_si128(_mm_srli_epi32(composedminus, 10), _mm_set1_epi32(0x3ff));
  164|  72.5k|    const __m128i lowtenbitsadd =
  165|  72.5k|        _mm_add_epi32(lowtenbits, _mm_set1_epi32(0xDC00));
  166|  72.5k|    const __m128i hightenbitsadd =
  167|  72.5k|        _mm_add_epi32(hightenbits, _mm_set1_epi32(0xD800));
  168|  72.5k|    const __m128i lowtenbitsaddshifted = _mm_slli_epi32(lowtenbitsadd, 16);
  169|  72.5k|    __m128i surrogates = _mm_or_si128(hightenbitsadd, lowtenbitsaddshifted);
  170|  72.5k|    uint32_t basic_buffer[4];
  171|  72.5k|    uint32_t basic_buffer_swap[4];
  172|  72.5k|    if (big_endian) {
  ------------------
  |  Branch (172:9): [Folded, False: 72.5k]
  ------------------
  173|      0|      _mm_storeu_si128((__m128i *)basic_buffer_swap,
  174|      0|                       _mm_shuffle_epi8(composed, swap));
  175|      0|      surrogates = _mm_shuffle_epi8(surrogates, swap);
  176|      0|    }
  177|  72.5k|    _mm_storeu_si128((__m128i *)basic_buffer, composed);
  178|  72.5k|    uint32_t surrogate_buffer[4];
  179|  72.5k|    _mm_storeu_si128((__m128i *)surrogate_buffer, surrogates);
  180|   290k|    for (size_t i = 0; i < 3; i++) {
  ------------------
  |  Branch (180:24): [True: 217k, False: 72.5k]
  ------------------
  181|   217k|      if (basic_buffer[i] > 0x3c00000) {
  ------------------
  |  Branch (181:11): [True: 59.9k, False: 157k]
  ------------------
  182|  59.9k|        utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff);
  183|  59.9k|        utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16);
  184|  59.9k|        utf16_output += 2;
  185|   157k|      } else {
  186|   157k|        utf16_output[0] = big_endian ? uint16_t(basic_buffer_swap[i])
  ------------------
  |  Branch (186:27): [Folded, False: 157k]
  ------------------
  187|   157k|                                     : uint16_t(basic_buffer[i]);
  188|   157k|        utf16_output++;
  189|   157k|      }
  190|   217k|    }
  191|  72.5k|  } else {
  192|       |    // here we know that there is an error but we do not handle errors
  193|  1.29k|  }
  194|  2.99M|  return consumed;
  195|  2.99M|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_128convert_masked_utf8_to_utf16ILNS_10endiannessE1EEEmPKcmRPDs:
   10|  3.04M|                                    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.04M|  const __m128i swap =
   23|  3.04M|      _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   24|  3.04M|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   25|  3.04M|  const uint16_t input_utf8_end_of_code_point_mask =
   26|  3.04M|      utf8_end_of_code_point_mask & 0xfff;
   27|  3.04M|  if (utf8_end_of_code_point_mask == 0xfff) {
  ------------------
  |  Branch (27:7): [True: 10.8k, False: 3.03M]
  ------------------
   28|       |    // We process the data in chunks of 12 bytes.
   29|  10.8k|    __m256i ascii = _mm256_cvtepu8_epi16(in);
   30|  10.8k|    if (big_endian) {
  ------------------
  |  Branch (30:9): [True: 10.8k, Folded]
  ------------------
   31|  10.8k|      const __m256i swap256 = _mm256_setr_epi8(
   32|  10.8k|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   33|  10.8k|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   34|  10.8k|      ascii = _mm256_shuffle_epi8(ascii, swap256);
   35|  10.8k|    }
   36|  10.8k|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf16_output), ascii);
   37|  10.8k|    utf16_output += 12; // We wrote 12 16-bit characters.
   38|  10.8k|    return 12;          // We consumed 12 bytes.
   39|  10.8k|  }
   40|  3.03M|  if (((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa)) {
  ------------------
  |  Branch (40:7): [True: 27.5k, False: 3.00M]
  ------------------
   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|  27.5k|    const __m128i sh =
   45|  27.5k|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   46|  27.5k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   47|  27.5k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   48|  27.5k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   49|  27.5k|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   50|  27.5k|    if (big_endian)
  ------------------
  |  Branch (50:9): [True: 27.5k, Folded]
  ------------------
   51|  27.5k|      composed = _mm_shuffle_epi8(composed, swap);
   52|  27.5k|    _mm_storeu_si128((__m128i *)utf16_output, composed);
   53|  27.5k|    utf16_output += 8; // We wrote 16 bytes, 8 code points.
   54|  27.5k|    return 16;
   55|  27.5k|  }
   56|  3.00M|  if (input_utf8_end_of_code_point_mask == 0x924) {
  ------------------
  |  Branch (56:7): [True: 7.44k, False: 2.99M]
  ------------------
   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|  7.44k|    const __m128i sh =
   61|  7.44k|        _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1);
   62|  7.44k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   63|  7.44k|    const __m128i ascii =
   64|  7.44k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   65|  7.44k|    const __m128i middlebyte =
   66|  7.44k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
   67|  7.44k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
   68|  7.44k|    const __m128i highbyte =
   69|  7.44k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
   70|  7.44k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
   71|  7.44k|    const __m128i composed =
   72|  7.44k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
   73|  7.44k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
   74|  7.44k|    if (big_endian)
  ------------------
  |  Branch (74:9): [True: 7.44k, Folded]
  ------------------
   75|  7.44k|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
   76|  7.44k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
   77|  7.44k|    utf16_output += 4;
   78|  7.44k|    return 12;
   79|  7.44k|  }
   80|       |
   81|  2.99M|  const uint8_t idx = simdutf::tables::utf8_to_utf16::utf8bigindex
   82|  2.99M|      [input_utf8_end_of_code_point_mask][0];
   83|  2.99M|  const uint8_t consumed = simdutf::tables::utf8_to_utf16::utf8bigindex
   84|  2.99M|      [input_utf8_end_of_code_point_mask][1];
   85|  2.99M|  if (idx < 64) {
  ------------------
  |  Branch (85:7): [True: 2.74M, False: 248k]
  ------------------
   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.74M|    const __m128i sh = _mm_loadu_si128(
   93|  2.74M|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
   94|  2.74M|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   95|  2.74M|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   96|  2.74M|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   97|  2.74M|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   98|  2.74M|    if (big_endian)
  ------------------
  |  Branch (98:9): [True: 2.74M, Folded]
  ------------------
   99|  2.74M|      composed = _mm_shuffle_epi8(composed, swap);
  100|  2.74M|    _mm_storeu_si128((__m128i *)utf16_output, composed);
  101|  2.74M|    utf16_output += 6; // We wrote 12 bytes, 6 code points. There is a potential
  102|       |                       // overflow of 4 bytes.
  103|  2.74M|  } else if (idx < 145) {
  ------------------
  |  Branch (103:14): [True: 164k, False: 83.8k]
  ------------------
  104|       |    // FOUR (4) input code-code units
  105|   164k|    const __m128i sh = _mm_loadu_si128(
  106|   164k|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
  107|   164k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  108|   164k|    const __m128i ascii =
  109|   164k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
  110|   164k|    const __m128i middlebyte =
  111|   164k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
  112|   164k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  113|   164k|    const __m128i highbyte =
  114|   164k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
  115|   164k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
  116|   164k|    const __m128i composed =
  117|   164k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
  118|   164k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
  119|   164k|    if (big_endian)
  ------------------
  |  Branch (119:9): [True: 164k, Folded]
  ------------------
  120|   164k|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
  121|   164k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
  122|   164k|    utf16_output += 4; // Here we overflow by 8 bytes.
  123|   164k|  } else if (idx < 209) {
  ------------------
  |  Branch (123:14): [True: 82.9k, False: 894]
  ------------------
  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|  82.9k|    const __m128i sh = _mm_loadu_si128(
  135|  82.9k|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
  136|  82.9k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  137|  82.9k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f));
  138|  82.9k|    const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00));
  139|  82.9k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  140|  82.9k|    __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000));
  141|       |    // correct for spurious high bit
  142|  82.9k|    const __m128i correct =
  143|  82.9k|        _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1);
  144|  82.9k|    middlehighbyte = _mm_xor_si128(correct, middlehighbyte);
  145|  82.9k|    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|  82.9k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0xff000000));
  149|  82.9k|    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|  82.9k|    const __m128i composed =
  155|  82.9k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted),
  156|  82.9k|                     _mm_or_si128(highbyte_shifted, middlehighbyte_shifted));
  157|  82.9k|    const __m128i composedminus =
  158|  82.9k|        _mm_sub_epi32(composed, _mm_set1_epi32(0x10000));
  159|  82.9k|    const __m128i lowtenbits =
  160|  82.9k|        _mm_and_si128(composedminus, _mm_set1_epi32(0x3ff));
  161|       |    // Notice the 0x3ff mask:
  162|  82.9k|    const __m128i hightenbits =
  163|  82.9k|        _mm_and_si128(_mm_srli_epi32(composedminus, 10), _mm_set1_epi32(0x3ff));
  164|  82.9k|    const __m128i lowtenbitsadd =
  165|  82.9k|        _mm_add_epi32(lowtenbits, _mm_set1_epi32(0xDC00));
  166|  82.9k|    const __m128i hightenbitsadd =
  167|  82.9k|        _mm_add_epi32(hightenbits, _mm_set1_epi32(0xD800));
  168|  82.9k|    const __m128i lowtenbitsaddshifted = _mm_slli_epi32(lowtenbitsadd, 16);
  169|  82.9k|    __m128i surrogates = _mm_or_si128(hightenbitsadd, lowtenbitsaddshifted);
  170|  82.9k|    uint32_t basic_buffer[4];
  171|  82.9k|    uint32_t basic_buffer_swap[4];
  172|  82.9k|    if (big_endian) {
  ------------------
  |  Branch (172:9): [True: 82.9k, Folded]
  ------------------
  173|  82.9k|      _mm_storeu_si128((__m128i *)basic_buffer_swap,
  174|  82.9k|                       _mm_shuffle_epi8(composed, swap));
  175|  82.9k|      surrogates = _mm_shuffle_epi8(surrogates, swap);
  176|  82.9k|    }
  177|  82.9k|    _mm_storeu_si128((__m128i *)basic_buffer, composed);
  178|  82.9k|    uint32_t surrogate_buffer[4];
  179|  82.9k|    _mm_storeu_si128((__m128i *)surrogate_buffer, surrogates);
  180|   331k|    for (size_t i = 0; i < 3; i++) {
  ------------------
  |  Branch (180:24): [True: 248k, False: 82.9k]
  ------------------
  181|   248k|      if (basic_buffer[i] > 0x3c00000) {
  ------------------
  |  Branch (181:11): [True: 69.3k, False: 179k]
  ------------------
  182|  69.3k|        utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff);
  183|  69.3k|        utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16);
  184|  69.3k|        utf16_output += 2;
  185|   179k|      } else {
  186|   179k|        utf16_output[0] = big_endian ? uint16_t(basic_buffer_swap[i])
  ------------------
  |  Branch (186:27): [True: 179k, Folded]
  ------------------
  187|   179k|                                     : uint16_t(basic_buffer[i]);
  188|   179k|        utf16_output++;
  189|   179k|      }
  190|   248k|    }
  191|  82.9k|  } else {
  192|       |    // here we know that there is an error but we do not handle errors
  193|    894|  }
  194|  2.99M|  return consumed;
  195|  3.00M|}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_utf16_to_utf32ILNS_10endiannessE0EEENSt3__14pairIPKDsPDiEES7_mS8_:
   57|    412|                           char32_t *utf32_output) {
   58|    412|  const char16_t *end = buf + len;
   59|       |
   60|    412|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
   61|    412|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
   62|       |
   63|   289k|  while (end - buf >= 8) {
  ------------------
  |  Branch (63:10): [True: 289k, False: 296]
  ------------------
   64|   289k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   65|       |
   66|   289k|    if (big_endian) {
  ------------------
  |  Branch (66:9): [Folded, False: 289k]
  ------------------
   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|   289k|    const __m128i surrogates_bytemask =
   76|   289k|        _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|   289k|    const uint16_t surrogates_bitmask =
   81|   289k|        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|   289k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (84:9): [True: 284k, False: 4.35k]
  ------------------
   85|       |      // case: no surrogate pair, extend 16-bit code units to 32-bit code units
   86|   284k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
   87|   284k|                       _mm_cvtepu16_epi32(in));
   88|   284k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
   89|   284k|                       _mm_cvtepu16_epi32(_mm_srli_si128(in, 8)));
   90|   284k|      utf32_output += 8;
   91|   284k|      buf += 8;
   92|       |      // surrogate pair(s) in a register
   93|   284k|    } else {
   94|       |      // Let us do a scalar fallback.
   95|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
   96|       |      // in the presence of surrogate pairs may require non-trivial tables.
   97|  4.35k|      size_t forward = 15;
   98|  4.35k|      size_t k = 0;
   99|  4.35k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (99:11): [True: 58, False: 4.29k]
  ------------------
  100|     58|        forward = size_t(end - buf - 1);
  101|     58|      }
  102|  62.9k|      for (; k < forward; k++) {
  ------------------
  |  Branch (102:14): [True: 58.7k, False: 4.24k]
  ------------------
  103|  58.7k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  104|  58.7k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (104:13): [True: 53.3k, False: 5.44k]
  ------------------
  105|  53.3k|          *utf32_output++ = char32_t(word);
  106|  53.3k|        } else {
  107|       |          // must be a surrogate pair
  108|  5.44k|          uint16_t diff = uint16_t(word - 0xD800);
  109|  5.44k|          uint16_t next_word =
  110|  5.44k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  111|  5.44k|          k++;
  112|  5.44k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  113|  5.44k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (113:15): [True: 116, False: 5.32k]
  ------------------
  114|    116|            return std::make_pair(nullptr, utf32_output);
  115|    116|          }
  116|  5.32k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  117|  5.32k|          *utf32_output++ = char32_t(value);
  118|  5.32k|        }
  119|  58.7k|      }
  120|  4.24k|      buf += k;
  121|  4.24k|    }
  122|   289k|  } // while
  123|    296|  return std::make_pair(buf, utf32_output);
  124|    412|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_utf16_to_utf32ILNS_10endiannessE1EEENSt3__14pairIPKDsPDiEES7_mS8_:
   57|    392|                           char32_t *utf32_output) {
   58|    392|  const char16_t *end = buf + len;
   59|       |
   60|    392|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
   61|    392|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
   62|       |
   63|   622k|  while (end - buf >= 8) {
  ------------------
  |  Branch (63:10): [True: 622k, False: 314]
  ------------------
   64|   622k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   65|       |
   66|   622k|    if (big_endian) {
  ------------------
  |  Branch (66:9): [True: 622k, Folded]
  ------------------
   67|   622k|      const __m128i swap =
   68|   622k|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   69|   622k|      in = _mm_shuffle_epi8(in, swap);
   70|   622k|    }
   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|   622k|    const __m128i surrogates_bytemask =
   76|   622k|        _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|   622k|    const uint16_t surrogates_bitmask =
   81|   622k|        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|   622k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (84:9): [True: 620k, False: 1.69k]
  ------------------
   85|       |      // case: no surrogate pair, extend 16-bit code units to 32-bit code units
   86|   620k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
   87|   620k|                       _mm_cvtepu16_epi32(in));
   88|   620k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
   89|   620k|                       _mm_cvtepu16_epi32(_mm_srli_si128(in, 8)));
   90|   620k|      utf32_output += 8;
   91|   620k|      buf += 8;
   92|       |      // surrogate pair(s) in a register
   93|   620k|    } 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.69k|      size_t forward = 15;
   98|  1.69k|      size_t k = 0;
   99|  1.69k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (99:11): [True: 80, False: 1.61k]
  ------------------
  100|     80|        forward = size_t(end - buf - 1);
  101|     80|      }
  102|  23.6k|      for (; k < forward; k++) {
  ------------------
  |  Branch (102:14): [True: 22.0k, False: 1.61k]
  ------------------
  103|  22.0k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  104|  22.0k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (104:13): [True: 19.6k, False: 2.37k]
  ------------------
  105|  19.6k|          *utf32_output++ = char32_t(word);
  106|  19.6k|        } else {
  107|       |          // must be a surrogate pair
  108|  2.37k|          uint16_t diff = uint16_t(word - 0xD800);
  109|  2.37k|          uint16_t next_word =
  110|  2.37k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  111|  2.37k|          k++;
  112|  2.37k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  113|  2.37k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (113:15): [True: 78, False: 2.29k]
  ------------------
  114|     78|            return std::make_pair(nullptr, utf32_output);
  115|     78|          }
  116|  2.29k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  117|  2.29k|          *utf32_output++ = char32_t(value);
  118|  2.29k|        }
  119|  22.0k|      }
  120|  1.61k|      buf += k;
  121|  1.61k|    }
  122|   622k|  } // while
  123|    314|  return std::make_pair(buf, utf32_output);
  124|    392|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_138sse_convert_utf16_to_utf32_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPDiEEPKDsmS7_:
  136|    418|                                       char32_t *utf32_output) {
  137|    418|  const char16_t *start = buf;
  138|    418|  const char16_t *end = buf + len;
  139|       |
  140|    418|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
  141|    418|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
  142|       |
  143|   530k|  while (end - buf >= 8) {
  ------------------
  |  Branch (143:10): [True: 529k, False: 250]
  ------------------
  144|   529k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  145|       |
  146|   529k|    if (big_endian) {
  ------------------
  |  Branch (146:9): [Folded, False: 529k]
  ------------------
  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|   529k|    const __m128i surrogates_bytemask =
  156|   529k|        _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|   529k|    const uint16_t surrogates_bitmask =
  161|   529k|        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|   529k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (164:9): [True: 520k, False: 9.32k]
  ------------------
  165|       |      // case: no surrogate pair, extend 16-bit code units to 32-bit code units
  166|   520k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
  167|   520k|                       _mm_cvtepu16_epi32(in));
  168|   520k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
  169|   520k|                       _mm_cvtepu16_epi32(_mm_srli_si128(in, 8)));
  170|   520k|      utf32_output += 8;
  171|   520k|      buf += 8;
  172|       |      // surrogate pair(s) in a register
  173|   520k|    } 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|  9.32k|      size_t forward = 15;
  178|  9.32k|      size_t k = 0;
  179|  9.32k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (179:11): [True: 82, False: 9.24k]
  ------------------
  180|     82|        forward = size_t(end - buf - 1);
  181|     82|      }
  182|   133k|      for (; k < forward; k++) {
  ------------------
  |  Branch (182:14): [True: 124k, False: 9.15k]
  ------------------
  183|   124k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  184|   124k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (184:13): [True: 109k, False: 14.7k]
  ------------------
  185|   109k|          *utf32_output++ = char32_t(word);
  186|   109k|        } else {
  187|       |          // must be a surrogate pair
  188|  14.7k|          uint16_t diff = uint16_t(word - 0xD800);
  189|  14.7k|          uint16_t next_word =
  190|  14.7k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  191|  14.7k|          k++;
  192|  14.7k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  193|  14.7k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (193:15): [True: 168, False: 14.6k]
  ------------------
  194|    168|            return std::make_pair(
  195|    168|                result(error_code::SURROGATE, buf - start + k - 1),
  196|    168|                utf32_output);
  197|    168|          }
  198|  14.6k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  199|  14.6k|          *utf32_output++ = char32_t(value);
  200|  14.6k|        }
  201|   124k|      }
  202|  9.15k|      buf += k;
  203|  9.15k|    }
  204|   529k|  } // while
  205|    250|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output);
  206|    418|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_138sse_convert_utf16_to_utf32_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPDiEEPKDsmS7_:
  136|    346|                                       char32_t *utf32_output) {
  137|    346|  const char16_t *start = buf;
  138|    346|  const char16_t *end = buf + len;
  139|       |
  140|    346|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
  141|    346|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
  142|       |
  143|   311k|  while (end - buf >= 8) {
  ------------------
  |  Branch (143:10): [True: 311k, False: 238]
  ------------------
  144|   311k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  145|       |
  146|   311k|    if (big_endian) {
  ------------------
  |  Branch (146:9): [True: 311k, Folded]
  ------------------
  147|   311k|      const __m128i swap =
  148|   311k|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  149|   311k|      in = _mm_shuffle_epi8(in, swap);
  150|   311k|    }
  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|   311k|    const __m128i surrogates_bytemask =
  156|   311k|        _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|   311k|    const uint16_t surrogates_bitmask =
  161|   311k|        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|   311k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (164:9): [True: 305k, False: 5.68k]
  ------------------
  165|       |      // case: no surrogate pair, extend 16-bit code units to 32-bit code units
  166|   305k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
  167|   305k|                       _mm_cvtepu16_epi32(in));
  168|   305k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
  169|   305k|                       _mm_cvtepu16_epi32(_mm_srli_si128(in, 8)));
  170|   305k|      utf32_output += 8;
  171|   305k|      buf += 8;
  172|       |      // surrogate pair(s) in a register
  173|   305k|    } else {
  174|       |      // Let us do a scalar fallback.
  175|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
  176|       |      // in the presence of surrogate pairs may require non-trivial tables.
  177|  5.68k|      size_t forward = 15;
  178|  5.68k|      size_t k = 0;
  179|  5.68k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (179:11): [True: 88, False: 5.59k]
  ------------------
  180|     88|        forward = size_t(end - buf - 1);
  181|     88|      }
  182|  79.7k|      for (; k < forward; k++) {
  ------------------
  |  Branch (182:14): [True: 74.1k, False: 5.57k]
  ------------------
  183|  74.1k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  184|  74.1k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (184:13): [True: 63.7k, False: 10.4k]
  ------------------
  185|  63.7k|          *utf32_output++ = char32_t(word);
  186|  63.7k|        } else {
  187|       |          // must be a surrogate pair
  188|  10.4k|          uint16_t diff = uint16_t(word - 0xD800);
  189|  10.4k|          uint16_t next_word =
  190|  10.4k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  191|  10.4k|          k++;
  192|  10.4k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  193|  10.4k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (193:15): [True: 108, False: 10.2k]
  ------------------
  194|    108|            return std::make_pair(
  195|    108|                result(error_code::SURROGATE, buf - start + k - 1),
  196|    108|                utf32_output);
  197|    108|          }
  198|  10.2k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  199|  10.2k|          *utf32_output++ = char32_t(value);
  200|  10.2k|        }
  201|  74.1k|      }
  202|  5.57k|      buf += k;
  203|  5.57k|    }
  204|   311k|  } // while
  205|    238|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output);
  206|    346|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_125sse_convert_utf16_to_utf8ILNS_10endiannessE0EEENSt3__14pairIPKDsPcEES7_mS8_:
   56|    856|sse_convert_utf16_to_utf8(const char16_t *buf, size_t len, char *utf8_output) {
   57|       |
   58|    856|  const char16_t *end = buf + len;
   59|       |
   60|    856|  const __m128i v_0000 = _mm_setzero_si128();
   61|    856|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
   62|    856|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
   63|    856|  const size_t safety_margin =
   64|    856|      12; // to avoid overruns, see issue
   65|       |          // https://github.com/simdutf/simdutf/issues/92
   66|       |
   67|  1.30M|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (67:10): [True: 1.30M, False: 742]
  ------------------
   68|  1.30M|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   69|  1.30M|    if (big_endian) {
  ------------------
  |  Branch (69:9): [Folded, False: 1.30M]
  ------------------
   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.30M|    const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80);
   76|  1.30M|    if (_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (76:9): [True: 715k, False: 584k]
  ------------------
   77|   715k|      __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
   78|   715k|      if (big_endian) {
  ------------------
  |  Branch (78:11): [Folded, False: 715k]
  ------------------
   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|   715k|      if (!_mm_testz_si128(nextin, v_ff80)) {
  ------------------
  |  Branch (83:11): [True: 59.0k, False: 656k]
  ------------------
   84|       |        // 1. pack the bytes
   85|       |        // obviously suboptimal.
   86|  59.0k|        const __m128i utf8_packed = _mm_packus_epi16(in, in);
   87|       |        // 2. store (16 bytes)
   88|  59.0k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   89|       |        // 3. adjust pointers
   90|  59.0k|        buf += 8;
   91|  59.0k|        utf8_output += 8;
   92|  59.0k|        in = nextin;
   93|   656k|      } else {
   94|       |        // 1. pack the bytes
   95|       |        // obviously suboptimal.
   96|   656k|        const __m128i utf8_packed = _mm_packus_epi16(in, nextin);
   97|       |        // 2. store (16 bytes)
   98|   656k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   99|       |        // 3. adjust pointers
  100|   656k|        buf += 16;
  101|   656k|        utf8_output += 16;
  102|   656k|        continue; // we are done for this round!
  103|   656k|      }
  104|   715k|    }
  105|       |
  106|       |    // no bits set above 7th bit
  107|   643k|    const __m128i one_byte_bytemask =
  108|   643k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000);
  109|   643k|    const uint16_t one_byte_bitmask =
  110|   643k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  111|       |
  112|       |    // no bits set above 11th bit
  113|   643k|    const __m128i one_or_two_bytes_bytemask =
  114|   643k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000);
  115|   643k|    const uint16_t one_or_two_bytes_bitmask =
  116|   643k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  117|       |
  118|   643k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (118:9): [True: 493k, False: 149k]
  ------------------
  119|   493k|      internal::westmere::write_v_u16_11bits_to_utf8(
  120|   493k|          in, utf8_output, one_byte_bytemask, one_byte_bitmask);
  121|   493k|      buf += 8;
  122|   493k|      continue;
  123|   493k|    }
  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|   149k|    const __m128i surrogates_bytemask =
  129|   149k|        _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|   149k|    const uint16_t surrogates_bitmask =
  134|   149k|        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|   149k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (137:9): [True: 139k, False: 9.90k]
  ------------------
  138|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  139|   139k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  140|   139k|                                              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|   139k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  170|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  171|   139k|      const __m128i t0 = _mm_shuffle_epi8(in, dup_even);
  172|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  173|   139k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  169|   139k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  174|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  175|   139k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  169|   139k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  176|       |
  177|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  178|   139k|      const __m128i s0 = _mm_srli_epi16(in, 4);
  179|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  180|   139k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  169|   139k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  181|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  182|   139k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  169|   139k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  183|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  184|   139k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  169|   139k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  185|   139k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  186|   139k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  169|   139k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  187|   139k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  188|   139k|#undef simdutf_vec
  189|       |
  190|       |      // 4. expand code units 16-bit => 32-bit
  191|   139k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  192|   139k|      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|   139k|      const uint16_t mask =
  196|   139k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  197|   139k|      if (mask == 0) {
  ------------------
  |  Branch (197:11): [True: 23.1k, False: 116k]
  ------------------
  198|       |        // We only have three-byte code units. Use fast path.
  199|  23.1k|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  200|  23.1k|                                              15, 13, -1, -1, -1, -1);
  201|  23.1k|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  202|  23.1k|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  203|  23.1k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  204|  23.1k|        utf8_output += 12;
  205|  23.1k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  206|  23.1k|        utf8_output += 12;
  207|  23.1k|        buf += 8;
  208|  23.1k|        continue;
  209|  23.1k|      }
  210|   116k|      const uint8_t mask0 = uint8_t(mask);
  211|       |
  212|   116k|      const uint8_t *row0 =
  213|   116k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  214|   116k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  215|   116k|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  216|       |
  217|   116k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  218|       |
  219|   116k|      const uint8_t *row1 =
  220|   116k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  221|   116k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  222|   116k|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  223|       |
  224|   116k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  225|   116k|      utf8_output += row0[0];
  226|   116k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  227|   116k|      utf8_output += row1[0];
  228|       |
  229|   116k|      buf += 8;
  230|       |      // surrogate pair(s) in a register
  231|   116k|    } 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|  9.90k|      size_t forward = 15;
  236|  9.90k|      size_t k = 0;
  237|  9.90k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (237:11): [True: 0, False: 9.90k]
  ------------------
  238|      0|        forward = size_t(end - buf - 1);
  239|      0|      }
  240|   146k|      for (; k < forward; k++) {
  ------------------
  |  Branch (240:14): [True: 136k, False: 9.78k]
  ------------------
  241|   136k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  242|   136k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (242:13): [True: 17.0k, False: 119k]
  ------------------
  243|  17.0k|          *utf8_output++ = char(word);
  244|   119k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (244:20): [True: 4.32k, False: 115k]
  ------------------
  245|  4.32k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  246|  4.32k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  247|   115k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (247:20): [True: 104k, False: 11.0k]
  ------------------
  248|   104k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  249|   104k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  250|   104k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  251|   104k|        } else {
  252|       |          // must be a surrogate pair
  253|  11.0k|          uint16_t diff = uint16_t(word - 0xD800);
  254|  11.0k|          uint16_t next_word =
  255|  11.0k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  256|  11.0k|          k++;
  257|  11.0k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  258|  11.0k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (258:15): [True: 114, False: 10.9k]
  ------------------
  259|    114|            return std::make_pair(nullptr, utf8_output);
  260|    114|          }
  261|  10.9k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  262|  10.9k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  263|  10.9k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  264|  10.9k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  265|  10.9k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  266|  10.9k|        }
  267|   136k|      }
  268|  9.78k|      buf += k;
  269|  9.78k|    }
  270|   149k|  } // while
  271|       |
  272|    742|  return std::make_pair(buf, utf8_output);
  273|    856|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_125sse_convert_utf16_to_utf8ILNS_10endiannessE1EEENSt3__14pairIPKDsPcEES7_mS8_:
   56|    750|sse_convert_utf16_to_utf8(const char16_t *buf, size_t len, char *utf8_output) {
   57|       |
   58|    750|  const char16_t *end = buf + len;
   59|       |
   60|    750|  const __m128i v_0000 = _mm_setzero_si128();
   61|    750|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
   62|    750|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
   63|    750|  const size_t safety_margin =
   64|    750|      12; // to avoid overruns, see issue
   65|       |          // https://github.com/simdutf/simdutf/issues/92
   66|       |
   67|  1.12M|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (67:10): [True: 1.12M, False: 662]
  ------------------
   68|  1.12M|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   69|  1.12M|    if (big_endian) {
  ------------------
  |  Branch (69:9): [True: 1.12M, Folded]
  ------------------
   70|  1.12M|      const __m128i swap =
   71|  1.12M|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   72|  1.12M|      in = _mm_shuffle_epi8(in, swap);
   73|  1.12M|    }
   74|       |    // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes
   75|  1.12M|    const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80);
   76|  1.12M|    if (_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (76:9): [True: 711k, False: 412k]
  ------------------
   77|   711k|      __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
   78|   711k|      if (big_endian) {
  ------------------
  |  Branch (78:11): [True: 711k, Folded]
  ------------------
   79|   711k|        const __m128i swap =
   80|   711k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   81|   711k|        nextin = _mm_shuffle_epi8(nextin, swap);
   82|   711k|      }
   83|   711k|      if (!_mm_testz_si128(nextin, v_ff80)) {
  ------------------
  |  Branch (83:11): [True: 35.8k, False: 675k]
  ------------------
   84|       |        // 1. pack the bytes
   85|       |        // obviously suboptimal.
   86|  35.8k|        const __m128i utf8_packed = _mm_packus_epi16(in, in);
   87|       |        // 2. store (16 bytes)
   88|  35.8k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   89|       |        // 3. adjust pointers
   90|  35.8k|        buf += 8;
   91|  35.8k|        utf8_output += 8;
   92|  35.8k|        in = nextin;
   93|   675k|      } else {
   94|       |        // 1. pack the bytes
   95|       |        // obviously suboptimal.
   96|   675k|        const __m128i utf8_packed = _mm_packus_epi16(in, nextin);
   97|       |        // 2. store (16 bytes)
   98|   675k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   99|       |        // 3. adjust pointers
  100|   675k|        buf += 16;
  101|   675k|        utf8_output += 16;
  102|   675k|        continue; // we are done for this round!
  103|   675k|      }
  104|   711k|    }
  105|       |
  106|       |    // no bits set above 7th bit
  107|   448k|    const __m128i one_byte_bytemask =
  108|   448k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000);
  109|   448k|    const uint16_t one_byte_bitmask =
  110|   448k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  111|       |
  112|       |    // no bits set above 11th bit
  113|   448k|    const __m128i one_or_two_bytes_bytemask =
  114|   448k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000);
  115|   448k|    const uint16_t one_or_two_bytes_bitmask =
  116|   448k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  117|       |
  118|   448k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (118:9): [True: 32.1k, False: 416k]
  ------------------
  119|  32.1k|      internal::westmere::write_v_u16_11bits_to_utf8(
  120|  32.1k|          in, utf8_output, one_byte_bytemask, one_byte_bitmask);
  121|  32.1k|      buf += 8;
  122|  32.1k|      continue;
  123|  32.1k|    }
  124|       |
  125|       |    // 1. Check if there are any surrogate word in the input chunk.
  126|       |    //    We have also deal with situation when there is a surrogate word
  127|       |    //    at the end of a chunk.
  128|   416k|    const __m128i surrogates_bytemask =
  129|   416k|        _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|   416k|    const uint16_t surrogates_bitmask =
  134|   416k|        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|   416k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (137:9): [True: 411k, False: 4.62k]
  ------------------
  138|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  139|   411k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  140|   411k|                                              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|   411k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  170|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  171|   411k|      const __m128i t0 = _mm_shuffle_epi8(in, dup_even);
  172|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  173|   411k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  169|   411k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  174|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  175|   411k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  169|   411k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  176|       |
  177|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  178|   411k|      const __m128i s0 = _mm_srli_epi16(in, 4);
  179|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  180|   411k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  169|   411k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  181|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  182|   411k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  169|   411k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  183|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  184|   411k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  169|   411k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  185|   411k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  186|   411k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  169|   411k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  187|   411k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  188|   411k|#undef simdutf_vec
  189|       |
  190|       |      // 4. expand code units 16-bit => 32-bit
  191|   411k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  192|   411k|      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|   411k|      const uint16_t mask =
  196|   411k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  197|   411k|      if (mask == 0) {
  ------------------
  |  Branch (197:11): [True: 269k, False: 142k]
  ------------------
  198|       |        // We only have three-byte code units. Use fast path.
  199|   269k|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  200|   269k|                                              15, 13, -1, -1, -1, -1);
  201|   269k|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  202|   269k|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  203|   269k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  204|   269k|        utf8_output += 12;
  205|   269k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  206|   269k|        utf8_output += 12;
  207|   269k|        buf += 8;
  208|   269k|        continue;
  209|   269k|      }
  210|   142k|      const uint8_t mask0 = uint8_t(mask);
  211|       |
  212|   142k|      const uint8_t *row0 =
  213|   142k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  214|   142k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  215|   142k|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  216|       |
  217|   142k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  218|       |
  219|   142k|      const uint8_t *row1 =
  220|   142k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  221|   142k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  222|   142k|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  223|       |
  224|   142k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  225|   142k|      utf8_output += row0[0];
  226|   142k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  227|   142k|      utf8_output += row1[0];
  228|       |
  229|   142k|      buf += 8;
  230|       |      // surrogate pair(s) in a register
  231|   142k|    } 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|  4.62k|      size_t forward = 15;
  236|  4.62k|      size_t k = 0;
  237|  4.62k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (237:11): [True: 0, False: 4.62k]
  ------------------
  238|      0|        forward = size_t(end - buf - 1);
  239|      0|      }
  240|  67.8k|      for (; k < forward; k++) {
  ------------------
  |  Branch (240:14): [True: 63.3k, False: 4.53k]
  ------------------
  241|  63.3k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  242|  63.3k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (242:13): [True: 10.5k, False: 52.7k]
  ------------------
  243|  10.5k|          *utf8_output++ = char(word);
  244|  52.7k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (244:20): [True: 1.84k, False: 50.9k]
  ------------------
  245|  1.84k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  246|  1.84k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  247|  50.9k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (247:20): [True: 45.7k, False: 5.24k]
  ------------------
  248|  45.7k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  249|  45.7k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  250|  45.7k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  251|  45.7k|        } else {
  252|       |          // must be a surrogate pair
  253|  5.24k|          uint16_t diff = uint16_t(word - 0xD800);
  254|  5.24k|          uint16_t next_word =
  255|  5.24k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  256|  5.24k|          k++;
  257|  5.24k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  258|  5.24k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (258:15): [True: 88, False: 5.15k]
  ------------------
  259|     88|            return std::make_pair(nullptr, utf8_output);
  260|     88|          }
  261|  5.15k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  262|  5.15k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  263|  5.15k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  264|  5.15k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  265|  5.15k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  266|  5.15k|        }
  267|  63.3k|      }
  268|  4.53k|      buf += k;
  269|  4.53k|    }
  270|   416k|  } // while
  271|       |
  272|    662|  return std::make_pair(buf, utf8_output);
  273|    750|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_137sse_convert_utf16_to_utf8_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
  285|    664|                                      char *utf8_output) {
  286|    664|  const char16_t *start = buf;
  287|    664|  const char16_t *end = buf + len;
  288|       |
  289|    664|  const __m128i v_0000 = _mm_setzero_si128();
  290|    664|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
  291|    664|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
  292|    664|  const size_t safety_margin =
  293|    664|      12; // to avoid overruns, see issue
  294|       |          // https://github.com/simdutf/simdutf/issues/92
  295|       |
  296|   830k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (296:10): [True: 829k, False: 516]
  ------------------
  297|   829k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  298|   829k|    if (big_endian) {
  ------------------
  |  Branch (298:9): [Folded, False: 829k]
  ------------------
  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|   829k|    const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80);
  305|   829k|    if (_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (305:9): [True: 270k, False: 559k]
  ------------------
  306|   270k|      __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  307|   270k|      if (big_endian) {
  ------------------
  |  Branch (307:11): [Folded, False: 270k]
  ------------------
  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|   270k|      if (!_mm_testz_si128(nextin, v_ff80)) {
  ------------------
  |  Branch (312:11): [True: 11.9k, False: 258k]
  ------------------
  313|       |        // 1. pack the bytes
  314|       |        // obviously suboptimal.
  315|  11.9k|        const __m128i utf8_packed = _mm_packus_epi16(in, in);
  316|       |        // 2. store (16 bytes)
  317|  11.9k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  318|       |        // 3. adjust pointers
  319|  11.9k|        buf += 8;
  320|  11.9k|        utf8_output += 8;
  321|  11.9k|        in = nextin;
  322|   258k|      } else {
  323|       |        // 1. pack the bytes
  324|       |        // obviously suboptimal.
  325|   258k|        const __m128i utf8_packed = _mm_packus_epi16(in, nextin);
  326|       |        // 2. store (16 bytes)
  327|   258k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  328|       |        // 3. adjust pointers
  329|   258k|        buf += 16;
  330|   258k|        utf8_output += 16;
  331|   258k|        continue; // we are done for this round!
  332|   258k|      }
  333|   270k|    }
  334|       |
  335|       |    // no bits set above 7th bit
  336|   571k|    const __m128i one_byte_bytemask =
  337|   571k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000);
  338|   571k|    const uint16_t one_byte_bitmask =
  339|   571k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  340|       |
  341|       |    // no bits set above 11th bit
  342|   571k|    const __m128i one_or_two_bytes_bytemask =
  343|   571k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000);
  344|   571k|    const uint16_t one_or_two_bytes_bitmask =
  345|   571k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  346|       |
  347|   571k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (347:9): [True: 174k, False: 397k]
  ------------------
  348|   174k|      internal::westmere::write_v_u16_11bits_to_utf8(
  349|   174k|          in, utf8_output, one_byte_bytemask, one_byte_bitmask);
  350|   174k|      buf += 8;
  351|   174k|      continue;
  352|   174k|    }
  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|   397k|    const __m128i surrogates_bytemask =
  358|   397k|        _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|   397k|    const uint16_t surrogates_bitmask =
  363|   397k|        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|   397k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (366:9): [True: 395k, False: 1.97k]
  ------------------
  367|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  368|   395k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  369|   395k|                                              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|   395k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  399|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  400|   395k|      const __m128i t0 = _mm_shuffle_epi8(in, dup_even);
  401|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  402|   395k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  398|   395k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  403|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  404|   395k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  398|   395k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  405|       |
  406|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  407|   395k|      const __m128i s0 = _mm_srli_epi16(in, 4);
  408|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  409|   395k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  398|   395k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  410|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  411|   395k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  398|   395k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  412|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  413|   395k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  398|   395k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  414|   395k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  415|   395k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  398|   395k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  416|   395k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  417|   395k|#undef simdutf_vec
  418|       |
  419|       |      // 4. expand code units 16-bit => 32-bit
  420|   395k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  421|   395k|      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|   395k|      const uint16_t mask =
  425|   395k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  426|   395k|      if (mask == 0) {
  ------------------
  |  Branch (426:11): [True: 313k, False: 81.4k]
  ------------------
  427|       |        // We only have three-byte code units. Use fast path.
  428|   313k|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  429|   313k|                                              15, 13, -1, -1, -1, -1);
  430|   313k|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  431|   313k|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  432|   313k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  433|   313k|        utf8_output += 12;
  434|   313k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  435|   313k|        utf8_output += 12;
  436|   313k|        buf += 8;
  437|   313k|        continue;
  438|   313k|      }
  439|  81.4k|      const uint8_t mask0 = uint8_t(mask);
  440|       |
  441|  81.4k|      const uint8_t *row0 =
  442|  81.4k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  443|  81.4k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  444|  81.4k|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  445|       |
  446|  81.4k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  447|       |
  448|  81.4k|      const uint8_t *row1 =
  449|  81.4k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  450|  81.4k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  451|  81.4k|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  452|       |
  453|  81.4k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  454|  81.4k|      utf8_output += row0[0];
  455|  81.4k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  456|  81.4k|      utf8_output += row1[0];
  457|       |
  458|  81.4k|      buf += 8;
  459|       |      // surrogate pair(s) in a register
  460|  81.4k|    } 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|  1.97k|      size_t forward = 15;
  465|  1.97k|      size_t k = 0;
  466|  1.97k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (466:11): [True: 0, False: 1.97k]
  ------------------
  467|      0|        forward = size_t(end - buf - 1);
  468|      0|      }
  469|  27.6k|      for (; k < forward; k++) {
  ------------------
  |  Branch (469:14): [True: 25.8k, False: 1.82k]
  ------------------
  470|  25.8k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  471|  25.8k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (471:13): [True: 4.96k, False: 20.8k]
  ------------------
  472|  4.96k|          *utf8_output++ = char(word);
  473|  20.8k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (473:20): [True: 1.26k, False: 19.5k]
  ------------------
  474|  1.26k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  475|  1.26k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  476|  19.5k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (476:20): [True: 17.1k, False: 2.39k]
  ------------------
  477|  17.1k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  478|  17.1k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  479|  17.1k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  480|  17.1k|        } else {
  481|       |          // must be a surrogate pair
  482|  2.39k|          uint16_t diff = uint16_t(word - 0xD800);
  483|  2.39k|          uint16_t next_word =
  484|  2.39k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  485|  2.39k|          k++;
  486|  2.39k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  487|  2.39k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (487:15): [True: 148, False: 2.24k]
  ------------------
  488|    148|            return std::make_pair(
  489|    148|                result(error_code::SURROGATE, buf - start + k - 1),
  490|    148|                utf8_output);
  491|    148|          }
  492|  2.24k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  493|  2.24k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  494|  2.24k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  495|  2.24k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  496|  2.24k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  497|  2.24k|        }
  498|  25.8k|      }
  499|  1.82k|      buf += k;
  500|  1.82k|    }
  501|   397k|  } // while
  502|       |
  503|    516|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output);
  504|    664|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_137sse_convert_utf16_to_utf8_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
  285|    728|                                      char *utf8_output) {
  286|    728|  const char16_t *start = buf;
  287|    728|  const char16_t *end = buf + len;
  288|       |
  289|    728|  const __m128i v_0000 = _mm_setzero_si128();
  290|    728|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
  291|    728|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
  292|    728|  const size_t safety_margin =
  293|    728|      12; // to avoid overruns, see issue
  294|       |          // https://github.com/simdutf/simdutf/issues/92
  295|       |
  296|   837k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (296:10): [True: 837k, False: 554]
  ------------------
  297|   837k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  298|   837k|    if (big_endian) {
  ------------------
  |  Branch (298:9): [True: 837k, Folded]
  ------------------
  299|   837k|      const __m128i swap =
  300|   837k|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  301|   837k|      in = _mm_shuffle_epi8(in, swap);
  302|   837k|    }
  303|       |    // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes
  304|   837k|    const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80);
  305|   837k|    if (_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (305:9): [True: 521k, False: 316k]
  ------------------
  306|   521k|      __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  307|   521k|      if (big_endian) {
  ------------------
  |  Branch (307:11): [True: 521k, Folded]
  ------------------
  308|   521k|        const __m128i swap =
  309|   521k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  310|   521k|        nextin = _mm_shuffle_epi8(nextin, swap);
  311|   521k|      }
  312|   521k|      if (!_mm_testz_si128(nextin, v_ff80)) {
  ------------------
  |  Branch (312:11): [True: 89.2k, False: 432k]
  ------------------
  313|       |        // 1. pack the bytes
  314|       |        // obviously suboptimal.
  315|  89.2k|        const __m128i utf8_packed = _mm_packus_epi16(in, in);
  316|       |        // 2. store (16 bytes)
  317|  89.2k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  318|       |        // 3. adjust pointers
  319|  89.2k|        buf += 8;
  320|  89.2k|        utf8_output += 8;
  321|  89.2k|        in = nextin;
  322|   432k|      } else {
  323|       |        // 1. pack the bytes
  324|       |        // obviously suboptimal.
  325|   432k|        const __m128i utf8_packed = _mm_packus_epi16(in, nextin);
  326|       |        // 2. store (16 bytes)
  327|   432k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  328|       |        // 3. adjust pointers
  329|   432k|        buf += 16;
  330|   432k|        utf8_output += 16;
  331|   432k|        continue; // we are done for this round!
  332|   432k|      }
  333|   521k|    }
  334|       |
  335|       |    // no bits set above 7th bit
  336|   405k|    const __m128i one_byte_bytemask =
  337|   405k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000);
  338|   405k|    const uint16_t one_byte_bitmask =
  339|   405k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  340|       |
  341|       |    // no bits set above 11th bit
  342|   405k|    const __m128i one_or_two_bytes_bytemask =
  343|   405k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000);
  344|   405k|    const uint16_t one_or_two_bytes_bitmask =
  345|   405k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  346|       |
  347|   405k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (347:9): [True: 112k, False: 292k]
  ------------------
  348|   112k|      internal::westmere::write_v_u16_11bits_to_utf8(
  349|   112k|          in, utf8_output, one_byte_bytemask, one_byte_bitmask);
  350|   112k|      buf += 8;
  351|   112k|      continue;
  352|   112k|    }
  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|   292k|    const __m128i surrogates_bytemask =
  358|   292k|        _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|   292k|    const uint16_t surrogates_bitmask =
  363|   292k|        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|   292k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (366:9): [True: 268k, False: 23.8k]
  ------------------
  367|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  368|   268k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  369|   268k|                                              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|   268k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  399|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  400|   268k|      const __m128i t0 = _mm_shuffle_epi8(in, dup_even);
  401|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  402|   268k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  398|   268k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  403|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  404|   268k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  398|   268k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  405|       |
  406|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  407|   268k|      const __m128i s0 = _mm_srli_epi16(in, 4);
  408|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  409|   268k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  398|   268k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  410|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  411|   268k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  398|   268k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  412|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  413|   268k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  398|   268k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  414|   268k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  415|   268k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  398|   268k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  416|   268k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  417|   268k|#undef simdutf_vec
  418|       |
  419|       |      // 4. expand code units 16-bit => 32-bit
  420|   268k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  421|   268k|      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|   268k|      const uint16_t mask =
  425|   268k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  426|   268k|      if (mask == 0) {
  ------------------
  |  Branch (426:11): [True: 52.3k, False: 216k]
  ------------------
  427|       |        // We only have three-byte code units. Use fast path.
  428|  52.3k|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  429|  52.3k|                                              15, 13, -1, -1, -1, -1);
  430|  52.3k|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  431|  52.3k|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  432|  52.3k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  433|  52.3k|        utf8_output += 12;
  434|  52.3k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  435|  52.3k|        utf8_output += 12;
  436|  52.3k|        buf += 8;
  437|  52.3k|        continue;
  438|  52.3k|      }
  439|   216k|      const uint8_t mask0 = uint8_t(mask);
  440|       |
  441|   216k|      const uint8_t *row0 =
  442|   216k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  443|   216k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  444|   216k|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  445|       |
  446|   216k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  447|       |
  448|   216k|      const uint8_t *row1 =
  449|   216k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  450|   216k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  451|   216k|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  452|       |
  453|   216k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  454|   216k|      utf8_output += row0[0];
  455|   216k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  456|   216k|      utf8_output += row1[0];
  457|       |
  458|   216k|      buf += 8;
  459|       |      // surrogate pair(s) in a register
  460|   216k|    } 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|  23.8k|      size_t forward = 15;
  465|  23.8k|      size_t k = 0;
  466|  23.8k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (466:11): [True: 0, False: 23.8k]
  ------------------
  467|      0|        forward = size_t(end - buf - 1);
  468|      0|      }
  469|   353k|      for (; k < forward; k++) {
  ------------------
  |  Branch (469:14): [True: 330k, False: 23.6k]
  ------------------
  470|   330k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  471|   330k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (471:13): [True: 133k, False: 196k]
  ------------------
  472|   133k|          *utf8_output++ = char(word);
  473|   196k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (473:20): [True: 14.7k, False: 181k]
  ------------------
  474|  14.7k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  475|  14.7k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  476|   181k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (476:20): [True: 156k, False: 25.8k]
  ------------------
  477|   156k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  478|   156k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  479|   156k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  480|   156k|        } else {
  481|       |          // must be a surrogate pair
  482|  25.8k|          uint16_t diff = uint16_t(word - 0xD800);
  483|  25.8k|          uint16_t next_word =
  484|  25.8k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  485|  25.8k|          k++;
  486|  25.8k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  487|  25.8k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (487:15): [True: 174, False: 25.6k]
  ------------------
  488|    174|            return std::make_pair(
  489|    174|                result(error_code::SURROGATE, buf - start + k - 1),
  490|    174|                utf8_output);
  491|    174|          }
  492|  25.6k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  493|  25.6k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  494|  25.6k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  495|  25.6k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  496|  25.6k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  497|  25.6k|        }
  498|   330k|      }
  499|  23.6k|      buf += k;
  500|  23.6k|    }
  501|   292k|  } // while
  502|       |
  503|    554|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output);
  504|    728|}

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

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_utf32_to_utf16ILNS_10endiannessE0EEENSt3__14pairIPKDiPDsEES7_mS8_:
   58|    774|                           char16_t *utf16_output) {
   59|       |
   60|    774|  const char32_t *end = buf + len;
   61|       |
   62|    774|  const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000);
   63|    774|  __m128i forbidden_bytemask = _mm_setzero_si128();
   64|       |
   65|  66.9k|  while (end - buf >= 16 + 8) {
  ------------------
  |  Branch (65:10): [True: 66.2k, False: 752]
  ------------------
   66|  66.2k|    const __m128i *ptr = reinterpret_cast<const __m128i *>(buf);
   67|  66.2k|    const __m128i in0 = _mm_loadu_si128(ptr + 0);
   68|  66.2k|    const __m128i in1 = _mm_loadu_si128(ptr + 1);
   69|  66.2k|    const __m128i in2 = _mm_loadu_si128(ptr + 2);
   70|  66.2k|    const __m128i in3 = _mm_loadu_si128(ptr + 3);
   71|       |
   72|  66.2k|    const __m128i combined =
   73|  66.2k|        _mm_or_si128(_mm_or_si128(in2, in3), _mm_or_si128(in0, in1));
   74|  66.2k|    if (simdutf_likely(_mm_testz_si128(combined, v_ffff0000))) {
  ------------------
  |  |   90|  66.2k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 64.9k, False: 1.26k]
  |  |  ------------------
  ------------------
   75|       |      // No bits set above 16th, directly pack UTF-32 to UTF-16
   76|  64.9k|      __m128i utf16_packed0 = _mm_packus_epi32(in0, in1);
   77|  64.9k|      __m128i utf16_packed1 = _mm_packus_epi32(in2, in3);
   78|       |
   79|  64.9k|      const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
   80|  64.9k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
   81|  64.9k|      forbidden_bytemask = _mm_or_si128(
   82|  64.9k|          forbidden_bytemask,
   83|  64.9k|          _mm_or_si128(
   84|  64.9k|              _mm_cmpeq_epi16(_mm_and_si128(utf16_packed0, v_f800), v_d800),
   85|  64.9k|              _mm_cmpeq_epi16(_mm_and_si128(utf16_packed1, v_f800), v_d800)));
   86|       |
   87|  64.9k|      if (big_endian) {
  ------------------
  |  Branch (87:11): [Folded, False: 64.9k]
  ------------------
   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|  64.9k|      _mm_storeu_si128((__m128i *)utf16_output + 0, utf16_packed0);
   95|  64.9k|      _mm_storeu_si128((__m128i *)utf16_output + 1, utf16_packed1);
   96|  64.9k|      utf16_output += 16;
   97|  64.9k|      buf += 16;
   98|  64.9k|    } else {
   99|  1.26k|      if (!validate_utf32(in0, in1) || !validate_utf32(in2, in3)) {
  ------------------
  |  Branch (99:11): [True: 12, False: 1.25k]
  |  Branch (99:40): [True: 10, False: 1.24k]
  ------------------
  100|     22|        return std::make_pair(nullptr, utf16_output);
  101|     22|      }
  102|       |
  103|  1.24k|      const auto ret0 = sse_expand_surrogate<big_endian>(in0);
  104|  1.24k|      _mm_storeu_si128((__m128i *)utf16_output, ret0.compressed);
  105|  1.24k|      utf16_output += ret0.u16count;
  106|       |
  107|  1.24k|      const auto ret1 = sse_expand_surrogate<big_endian>(in1);
  108|  1.24k|      _mm_storeu_si128((__m128i *)utf16_output, ret1.compressed);
  109|  1.24k|      utf16_output += ret1.u16count;
  110|       |
  111|  1.24k|      const auto ret2 = sse_expand_surrogate<big_endian>(in2);
  112|  1.24k|      _mm_storeu_si128((__m128i *)utf16_output, ret2.compressed);
  113|  1.24k|      utf16_output += ret2.u16count;
  114|       |
  115|  1.24k|      const auto ret3 = sse_expand_surrogate<big_endian>(in3);
  116|  1.24k|      _mm_storeu_si128((__m128i *)utf16_output, ret3.compressed);
  117|  1.24k|      utf16_output += ret3.u16count;
  118|       |
  119|  1.24k|      buf += 16;
  120|  1.24k|    }
  121|  66.2k|  }
  122|       |
  123|       |  // check for invalid input
  124|    752|  if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (124:7): [True: 20, False: 732]
  ------------------
  125|     20|    return std::make_pair(nullptr, utf16_output);
  126|     20|  }
  127|       |
  128|    732|  return std::make_pair(buf, utf16_output);
  129|    752|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114validate_utf32EDv2_xS2_:
   37|  5.34k|simdutf_really_inline bool validate_utf32(const __m128i a, const __m128i b) {
   38|  5.34k|  using vector_u32 = simd32<uint32_t>;
   39|       |
   40|  5.34k|  const auto in0 = vector_u32(a);
   41|  5.34k|  const auto in1 = vector_u32(b);
   42|       |
   43|  5.34k|  const auto standardmax = vector_u32::splat(0x10ffff);
   44|  5.34k|  const auto offset = vector_u32::splat(0xffff2000);
   45|  5.34k|  const auto standardoffsetmax = vector_u32::splat(0xfffff7ff);
   46|       |
   47|  5.34k|  const auto too_large = max(in0, in1) > standardmax;
   48|  5.34k|  const auto surrogate0 = (in0 + offset) > standardoffsetmax;
   49|  5.34k|  const auto surrogate1 = (in1 + offset) > standardoffsetmax;
   50|       |
   51|  5.34k|  const auto combined = too_large | surrogate0 | surrogate1;
   52|  5.34k|  return !combined.any();
   53|  5.34k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_120sse_expand_surrogateILNS_10endiannessE0EEENS1_18expansion_result_tEDv2_x:
    9|  4.97k|expansion_result_t sse_expand_surrogate(const __m128i x) {
   10|  4.97k|  using vector_u32 = simd32<uint32_t>;
   11|  4.97k|  using vector_u8 = simd8<uint8_t>;
   12|       |
   13|  4.97k|  const auto in = vector_u32(x);
   14|       |
   15|  4.97k|  const auto non_surrogate_mask = (in & uint32_t(0xffff0000)) == uint32_t(0);
   16|  4.97k|  const auto mask = (~non_surrogate_mask.to_4bit_bitmask()) & 0xf;
   17|       |
   18|  4.97k|  const auto t0 = in - uint32_t(0x00010000);
   19|  4.97k|  const auto hi = t0.shr<10>() & uint32_t(0x000003ff);
   20|  4.97k|  const auto lo = t0.shl<16>() & uint32_t(0x03ff0000);
   21|  4.97k|  const auto surrogates = (lo | hi) | uint32_t(0xdc00d800);
   22|       |
   23|  4.97k|  const auto merged = as_vector_u8(select(non_surrogate_mask, in, surrogates));
   24|       |
   25|  4.97k|  const auto shuffle = vector_u8::load(
   26|  4.97k|      (byte_order == endianness::LITTLE)
  ------------------
  |  Branch (26:7): [True: 4.97k, Folded]
  ------------------
   27|  4.97k|          ? tables::utf32_to_utf16::pack_utf32_to_utf16le[mask]
   28|  4.97k|          : tables::utf32_to_utf16::pack_utf32_to_utf16be[mask]);
   29|       |
   30|  4.97k|  const size_t u16count = (4 + count_ones(mask));
   31|  4.97k|  const auto compressed = shuffle.lookup_16(merged);
   32|       |
   33|  4.97k|  return {u16count, compressed};
   34|  4.97k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_utf32_to_utf16ILNS_10endiannessE1EEENSt3__14pairIPKDiPDsEES7_mS8_:
   58|    662|                           char16_t *utf16_output) {
   59|       |
   60|    662|  const char32_t *end = buf + len;
   61|       |
   62|    662|  const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000);
   63|    662|  __m128i forbidden_bytemask = _mm_setzero_si128();
   64|       |
   65|  13.1k|  while (end - buf >= 16 + 8) {
  ------------------
  |  Branch (65:10): [True: 12.6k, False: 568]
  ------------------
   66|  12.6k|    const __m128i *ptr = reinterpret_cast<const __m128i *>(buf);
   67|  12.6k|    const __m128i in0 = _mm_loadu_si128(ptr + 0);
   68|  12.6k|    const __m128i in1 = _mm_loadu_si128(ptr + 1);
   69|  12.6k|    const __m128i in2 = _mm_loadu_si128(ptr + 2);
   70|  12.6k|    const __m128i in3 = _mm_loadu_si128(ptr + 3);
   71|       |
   72|  12.6k|    const __m128i combined =
   73|  12.6k|        _mm_or_si128(_mm_or_si128(in2, in3), _mm_or_si128(in0, in1));
   74|  12.6k|    if (simdutf_likely(_mm_testz_si128(combined, v_ffff0000))) {
  ------------------
  |  |   90|  12.6k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 11.1k, False: 1.44k]
  |  |  ------------------
  ------------------
   75|       |      // No bits set above 16th, directly pack UTF-32 to UTF-16
   76|  11.1k|      __m128i utf16_packed0 = _mm_packus_epi32(in0, in1);
   77|  11.1k|      __m128i utf16_packed1 = _mm_packus_epi32(in2, in3);
   78|       |
   79|  11.1k|      const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
   80|  11.1k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
   81|  11.1k|      forbidden_bytemask = _mm_or_si128(
   82|  11.1k|          forbidden_bytemask,
   83|  11.1k|          _mm_or_si128(
   84|  11.1k|              _mm_cmpeq_epi16(_mm_and_si128(utf16_packed0, v_f800), v_d800),
   85|  11.1k|              _mm_cmpeq_epi16(_mm_and_si128(utf16_packed1, v_f800), v_d800)));
   86|       |
   87|  11.1k|      if (big_endian) {
  ------------------
  |  Branch (87:11): [True: 11.1k, Folded]
  ------------------
   88|  11.1k|        const __m128i swap =
   89|  11.1k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   90|  11.1k|        utf16_packed0 = _mm_shuffle_epi8(utf16_packed0, swap);
   91|  11.1k|        utf16_packed1 = _mm_shuffle_epi8(utf16_packed1, swap);
   92|  11.1k|      }
   93|       |
   94|  11.1k|      _mm_storeu_si128((__m128i *)utf16_output + 0, utf16_packed0);
   95|  11.1k|      _mm_storeu_si128((__m128i *)utf16_output + 1, utf16_packed1);
   96|  11.1k|      utf16_output += 16;
   97|  11.1k|      buf += 16;
   98|  11.1k|    } else {
   99|  1.44k|      if (!validate_utf32(in0, in1) || !validate_utf32(in2, in3)) {
  ------------------
  |  Branch (99:11): [True: 66, False: 1.37k]
  |  Branch (99:40): [True: 28, False: 1.35k]
  ------------------
  100|     94|        return std::make_pair(nullptr, utf16_output);
  101|     94|      }
  102|       |
  103|  1.35k|      const auto ret0 = sse_expand_surrogate<big_endian>(in0);
  104|  1.35k|      _mm_storeu_si128((__m128i *)utf16_output, ret0.compressed);
  105|  1.35k|      utf16_output += ret0.u16count;
  106|       |
  107|  1.35k|      const auto ret1 = sse_expand_surrogate<big_endian>(in1);
  108|  1.35k|      _mm_storeu_si128((__m128i *)utf16_output, ret1.compressed);
  109|  1.35k|      utf16_output += ret1.u16count;
  110|       |
  111|  1.35k|      const auto ret2 = sse_expand_surrogate<big_endian>(in2);
  112|  1.35k|      _mm_storeu_si128((__m128i *)utf16_output, ret2.compressed);
  113|  1.35k|      utf16_output += ret2.u16count;
  114|       |
  115|  1.35k|      const auto ret3 = sse_expand_surrogate<big_endian>(in3);
  116|  1.35k|      _mm_storeu_si128((__m128i *)utf16_output, ret3.compressed);
  117|  1.35k|      utf16_output += ret3.u16count;
  118|       |
  119|  1.35k|      buf += 16;
  120|  1.35k|    }
  121|  12.6k|  }
  122|       |
  123|       |  // check for invalid input
  124|    568|  if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (124:7): [True: 6, False: 562]
  ------------------
  125|      6|    return std::make_pair(nullptr, utf16_output);
  126|      6|  }
  127|       |
  128|    562|  return std::make_pair(buf, utf16_output);
  129|    568|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_120sse_expand_surrogateILNS_10endiannessE1EEENS1_18expansion_result_tEDv2_x:
    9|  5.40k|expansion_result_t sse_expand_surrogate(const __m128i x) {
   10|  5.40k|  using vector_u32 = simd32<uint32_t>;
   11|  5.40k|  using vector_u8 = simd8<uint8_t>;
   12|       |
   13|  5.40k|  const auto in = vector_u32(x);
   14|       |
   15|  5.40k|  const auto non_surrogate_mask = (in & uint32_t(0xffff0000)) == uint32_t(0);
   16|  5.40k|  const auto mask = (~non_surrogate_mask.to_4bit_bitmask()) & 0xf;
   17|       |
   18|  5.40k|  const auto t0 = in - uint32_t(0x00010000);
   19|  5.40k|  const auto hi = t0.shr<10>() & uint32_t(0x000003ff);
   20|  5.40k|  const auto lo = t0.shl<16>() & uint32_t(0x03ff0000);
   21|  5.40k|  const auto surrogates = (lo | hi) | uint32_t(0xdc00d800);
   22|       |
   23|  5.40k|  const auto merged = as_vector_u8(select(non_surrogate_mask, in, surrogates));
   24|       |
   25|  5.40k|  const auto shuffle = vector_u8::load(
   26|  5.40k|      (byte_order == endianness::LITTLE)
  ------------------
  |  Branch (26:7): [Folded, False: 5.40k]
  ------------------
   27|  5.40k|          ? tables::utf32_to_utf16::pack_utf32_to_utf16le[mask]
   28|  5.40k|          : tables::utf32_to_utf16::pack_utf32_to_utf16be[mask]);
   29|       |
   30|  5.40k|  const size_t u16count = (4 + count_ones(mask));
   31|  5.40k|  const auto compressed = shuffle.lookup_16(merged);
   32|       |
   33|  5.40k|  return {u16count, compressed};
   34|  5.40k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_138sse_convert_utf32_to_utf16_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPDsEEPKDimS7_:
  134|    684|                                       char16_t *utf16_output) {
  135|    684|  const char32_t *start = buf;
  136|    684|  const char32_t *end = buf + len;
  137|       |
  138|    684|  const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000);
  139|       |
  140|  55.9k|  while (end - buf >= 8) {
  ------------------
  |  Branch (140:10): [True: 55.6k, False: 316]
  ------------------
  141|  55.6k|    const __m128i in = _mm_loadu_si128((__m128i *)buf);
  142|  55.6k|    const __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  143|       |
  144|  55.6k|    const __m128i combined = _mm_or_si128(in, nextin);
  145|  55.6k|    if (simdutf_likely(_mm_testz_si128(combined, v_ffff0000))) {
  ------------------
  |  |   90|  55.6k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 53.4k, False: 2.17k]
  |  |  ------------------
  ------------------
  146|       |      // No bits set above 16th, directly pack UTF-32 to UTF-16
  147|  53.4k|      __m128i utf16_packed = _mm_packus_epi32(in, nextin);
  148|       |
  149|  53.4k|      const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
  150|  53.4k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
  151|  53.4k|      const __m128i forbidden_bytemask =
  152|  53.4k|          _mm_cmpeq_epi16(_mm_and_si128(utf16_packed, v_f800), v_d800);
  153|  53.4k|      if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (153:11): [True: 44, False: 53.4k]
  ------------------
  154|     44|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  155|     44|                              utf16_output);
  156|     44|      }
  157|       |
  158|  53.4k|      if (big_endian) {
  ------------------
  |  Branch (158:11): [Folded, False: 53.4k]
  ------------------
  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|  53.4k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
  165|  53.4k|      utf16_output += 8;
  166|  53.4k|      buf += 8;
  167|  53.4k|    } else {
  168|  2.17k|      size_t forward = 7;
  169|  2.17k|      size_t k = 0;
  170|  2.17k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (170:11): [True: 0, False: 2.17k]
  ------------------
  171|      0|        forward = size_t(end - buf - 1);
  172|      0|      }
  173|  15.8k|      for (; k < forward; k++) {
  ------------------
  |  Branch (173:14): [True: 14.0k, False: 1.85k]
  ------------------
  174|  14.0k|        uint32_t word = buf[k];
  175|  14.0k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (175:13): [True: 6.58k, False: 7.44k]
  ------------------
  176|       |          // will not generate a surrogate pair
  177|  6.58k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (177:15): [True: 702, False: 5.88k]
  |  Branch (177:33): [True: 30, False: 672]
  ------------------
  178|     30|            return std::make_pair(
  179|     30|                result(error_code::SURROGATE, buf - start + k), utf16_output);
  180|     30|          }
  181|  6.55k|          *utf16_output++ =
  182|  6.55k|              big_endian
  ------------------
  |  Branch (182:15): [Folded, False: 6.55k]
  ------------------
  183|  6.55k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
  184|  6.55k|                  : char16_t(word);
  185|  7.44k|        } else {
  186|       |          // will generate a surrogate pair
  187|  7.44k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (187:15): [True: 294, False: 7.14k]
  ------------------
  188|    294|            return std::make_pair(
  189|    294|                result(error_code::TOO_LARGE, buf - start + k), utf16_output);
  190|    294|          }
  191|  7.14k|          word -= 0x10000;
  192|  7.14k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
  193|  7.14k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
  194|  7.14k|          if (big_endian) {
  ------------------
  |  Branch (194:15): [Folded, False: 7.14k]
  ------------------
  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|  7.14k|          *utf16_output++ = char16_t(high_surrogate);
  201|  7.14k|          *utf16_output++ = char16_t(low_surrogate);
  202|  7.14k|        }
  203|  14.0k|      }
  204|  1.85k|      buf += k;
  205|  1.85k|    }
  206|  55.6k|  }
  207|       |
  208|    316|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output);
  209|    684|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_138sse_convert_utf32_to_utf16_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPDsEEPKDimS7_:
  134|    630|                                       char16_t *utf16_output) {
  135|    630|  const char32_t *start = buf;
  136|    630|  const char32_t *end = buf + len;
  137|       |
  138|    630|  const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000);
  139|       |
  140|  3.68k|  while (end - buf >= 8) {
  ------------------
  |  Branch (140:10): [True: 3.37k, False: 302]
  ------------------
  141|  3.37k|    const __m128i in = _mm_loadu_si128((__m128i *)buf);
  142|  3.37k|    const __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  143|       |
  144|  3.37k|    const __m128i combined = _mm_or_si128(in, nextin);
  145|  3.37k|    if (simdutf_likely(_mm_testz_si128(combined, v_ffff0000))) {
  ------------------
  |  |   90|  3.37k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 2.37k, False: 1.00k]
  |  |  ------------------
  ------------------
  146|       |      // No bits set above 16th, directly pack UTF-32 to UTF-16
  147|  2.37k|      __m128i utf16_packed = _mm_packus_epi32(in, nextin);
  148|       |
  149|  2.37k|      const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
  150|  2.37k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
  151|  2.37k|      const __m128i forbidden_bytemask =
  152|  2.37k|          _mm_cmpeq_epi16(_mm_and_si128(utf16_packed, v_f800), v_d800);
  153|  2.37k|      if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (153:11): [True: 14, False: 2.36k]
  ------------------
  154|     14|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  155|     14|                              utf16_output);
  156|     14|      }
  157|       |
  158|  2.36k|      if (big_endian) {
  ------------------
  |  Branch (158:11): [True: 2.36k, Folded]
  ------------------
  159|  2.36k|        const __m128i swap =
  160|  2.36k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  161|  2.36k|        utf16_packed = _mm_shuffle_epi8(utf16_packed, swap);
  162|  2.36k|      }
  163|       |
  164|  2.36k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
  165|  2.36k|      utf16_output += 8;
  166|  2.36k|      buf += 8;
  167|  2.36k|    } else {
  168|  1.00k|      size_t forward = 7;
  169|  1.00k|      size_t k = 0;
  170|  1.00k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (170:11): [True: 0, False: 1.00k]
  ------------------
  171|      0|        forward = size_t(end - buf - 1);
  172|      0|      }
  173|  6.43k|      for (; k < forward; k++) {
  ------------------
  |  Branch (173:14): [True: 5.74k, False: 686]
  ------------------
  174|  5.74k|        uint32_t word = buf[k];
  175|  5.74k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (175:13): [True: 2.98k, False: 2.76k]
  ------------------
  176|       |          // will not generate a surrogate pair
  177|  2.98k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (177:15): [True: 732, False: 2.25k]
  |  Branch (177:33): [True: 28, False: 704]
  ------------------
  178|     28|            return std::make_pair(
  179|     28|                result(error_code::SURROGATE, buf - start + k), utf16_output);
  180|     28|          }
  181|  2.95k|          *utf16_output++ =
  182|  2.95k|              big_endian
  ------------------
  |  Branch (182:15): [True: 2.95k, Folded]
  ------------------
  183|  2.95k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
  184|  2.95k|                  : char16_t(word);
  185|  2.95k|        } else {
  186|       |          // will generate a surrogate pair
  187|  2.76k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (187:15): [True: 286, False: 2.47k]
  ------------------
  188|    286|            return std::make_pair(
  189|    286|                result(error_code::TOO_LARGE, buf - start + k), utf16_output);
  190|    286|          }
  191|  2.47k|          word -= 0x10000;
  192|  2.47k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
  193|  2.47k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
  194|  2.47k|          if (big_endian) {
  ------------------
  |  Branch (194:15): [True: 2.47k, Folded]
  ------------------
  195|  2.47k|            high_surrogate =
  196|  2.47k|                uint16_t((high_surrogate >> 8) | (high_surrogate << 8));
  197|  2.47k|            low_surrogate =
  198|  2.47k|                uint16_t((low_surrogate >> 8) | (low_surrogate << 8));
  199|  2.47k|          }
  200|  2.47k|          *utf16_output++ = char16_t(high_surrogate);
  201|  2.47k|          *utf16_output++ = char16_t(low_surrogate);
  202|  2.47k|        }
  203|  5.74k|      }
  204|    686|      buf += k;
  205|    686|    }
  206|  3.37k|  }
  207|       |
  208|    302|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output);
  209|    630|}

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

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

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_128convert_masked_utf8_to_utf16ILNS_10endiannessE0EEEmPKcmRPDs:
   10|  3.02M|                                    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.02M|  const __m128i swap =
   23|  3.02M|      _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   24|  3.02M|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   25|  3.02M|  const uint16_t input_utf8_end_of_code_point_mask =
   26|  3.02M|      utf8_end_of_code_point_mask & 0xfff;
   27|  3.02M|  if (utf8_end_of_code_point_mask == 0xfff) {
  ------------------
  |  Branch (27:7): [True: 10.8k, False: 3.01M]
  ------------------
   28|       |    // We process the data in chunks of 12 bytes.
   29|       |    // Note: using 16 bytes is unsafe, see issue_ossfuzz_71218
   30|  10.8k|    __m128i ascii_first = _mm_cvtepu8_epi16(in);
   31|  10.8k|    __m128i ascii_second = _mm_cvtepu8_epi16(_mm_srli_si128(in, 8));
   32|  10.8k|    if (big_endian) {
  ------------------
  |  Branch (32:9): [Folded, False: 10.8k]
  ------------------
   33|      0|      ascii_first = _mm_shuffle_epi8(ascii_first, swap);
   34|      0|      ascii_second = _mm_shuffle_epi8(ascii_second, swap);
   35|      0|    }
   36|  10.8k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf16_output), ascii_first);
   37|  10.8k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf16_output + 8),
   38|  10.8k|                     ascii_second);
   39|  10.8k|    utf16_output += 12; // We wrote 12 16-bit characters.
   40|  10.8k|    return 12;          // We consumed 12 bytes.
   41|  10.8k|  }
   42|  3.01M|  if (((utf8_end_of_code_point_mask & 0xFFFF) == 0xaaaa)) {
  ------------------
  |  Branch (42:7): [True: 14.8k, False: 2.99M]
  ------------------
   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|  14.8k|    const __m128i sh =
   47|  14.8k|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   48|  14.8k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   49|  14.8k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   50|  14.8k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   51|  14.8k|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   52|  14.8k|    if (big_endian)
  ------------------
  |  Branch (52:9): [Folded, False: 14.8k]
  ------------------
   53|      0|      composed = _mm_shuffle_epi8(composed, swap);
   54|  14.8k|    _mm_storeu_si128((__m128i *)utf16_output, composed);
   55|  14.8k|    utf16_output += 8; // We wrote 16 bytes, 8 code points.
   56|  14.8k|    return 16;
   57|  14.8k|  }
   58|  2.99M|  if (input_utf8_end_of_code_point_mask == 0x924) {
  ------------------
  |  Branch (58:7): [True: 2.78k, False: 2.99M]
  ------------------
   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.78k|    const __m128i sh =
   63|  2.78k|        _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1);
   64|  2.78k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   65|  2.78k|    const __m128i ascii =
   66|  2.78k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   67|  2.78k|    const __m128i middlebyte =
   68|  2.78k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
   69|  2.78k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
   70|  2.78k|    const __m128i highbyte =
   71|  2.78k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
   72|  2.78k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
   73|  2.78k|    const __m128i composed =
   74|  2.78k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
   75|  2.78k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
   76|  2.78k|    if (big_endian)
  ------------------
  |  Branch (76:9): [Folded, False: 2.78k]
  ------------------
   77|      0|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
   78|  2.78k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
   79|  2.78k|    utf16_output += 4;
   80|  2.78k|    return 12;
   81|  2.78k|  }
   82|       |  /// We do not have a fast path available, so we fallback.
   83|       |
   84|  2.99M|  const uint8_t idx =
   85|  2.99M|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0];
   86|  2.99M|  const uint8_t consumed =
   87|  2.99M|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1];
   88|  2.99M|  if (idx < 64) {
  ------------------
  |  Branch (88:7): [True: 2.54M, False: 443k]
  ------------------
   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.54M|    const __m128i sh =
   96|  2.54M|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
   97|  2.54M|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   98|  2.54M|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   99|  2.54M|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
  100|  2.54M|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
  101|  2.54M|    if (big_endian)
  ------------------
  |  Branch (101:9): [Folded, False: 2.54M]
  ------------------
  102|      0|      composed = _mm_shuffle_epi8(composed, swap);
  103|  2.54M|    _mm_storeu_si128((__m128i *)utf16_output, composed);
  104|  2.54M|    utf16_output += 6; // We wrote 12 bytes, 6 code points.
  105|  2.54M|  } else if (idx < 145) {
  ------------------
  |  Branch (105:14): [True: 369k, False: 73.8k]
  ------------------
  106|       |    // FOUR (4) input code-code units
  107|   369k|    const __m128i sh =
  108|   369k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  109|   369k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  110|   369k|    const __m128i ascii =
  111|   369k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
  112|   369k|    const __m128i middlebyte =
  113|   369k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
  114|   369k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  115|   369k|    const __m128i highbyte =
  116|   369k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
  117|   369k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
  118|   369k|    const __m128i composed =
  119|   369k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
  120|   369k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
  121|   369k|    if (big_endian)
  ------------------
  |  Branch (121:9): [Folded, False: 369k]
  ------------------
  122|      0|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
  123|   369k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
  124|   369k|    utf16_output += 4;
  125|   369k|  } else if (idx < 209) {
  ------------------
  |  Branch (125:14): [True: 72.5k, False: 1.29k]
  ------------------
  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|  72.5k|    const __m128i sh =
  137|  72.5k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  138|  72.5k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  139|  72.5k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f));
  140|  72.5k|    const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00));
  141|  72.5k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  142|  72.5k|    __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000));
  143|       |    // correct for spurious high bit
  144|  72.5k|    const __m128i correct =
  145|  72.5k|        _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1);
  146|  72.5k|    middlehighbyte = _mm_xor_si128(correct, middlehighbyte);
  147|  72.5k|    const __m128i middlehighbyte_shifted = _mm_srli_epi32(middlehighbyte, 4);
  148|       |    // We deliberately carry the leading four bits in highbyte if they are
  149|       |    // present, we remove them later when computing hightenbits.
  150|  72.5k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0xff000000));
  151|  72.5k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 6);
  152|       |    // When we need to generate a surrogate pair (leading byte > 0xF0), then
  153|       |    // the corresponding 32-bit value in 'composed'  will be greater than
  154|       |    // > (0xff00000>>6) or > 0x3c00000. This can be used later to identify the
  155|       |    // location of the surrogate pairs.
  156|  72.5k|    const __m128i composed =
  157|  72.5k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted),
  158|  72.5k|                     _mm_or_si128(highbyte_shifted, middlehighbyte_shifted));
  159|  72.5k|    const __m128i composedminus =
  160|  72.5k|        _mm_sub_epi32(composed, _mm_set1_epi32(0x10000));
  161|  72.5k|    const __m128i lowtenbits =
  162|  72.5k|        _mm_and_si128(composedminus, _mm_set1_epi32(0x3ff));
  163|       |    // Notice the 0x3ff mask:
  164|  72.5k|    const __m128i hightenbits =
  165|  72.5k|        _mm_and_si128(_mm_srli_epi32(composedminus, 10), _mm_set1_epi32(0x3ff));
  166|  72.5k|    const __m128i lowtenbitsadd =
  167|  72.5k|        _mm_add_epi32(lowtenbits, _mm_set1_epi32(0xDC00));
  168|  72.5k|    const __m128i hightenbitsadd =
  169|  72.5k|        _mm_add_epi32(hightenbits, _mm_set1_epi32(0xD800));
  170|  72.5k|    const __m128i lowtenbitsaddshifted = _mm_slli_epi32(lowtenbitsadd, 16);
  171|  72.5k|    __m128i surrogates = _mm_or_si128(hightenbitsadd, lowtenbitsaddshifted);
  172|  72.5k|    uint32_t basic_buffer[4];
  173|  72.5k|    uint32_t basic_buffer_swap[4];
  174|  72.5k|    if (big_endian) {
  ------------------
  |  Branch (174:9): [Folded, False: 72.5k]
  ------------------
  175|      0|      _mm_storeu_si128((__m128i *)basic_buffer_swap,
  176|      0|                       _mm_shuffle_epi8(composed, swap));
  177|      0|      surrogates = _mm_shuffle_epi8(surrogates, swap);
  178|      0|    }
  179|  72.5k|    _mm_storeu_si128((__m128i *)basic_buffer, composed);
  180|  72.5k|    uint32_t surrogate_buffer[4];
  181|  72.5k|    _mm_storeu_si128((__m128i *)surrogate_buffer, surrogates);
  182|   290k|    for (size_t i = 0; i < 3; i++) {
  ------------------
  |  Branch (182:24): [True: 217k, False: 72.5k]
  ------------------
  183|   217k|      if (basic_buffer[i] > 0x3c00000) {
  ------------------
  |  Branch (183:11): [True: 59.9k, False: 157k]
  ------------------
  184|  59.9k|        utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff);
  185|  59.9k|        utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16);
  186|  59.9k|        utf16_output += 2;
  187|   157k|      } else {
  188|   157k|        utf16_output[0] = big_endian ? uint16_t(basic_buffer_swap[i])
  ------------------
  |  Branch (188:27): [Folded, False: 157k]
  ------------------
  189|   157k|                                     : uint16_t(basic_buffer[i]);
  190|   157k|        utf16_output++;
  191|   157k|      }
  192|   217k|    }
  193|  72.5k|  } else {
  194|       |    // here we know that there is an error but we do not handle errors
  195|  1.29k|  }
  196|  2.99M|  return consumed;
  197|  2.99M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_128convert_masked_utf8_to_utf16ILNS_10endiannessE1EEEmPKcmRPDs:
   10|  3.04M|                                    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.04M|  const __m128i swap =
   23|  3.04M|      _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   24|  3.04M|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   25|  3.04M|  const uint16_t input_utf8_end_of_code_point_mask =
   26|  3.04M|      utf8_end_of_code_point_mask & 0xfff;
   27|  3.04M|  if (utf8_end_of_code_point_mask == 0xfff) {
  ------------------
  |  Branch (27:7): [True: 10.8k, False: 3.03M]
  ------------------
   28|       |    // We process the data in chunks of 12 bytes.
   29|       |    // Note: using 16 bytes is unsafe, see issue_ossfuzz_71218
   30|  10.8k|    __m128i ascii_first = _mm_cvtepu8_epi16(in);
   31|  10.8k|    __m128i ascii_second = _mm_cvtepu8_epi16(_mm_srli_si128(in, 8));
   32|  10.8k|    if (big_endian) {
  ------------------
  |  Branch (32:9): [True: 10.8k, Folded]
  ------------------
   33|  10.8k|      ascii_first = _mm_shuffle_epi8(ascii_first, swap);
   34|  10.8k|      ascii_second = _mm_shuffle_epi8(ascii_second, swap);
   35|  10.8k|    }
   36|  10.8k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf16_output), ascii_first);
   37|  10.8k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf16_output + 8),
   38|  10.8k|                     ascii_second);
   39|  10.8k|    utf16_output += 12; // We wrote 12 16-bit characters.
   40|  10.8k|    return 12;          // We consumed 12 bytes.
   41|  10.8k|  }
   42|  3.03M|  if (((utf8_end_of_code_point_mask & 0xFFFF) == 0xaaaa)) {
  ------------------
  |  Branch (42:7): [True: 27.5k, False: 3.00M]
  ------------------
   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|  27.5k|    const __m128i sh =
   47|  27.5k|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   48|  27.5k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   49|  27.5k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   50|  27.5k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   51|  27.5k|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   52|  27.5k|    if (big_endian)
  ------------------
  |  Branch (52:9): [True: 27.5k, Folded]
  ------------------
   53|  27.5k|      composed = _mm_shuffle_epi8(composed, swap);
   54|  27.5k|    _mm_storeu_si128((__m128i *)utf16_output, composed);
   55|  27.5k|    utf16_output += 8; // We wrote 16 bytes, 8 code points.
   56|  27.5k|    return 16;
   57|  27.5k|  }
   58|  3.00M|  if (input_utf8_end_of_code_point_mask == 0x924) {
  ------------------
  |  Branch (58:7): [True: 7.44k, False: 2.99M]
  ------------------
   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|  7.44k|    const __m128i sh =
   63|  7.44k|        _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1);
   64|  7.44k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   65|  7.44k|    const __m128i ascii =
   66|  7.44k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   67|  7.44k|    const __m128i middlebyte =
   68|  7.44k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
   69|  7.44k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
   70|  7.44k|    const __m128i highbyte =
   71|  7.44k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
   72|  7.44k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
   73|  7.44k|    const __m128i composed =
   74|  7.44k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
   75|  7.44k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
   76|  7.44k|    if (big_endian)
  ------------------
  |  Branch (76:9): [True: 7.44k, Folded]
  ------------------
   77|  7.44k|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
   78|  7.44k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
   79|  7.44k|    utf16_output += 4;
   80|  7.44k|    return 12;
   81|  7.44k|  }
   82|       |  /// We do not have a fast path available, so we fallback.
   83|       |
   84|  2.99M|  const uint8_t idx =
   85|  2.99M|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0];
   86|  2.99M|  const uint8_t consumed =
   87|  2.99M|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1];
   88|  2.99M|  if (idx < 64) {
  ------------------
  |  Branch (88:7): [True: 2.74M, False: 248k]
  ------------------
   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.74M|    const __m128i sh =
   96|  2.74M|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
   97|  2.74M|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   98|  2.74M|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   99|  2.74M|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
  100|  2.74M|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
  101|  2.74M|    if (big_endian)
  ------------------
  |  Branch (101:9): [True: 2.74M, Folded]
  ------------------
  102|  2.74M|      composed = _mm_shuffle_epi8(composed, swap);
  103|  2.74M|    _mm_storeu_si128((__m128i *)utf16_output, composed);
  104|  2.74M|    utf16_output += 6; // We wrote 12 bytes, 6 code points.
  105|  2.74M|  } else if (idx < 145) {
  ------------------
  |  Branch (105:14): [True: 164k, False: 83.8k]
  ------------------
  106|       |    // FOUR (4) input code-code units
  107|   164k|    const __m128i sh =
  108|   164k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  109|   164k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  110|   164k|    const __m128i ascii =
  111|   164k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
  112|   164k|    const __m128i middlebyte =
  113|   164k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
  114|   164k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  115|   164k|    const __m128i highbyte =
  116|   164k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
  117|   164k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
  118|   164k|    const __m128i composed =
  119|   164k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
  120|   164k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
  121|   164k|    if (big_endian)
  ------------------
  |  Branch (121:9): [True: 164k, Folded]
  ------------------
  122|   164k|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
  123|   164k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
  124|   164k|    utf16_output += 4;
  125|   164k|  } else if (idx < 209) {
  ------------------
  |  Branch (125:14): [True: 82.9k, False: 894]
  ------------------
  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|  82.9k|    const __m128i sh =
  137|  82.9k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  138|  82.9k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  139|  82.9k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f));
  140|  82.9k|    const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00));
  141|  82.9k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  142|  82.9k|    __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000));
  143|       |    // correct for spurious high bit
  144|  82.9k|    const __m128i correct =
  145|  82.9k|        _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1);
  146|  82.9k|    middlehighbyte = _mm_xor_si128(correct, middlehighbyte);
  147|  82.9k|    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|  82.9k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0xff000000));
  151|  82.9k|    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|  82.9k|    const __m128i composed =
  157|  82.9k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted),
  158|  82.9k|                     _mm_or_si128(highbyte_shifted, middlehighbyte_shifted));
  159|  82.9k|    const __m128i composedminus =
  160|  82.9k|        _mm_sub_epi32(composed, _mm_set1_epi32(0x10000));
  161|  82.9k|    const __m128i lowtenbits =
  162|  82.9k|        _mm_and_si128(composedminus, _mm_set1_epi32(0x3ff));
  163|       |    // Notice the 0x3ff mask:
  164|  82.9k|    const __m128i hightenbits =
  165|  82.9k|        _mm_and_si128(_mm_srli_epi32(composedminus, 10), _mm_set1_epi32(0x3ff));
  166|  82.9k|    const __m128i lowtenbitsadd =
  167|  82.9k|        _mm_add_epi32(lowtenbits, _mm_set1_epi32(0xDC00));
  168|  82.9k|    const __m128i hightenbitsadd =
  169|  82.9k|        _mm_add_epi32(hightenbits, _mm_set1_epi32(0xD800));
  170|  82.9k|    const __m128i lowtenbitsaddshifted = _mm_slli_epi32(lowtenbitsadd, 16);
  171|  82.9k|    __m128i surrogates = _mm_or_si128(hightenbitsadd, lowtenbitsaddshifted);
  172|  82.9k|    uint32_t basic_buffer[4];
  173|  82.9k|    uint32_t basic_buffer_swap[4];
  174|  82.9k|    if (big_endian) {
  ------------------
  |  Branch (174:9): [True: 82.9k, Folded]
  ------------------
  175|  82.9k|      _mm_storeu_si128((__m128i *)basic_buffer_swap,
  176|  82.9k|                       _mm_shuffle_epi8(composed, swap));
  177|  82.9k|      surrogates = _mm_shuffle_epi8(surrogates, swap);
  178|  82.9k|    }
  179|  82.9k|    _mm_storeu_si128((__m128i *)basic_buffer, composed);
  180|  82.9k|    uint32_t surrogate_buffer[4];
  181|  82.9k|    _mm_storeu_si128((__m128i *)surrogate_buffer, surrogates);
  182|   331k|    for (size_t i = 0; i < 3; i++) {
  ------------------
  |  Branch (182:24): [True: 248k, False: 82.9k]
  ------------------
  183|   248k|      if (basic_buffer[i] > 0x3c00000) {
  ------------------
  |  Branch (183:11): [True: 69.3k, False: 179k]
  ------------------
  184|  69.3k|        utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff);
  185|  69.3k|        utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16);
  186|  69.3k|        utf16_output += 2;
  187|   179k|      } else {
  188|   179k|        utf16_output[0] = big_endian ? uint16_t(basic_buffer_swap[i])
  ------------------
  |  Branch (188:27): [True: 179k, Folded]
  ------------------
  189|   179k|                                     : uint16_t(basic_buffer[i]);
  190|   179k|        utf16_output++;
  191|   179k|      }
  192|   248k|    }
  193|  82.9k|  } else {
  194|       |    // here we know that there is an error but we do not handle errors
  195|    894|  }
  196|  2.99M|  return consumed;
  197|  3.00M|}

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

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

