_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.22k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  640|  9.22k|  static const auto fptrs = populate_functions();
  641|  9.22k|  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.22k|  if (size < 4) {
  ------------------
  |  Branch (646:7): [True: 3, False: 9.21k]
  ------------------
  647|      3|    return 0;
  648|      3|  }
  649|       |
  650|  9.21k|  constexpr auto actionmask = std::bit_ceil(Ncases) - 1;
  651|  9.21k|  const auto action = data[0] & actionmask;
  652|  9.21k|  data += 4;
  653|  9.21k|  size -= 4;
  654|       |
  655|  9.21k|  if (action >= Ncases) {
  ------------------
  |  Branch (655:7): [True: 1, False: 9.21k]
  ------------------
  656|      1|    return 0;
  657|      1|  }
  658|       |
  659|  9.21k|  if constexpr (use_separate_allocation) {
  660|       |    // this is better at exercising null input and catch buffer underflows
  661|  9.21k|    const std::vector<char> separate{data, data + size};
  662|  9.21k|    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.21k|  return 0;
  669|  9.21k|}
conversion.cpp:_ZZ18populate_functionsvENK3$_0clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     96|    +[](std::span<const char> chardata) {                                      \
  555|     96|      const auto c =                                                           \
  556|     96|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     96|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     96|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     96|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     96|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     96|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     96|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     96|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     96|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     96|  constexpr auto _size = _name.size();                                \
  |  | 1183|     96|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     96|  return _nameof; }()
  ------------------
  561|     96|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     96|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     96|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     96|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     96|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     96|  constexpr auto _size = _name.size();                                \
  |  | 1183|     96|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     96|  return _nameof; }()
  ------------------
  562|     96|      c.fuzz(chardata);                                                        \
  563|     96|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    237|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    237|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    237|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    237|    static const bool do_print_testcase =
  181|    237|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    237|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 237]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    237|    do {
  189|       |      // step 0 - is the input valid?
  190|    237|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    237|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 237]
  |  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|    237|                    From == UtfEncodings::UTF8) {
  198|    237|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 237]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    237|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    237|      const auto [output_length, length_agree] =
  204|    237|          calculate_length(from, inputisvalid);
  205|    237|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 237]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    237|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 101, False: 136]
  |  Branch (208:28): [True: 13, False: 88]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     13|        return;
  211|     13|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    224|      const auto [written, outputs_agree] =
  215|    224|          do_conversion(from, output_length, inputisvalid);
  216|    224|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 224]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    224|      return;
  221|    224|    } 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|    237|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    237|  validation_result verify_valid_input(FromSpan src) const {
  231|    237|    validation_result ret{};
  232|       |
  233|    237|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    237|    const auto implementations = get_supported_implementations();
  235|    237|    std::vector<simdutf::result> results;
  236|    237|    results.reserve(implementations.size());
  237|       |
  238|    711|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 711, False: 237]
  ------------------
  239|    711|      results.push_back(
  240|    711|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    711|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    711|      const bool validation2 =
  245|    711|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    711|                      src.data(), src.size());
  247|    711|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 711]
  ------------------
  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|    711|    }
  258|       |
  259|    237|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    237|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 237]
  ------------------
  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|    237|    } else {
  273|    237|      ret.implementations_agree = true;
  274|    237|    }
  275|    237|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    237|      return r.error == simdutf::SUCCESS;
  277|    237|    });
  278|    237|    return ret;
  279|    237|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    474|    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|    509|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    509|      return r.error == simdutf::SUCCESS;
  277|    509|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    237|  bool count_the_input(FromSpan src) const {
  290|    237|    const auto implementations = get_supported_implementations();
  291|    237|    std::vector<std::size_t> results;
  292|    237|    results.reserve(implementations.size());
  293|       |
  294|    711|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 711, False: 237]
  ------------------
  295|    711|      std::size_t ret;
  296|    711|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    711|        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|    711|      results.push_back(ret);
  304|    711|    }
  305|    237|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    237|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 237]
  ------------------
  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|    237|    return true;
  321|    237|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    474|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    237|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    237|    length_result ret{};
  344|       |
  345|    237|    const auto implementations = get_supported_implementations();
  346|    237|    std::vector<std::size_t> results;
  347|    237|    results.reserve(implementations.size());
  348|       |
  349|    711|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 711, False: 237]
  ------------------
  350|    711|      const auto len = invoke_lengthcalc(impl, src);
  351|    711|      results.push_back(len);
  352|    711|      ret.length.push_back(len);
  353|    711|    }
  354|       |
  355|    237|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    237|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 237]
  ------------------
  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|    237|    } else {
  375|    237|      ret.implementations_agree = true;
  376|    237|    }
  377|    237|    return ret;
  378|    237|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    711|                                FromSpan src) const {
  331|    711|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    711|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    474|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    224|                                  const bool inputisvalid) const {
  383|    224|    conversion_result ret{};
  384|       |
  385|    224|    const auto implementations = get_supported_implementations();
  386|       |
  387|    224|    std::vector<result<ConversionResult>> results;
  388|    224|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    224|    std::vector<std::vector<ToType>> outputbuffers;
  393|    224|    outputbuffers.reserve(implementations.size());
  394|    896|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 672, False: 224]
  ------------------
  395|    672|      auto impl = implementations[i];
  396|    672|      const ToType canary1{42};
  397|    672|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    672|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    672|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    672|      const auto success = [](const ConversionResult& r) -> bool {
  402|    672|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    672|          return r != 0;
  404|    672|        } else {
  405|    672|          return r.error == simdutf::error_code::SUCCESS;
  406|    672|        }
  407|    672|      }(implret1);
  408|    672|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    672|      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|    672|        const ToType canary2{25};
  414|    672|        const auto outputbuffer_first_run = outputbuffer;
  415|    672|        std::ranges::fill(outputbuffer, canary2);
  416|    672|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    672|                                          src.size(), outputbuffer.data());
  418|       |
  419|    672|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 672]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    672|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 408, False: 264]
  |  Branch (423:29): [True: 396, False: 12]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    396|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    396|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 396]
  ------------------
  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|    396|        }
  440|    672|      }
  441|    672|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 396, False: 276]
  ------------------
  442|    672|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    224|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 88, False: 136]
  ------------------
  447|    264|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 264, False: 88]
  ------------------
  448|    264|        e.outputhash.clear();
  449|    264|      }
  450|     88|    }
  451|       |
  452|    224|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    224|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 224]
  ------------------
  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|    224|    } else {
  474|    224|      ret.implementations_agree = true;
  475|    224|    }
  476|    224|    return ret;
  477|    224|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    672|      const auto success = [](const ConversionResult& r) -> bool {
  402|    672|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    672|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    672|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    448|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_1clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    224|    +[](std::span<const char> chardata) {                                      \
  555|    224|      const auto c =                                                           \
  556|    224|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    224|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    224|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    224|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    224|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    224|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    224|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    224|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    224|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    224|  constexpr auto _size = _name.size();                                \
  |  | 1183|    224|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    224|  return _nameof; }()
  ------------------
  561|    224|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    224|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    224|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    224|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    224|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    224|  constexpr auto _size = _name.size();                                \
  |  | 1183|    224|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    224|  return _nameof; }()
  ------------------
  562|    224|      c.fuzz(chardata);                                                        \
  563|    224|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    403|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    403|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    403|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    403|    static const bool do_print_testcase =
  181|    403|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    403|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 403]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    403|    do {
  189|       |      // step 0 - is the input valid?
  190|    403|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    403|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 403]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    403|                    From == UtfEncodings::UTF8) {
  198|    403|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 403]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    403|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    403|      const auto [output_length, length_agree] =
  204|    403|          calculate_length(from, inputisvalid);
  205|    403|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 403]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    403|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 86, False: 317]
  |  Branch (208:28): [True: 17, False: 69]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     17|        return;
  211|     17|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    386|      const auto [written, outputs_agree] =
  215|    386|          do_conversion(from, output_length, inputisvalid);
  216|    386|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 386]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    386|      return;
  221|    386|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    403|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    403|  validation_result verify_valid_input(FromSpan src) const {
  231|    403|    validation_result ret{};
  232|       |
  233|    403|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    403|    const auto implementations = get_supported_implementations();
  235|    403|    std::vector<simdutf::result> results;
  236|    403|    results.reserve(implementations.size());
  237|       |
  238|  1.20k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.20k, False: 403]
  ------------------
  239|  1.20k|      results.push_back(
  240|  1.20k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.20k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.20k|      const bool validation2 =
  245|  1.20k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.20k|                      src.data(), src.size());
  247|  1.20k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.20k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  1.20k|    }
  258|       |
  259|    403|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    403|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 403]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    403|    } else {
  273|    403|      ret.implementations_agree = true;
  274|    403|    }
  275|    403|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    403|      return r.error == simdutf::SUCCESS;
  277|    403|    });
  278|    403|    return ret;
  279|    403|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    806|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKNS1_6resultEE_clESI_:
  275|  1.03k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.03k|      return r.error == simdutf::SUCCESS;
  277|  1.03k|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    403|  bool count_the_input(FromSpan src) const {
  290|    403|    const auto implementations = get_supported_implementations();
  291|    403|    std::vector<std::size_t> results;
  292|    403|    results.reserve(implementations.size());
  293|       |
  294|  1.20k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.20k, False: 403]
  ------------------
  295|  1.20k|      std::size_t ret;
  296|  1.20k|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|  1.20k|        ret = impl->count_utf16be(src.data(), src.size());
  298|       |      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|       |        ret = impl->count_utf16le(src.data(), src.size());
  300|       |      } else if constexpr (From == UtfEncodings::UTF8) {
  301|       |        ret = impl->count_utf8(src.data(), src.size());
  302|       |      }
  303|  1.20k|      results.push_back(ret);
  304|  1.20k|    }
  305|    403|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    403|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 403]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    403|    return true;
  321|    403|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    806|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    403|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    403|    length_result ret{};
  344|       |
  345|    403|    const auto implementations = get_supported_implementations();
  346|    403|    std::vector<std::size_t> results;
  347|    403|    results.reserve(implementations.size());
  348|       |
  349|  1.20k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.20k, False: 403]
  ------------------
  350|  1.20k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.20k|      results.push_back(len);
  352|  1.20k|      ret.length.push_back(len);
  353|  1.20k|    }
  354|       |
  355|    403|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    403|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 403]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    403|    } else {
  375|    403|      ret.implementations_agree = true;
  376|    403|    }
  377|    403|    return ret;
  378|    403|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.20k|                                FromSpan src) const {
  331|  1.20k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.20k|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    806|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    386|                                  const bool inputisvalid) const {
  383|    386|    conversion_result ret{};
  384|       |
  385|    386|    const auto implementations = get_supported_implementations();
  386|       |
  387|    386|    std::vector<result<ConversionResult>> results;
  388|    386|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    386|    std::vector<std::vector<ToType>> outputbuffers;
  393|    386|    outputbuffers.reserve(implementations.size());
  394|  1.54k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.15k, False: 386]
  ------------------
  395|  1.15k|      auto impl = implementations[i];
  396|  1.15k|      const ToType canary1{42};
  397|  1.15k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.15k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.15k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.15k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.15k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.15k|          return r != 0;
  404|  1.15k|        } else {
  405|  1.15k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.15k|        }
  407|  1.15k|      }(implret1);
  408|  1.15k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.15k|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|  1.15k|        const ToType canary2{25};
  414|  1.15k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.15k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.15k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.15k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.15k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.15k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.15k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 951, False: 207]
  |  Branch (423:29): [True: 942, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    942|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    942|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 942]
  ------------------
  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|    942|        }
  440|  1.15k|      }
  441|  1.15k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 942, False: 216]
  ------------------
  442|  1.15k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    386|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 69, False: 317]
  ------------------
  447|    207|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 207, False: 69]
  ------------------
  448|    207|        e.outputhash.clear();
  449|    207|      }
  450|     69|    }
  451|       |
  452|    386|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    386|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 386]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    386|    } else {
  474|    386|      ret.implementations_agree = true;
  475|    386|    }
  476|    386|    return ret;
  477|    386|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.15k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.15k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.15k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.15k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    772|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_2clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     65|    +[](std::span<const char> chardata) {                                      \
  555|     65|      const auto c =                                                           \
  556|     65|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     65|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     65|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     65|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     65|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     65|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     65|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     65|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     65|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     65|  constexpr auto _size = _name.size();                                \
  |  | 1183|     65|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     65|  return _nameof; }()
  ------------------
  561|     65|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     65|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     65|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     65|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     65|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     65|  constexpr auto _size = _name.size();                                \
  |  | 1183|     65|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     65|  return _nameof; }()
  ------------------
  562|     65|      c.fuzz(chardata);                                                        \
  563|     65|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    219|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    219|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    219|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    219|    static const bool do_print_testcase =
  181|    219|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    219|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 219]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    219|    do {
  189|       |      // step 0 - is the input valid?
  190|    219|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    219|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 219]
  |  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|    219|                    From == UtfEncodings::UTF8) {
  198|    219|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 219]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    219|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    219|      const auto [output_length, length_agree] =
  204|    219|          calculate_length(from, inputisvalid);
  205|    219|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 219]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    219|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 101, False: 118]
  |  Branch (208:28): [True: 5, False: 96]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      5|        return;
  211|      5|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    214|      const auto [written, outputs_agree] =
  215|    214|          do_conversion(from, output_length, inputisvalid);
  216|    214|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 214]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    214|      return;
  221|    214|    } 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|    219|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    219|  validation_result verify_valid_input(FromSpan src) const {
  231|    219|    validation_result ret{};
  232|       |
  233|    219|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    219|    const auto implementations = get_supported_implementations();
  235|    219|    std::vector<simdutf::result> results;
  236|    219|    results.reserve(implementations.size());
  237|       |
  238|    657|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 657, False: 219]
  ------------------
  239|    657|      results.push_back(
  240|    657|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    657|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    657|      const bool validation2 =
  245|    657|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    657|                      src.data(), src.size());
  247|    657|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 657]
  ------------------
  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|    657|    }
  258|       |
  259|    219|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    219|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 219]
  ------------------
  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|    219|    } else {
  273|    219|      ret.implementations_agree = true;
  274|    219|    }
  275|    219|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    219|      return r.error == simdutf::SUCCESS;
  277|    219|    });
  278|    219|    return ret;
  279|    219|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    438|    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|    455|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    455|      return r.error == simdutf::SUCCESS;
  277|    455|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    219|  bool count_the_input(FromSpan src) const {
  290|    219|    const auto implementations = get_supported_implementations();
  291|    219|    std::vector<std::size_t> results;
  292|    219|    results.reserve(implementations.size());
  293|       |
  294|    657|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 657, False: 219]
  ------------------
  295|    657|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    657|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    657|        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|    657|      results.push_back(ret);
  304|    657|    }
  305|    219|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    219|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 219]
  ------------------
  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|    219|    return true;
  321|    219|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    438|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    219|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    219|    length_result ret{};
  344|       |
  345|    219|    const auto implementations = get_supported_implementations();
  346|    219|    std::vector<std::size_t> results;
  347|    219|    results.reserve(implementations.size());
  348|       |
  349|    657|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 657, False: 219]
  ------------------
  350|    657|      const auto len = invoke_lengthcalc(impl, src);
  351|    657|      results.push_back(len);
  352|    657|      ret.length.push_back(len);
  353|    657|    }
  354|       |
  355|    219|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    219|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 219]
  ------------------
  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|    219|    } else {
  375|    219|      ret.implementations_agree = true;
  376|    219|    }
  377|    219|    return ret;
  378|    219|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    657|                                FromSpan src) const {
  331|    657|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    657|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    438|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    214|                                  const bool inputisvalid) const {
  383|    214|    conversion_result ret{};
  384|       |
  385|    214|    const auto implementations = get_supported_implementations();
  386|       |
  387|    214|    std::vector<result<ConversionResult>> results;
  388|    214|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    214|    std::vector<std::vector<ToType>> outputbuffers;
  393|    214|    outputbuffers.reserve(implementations.size());
  394|    856|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 642, False: 214]
  ------------------
  395|    642|      auto impl = implementations[i];
  396|    642|      const ToType canary1{42};
  397|    642|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    642|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    642|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    642|      const auto success = [](const ConversionResult& r) -> bool {
  402|    642|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    642|          return r != 0;
  404|    642|        } else {
  405|    642|          return r.error == simdutf::error_code::SUCCESS;
  406|    642|        }
  407|    642|      }(implret1);
  408|    642|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    642|      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|    642|        const ToType canary2{25};
  414|    642|        const auto outputbuffer_first_run = outputbuffer;
  415|    642|        std::ranges::fill(outputbuffer, canary2);
  416|    642|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    642|                                          src.size(), outputbuffer.data());
  418|       |
  419|    642|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 642]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    642|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 354, False: 288]
  |  Branch (423:29): [True: 342, False: 12]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    342|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    342|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 342]
  ------------------
  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|    342|        }
  440|    642|      }
  441|    642|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 342, False: 300]
  ------------------
  442|    642|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    214|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 96, False: 118]
  ------------------
  447|    288|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 288, False: 96]
  ------------------
  448|    288|        e.outputhash.clear();
  449|    288|      }
  450|     96|    }
  451|       |
  452|    214|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    214|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 214]
  ------------------
  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|    214|    } else {
  474|    214|      ret.implementations_agree = true;
  475|    214|    }
  476|    214|    return ret;
  477|    214|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    642|      const auto success = [](const ConversionResult& r) -> bool {
  402|    642|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    642|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    642|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    428|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_3clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    205|    +[](std::span<const char> chardata) {                                      \
  555|    205|      const auto c =                                                           \
  556|    205|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    205|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    205|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    205|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    205|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    205|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    205|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    205|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    205|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    205|  constexpr auto _size = _name.size();                                \
  |  | 1183|    205|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    205|  return _nameof; }()
  ------------------
  561|    205|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    205|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    205|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    205|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    205|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    205|  constexpr auto _size = _name.size();                                \
  |  | 1183|    205|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    205|  return _nameof; }()
  ------------------
  562|    205|      c.fuzz(chardata);                                                        \
  563|    205|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    451|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    451|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    451|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    451|    static const bool do_print_testcase =
  181|    451|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    451|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 451]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    451|    do {
  189|       |      // step 0 - is the input valid?
  190|    451|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    451|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 451]
  |  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|    451|                    From == UtfEncodings::UTF8) {
  198|    451|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 451]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    451|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    451|      const auto [output_length, length_agree] =
  204|    451|          calculate_length(from, inputisvalid);
  205|    451|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 451]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    451|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 132, False: 319]
  |  Branch (208:28): [True: 13, False: 119]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     13|        return;
  211|     13|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    438|      const auto [written, outputs_agree] =
  215|    438|          do_conversion(from, output_length, inputisvalid);
  216|    438|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 438]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    438|      return;
  221|    438|    } 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|    451|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    451|  validation_result verify_valid_input(FromSpan src) const {
  231|    451|    validation_result ret{};
  232|       |
  233|    451|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    451|    const auto implementations = get_supported_implementations();
  235|    451|    std::vector<simdutf::result> results;
  236|    451|    results.reserve(implementations.size());
  237|       |
  238|  1.35k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.35k, False: 451]
  ------------------
  239|  1.35k|      results.push_back(
  240|  1.35k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.35k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.35k|      const bool validation2 =
  245|  1.35k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.35k|                      src.data(), src.size());
  247|  1.35k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.35k]
  ------------------
  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.35k|    }
  258|       |
  259|    451|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    451|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 451]
  ------------------
  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|    451|    } else {
  273|    451|      ret.implementations_agree = true;
  274|    451|    }
  275|    451|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    451|      return r.error == simdutf::SUCCESS;
  277|    451|    });
  278|    451|    return ret;
  279|    451|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    902|    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.08k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.08k|      return r.error == simdutf::SUCCESS;
  277|  1.08k|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    451|  bool count_the_input(FromSpan src) const {
  290|    451|    const auto implementations = get_supported_implementations();
  291|    451|    std::vector<std::size_t> results;
  292|    451|    results.reserve(implementations.size());
  293|       |
  294|  1.35k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.35k, False: 451]
  ------------------
  295|  1.35k|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|  1.35k|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|  1.35k|        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.35k|      results.push_back(ret);
  304|  1.35k|    }
  305|    451|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    451|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 451]
  ------------------
  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|    451|    return true;
  321|    451|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    902|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    451|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    451|    length_result ret{};
  344|       |
  345|    451|    const auto implementations = get_supported_implementations();
  346|    451|    std::vector<std::size_t> results;
  347|    451|    results.reserve(implementations.size());
  348|       |
  349|  1.35k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.35k, False: 451]
  ------------------
  350|  1.35k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.35k|      results.push_back(len);
  352|  1.35k|      ret.length.push_back(len);
  353|  1.35k|    }
  354|       |
  355|    451|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    451|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 451]
  ------------------
  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|    451|    } else {
  375|    451|      ret.implementations_agree = true;
  376|    451|    }
  377|    451|    return ret;
  378|    451|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.35k|                                FromSpan src) const {
  331|  1.35k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.35k|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    902|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    438|                                  const bool inputisvalid) const {
  383|    438|    conversion_result ret{};
  384|       |
  385|    438|    const auto implementations = get_supported_implementations();
  386|       |
  387|    438|    std::vector<result<ConversionResult>> results;
  388|    438|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    438|    std::vector<std::vector<ToType>> outputbuffers;
  393|    438|    outputbuffers.reserve(implementations.size());
  394|  1.75k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.31k, False: 438]
  ------------------
  395|  1.31k|      auto impl = implementations[i];
  396|  1.31k|      const ToType canary1{42};
  397|  1.31k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.31k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.31k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.31k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.31k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.31k|          return r != 0;
  404|  1.31k|        } else {
  405|  1.31k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.31k|        }
  407|  1.31k|      }(implret1);
  408|  1.31k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.31k|      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.31k|        const ToType canary2{25};
  414|  1.31k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.31k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.31k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.31k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.31k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.31k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.31k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 957, False: 357]
  |  Branch (423:29): [True: 948, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    948|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    948|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 948]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    948|        }
  440|  1.31k|      }
  441|  1.31k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 948, False: 366]
  ------------------
  442|  1.31k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    438|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 119, False: 319]
  ------------------
  447|    357|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 357, False: 119]
  ------------------
  448|    357|        e.outputhash.clear();
  449|    357|      }
  450|    119|    }
  451|       |
  452|    438|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    438|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 438]
  ------------------
  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|    438|    } else {
  474|    438|      ret.implementations_agree = true;
  475|    438|    }
  476|    438|    return ret;
  477|    438|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.31k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.31k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.31k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.31k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    876|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_4clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     61|    +[](std::span<const char> chardata) {                                      \
  555|     61|      const auto c =                                                           \
  556|     61|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     61|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     61|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     61|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     61|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     61|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     61|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     61|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     61|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     61|  constexpr auto _size = _name.size();                                \
  |  | 1183|     61|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     61|  return _nameof; }()
  ------------------
  561|     61|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     61|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     61|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     61|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     61|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     61|  constexpr auto _size = _name.size();                                \
  |  | 1183|     61|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     61|  return _nameof; }()
  ------------------
  562|     61|      c.fuzz(chardata);                                                        \
  563|     61|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    274|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    274|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    274|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    274|    static const bool do_print_testcase =
  181|    274|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    274|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 274]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    274|    do {
  189|       |      // step 0 - is the input valid?
  190|    274|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    274|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 274]
  |  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|    274|      const auto [output_length, length_agree] =
  204|    274|          calculate_length(from, inputisvalid);
  205|    274|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 274]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    274|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 148, False: 126]
  |  Branch (208:28): [True: 4, False: 144]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      4|        return;
  211|      4|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    270|      const auto [written, outputs_agree] =
  215|    270|          do_conversion(from, output_length, inputisvalid);
  216|    270|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 270]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    270|      return;
  221|    270|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    274|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    274|  validation_result verify_valid_input(FromSpan src) const {
  231|    274|    validation_result ret{};
  232|       |
  233|    274|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    274|    const auto implementations = get_supported_implementations();
  235|    274|    std::vector<simdutf::result> results;
  236|    274|    results.reserve(implementations.size());
  237|       |
  238|    822|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 822, False: 274]
  ------------------
  239|    822|      results.push_back(
  240|    822|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    822|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    822|      const bool validation2 =
  245|    822|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    822|                      src.data(), src.size());
  247|    822|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 822]
  ------------------
  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|    822|    }
  258|       |
  259|    274|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    274|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 274]
  ------------------
  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|    274|    } else {
  273|    274|      ret.implementations_agree = true;
  274|    274|    }
  275|    274|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    274|      return r.error == simdutf::SUCCESS;
  277|    274|    });
  278|    274|    return ret;
  279|    274|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    548|    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|    526|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    526|      return r.error == simdutf::SUCCESS;
  277|    526|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    274|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    274|    length_result ret{};
  344|       |
  345|    274|    const auto implementations = get_supported_implementations();
  346|    274|    std::vector<std::size_t> results;
  347|    274|    results.reserve(implementations.size());
  348|       |
  349|    822|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 822, False: 274]
  ------------------
  350|    822|      const auto len = invoke_lengthcalc(impl, src);
  351|    822|      results.push_back(len);
  352|    822|      ret.length.push_back(len);
  353|    822|    }
  354|       |
  355|    274|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    274|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 274]
  ------------------
  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|    274|    } else {
  375|    274|      ret.implementations_agree = true;
  376|    274|    }
  377|    274|    return ret;
  378|    274|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    822|                                FromSpan src) const {
  331|    822|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    822|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    548|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    270|                                  const bool inputisvalid) const {
  383|    270|    conversion_result ret{};
  384|       |
  385|    270|    const auto implementations = get_supported_implementations();
  386|       |
  387|    270|    std::vector<result<ConversionResult>> results;
  388|    270|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    270|    std::vector<std::vector<ToType>> outputbuffers;
  393|    270|    outputbuffers.reserve(implementations.size());
  394|  1.08k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 810, False: 270]
  ------------------
  395|    810|      auto impl = implementations[i];
  396|    810|      const ToType canary1{42};
  397|    810|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    810|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    810|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    810|      const auto success = [](const ConversionResult& r) -> bool {
  402|    810|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    810|          return r != 0;
  404|    810|        } else {
  405|    810|          return r.error == simdutf::error_code::SUCCESS;
  406|    810|        }
  407|    810|      }(implret1);
  408|    810|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    810|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    810|        const ToType canary2{25};
  414|    810|        const auto outputbuffer_first_run = outputbuffer;
  415|    810|        std::ranges::fill(outputbuffer, canary2);
  416|    810|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    810|                                          src.size(), outputbuffer.data());
  418|       |
  419|    810|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 810]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    810|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 378, False: 432]
  |  Branch (423:29): [True: 369, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    369|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    369|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 369]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    369|        }
  440|    810|      }
  441|    810|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 369, False: 441]
  ------------------
  442|    810|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    270|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 144, False: 126]
  ------------------
  447|    432|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 432, False: 144]
  ------------------
  448|    432|        e.outputhash.clear();
  449|    432|      }
  450|    144|    }
  451|       |
  452|    270|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    270|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 270]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    270|    } else {
  474|    270|      ret.implementations_agree = true;
  475|    270|    }
  476|    270|    return ret;
  477|    270|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    810|      const auto success = [](const ConversionResult& r) -> bool {
  402|    810|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    810|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    810|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    540|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_5clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    136|    +[](std::span<const char> chardata) {                                      \
  555|    136|      const auto c =                                                           \
  556|    136|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    136|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    136|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    136|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    136|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    136|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    136|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    136|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    136|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    136|  constexpr auto _size = _name.size();                                \
  |  | 1183|    136|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    136|  return _nameof; }()
  ------------------
  561|    136|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    136|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    136|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    136|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    136|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    136|  constexpr auto _size = _name.size();                                \
  |  | 1183|    136|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    136|  return _nameof; }()
  ------------------
  562|    136|      c.fuzz(chardata);                                                        \
  563|    136|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    376|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    376|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    376|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    376|    static const bool do_print_testcase =
  181|    376|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    376|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 376]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    376|    do {
  189|       |      // step 0 - is the input valid?
  190|    376|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    376|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 376]
  |  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|    376|      const auto [output_length, length_agree] =
  204|    376|          calculate_length(from, inputisvalid);
  205|    376|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 376]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    376|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 185, False: 191]
  |  Branch (208:28): [True: 10, False: 175]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     10|        return;
  211|     10|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    366|      const auto [written, outputs_agree] =
  215|    366|          do_conversion(from, output_length, inputisvalid);
  216|    366|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 366]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    366|      return;
  221|    366|    } 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|    376|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    376|  validation_result verify_valid_input(FromSpan src) const {
  231|    376|    validation_result ret{};
  232|       |
  233|    376|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    376|    const auto implementations = get_supported_implementations();
  235|    376|    std::vector<simdutf::result> results;
  236|    376|    results.reserve(implementations.size());
  237|       |
  238|  1.12k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.12k, False: 376]
  ------------------
  239|  1.12k|      results.push_back(
  240|  1.12k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.12k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.12k|      const bool validation2 =
  245|  1.12k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.12k|                      src.data(), src.size());
  247|  1.12k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.12k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  1.12k|    }
  258|       |
  259|    376|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    376|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 376]
  ------------------
  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|    376|    } else {
  273|    376|      ret.implementations_agree = true;
  274|    376|    }
  275|    376|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    376|      return r.error == simdutf::SUCCESS;
  277|    376|    });
  278|    376|    return ret;
  279|    376|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    752|    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|    758|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    758|      return r.error == simdutf::SUCCESS;
  277|    758|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    376|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    376|    length_result ret{};
  344|       |
  345|    376|    const auto implementations = get_supported_implementations();
  346|    376|    std::vector<std::size_t> results;
  347|    376|    results.reserve(implementations.size());
  348|       |
  349|  1.12k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.12k, False: 376]
  ------------------
  350|  1.12k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.12k|      results.push_back(len);
  352|  1.12k|      ret.length.push_back(len);
  353|  1.12k|    }
  354|       |
  355|    376|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    376|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 376]
  ------------------
  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|    376|    } else {
  375|    376|      ret.implementations_agree = true;
  376|    376|    }
  377|    376|    return ret;
  378|    376|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.12k|                                FromSpan src) const {
  331|  1.12k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.12k|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    752|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    366|                                  const bool inputisvalid) const {
  383|    366|    conversion_result ret{};
  384|       |
  385|    366|    const auto implementations = get_supported_implementations();
  386|       |
  387|    366|    std::vector<result<ConversionResult>> results;
  388|    366|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    366|    std::vector<std::vector<ToType>> outputbuffers;
  393|    366|    outputbuffers.reserve(implementations.size());
  394|  1.46k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.09k, False: 366]
  ------------------
  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: 573, False: 525]
  |  Branch (423:29): [True: 558, False: 15]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    558|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    558|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 558]
  ------------------
  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|    558|        }
  440|  1.09k|      }
  441|  1.09k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 558, False: 540]
  ------------------
  442|  1.09k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    366|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 175, False: 191]
  ------------------
  447|    525|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 525, False: 175]
  ------------------
  448|    525|        e.outputhash.clear();
  449|    525|      }
  450|    175|    }
  451|       |
  452|    366|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    366|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 366]
  ------------------
  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|    366|    } else {
  474|    366|      ret.implementations_agree = true;
  475|    366|    }
  476|    366|    return ret;
  477|    366|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  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|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.09k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    732|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_6clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    100|    +[](std::span<const char> chardata) {                                      \
  555|    100|      const auto c =                                                           \
  556|    100|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    100|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    100|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    100|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    100|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    100|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    100|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    100|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    100|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    100|  constexpr auto _size = _name.size();                                \
  |  | 1183|    100|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    100|  return _nameof; }()
  ------------------
  561|    100|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    100|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    100|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    100|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    100|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    100|  constexpr auto _size = _name.size();                                \
  |  | 1183|    100|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    100|  return _nameof; }()
  ------------------
  562|    100|      c.fuzz(chardata);                                                        \
  563|    100|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    442|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    442|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    442|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    442|    static const bool do_print_testcase =
  181|    442|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    442|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 442]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    442|    do {
  189|       |      // step 0 - is the input valid?
  190|    442|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    442|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 442]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|       |                    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|    442|      const auto [output_length, length_agree] =
  204|    442|          calculate_length(from, inputisvalid);
  205|    442|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 442]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    442|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 293, False: 149]
  |  Branch (208:28): [True: 6, False: 287]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      6|        return;
  211|      6|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    436|      const auto [written, outputs_agree] =
  215|    436|          do_conversion(from, output_length, inputisvalid);
  216|    436|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 436]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    436|      return;
  221|    436|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    442|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    442|  validation_result verify_valid_input(FromSpan src) const {
  231|    442|    validation_result ret{};
  232|       |
  233|    442|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    442|    const auto implementations = get_supported_implementations();
  235|    442|    std::vector<simdutf::result> results;
  236|    442|    results.reserve(implementations.size());
  237|       |
  238|  1.32k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.32k, False: 442]
  ------------------
  239|  1.32k|      results.push_back(
  240|  1.32k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.32k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.32k|      const bool validation2 =
  245|  1.32k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.32k|                      src.data(), src.size());
  247|  1.32k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.32k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  1.32k|    }
  258|       |
  259|    442|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    442|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 442]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    442|    } else {
  273|    442|      ret.implementations_agree = true;
  274|    442|    }
  275|    442|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    442|      return r.error == simdutf::SUCCESS;
  277|    442|    });
  278|    442|    return ret;
  279|    442|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    884|    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|    740|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    740|      return r.error == simdutf::SUCCESS;
  277|    740|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    442|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    442|    length_result ret{};
  344|       |
  345|    442|    const auto implementations = get_supported_implementations();
  346|    442|    std::vector<std::size_t> results;
  347|    442|    results.reserve(implementations.size());
  348|       |
  349|  1.32k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.32k, False: 442]
  ------------------
  350|  1.32k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.32k|      results.push_back(len);
  352|  1.32k|      ret.length.push_back(len);
  353|  1.32k|    }
  354|       |
  355|    442|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    442|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 442]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    442|    } else {
  375|    442|      ret.implementations_agree = true;
  376|    442|    }
  377|    442|    return ret;
  378|    442|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.32k|                                FromSpan src) const {
  331|  1.32k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.32k|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    884|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    436|                                  const bool inputisvalid) const {
  383|    436|    conversion_result ret{};
  384|       |
  385|    436|    const auto implementations = get_supported_implementations();
  386|       |
  387|    436|    std::vector<result<ConversionResult>> results;
  388|    436|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    436|    std::vector<std::vector<ToType>> outputbuffers;
  393|    436|    outputbuffers.reserve(implementations.size());
  394|  1.74k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.30k, False: 436]
  ------------------
  395|  1.30k|      auto impl = implementations[i];
  396|  1.30k|      const ToType canary1{42};
  397|  1.30k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.30k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.30k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.30k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.30k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.30k|          return r != 0;
  404|  1.30k|        } else {
  405|  1.30k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.30k|        }
  407|  1.30k|      }(implret1);
  408|  1.30k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.30k|      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.30k|        const ToType canary2{25};
  414|  1.30k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.30k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.30k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.30k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.30k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.30k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.30k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 447, False: 861]
  |  Branch (423:29): [True: 438, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    438|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    438|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 438]
  ------------------
  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|    438|        }
  440|  1.30k|      }
  441|  1.30k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 438, False: 870]
  ------------------
  442|  1.30k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    436|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 287, False: 149]
  ------------------
  447|    861|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 861, False: 287]
  ------------------
  448|    861|        e.outputhash.clear();
  449|    861|      }
  450|    287|    }
  451|       |
  452|    436|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    436|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 436]
  ------------------
  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|    436|    } else {
  474|    436|      ret.implementations_agree = true;
  475|    436|    }
  476|    436|    return ret;
  477|    436|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.30k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.30k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.30k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.30k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    872|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_7clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    240|    +[](std::span<const char> chardata) {                                      \
  555|    240|      const auto c =                                                           \
  556|    240|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    240|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    240|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    240|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    240|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    240|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    240|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    240|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    240|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    240|  constexpr auto _size = _name.size();                                \
  |  | 1183|    240|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    240|  return _nameof; }()
  ------------------
  561|    240|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    240|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    240|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    240|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    240|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    240|  constexpr auto _size = _name.size();                                \
  |  | 1183|    240|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    240|  return _nameof; }()
  ------------------
  562|    240|      c.fuzz(chardata);                                                        \
  563|    240|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    619|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    619|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    619|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    619|    static const bool do_print_testcase =
  181|    619|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    619|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 619]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    619|    do {
  189|       |      // step 0 - is the input valid?
  190|    619|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    619|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 619]
  |  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|    619|                    From == UtfEncodings::UTF8) {
  198|    619|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 619]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    619|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    619|      const auto [output_length, length_agree] =
  204|    619|          calculate_length(from, inputisvalid);
  205|    619|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 619]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    619|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 287, False: 332]
  |  Branch (208:28): [True: 10, False: 277]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     10|        return;
  211|     10|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    609|      const auto [written, outputs_agree] =
  215|    609|          do_conversion(from, output_length, inputisvalid);
  216|    609|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 609]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    609|      return;
  221|    609|    } 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|    619|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    619|  validation_result verify_valid_input(FromSpan src) const {
  231|    619|    validation_result ret{};
  232|       |
  233|    619|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    619|    const auto implementations = get_supported_implementations();
  235|    619|    std::vector<simdutf::result> results;
  236|    619|    results.reserve(implementations.size());
  237|       |
  238|  1.85k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.85k, False: 619]
  ------------------
  239|  1.85k|      results.push_back(
  240|  1.85k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.85k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.85k|      const bool validation2 =
  245|  1.85k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.85k|                      src.data(), src.size());
  247|  1.85k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.85k]
  ------------------
  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.85k|    }
  258|       |
  259|    619|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    619|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 619]
  ------------------
  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|    619|    } else {
  273|    619|      ret.implementations_agree = true;
  274|    619|    }
  275|    619|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    619|      return r.error == simdutf::SUCCESS;
  277|    619|    });
  278|    619|    return ret;
  279|    619|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|  1.23k|    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.28k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.28k|      return r.error == simdutf::SUCCESS;
  277|  1.28k|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    619|  bool count_the_input(FromSpan src) const {
  290|    619|    const auto implementations = get_supported_implementations();
  291|    619|    std::vector<std::size_t> results;
  292|    619|    results.reserve(implementations.size());
  293|       |
  294|  1.85k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.85k, False: 619]
  ------------------
  295|  1.85k|      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.85k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.85k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.85k|      }
  303|  1.85k|      results.push_back(ret);
  304|  1.85k|    }
  305|    619|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    619|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 619]
  ------------------
  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|    619|    return true;
  321|    619|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|  1.23k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    619|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    619|    length_result ret{};
  344|       |
  345|    619|    const auto implementations = get_supported_implementations();
  346|    619|    std::vector<std::size_t> results;
  347|    619|    results.reserve(implementations.size());
  348|       |
  349|  1.85k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.85k, False: 619]
  ------------------
  350|  1.85k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.85k|      results.push_back(len);
  352|  1.85k|      ret.length.push_back(len);
  353|  1.85k|    }
  354|       |
  355|    619|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    619|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 619]
  ------------------
  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|    619|    } else {
  375|    619|      ret.implementations_agree = true;
  376|    619|    }
  377|    619|    return ret;
  378|    619|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.85k|                                FromSpan src) const {
  331|  1.85k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.85k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|  1.23k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    609|                                  const bool inputisvalid) const {
  383|    609|    conversion_result ret{};
  384|       |
  385|    609|    const auto implementations = get_supported_implementations();
  386|       |
  387|    609|    std::vector<result<ConversionResult>> results;
  388|    609|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    609|    std::vector<std::vector<ToType>> outputbuffers;
  393|    609|    outputbuffers.reserve(implementations.size());
  394|  2.43k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.82k, False: 609]
  ------------------
  395|  1.82k|      auto impl = implementations[i];
  396|  1.82k|      const ToType canary1{42};
  397|  1.82k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.82k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.82k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.82k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.82k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.82k|          return r != 0;
  404|  1.82k|        } else {
  405|  1.82k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.82k|        }
  407|  1.82k|      }(implret1);
  408|  1.82k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.82k|      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.82k|        const ToType canary2{25};
  414|  1.82k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.82k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.82k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.82k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.82k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.82k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.82k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 996, False: 831]
  |  Branch (423:29): [True: 990, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    990|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    990|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 990]
  ------------------
  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|    990|        }
  440|  1.82k|      }
  441|  1.82k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 990, False: 837]
  ------------------
  442|  1.82k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    609|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 277, False: 332]
  ------------------
  447|    831|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 831, False: 277]
  ------------------
  448|    831|        e.outputhash.clear();
  449|    831|      }
  450|    277|    }
  451|       |
  452|    609|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    609|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 609]
  ------------------
  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|    609|    } else {
  474|    609|      ret.implementations_agree = true;
  475|    609|    }
  476|    609|    return ret;
  477|    609|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.82k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.82k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.82k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.82k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|  1.21k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_8clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    231|    +[](std::span<const char> chardata) {                                      \
  555|    231|      const auto c =                                                           \
  556|    231|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    231|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    231|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    231|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    231|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    231|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    231|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    231|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    231|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    231|  constexpr auto _size = _name.size();                                \
  |  | 1183|    231|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    231|  return _nameof; }()
  ------------------
  561|    231|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    231|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    231|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    231|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    231|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    231|  constexpr auto _size = _name.size();                                \
  |  | 1183|    231|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    231|  return _nameof; }()
  ------------------
  562|    231|      c.fuzz(chardata);                                                        \
  563|    231|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    623|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    623|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    623|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    623|    static const bool do_print_testcase =
  181|    623|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    623|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 623]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    623|    do {
  189|       |      // step 0 - is the input valid?
  190|    623|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    623|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 623]
  |  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|    623|                    From == UtfEncodings::UTF8) {
  198|    623|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 623]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    623|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    623|      const auto [output_length, length_agree] =
  204|    623|          calculate_length(from, inputisvalid);
  205|    623|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 623]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    623|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 283, False: 340]
  |  Branch (208:28): [True: 15, False: 268]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     15|        return;
  211|     15|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    608|      const auto [written, outputs_agree] =
  215|    608|          do_conversion(from, output_length, inputisvalid);
  216|    608|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 608]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    608|      return;
  221|    608|    } 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|    623|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    623|  validation_result verify_valid_input(FromSpan src) const {
  231|    623|    validation_result ret{};
  232|       |
  233|    623|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    623|    const auto implementations = get_supported_implementations();
  235|    623|    std::vector<simdutf::result> results;
  236|    623|    results.reserve(implementations.size());
  237|       |
  238|  1.86k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.86k, False: 623]
  ------------------
  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|    623|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    623|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 623]
  ------------------
  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|    623|    } else {
  273|    623|      ret.implementations_agree = true;
  274|    623|    }
  275|    623|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    623|      return r.error == simdutf::SUCCESS;
  277|    623|    });
  278|    623|    return ret;
  279|    623|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|  1.24k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKNS1_6resultEE_clESI_:
  275|  1.30k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.30k|      return r.error == simdutf::SUCCESS;
  277|  1.30k|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    623|  bool count_the_input(FromSpan src) const {
  290|    623|    const auto implementations = get_supported_implementations();
  291|    623|    std::vector<std::size_t> results;
  292|    623|    results.reserve(implementations.size());
  293|       |
  294|  1.86k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.86k, False: 623]
  ------------------
  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|    623|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    623|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 623]
  ------------------
  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|    623|    return true;
  321|    623|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|  1.24k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    623|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    623|    length_result ret{};
  344|       |
  345|    623|    const auto implementations = get_supported_implementations();
  346|    623|    std::vector<std::size_t> results;
  347|    623|    results.reserve(implementations.size());
  348|       |
  349|  1.86k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.86k, False: 623]
  ------------------
  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|    623|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    623|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 623]
  ------------------
  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|    623|    } else {
  375|    623|      ret.implementations_agree = true;
  376|    623|    }
  377|    623|    return ret;
  378|    623|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE17invoke_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_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|  1.24k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    608|                                  const bool inputisvalid) const {
  383|    608|    conversion_result ret{};
  384|       |
  385|    608|    const auto implementations = get_supported_implementations();
  386|       |
  387|    608|    std::vector<result<ConversionResult>> results;
  388|    608|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    608|    std::vector<std::vector<ToType>> outputbuffers;
  393|    608|    outputbuffers.reserve(implementations.size());
  394|  2.43k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.82k, False: 608]
  ------------------
  395|  1.82k|      auto impl = implementations[i];
  396|  1.82k|      const ToType canary1{42};
  397|  1.82k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.82k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.82k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.82k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.82k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.82k|          return r != 0;
  404|  1.82k|        } else {
  405|  1.82k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.82k|        }
  407|  1.82k|      }(implret1);
  408|  1.82k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.82k|      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.82k|        const ToType canary2{25};
  414|  1.82k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.82k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.82k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.82k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.82k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.82k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.82k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 1.02k, False: 804]
  |  Branch (423:29): [True: 1.01k, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|  1.01k|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|  1.01k|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 1.01k]
  ------------------
  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.01k|        }
  440|  1.82k|      }
  441|  1.82k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 1.01k, False: 810]
  ------------------
  442|  1.82k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    608|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 268, False: 340]
  ------------------
  447|    804|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 804, False: 268]
  ------------------
  448|    804|        e.outputhash.clear();
  449|    804|      }
  450|    268|    }
  451|       |
  452|    608|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    608|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 608]
  ------------------
  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|    608|    } else {
  474|    608|      ret.implementations_agree = true;
  475|    608|    }
  476|    608|    return ret;
  477|    608|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.82k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.82k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.82k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.82k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|  1.21k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_9clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    226|    +[](std::span<const char> chardata) {                                      \
  555|    226|      const auto c =                                                           \
  556|    226|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    226|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    226|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    226|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    226|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    226|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    226|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    226|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    226|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    226|  constexpr auto _size = _name.size();                                \
  |  | 1183|    226|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    226|  return _nameof; }()
  ------------------
  561|    226|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    226|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    226|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    226|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    226|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    226|  constexpr auto _size = _name.size();                                \
  |  | 1183|    226|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    226|  return _nameof; }()
  ------------------
  562|    226|      c.fuzz(chardata);                                                        \
  563|    226|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    635|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    635|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    635|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    635|    static const bool do_print_testcase =
  181|    635|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    635|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 635]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    635|    do {
  189|       |      // step 0 - is the input valid?
  190|    635|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    635|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 635]
  |  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|    635|                    From == UtfEncodings::UTF8) {
  198|    635|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 635]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    635|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    635|      const auto [output_length, length_agree] =
  204|    635|          calculate_length(from, inputisvalid);
  205|    635|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 635]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    635|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 279, False: 356]
  |  Branch (208:28): [True: 10, False: 269]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     10|        return;
  211|     10|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    625|      const auto [written, outputs_agree] =
  215|    625|          do_conversion(from, output_length, inputisvalid);
  216|    625|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 625]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    625|      return;
  221|    625|    } 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|    635|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    635|  validation_result verify_valid_input(FromSpan src) const {
  231|    635|    validation_result ret{};
  232|       |
  233|    635|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    635|    const auto implementations = get_supported_implementations();
  235|    635|    std::vector<simdutf::result> results;
  236|    635|    results.reserve(implementations.size());
  237|       |
  238|  1.90k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.90k, False: 635]
  ------------------
  239|  1.90k|      results.push_back(
  240|  1.90k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.90k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.90k|      const bool validation2 =
  245|  1.90k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.90k|                      src.data(), src.size());
  247|  1.90k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.90k]
  ------------------
  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.90k|    }
  258|       |
  259|    635|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    635|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 635]
  ------------------
  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|    635|    } else {
  273|    635|      ret.implementations_agree = true;
  274|    635|    }
  275|    635|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    635|      return r.error == simdutf::SUCCESS;
  277|    635|    });
  278|    635|    return ret;
  279|    635|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|  1.27k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKNS1_6resultEE_clESI_:
  275|  1.34k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.34k|      return r.error == simdutf::SUCCESS;
  277|  1.34k|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    635|  bool count_the_input(FromSpan src) const {
  290|    635|    const auto implementations = get_supported_implementations();
  291|    635|    std::vector<std::size_t> results;
  292|    635|    results.reserve(implementations.size());
  293|       |
  294|  1.90k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.90k, False: 635]
  ------------------
  295|  1.90k|      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.90k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.90k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.90k|      }
  303|  1.90k|      results.push_back(ret);
  304|  1.90k|    }
  305|    635|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    635|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 635]
  ------------------
  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|    635|    return true;
  321|    635|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|  1.27k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    635|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    635|    length_result ret{};
  344|       |
  345|    635|    const auto implementations = get_supported_implementations();
  346|    635|    std::vector<std::size_t> results;
  347|    635|    results.reserve(implementations.size());
  348|       |
  349|  1.90k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.90k, False: 635]
  ------------------
  350|  1.90k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.90k|      results.push_back(len);
  352|  1.90k|      ret.length.push_back(len);
  353|  1.90k|    }
  354|       |
  355|    635|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    635|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 635]
  ------------------
  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|    635|    } else {
  375|    635|      ret.implementations_agree = true;
  376|    635|    }
  377|    635|    return ret;
  378|    635|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.90k|                                FromSpan src) const {
  331|  1.90k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.90k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|  1.27k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    625|                                  const bool inputisvalid) const {
  383|    625|    conversion_result ret{};
  384|       |
  385|    625|    const auto implementations = get_supported_implementations();
  386|       |
  387|    625|    std::vector<result<ConversionResult>> results;
  388|    625|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    625|    std::vector<std::vector<ToType>> outputbuffers;
  393|    625|    outputbuffers.reserve(implementations.size());
  394|  2.50k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.87k, False: 625]
  ------------------
  395|  1.87k|      auto impl = implementations[i];
  396|  1.87k|      const ToType canary1{42};
  397|  1.87k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.87k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.87k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.87k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.87k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.87k|          return r != 0;
  404|  1.87k|        } else {
  405|  1.87k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.87k|        }
  407|  1.87k|      }(implret1);
  408|  1.87k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.87k|      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.87k|        const ToType canary2{25};
  414|  1.87k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.87k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.87k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.87k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.87k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.87k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.87k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 1.06k, False: 807]
  |  Branch (423:29): [True: 1.06k, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|  1.06k|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|  1.06k|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 1.06k]
  ------------------
  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.06k|        }
  440|  1.87k|      }
  441|  1.87k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 1.06k, False: 813]
  ------------------
  442|  1.87k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    625|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 269, False: 356]
  ------------------
  447|    807|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 807, False: 269]
  ------------------
  448|    807|        e.outputhash.clear();
  449|    807|      }
  450|    269|    }
  451|       |
  452|    625|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    625|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 625]
  ------------------
  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|    625|    } else {
  474|    625|      ret.implementations_agree = true;
  475|    625|    }
  476|    625|    return ret;
  477|    625|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.87k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.87k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.87k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.87k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|  1.25k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_10clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     56|    +[](std::span<const char> chardata) {                                      \
  555|     56|      const auto c =                                                           \
  556|     56|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     56|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     56|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     56|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     56|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     56|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     56|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     56|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     56|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     56|  constexpr auto _size = _name.size();                                \
  |  | 1183|     56|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     56|  return _nameof; }()
  ------------------
  561|     56|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     56|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     56|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     56|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     56|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     56|  constexpr auto _size = _name.size();                                \
  |  | 1183|     56|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     56|  return _nameof; }()
  ------------------
  562|     56|      c.fuzz(chardata);                                                        \
  563|     56|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|     56|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     56|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     56|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     56|    static const bool do_print_testcase =
  181|     56|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     56|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 56]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     56|    do {
  189|       |      // step 0 - is the input valid?
  190|     56|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     56|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 56]
  |  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|     56|                    From == UtfEncodings::UTF8) {
  198|     56|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 56]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|     56|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|     56|      const auto [output_length, length_agree] =
  204|     56|          calculate_length(from, inputisvalid);
  205|     56|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 56]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     56|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 12, False: 44]
  |  Branch (208:28): [True: 0, False: 12]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|     56|      const auto [written, outputs_agree] =
  215|     56|          do_conversion(from, output_length, inputisvalid);
  216|     56|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 56]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     56|      return;
  221|     56|    } 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|     56|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  230|     56|  validation_result verify_valid_input(FromSpan src) const {
  231|     56|    validation_result ret{};
  232|       |
  233|     56|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|     56|    const auto implementations = get_supported_implementations();
  235|     56|    std::vector<simdutf::result> results;
  236|     56|    results.reserve(implementations.size());
  237|       |
  238|    168|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 168, False: 56]
  ------------------
  239|    168|      results.push_back(
  240|    168|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    168|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    168|      const bool validation2 =
  245|    168|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    168|                      src.data(), src.size());
  247|    168|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 168]
  ------------------
  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|    168|    }
  258|       |
  259|     56|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|     56|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 56]
  ------------------
  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|     56|    } else {
  273|     56|      ret.implementations_agree = true;
  274|     56|    }
  275|     56|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|     56|      return r.error == simdutf::SUCCESS;
  277|     56|    });
  278|     56|    return ret;
  279|     56|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    112|    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|    144|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    144|      return r.error == simdutf::SUCCESS;
  277|    144|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE15count_the_inputENSt3__14spanIS5_Lm18446744073709551615EEE:
  289|     56|  bool count_the_input(FromSpan src) const {
  290|     56|    const auto implementations = get_supported_implementations();
  291|     56|    std::vector<std::size_t> results;
  292|     56|    results.reserve(implementations.size());
  293|       |
  294|    168|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 168, False: 56]
  ------------------
  295|    168|      std::size_t ret;
  296|    168|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    168|        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|    168|      results.push_back(ret);
  304|    168|    }
  305|     56|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|     56|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 56]
  ------------------
  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|     56|    return true;
  321|     56|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE15count_the_inputENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    112|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     56|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     56|    length_result ret{};
  344|       |
  345|     56|    const auto implementations = get_supported_implementations();
  346|     56|    std::vector<std::size_t> results;
  347|     56|    results.reserve(implementations.size());
  348|       |
  349|    168|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 168, False: 56]
  ------------------
  350|    168|      const auto len = invoke_lengthcalc(impl, src);
  351|    168|      results.push_back(len);
  352|    168|      ret.length.push_back(len);
  353|    168|    }
  354|       |
  355|     56|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     56|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 56]
  ------------------
  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|     56|    } else {
  375|     56|      ret.implementations_agree = true;
  376|     56|    }
  377|     56|    return ret;
  378|     56|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    168|                                FromSpan src) const {
  339|    168|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    168|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    112|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     56|                                  const bool inputisvalid) const {
  383|     56|    conversion_result ret{};
  384|       |
  385|     56|    const auto implementations = get_supported_implementations();
  386|       |
  387|     56|    std::vector<result<ConversionResult>> results;
  388|     56|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     56|    std::vector<std::vector<ToType>> outputbuffers;
  393|     56|    outputbuffers.reserve(implementations.size());
  394|    224|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 168, False: 56]
  ------------------
  395|    168|      auto impl = implementations[i];
  396|    168|      const ToType canary1{42};
  397|    168|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    168|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    168|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    168|      const auto success = [](const ConversionResult& r) -> bool {
  402|    168|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    168|          return r != 0;
  404|    168|        } else {
  405|    168|          return r.error == simdutf::error_code::SUCCESS;
  406|    168|        }
  407|    168|      }(implret1);
  408|    168|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    168|      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|    168|        const ToType canary2{25};
  414|    168|        const auto outputbuffer_first_run = outputbuffer;
  415|    168|        std::ranges::fill(outputbuffer, canary2);
  416|    168|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    168|                                          src.size(), outputbuffer.data());
  418|       |
  419|    168|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 168]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    168|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 132, False: 36]
  |  Branch (423:29): [True: 63, False: 69]
  ------------------
  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|    168|      }
  441|    168|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 63, False: 105]
  ------------------
  442|    168|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     56|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 12, False: 44]
  ------------------
  447|     36|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 36, False: 12]
  ------------------
  448|     36|        e.outputhash.clear();
  449|     36|      }
  450|     12|    }
  451|       |
  452|     56|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     56|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 56]
  ------------------
  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|     56|    } else {
  474|     56|      ret.implementations_agree = true;
  475|     56|    }
  476|     56|    return ret;
  477|     56|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    168|      const auto success = [](const ConversionResult& r) -> bool {
  402|    168|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    168|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    168|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    112|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_11clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    141|    +[](std::span<const char> chardata) {                                      \
  555|    141|      const auto c =                                                           \
  556|    141|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    141|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    141|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    141|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    141|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    141|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    141|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    141|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    141|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    141|  constexpr auto _size = _name.size();                                \
  |  | 1183|    141|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    141|  return _nameof; }()
  ------------------
  561|    141|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    141|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    141|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    141|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    141|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    141|  constexpr auto _size = _name.size();                                \
  |  | 1183|    141|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    141|  return _nameof; }()
  ------------------
  562|    141|      c.fuzz(chardata);                                                        \
  563|    141|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_12clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    179|    +[](std::span<const char> chardata) {                                      \
  555|    179|      const auto c =                                                           \
  556|    179|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    179|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    179|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    179|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    179|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    179|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    179|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    179|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    179|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    179|  constexpr auto _size = _name.size();                                \
  |  | 1183|    179|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    179|  return _nameof; }()
  ------------------
  561|    179|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    179|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    179|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    179|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    179|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    179|  constexpr auto _size = _name.size();                                \
  |  | 1183|    179|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    179|  return _nameof; }()
  ------------------
  562|    179|      c.fuzz(chardata);                                                        \
  563|    179|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_13clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     75|    +[](std::span<const char> chardata) {                                      \
  555|     75|      const auto c =                                                           \
  556|     75|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     75|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     75|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     75|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     75|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     75|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     75|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     75|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     75|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     75|  constexpr auto _size = _name.size();                                \
  |  | 1183|     75|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     75|  return _nameof; }()
  ------------------
  561|     75|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     75|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     75|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     75|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     75|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     75|  constexpr auto _size = _name.size();                                \
  |  | 1183|     75|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     75|  return _nameof; }()
  ------------------
  562|     75|      c.fuzz(chardata);                                                        \
  563|     75|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|     75|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     75|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     75|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     75|    static const bool do_print_testcase =
  181|     75|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     75|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 75]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     75|    do {
  189|       |      // step 0 - is the input valid?
  190|     75|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     75|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 75]
  |  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|     75|                    From == UtfEncodings::UTF8) {
  198|     75|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 75]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|     75|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|     75|      const auto [output_length, length_agree] =
  204|     75|          calculate_length(from, inputisvalid);
  205|     75|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 75]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     75|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 23, False: 52]
  |  Branch (208:28): [True: 0, False: 23]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|     75|      const auto [written, outputs_agree] =
  215|     75|          do_conversion(from, output_length, inputisvalid);
  216|     75|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 75]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     75|      return;
  221|     75|    } 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|     75|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  230|     75|  validation_result verify_valid_input(FromSpan src) const {
  231|     75|    validation_result ret{};
  232|       |
  233|     75|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|     75|    const auto implementations = get_supported_implementations();
  235|     75|    std::vector<simdutf::result> results;
  236|     75|    results.reserve(implementations.size());
  237|       |
  238|    225|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 225, False: 75]
  ------------------
  239|    225|      results.push_back(
  240|    225|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    225|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    225|      const bool validation2 =
  245|    225|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    225|                      src.data(), src.size());
  247|    225|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 225]
  ------------------
  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|    225|    }
  258|       |
  259|     75|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|     75|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 75]
  ------------------
  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|     75|    } else {
  273|     75|      ret.implementations_agree = true;
  274|     75|    }
  275|     75|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|     75|      return r.error == simdutf::SUCCESS;
  277|     75|    });
  278|     75|    return ret;
  279|     75|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    150|    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|    179|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    179|      return r.error == simdutf::SUCCESS;
  277|    179|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE15count_the_inputENSt3__14spanIS5_Lm18446744073709551615EEE:
  289|     75|  bool count_the_input(FromSpan src) const {
  290|     75|    const auto implementations = get_supported_implementations();
  291|     75|    std::vector<std::size_t> results;
  292|     75|    results.reserve(implementations.size());
  293|       |
  294|    225|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 225, False: 75]
  ------------------
  295|    225|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    225|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    225|        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|    225|      results.push_back(ret);
  304|    225|    }
  305|     75|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|     75|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 75]
  ------------------
  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|     75|    return true;
  321|     75|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE15count_the_inputENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    150|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     75|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     75|    length_result ret{};
  344|       |
  345|     75|    const auto implementations = get_supported_implementations();
  346|     75|    std::vector<std::size_t> results;
  347|     75|    results.reserve(implementations.size());
  348|       |
  349|    225|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 225, False: 75]
  ------------------
  350|    225|      const auto len = invoke_lengthcalc(impl, src);
  351|    225|      results.push_back(len);
  352|    225|      ret.length.push_back(len);
  353|    225|    }
  354|       |
  355|     75|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     75|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 75]
  ------------------
  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|     75|    } else {
  375|     75|      ret.implementations_agree = true;
  376|     75|    }
  377|     75|    return ret;
  378|     75|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    225|                                FromSpan src) const {
  339|    225|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    225|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    150|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     75|                                  const bool inputisvalid) const {
  383|     75|    conversion_result ret{};
  384|       |
  385|     75|    const auto implementations = get_supported_implementations();
  386|       |
  387|     75|    std::vector<result<ConversionResult>> results;
  388|     75|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     75|    std::vector<std::vector<ToType>> outputbuffers;
  393|     75|    outputbuffers.reserve(implementations.size());
  394|    300|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 225, False: 75]
  ------------------
  395|    225|      auto impl = implementations[i];
  396|    225|      const ToType canary1{42};
  397|    225|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    225|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    225|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    225|      const auto success = [](const ConversionResult& r) -> bool {
  402|    225|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    225|          return r != 0;
  404|    225|        } else {
  405|    225|          return r.error == simdutf::error_code::SUCCESS;
  406|    225|        }
  407|    225|      }(implret1);
  408|    225|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    225|      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|    225|        const ToType canary2{25};
  414|    225|        const auto outputbuffer_first_run = outputbuffer;
  415|    225|        std::ranges::fill(outputbuffer, canary2);
  416|    225|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    225|                                          src.size(), outputbuffer.data());
  418|       |
  419|    225|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 225]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    225|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 156, False: 69]
  |  Branch (423:29): [True: 69, False: 87]
  ------------------
  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|    225|      }
  441|    225|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 69, False: 156]
  ------------------
  442|    225|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     75|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 23, False: 52]
  ------------------
  447|     69|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 69, False: 23]
  ------------------
  448|     69|        e.outputhash.clear();
  449|     69|      }
  450|     23|    }
  451|       |
  452|     75|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     75|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 75]
  ------------------
  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|     75|    } else {
  474|     75|      ret.implementations_agree = true;
  475|     75|    }
  476|     75|    return ret;
  477|     75|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    225|      const auto success = [](const ConversionResult& r) -> bool {
  402|    225|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    225|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    225|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    150|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_14clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    154|    +[](std::span<const char> chardata) {                                      \
  555|    154|      const auto c =                                                           \
  556|    154|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    154|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    154|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    154|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    154|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    154|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    154|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    154|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    154|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    154|  constexpr auto _size = _name.size();                                \
  |  | 1183|    154|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    154|  return _nameof; }()
  ------------------
  561|    154|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    154|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    154|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    154|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    154|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    154|  constexpr auto _size = _name.size();                                \
  |  | 1183|    154|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    154|  return _nameof; }()
  ------------------
  562|    154|      c.fuzz(chardata);                                                        \
  563|    154|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_15clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    246|    +[](std::span<const char> chardata) {                                      \
  555|    246|      const auto c =                                                           \
  556|    246|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    246|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    246|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    246|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    246|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    246|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    246|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    246|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    246|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    246|  constexpr auto _size = _name.size();                                \
  |  | 1183|    246|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    246|  return _nameof; }()
  ------------------
  561|    246|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    246|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    246|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    246|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    246|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    246|  constexpr auto _size = _name.size();                                \
  |  | 1183|    246|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    246|  return _nameof; }()
  ------------------
  562|    246|      c.fuzz(chardata);                                                        \
  563|    246|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_16clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    103|    +[](std::span<const char> chardata) {                                      \
  555|    103|      const auto c =                                                           \
  556|    103|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    103|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    103|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    103|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    103|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    103|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    103|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    103|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    103|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    103|  constexpr auto _size = _name.size();                                \
  |  | 1183|    103|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    103|  return _nameof; }()
  ------------------
  561|    103|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    103|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    103|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    103|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    103|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    103|  constexpr auto _size = _name.size();                                \
  |  | 1183|    103|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    103|  return _nameof; }()
  ------------------
  562|    103|      c.fuzz(chardata);                                                        \
  563|    103|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    103|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    103|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    103|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    103|    static const bool do_print_testcase =
  181|    103|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    103|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 103]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    103|    do {
  189|       |      // step 0 - is the input valid?
  190|    103|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    103|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 103]
  |  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|    103|      const auto [output_length, length_agree] =
  204|    103|          calculate_length(from, inputisvalid);
  205|    103|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 103]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    103|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 72, False: 31]
  |  Branch (208:28): [True: 0, False: 72]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    103|      const auto [written, outputs_agree] =
  215|    103|          do_conversion(from, output_length, inputisvalid);
  216|    103|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 103]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    103|      return;
  221|    103|    } 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|    103|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  230|    103|  validation_result verify_valid_input(FromSpan src) const {
  231|    103|    validation_result ret{};
  232|       |
  233|    103|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    103|    const auto implementations = get_supported_implementations();
  235|    103|    std::vector<simdutf::result> results;
  236|    103|    results.reserve(implementations.size());
  237|       |
  238|    309|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 309, False: 103]
  ------------------
  239|    309|      results.push_back(
  240|    309|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    309|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    309|      const bool validation2 =
  245|    309|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    309|                      src.data(), src.size());
  247|    309|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 309]
  ------------------
  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|    309|    }
  258|       |
  259|    103|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    103|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 103]
  ------------------
  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|    103|    } else {
  273|    103|      ret.implementations_agree = true;
  274|    103|    }
  275|    103|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    103|      return r.error == simdutf::SUCCESS;
  277|    103|    });
  278|    103|    return ret;
  279|    103|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    206|    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|    165|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    165|      return r.error == simdutf::SUCCESS;
  277|    165|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|    103|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    103|    length_result ret{};
  344|       |
  345|    103|    const auto implementations = get_supported_implementations();
  346|    103|    std::vector<std::size_t> results;
  347|    103|    results.reserve(implementations.size());
  348|       |
  349|    309|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 309, False: 103]
  ------------------
  350|    309|      const auto len = invoke_lengthcalc(impl, src);
  351|    309|      results.push_back(len);
  352|    309|      ret.length.push_back(len);
  353|    309|    }
  354|       |
  355|    103|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    103|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 103]
  ------------------
  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|    103|    } else {
  375|    103|      ret.implementations_agree = true;
  376|    103|    }
  377|    103|    return ret;
  378|    103|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    309|                                FromSpan src) const {
  339|    309|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    309|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    206|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    103|                                  const bool inputisvalid) const {
  383|    103|    conversion_result ret{};
  384|       |
  385|    103|    const auto implementations = get_supported_implementations();
  386|       |
  387|    103|    std::vector<result<ConversionResult>> results;
  388|    103|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    103|    std::vector<std::vector<ToType>> outputbuffers;
  393|    103|    outputbuffers.reserve(implementations.size());
  394|    412|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 309, False: 103]
  ------------------
  395|    309|      auto impl = implementations[i];
  396|    309|      const ToType canary1{42};
  397|    309|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    309|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    309|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    309|      const auto success = [](const ConversionResult& r) -> bool {
  402|    309|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    309|          return r != 0;
  404|    309|        } else {
  405|    309|          return r.error == simdutf::error_code::SUCCESS;
  406|    309|        }
  407|    309|      }(implret1);
  408|    309|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    309|      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|    309|        const ToType canary2{25};
  414|    309|        const auto outputbuffer_first_run = outputbuffer;
  415|    309|        std::ranges::fill(outputbuffer, canary2);
  416|    309|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    309|                                          src.size(), outputbuffer.data());
  418|       |
  419|    309|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 309]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    309|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 93, False: 216]
  |  Branch (423:29): [True: 72, False: 21]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|     72|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|     72|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 72]
  ------------------
  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|     72|        }
  440|    309|      }
  441|    309|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 72, False: 237]
  ------------------
  442|    309|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    103|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 72, False: 31]
  ------------------
  447|    216|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 216, False: 72]
  ------------------
  448|    216|        e.outputhash.clear();
  449|    216|      }
  450|     72|    }
  451|       |
  452|    103|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    103|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 103]
  ------------------
  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|    103|    } else {
  474|    103|      ret.implementations_agree = true;
  475|    103|    }
  476|    103|    return ret;
  477|    103|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    309|      const auto success = [](const ConversionResult& r) -> bool {
  402|    309|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    309|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    309|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    206|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_17clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    213|    +[](std::span<const char> chardata) {                                      \
  555|    213|      const auto c =                                                           \
  556|    213|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    213|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    213|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    213|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    213|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    213|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    213|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    213|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    213|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    213|  constexpr auto _size = _name.size();                                \
  |  | 1183|    213|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    213|  return _nameof; }()
  ------------------
  561|    213|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    213|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    213|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    213|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    213|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    213|  constexpr auto _size = _name.size();                                \
  |  | 1183|    213|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    213|  return _nameof; }()
  ------------------
  562|    213|      c.fuzz(chardata);                                                        \
  563|    213|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_18clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    240|    +[](std::span<const char> chardata) {                                      \
  555|    240|      const auto c =                                                           \
  556|    240|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    240|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    240|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    240|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    240|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    240|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    240|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    240|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    240|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    240|  constexpr auto _size = _name.size();                                \
  |  | 1183|    240|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    240|  return _nameof; }()
  ------------------
  561|    240|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    240|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    240|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    240|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    240|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    240|  constexpr auto _size = _name.size();                                \
  |  | 1183|    240|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    240|  return _nameof; }()
  ------------------
  562|    240|      c.fuzz(chardata);                                                        \
  563|    240|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_19clENSt3__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|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_20clENSt3__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_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE4fuzzENSt3__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: 204, False: 102]
  |  Branch (208:28): [True: 0, False: 204]
  ------------------
  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_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_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_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    612|    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|    510|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    510|      return r.error == simdutf::SUCCESS;
  277|    510|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE15count_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_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    612|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE16calculate_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_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    918|                                FromSpan src) const {
  331|    918|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    918|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    612|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_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: 306, False: 612]
  |  Branch (423:29): [True: 276, False: 30]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    276|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    276|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 276]
  ------------------
  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|    276|        }
  440|    918|      }
  441|    918|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 276, False: 642]
  ------------------
  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: 204, False: 102]
  ------------------
  447|    612|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 612, False: 204]
  ------------------
  448|    612|        e.outputhash.clear();
  449|    612|      }
  450|    204|    }
  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_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  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|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    918|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    612|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_21clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    379|    +[](std::span<const char> chardata) {                                      \
  555|    379|      const auto c =                                                           \
  556|    379|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    379|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    379|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    379|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    379|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    379|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    379|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    379|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    379|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    379|  constexpr auto _size = _name.size();                                \
  |  | 1183|    379|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    379|  return _nameof; }()
  ------------------
  561|    379|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    379|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    379|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    379|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    379|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    379|  constexpr auto _size = _name.size();                                \
  |  | 1183|    379|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    379|  return _nameof; }()
  ------------------
  562|    379|      c.fuzz(chardata);                                                        \
  563|    379|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_22clENSt3__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$_23clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    409|    +[](std::span<const char> chardata) {                                      \
  555|    409|      const auto c =                                                           \
  556|    409|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    409|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    409|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    409|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    409|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    409|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    409|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    409|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    409|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    409|  constexpr auto _size = _name.size();                                \
  |  | 1183|    409|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    409|  return _nameof; }()
  ------------------
  561|    409|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    409|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    409|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    409|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    409|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    409|  constexpr auto _size = _name.size();                                \
  |  | 1183|    409|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    409|  return _nameof; }()
  ------------------
  562|    409|      c.fuzz(chardata);                                                        \
  563|    409|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_24clENSt3__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|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    115|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    115|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    115|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    115|    static const bool do_print_testcase =
  181|    115|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    115|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 115]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    115|    do {
  189|       |      // step 0 - is the input valid?
  190|    115|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    115|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 115]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    115|                    From == UtfEncodings::UTF8) {
  198|    115|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 115]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    115|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    115|      const auto [output_length, length_agree] =
  204|    115|          calculate_length(from, inputisvalid);
  205|    115|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 115]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    115|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 20, False: 95]
  |  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|    115|      const auto [written, outputs_agree] =
  215|    115|          do_conversion(from, output_length, inputisvalid);
  216|    115|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 115]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    115|      return;
  221|    115|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    115|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEE:
  230|    115|  validation_result verify_valid_input(FromSpan src) const {
  231|    115|    validation_result ret{};
  232|       |
  233|    115|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    115|    const auto implementations = get_supported_implementations();
  235|    115|    std::vector<simdutf::result> results;
  236|    115|    results.reserve(implementations.size());
  237|       |
  238|    345|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 345, False: 115]
  ------------------
  239|    345|      results.push_back(
  240|    345|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    345|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    345|      const bool validation2 =
  245|    345|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    345|                      src.data(), src.size());
  247|    345|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 345]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    345|    }
  258|       |
  259|    115|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    115|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 115]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    115|    } else {
  273|    115|      ret.implementations_agree = true;
  274|    115|    }
  275|    115|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    115|      return r.error == simdutf::SUCCESS;
  277|    115|    });
  278|    115|    return ret;
  279|    115|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS5_S5_EEDaSJ_SM_:
  259|    230|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKS5_E_clESI_:
  275|    305|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    305|      return r.error == simdutf::SUCCESS;
  277|    305|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE15count_the_inputENSt3__14spanIS6_Lm18446744073709551615EEE:
  289|    115|  bool count_the_input(FromSpan src) const {
  290|    115|    const auto implementations = get_supported_implementations();
  291|    115|    std::vector<std::size_t> results;
  292|    115|    results.reserve(implementations.size());
  293|       |
  294|    345|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 345, False: 115]
  ------------------
  295|    345|      std::size_t ret;
  296|    345|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    345|        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|    345|      results.push_back(ret);
  304|    345|    }
  305|    115|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    115|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 115]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    115|    return true;
  321|    115|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE15count_the_inputENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    230|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEb:
  342|    115|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    115|    length_result ret{};
  344|       |
  345|    115|    const auto implementations = get_supported_implementations();
  346|    115|    std::vector<std::size_t> results;
  347|    115|    results.reserve(implementations.size());
  348|       |
  349|    345|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 345, False: 115]
  ------------------
  350|    345|      const auto len = invoke_lengthcalc(impl, src);
  351|    345|      results.push_back(len);
  352|    345|      ret.length.push_back(len);
  353|    345|    }
  354|       |
  355|    115|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    115|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 115]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    115|    } else {
  375|    115|      ret.implementations_agree = true;
  376|    115|    }
  377|    115|    return ret;
  378|    115|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSF_NSt3__14spanIS6_Lm18446744073709551615EEE:
  338|    345|                                FromSpan src) const {
  339|    345|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    345|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    230|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    115|                                  const bool inputisvalid) const {
  383|    115|    conversion_result ret{};
  384|       |
  385|    115|    const auto implementations = get_supported_implementations();
  386|       |
  387|    115|    std::vector<result<ConversionResult>> results;
  388|    115|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    115|    std::vector<std::vector<ToType>> outputbuffers;
  393|    115|    outputbuffers.reserve(implementations.size());
  394|    460|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 345, False: 115]
  ------------------
  395|    345|      auto impl = implementations[i];
  396|    345|      const ToType canary1{42};
  397|    345|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    345|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    345|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    345|      const auto success = [](const ConversionResult& r) -> bool {
  402|    345|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    345|          return r != 0;
  404|    345|        } else {
  405|    345|          return r.error == simdutf::error_code::SUCCESS;
  406|    345|        }
  407|    345|      }(implret1);
  408|    345|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    345|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    345|        const ToType canary2{25};
  414|    345|        const auto outputbuffer_first_run = outputbuffer;
  415|    345|        std::ranges::fill(outputbuffer, canary2);
  416|    345|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    345|                                          src.size(), outputbuffer.data());
  418|       |
  419|    345|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 345]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    345|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 285, False: 60]
  |  Branch (423:29): [True: 111, False: 174]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    111|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    111|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 111]
  ------------------
  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|    111|        }
  440|    345|      }
  441|    345|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 111, False: 234]
  ------------------
  442|    345|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    115|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 20, False: 95]
  ------------------
  447|     60|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 60, False: 20]
  ------------------
  448|     60|        e.outputhash.clear();
  449|     60|      }
  450|     20|    }
  451|       |
  452|    115|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    115|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 115]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    115|    } else {
  474|    115|      ret.implementations_agree = true;
  475|    115|    }
  476|    115|    return ret;
  477|    115|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS5_E_clESM_:
  401|    345|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    345|        } else {
  405|    345|          return r.error == simdutf::error_code::SUCCESS;
  406|    345|        }
  407|    345|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS5_ESU_EEDaSN_SQ_:
  452|    230|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_25clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    211|    +[](std::span<const char> chardata) {                                      \
  555|    211|      const auto c =                                                           \
  556|    211|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    211|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    211|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    211|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    211|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    211|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    211|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    211|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    211|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    211|  constexpr auto _size = _name.size();                                \
  |  | 1183|    211|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    211|  return _nameof; }()
  ------------------
  561|    211|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    211|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    211|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    211|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    211|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    211|  constexpr auto _size = _name.size();                                \
  |  | 1183|    211|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    211|  return _nameof; }()
  ------------------
  562|    211|      c.fuzz(chardata);                                                        \
  563|    211|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_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: 123, False: 88]
  |  Branch (208:28): [True: 0, False: 123]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    211|      const auto [written, outputs_agree] =
  215|    211|          do_conversion(from, output_length, inputisvalid);
  216|    211|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 211]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    211|      return;
  221|    211|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    211|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_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|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    422|    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|    387|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    387|      return r.error == simdutf::SUCCESS;
  277|    387|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_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|    633|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    633|        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|    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|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    422|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_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|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    633|                                FromSpan src) const {
  331|    633|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    633|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    422|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    211|                                  const bool inputisvalid) const {
  383|    211|    conversion_result ret{};
  384|       |
  385|    211|    const auto implementations = get_supported_implementations();
  386|       |
  387|    211|    std::vector<result<ConversionResult>> results;
  388|    211|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    211|    std::vector<std::vector<ToType>> outputbuffers;
  393|    211|    outputbuffers.reserve(implementations.size());
  394|    844|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 633, False: 211]
  ------------------
  395|    633|      auto impl = implementations[i];
  396|    633|      const ToType canary1{42};
  397|    633|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    633|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    633|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    633|      const auto success = [](const ConversionResult& r) -> bool {
  402|    633|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    633|          return r != 0;
  404|    633|        } else {
  405|    633|          return r.error == simdutf::error_code::SUCCESS;
  406|    633|        }
  407|    633|      }(implret1);
  408|    633|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    633|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    633|        const ToType canary2{25};
  414|    633|        const auto outputbuffer_first_run = outputbuffer;
  415|    633|        std::ranges::fill(outputbuffer, canary2);
  416|    633|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    633|                                          src.size(), outputbuffer.data());
  418|       |
  419|    633|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 633]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    633|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 264, False: 369]
  |  Branch (423:29): [True: 264, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    264|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    264|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 264]
  ------------------
  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|    264|        }
  440|    633|      }
  441|    633|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 264, False: 369]
  ------------------
  442|    633|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    211|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 123, False: 88]
  ------------------
  447|    369|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 369, False: 123]
  ------------------
  448|    369|        e.outputhash.clear();
  449|    369|      }
  450|    123|    }
  451|       |
  452|    211|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    211|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 211]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    211|    } else {
  474|    211|      ret.implementations_agree = true;
  475|    211|    }
  476|    211|    return ret;
  477|    211|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    633|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    633|        } else {
  405|    633|          return r.error == simdutf::error_code::SUCCESS;
  406|    633|        }
  407|    633|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    422|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_26clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    324|    +[](std::span<const char> chardata) {                                      \
  555|    324|      const auto c =                                                           \
  556|    324|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    324|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    324|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    324|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    324|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    324|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    324|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    324|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    324|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    324|  constexpr auto _size = _name.size();                                \
  |  | 1183|    324|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    324|  return _nameof; }()
  ------------------
  561|    324|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    324|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    324|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    324|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    324|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    324|  constexpr auto _size = _name.size();                                \
  |  | 1183|    324|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    324|  return _nameof; }()
  ------------------
  562|    324|      c.fuzz(chardata);                                                        \
  563|    324|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    324|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    324|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    324|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    324|    static const bool do_print_testcase =
  181|    324|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    324|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 324]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    324|    do {
  189|       |      // step 0 - is the input valid?
  190|    324|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    324|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 324]
  |  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|    324|                    From == UtfEncodings::UTF8) {
  198|    324|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 324]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    324|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    324|      const auto [output_length, length_agree] =
  204|    324|          calculate_length(from, inputisvalid);
  205|    324|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 324]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    324|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 134, False: 190]
  |  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|    324|      const auto [written, outputs_agree] =
  215|    324|          do_conversion(from, output_length, inputisvalid);
  216|    324|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 324]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    324|      return;
  221|    324|    } 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|    324|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    324|  validation_result verify_valid_input(FromSpan src) const {
  231|    324|    validation_result ret{};
  232|       |
  233|    324|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    324|    const auto implementations = get_supported_implementations();
  235|    324|    std::vector<simdutf::result> results;
  236|    324|    results.reserve(implementations.size());
  237|       |
  238|    972|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 972, False: 324]
  ------------------
  239|    972|      results.push_back(
  240|    972|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    972|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    972|      const bool validation2 =
  245|    972|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    972|                      src.data(), src.size());
  247|    972|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 972]
  ------------------
  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|    972|    }
  258|       |
  259|    324|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    324|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 324]
  ------------------
  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|    324|    } else {
  273|    324|      ret.implementations_agree = true;
  274|    324|    }
  275|    324|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    324|      return r.error == simdutf::SUCCESS;
  277|    324|    });
  278|    324|    return ret;
  279|    324|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    648|    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|    704|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    704|      return r.error == simdutf::SUCCESS;
  277|    704|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    324|  bool count_the_input(FromSpan src) const {
  290|    324|    const auto implementations = get_supported_implementations();
  291|    324|    std::vector<std::size_t> results;
  292|    324|    results.reserve(implementations.size());
  293|       |
  294|    972|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 972, False: 324]
  ------------------
  295|    972|      std::size_t ret;
  296|    972|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    972|        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|    972|      results.push_back(ret);
  304|    972|    }
  305|    324|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    324|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 324]
  ------------------
  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|    324|    return true;
  321|    324|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    648|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    324|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    324|    length_result ret{};
  344|       |
  345|    324|    const auto implementations = get_supported_implementations();
  346|    324|    std::vector<std::size_t> results;
  347|    324|    results.reserve(implementations.size());
  348|       |
  349|    972|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 972, False: 324]
  ------------------
  350|    972|      const auto len = invoke_lengthcalc(impl, src);
  351|    972|      results.push_back(len);
  352|    972|      ret.length.push_back(len);
  353|    972|    }
  354|       |
  355|    324|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    324|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 324]
  ------------------
  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|    324|    } else {
  375|    324|      ret.implementations_agree = true;
  376|    324|    }
  377|    324|    return ret;
  378|    324|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    972|                                FromSpan src) const {
  331|    972|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    972|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    648|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    324|                                  const bool inputisvalid) const {
  383|    324|    conversion_result ret{};
  384|       |
  385|    324|    const auto implementations = get_supported_implementations();
  386|       |
  387|    324|    std::vector<result<ConversionResult>> results;
  388|    324|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    324|    std::vector<std::vector<ToType>> outputbuffers;
  393|    324|    outputbuffers.reserve(implementations.size());
  394|  1.29k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 972, False: 324]
  ------------------
  395|    972|      auto impl = implementations[i];
  396|    972|      const ToType canary1{42};
  397|    972|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    972|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    972|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    972|      const auto success = [](const ConversionResult& r) -> bool {
  402|    972|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    972|          return r != 0;
  404|    972|        } else {
  405|    972|          return r.error == simdutf::error_code::SUCCESS;
  406|    972|        }
  407|    972|      }(implret1);
  408|    972|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    972|      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|    972|        const ToType canary2{25};
  414|    972|        const auto outputbuffer_first_run = outputbuffer;
  415|    972|        std::ranges::fill(outputbuffer, canary2);
  416|    972|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    972|                                          src.size(), outputbuffer.data());
  418|       |
  419|    972|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 972]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    972|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 570, False: 402]
  |  Branch (423:29): [True: 570, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    570|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    570|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 570]
  ------------------
  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|    570|        }
  440|    972|      }
  441|    972|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 570, False: 402]
  ------------------
  442|    972|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    324|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 134, False: 190]
  ------------------
  447|    402|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 402, False: 134]
  ------------------
  448|    402|        e.outputhash.clear();
  449|    402|      }
  450|    134|    }
  451|       |
  452|    324|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    324|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 324]
  ------------------
  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|    324|    } else {
  474|    324|      ret.implementations_agree = true;
  475|    324|    }
  476|    324|    return ret;
  477|    324|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    972|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    972|        } else {
  405|    972|          return r.error == simdutf::error_code::SUCCESS;
  406|    972|        }
  407|    972|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    648|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_27clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    113|    +[](std::span<const char> chardata) {                                      \
  555|    113|      const auto c =                                                           \
  556|    113|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    113|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    113|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    113|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    113|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    113|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    113|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    113|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    113|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    113|  constexpr auto _size = _name.size();                                \
  |  | 1183|    113|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    113|  return _nameof; }()
  ------------------
  561|    113|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    113|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    113|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    113|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    113|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    113|  constexpr auto _size = _name.size();                                \
  |  | 1183|    113|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    113|  return _nameof; }()
  ------------------
  562|    113|      c.fuzz(chardata);                                                        \
  563|    113|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    113|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    113|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    113|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    113|    static const bool do_print_testcase =
  181|    113|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    113|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 113]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    113|    do {
  189|       |      // step 0 - is the input valid?
  190|    113|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    113|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 113]
  |  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|    113|                    From == UtfEncodings::UTF8) {
  198|    113|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 113]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    113|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    113|      const auto [output_length, length_agree] =
  204|    113|          calculate_length(from, inputisvalid);
  205|    113|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 113]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    113|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 19, False: 94]
  |  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|    113|      const auto [written, outputs_agree] =
  215|    113|          do_conversion(from, output_length, inputisvalid);
  216|    113|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 113]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    113|      return;
  221|    113|    } 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|    113|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEE:
  230|    113|  validation_result verify_valid_input(FromSpan src) const {
  231|    113|    validation_result ret{};
  232|       |
  233|    113|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    113|    const auto implementations = get_supported_implementations();
  235|    113|    std::vector<simdutf::result> results;
  236|    113|    results.reserve(implementations.size());
  237|       |
  238|    339|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 339, False: 113]
  ------------------
  239|    339|      results.push_back(
  240|    339|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    339|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    339|      const bool validation2 =
  245|    339|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    339|                      src.data(), src.size());
  247|    339|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 339]
  ------------------
  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|    339|    }
  258|       |
  259|    113|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    113|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 113]
  ------------------
  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|    113|    } else {
  273|    113|      ret.implementations_agree = true;
  274|    113|    }
  275|    113|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    113|      return r.error == simdutf::SUCCESS;
  277|    113|    });
  278|    113|    return ret;
  279|    113|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS5_S5_EEDaSJ_SM_:
  259|    226|    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|    301|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    301|      return r.error == simdutf::SUCCESS;
  277|    301|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE15count_the_inputENSt3__14spanIS6_Lm18446744073709551615EEE:
  289|    113|  bool count_the_input(FromSpan src) const {
  290|    113|    const auto implementations = get_supported_implementations();
  291|    113|    std::vector<std::size_t> results;
  292|    113|    results.reserve(implementations.size());
  293|       |
  294|    339|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 339, False: 113]
  ------------------
  295|    339|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    339|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    339|        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|    339|      results.push_back(ret);
  304|    339|    }
  305|    113|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    113|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 113]
  ------------------
  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|    113|    return true;
  321|    113|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE15count_the_inputENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    226|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEb:
  342|    113|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    113|    length_result ret{};
  344|       |
  345|    113|    const auto implementations = get_supported_implementations();
  346|    113|    std::vector<std::size_t> results;
  347|    113|    results.reserve(implementations.size());
  348|       |
  349|    339|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 339, False: 113]
  ------------------
  350|    339|      const auto len = invoke_lengthcalc(impl, src);
  351|    339|      results.push_back(len);
  352|    339|      ret.length.push_back(len);
  353|    339|    }
  354|       |
  355|    113|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    113|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 113]
  ------------------
  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|    113|    } else {
  375|    113|      ret.implementations_agree = true;
  376|    113|    }
  377|    113|    return ret;
  378|    113|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSF_NSt3__14spanIS6_Lm18446744073709551615EEE:
  338|    339|                                FromSpan src) const {
  339|    339|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    339|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    226|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    113|                                  const bool inputisvalid) const {
  383|    113|    conversion_result ret{};
  384|       |
  385|    113|    const auto implementations = get_supported_implementations();
  386|       |
  387|    113|    std::vector<result<ConversionResult>> results;
  388|    113|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    113|    std::vector<std::vector<ToType>> outputbuffers;
  393|    113|    outputbuffers.reserve(implementations.size());
  394|    452|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 339, False: 113]
  ------------------
  395|    339|      auto impl = implementations[i];
  396|    339|      const ToType canary1{42};
  397|    339|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    339|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    339|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    339|      const auto success = [](const ConversionResult& r) -> bool {
  402|    339|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    339|          return r != 0;
  404|    339|        } else {
  405|    339|          return r.error == simdutf::error_code::SUCCESS;
  406|    339|        }
  407|    339|      }(implret1);
  408|    339|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    339|      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|    339|        const ToType canary2{25};
  414|    339|        const auto outputbuffer_first_run = outputbuffer;
  415|    339|        std::ranges::fill(outputbuffer, canary2);
  416|    339|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    339|                                          src.size(), outputbuffer.data());
  418|       |
  419|    339|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 339]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    339|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 282, False: 57]
  |  Branch (423:29): [True: 141, False: 141]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    141|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    141|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 141]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    141|        }
  440|    339|      }
  441|    339|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 141, False: 198]
  ------------------
  442|    339|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    113|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 19, False: 94]
  ------------------
  447|     57|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 57, False: 19]
  ------------------
  448|     57|        e.outputhash.clear();
  449|     57|      }
  450|     19|    }
  451|       |
  452|    113|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    113|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 113]
  ------------------
  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|    113|    } else {
  474|    113|      ret.implementations_agree = true;
  475|    113|    }
  476|    113|    return ret;
  477|    113|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS5_E_clESM_:
  401|    339|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    339|        } else {
  405|    339|          return r.error == simdutf::error_code::SUCCESS;
  406|    339|        }
  407|    339|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS5_ESU_EEDaSN_SQ_:
  452|    226|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_28clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    201|    +[](std::span<const char> chardata) {                                      \
  555|    201|      const auto c =                                                           \
  556|    201|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    201|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    201|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    201|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    201|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    201|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    201|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    201|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    201|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    201|  constexpr auto _size = _name.size();                                \
  |  | 1183|    201|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    201|  return _nameof; }()
  ------------------
  561|    201|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    201|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    201|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    201|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    201|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    201|  constexpr auto _size = _name.size();                                \
  |  | 1183|    201|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    201|  return _nameof; }()
  ------------------
  562|    201|      c.fuzz(chardata);                                                        \
  563|    201|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    201|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    201|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    201|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    201|    static const bool do_print_testcase =
  181|    201|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    201|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 201]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    201|    do {
  189|       |      // step 0 - is the input valid?
  190|    201|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    201|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 201]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    201|                    From == UtfEncodings::UTF8) {
  198|    201|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 201]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    201|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    201|      const auto [output_length, length_agree] =
  204|    201|          calculate_length(from, inputisvalid);
  205|    201|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 201]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    201|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 101, False: 100]
  |  Branch (208:28): [True: 0, False: 101]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    201|      const auto [written, outputs_agree] =
  215|    201|          do_conversion(from, output_length, inputisvalid);
  216|    201|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 201]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    201|      return;
  221|    201|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    201|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    201|  validation_result verify_valid_input(FromSpan src) const {
  231|    201|    validation_result ret{};
  232|       |
  233|    201|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    201|    const auto implementations = get_supported_implementations();
  235|    201|    std::vector<simdutf::result> results;
  236|    201|    results.reserve(implementations.size());
  237|       |
  238|    603|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 603, False: 201]
  ------------------
  239|    603|      results.push_back(
  240|    603|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    603|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    603|      const bool validation2 =
  245|    603|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    603|                      src.data(), src.size());
  247|    603|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 603]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    603|    }
  258|       |
  259|    201|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    201|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 201]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    201|    } else {
  273|    201|      ret.implementations_agree = true;
  274|    201|    }
  275|    201|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    201|      return r.error == simdutf::SUCCESS;
  277|    201|    });
  278|    201|    return ret;
  279|    201|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    402|    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|    401|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    401|      return r.error == simdutf::SUCCESS;
  277|    401|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    201|  bool count_the_input(FromSpan src) const {
  290|    201|    const auto implementations = get_supported_implementations();
  291|    201|    std::vector<std::size_t> results;
  292|    201|    results.reserve(implementations.size());
  293|       |
  294|    603|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 603, False: 201]
  ------------------
  295|    603|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    603|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    603|        ret = impl->count_utf16le(src.data(), src.size());
  300|       |      } else if constexpr (From == UtfEncodings::UTF8) {
  301|       |        ret = impl->count_utf8(src.data(), src.size());
  302|       |      }
  303|    603|      results.push_back(ret);
  304|    603|    }
  305|    201|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    201|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 201]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    201|    return true;
  321|    201|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    402|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    201|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    201|    length_result ret{};
  344|       |
  345|    201|    const auto implementations = get_supported_implementations();
  346|    201|    std::vector<std::size_t> results;
  347|    201|    results.reserve(implementations.size());
  348|       |
  349|    603|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 603, False: 201]
  ------------------
  350|    603|      const auto len = invoke_lengthcalc(impl, src);
  351|    603|      results.push_back(len);
  352|    603|      ret.length.push_back(len);
  353|    603|    }
  354|       |
  355|    201|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    201|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 201]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    201|    } else {
  375|    201|      ret.implementations_agree = true;
  376|    201|    }
  377|    201|    return ret;
  378|    201|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    603|                                FromSpan src) const {
  331|    603|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    603|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    402|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    201|                                  const bool inputisvalid) const {
  383|    201|    conversion_result ret{};
  384|       |
  385|    201|    const auto implementations = get_supported_implementations();
  386|       |
  387|    201|    std::vector<result<ConversionResult>> results;
  388|    201|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    201|    std::vector<std::vector<ToType>> outputbuffers;
  393|    201|    outputbuffers.reserve(implementations.size());
  394|    804|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 603, False: 201]
  ------------------
  395|    603|      auto impl = implementations[i];
  396|    603|      const ToType canary1{42};
  397|    603|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    603|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    603|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    603|      const auto success = [](const ConversionResult& r) -> bool {
  402|    603|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    603|          return r != 0;
  404|    603|        } else {
  405|    603|          return r.error == simdutf::error_code::SUCCESS;
  406|    603|        }
  407|    603|      }(implret1);
  408|    603|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    603|      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|    603|        const ToType canary2{25};
  414|    603|        const auto outputbuffer_first_run = outputbuffer;
  415|    603|        std::ranges::fill(outputbuffer, canary2);
  416|    603|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    603|                                          src.size(), outputbuffer.data());
  418|       |
  419|    603|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 603]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    603|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 300, False: 303]
  |  Branch (423:29): [True: 300, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    300|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    300|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 300]
  ------------------
  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|    300|        }
  440|    603|      }
  441|    603|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 300, False: 303]
  ------------------
  442|    603|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    201|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 101, False: 100]
  ------------------
  447|    303|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 303, False: 101]
  ------------------
  448|    303|        e.outputhash.clear();
  449|    303|      }
  450|    101|    }
  451|       |
  452|    201|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    201|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 201]
  ------------------
  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|    201|    } else {
  474|    201|      ret.implementations_agree = true;
  475|    201|    }
  476|    201|    return ret;
  477|    201|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    603|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    603|        } else {
  405|    603|          return r.error == simdutf::error_code::SUCCESS;
  406|    603|        }
  407|    603|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    402|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_29clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    327|    +[](std::span<const char> chardata) {                                      \
  555|    327|      const auto c =                                                           \
  556|    327|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    327|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    327|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    327|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    327|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    327|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    327|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    327|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    327|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    327|  constexpr auto _size = _name.size();                                \
  |  | 1183|    327|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    327|  return _nameof; }()
  ------------------
  561|    327|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    327|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    327|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    327|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    327|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    327|  constexpr auto _size = _name.size();                                \
  |  | 1183|    327|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    327|  return _nameof; }()
  ------------------
  562|    327|      c.fuzz(chardata);                                                        \
  563|    327|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    327|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    327|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    327|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    327|    static const bool do_print_testcase =
  181|    327|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    327|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 327]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    327|    do {
  189|       |      // step 0 - is the input valid?
  190|    327|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    327|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 327]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    327|                    From == UtfEncodings::UTF8) {
  198|    327|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 327]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    327|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    327|      const auto [output_length, length_agree] =
  204|    327|          calculate_length(from, inputisvalid);
  205|    327|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 327]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    327|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 119, False: 208]
  |  Branch (208:28): [True: 0, False: 119]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    327|      const auto [written, outputs_agree] =
  215|    327|          do_conversion(from, output_length, inputisvalid);
  216|    327|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 327]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    327|      return;
  221|    327|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    327|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    327|  validation_result verify_valid_input(FromSpan src) const {
  231|    327|    validation_result ret{};
  232|       |
  233|    327|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    327|    const auto implementations = get_supported_implementations();
  235|    327|    std::vector<simdutf::result> results;
  236|    327|    results.reserve(implementations.size());
  237|       |
  238|    981|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 981, False: 327]
  ------------------
  239|    981|      results.push_back(
  240|    981|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    981|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    981|      const bool validation2 =
  245|    981|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    981|                      src.data(), src.size());
  247|    981|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 981]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    981|    }
  258|       |
  259|    327|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    327|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 327]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    327|    } else {
  273|    327|      ret.implementations_agree = true;
  274|    327|    }
  275|    327|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    327|      return r.error == simdutf::SUCCESS;
  277|    327|    });
  278|    327|    return ret;
  279|    327|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    654|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKS7_E_clESI_:
  275|    743|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    743|      return r.error == simdutf::SUCCESS;
  277|    743|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    327|  bool count_the_input(FromSpan src) const {
  290|    327|    const auto implementations = get_supported_implementations();
  291|    327|    std::vector<std::size_t> results;
  292|    327|    results.reserve(implementations.size());
  293|       |
  294|    981|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 981, False: 327]
  ------------------
  295|    981|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    981|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    981|        ret = impl->count_utf16le(src.data(), src.size());
  300|       |      } else if constexpr (From == UtfEncodings::UTF8) {
  301|       |        ret = impl->count_utf8(src.data(), src.size());
  302|       |      }
  303|    981|      results.push_back(ret);
  304|    981|    }
  305|    327|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    327|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 327]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    327|    return true;
  321|    327|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    654|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    327|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    327|    length_result ret{};
  344|       |
  345|    327|    const auto implementations = get_supported_implementations();
  346|    327|    std::vector<std::size_t> results;
  347|    327|    results.reserve(implementations.size());
  348|       |
  349|    981|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 981, False: 327]
  ------------------
  350|    981|      const auto len = invoke_lengthcalc(impl, src);
  351|    981|      results.push_back(len);
  352|    981|      ret.length.push_back(len);
  353|    981|    }
  354|       |
  355|    327|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    327|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 327]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    327|    } else {
  375|    327|      ret.implementations_agree = true;
  376|    327|    }
  377|    327|    return ret;
  378|    327|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    981|                                FromSpan src) const {
  331|    981|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    981|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    654|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    327|                                  const bool inputisvalid) const {
  383|    327|    conversion_result ret{};
  384|       |
  385|    327|    const auto implementations = get_supported_implementations();
  386|       |
  387|    327|    std::vector<result<ConversionResult>> results;
  388|    327|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    327|    std::vector<std::vector<ToType>> outputbuffers;
  393|    327|    outputbuffers.reserve(implementations.size());
  394|  1.30k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 981, False: 327]
  ------------------
  395|    981|      auto impl = implementations[i];
  396|    981|      const ToType canary1{42};
  397|    981|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    981|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    981|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    981|      const auto success = [](const ConversionResult& r) -> bool {
  402|    981|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    981|          return r != 0;
  404|    981|        } else {
  405|    981|          return r.error == simdutf::error_code::SUCCESS;
  406|    981|        }
  407|    981|      }(implret1);
  408|    981|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    981|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    981|        const ToType canary2{25};
  414|    981|        const auto outputbuffer_first_run = outputbuffer;
  415|    981|        std::ranges::fill(outputbuffer, canary2);
  416|    981|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    981|                                          src.size(), outputbuffer.data());
  418|       |
  419|    981|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 981]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    981|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 624, False: 357]
  |  Branch (423:29): [True: 624, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    624|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    624|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 624]
  ------------------
  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|    624|        }
  440|    981|      }
  441|    981|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 624, False: 357]
  ------------------
  442|    981|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    327|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 119, False: 208]
  ------------------
  447|    357|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 357, False: 119]
  ------------------
  448|    357|        e.outputhash.clear();
  449|    357|      }
  450|    119|    }
  451|       |
  452|    327|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    327|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 327]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    327|    } else {
  474|    327|      ret.implementations_agree = true;
  475|    327|    }
  476|    327|    return ret;
  477|    327|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    981|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    981|        } else {
  405|    981|          return r.error == simdutf::error_code::SUCCESS;
  406|    981|        }
  407|    981|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    654|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_30clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    227|    +[](std::span<const char> chardata) {                                      \
  555|    227|      const auto c =                                                           \
  556|    227|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    227|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    227|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    227|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    227|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    227|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    227|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    227|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    227|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    227|  constexpr auto _size = _name.size();                                \
  |  | 1183|    227|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    227|  return _nameof; }()
  ------------------
  561|    227|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    227|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    227|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    227|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    227|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    227|  constexpr auto _size = _name.size();                                \
  |  | 1183|    227|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    227|  return _nameof; }()
  ------------------
  562|    227|      c.fuzz(chardata);                                                        \
  563|    227|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    227|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    227|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    227|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    227|    static const bool do_print_testcase =
  181|    227|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    227|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 227]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    227|    do {
  189|       |      // step 0 - is the input valid?
  190|    227|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    227|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 227]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|       |                    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|    227|      const auto [output_length, length_agree] =
  204|    227|          calculate_length(from, inputisvalid);
  205|    227|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 227]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    227|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 195, False: 32]
  |  Branch (208:28): [True: 0, False: 195]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    227|      const auto [written, outputs_agree] =
  215|    227|          do_conversion(from, output_length, inputisvalid);
  216|    227|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 227]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    227|      return;
  221|    227|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    227|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEE:
  230|    227|  validation_result verify_valid_input(FromSpan src) const {
  231|    227|    validation_result ret{};
  232|       |
  233|    227|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    227|    const auto implementations = get_supported_implementations();
  235|    227|    std::vector<simdutf::result> results;
  236|    227|    results.reserve(implementations.size());
  237|       |
  238|    681|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 681, False: 227]
  ------------------
  239|    681|      results.push_back(
  240|    681|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    681|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    681|      const bool validation2 =
  245|    681|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    681|                      src.data(), src.size());
  247|    681|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 681]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    681|    }
  258|       |
  259|    227|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    227|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 227]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    227|    } else {
  273|    227|      ret.implementations_agree = true;
  274|    227|    }
  275|    227|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    227|      return r.error == simdutf::SUCCESS;
  277|    227|    });
  278|    227|    return ret;
  279|    227|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS5_S5_EEDaSJ_SM_:
  259|    454|    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|    291|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    291|      return r.error == simdutf::SUCCESS;
  277|    291|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEb:
  342|    227|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    227|    length_result ret{};
  344|       |
  345|    227|    const auto implementations = get_supported_implementations();
  346|    227|    std::vector<std::size_t> results;
  347|    227|    results.reserve(implementations.size());
  348|       |
  349|    681|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 681, False: 227]
  ------------------
  350|    681|      const auto len = invoke_lengthcalc(impl, src);
  351|    681|      results.push_back(len);
  352|    681|      ret.length.push_back(len);
  353|    681|    }
  354|       |
  355|    227|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    227|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 227]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    227|    } else {
  375|    227|      ret.implementations_agree = true;
  376|    227|    }
  377|    227|    return ret;
  378|    227|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSF_NSt3__14spanIS6_Lm18446744073709551615EEE:
  338|    681|                                FromSpan src) const {
  339|    681|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    681|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    454|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    227|                                  const bool inputisvalid) const {
  383|    227|    conversion_result ret{};
  384|       |
  385|    227|    const auto implementations = get_supported_implementations();
  386|       |
  387|    227|    std::vector<result<ConversionResult>> results;
  388|    227|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    227|    std::vector<std::vector<ToType>> outputbuffers;
  393|    227|    outputbuffers.reserve(implementations.size());
  394|    908|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 681, False: 227]
  ------------------
  395|    681|      auto impl = implementations[i];
  396|    681|      const ToType canary1{42};
  397|    681|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    681|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    681|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    681|      const auto success = [](const ConversionResult& r) -> bool {
  402|    681|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    681|          return r != 0;
  404|    681|        } else {
  405|    681|          return r.error == simdutf::error_code::SUCCESS;
  406|    681|        }
  407|    681|      }(implret1);
  408|    681|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    681|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    681|        const ToType canary2{25};
  414|    681|        const auto outputbuffer_first_run = outputbuffer;
  415|    681|        std::ranges::fill(outputbuffer, canary2);
  416|    681|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    681|                                          src.size(), outputbuffer.data());
  418|       |
  419|    681|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 681]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    681|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 96, False: 585]
  |  Branch (423:29): [True: 75, False: 21]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|     75|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|     75|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 75]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|     75|        }
  440|    681|      }
  441|    681|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 75, False: 606]
  ------------------
  442|    681|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    227|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 195, False: 32]
  ------------------
  447|    585|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 585, False: 195]
  ------------------
  448|    585|        e.outputhash.clear();
  449|    585|      }
  450|    195|    }
  451|       |
  452|    227|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    227|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 227]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    227|    } else {
  474|    227|      ret.implementations_agree = true;
  475|    227|    }
  476|    227|    return ret;
  477|    227|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS5_E_clESM_:
  401|    681|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    681|        } else {
  405|    681|          return r.error == simdutf::error_code::SUCCESS;
  406|    681|        }
  407|    681|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS5_ESU_EEDaSN_SQ_:
  452|    454|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_31clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    330|    +[](std::span<const char> chardata) {                                      \
  555|    330|      const auto c =                                                           \
  556|    330|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    330|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    330|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    330|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    330|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    330|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    330|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    330|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    330|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    330|  constexpr auto _size = _name.size();                                \
  |  | 1183|    330|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    330|  return _nameof; }()
  ------------------
  561|    330|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    330|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    330|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    330|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    330|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    330|  constexpr auto _size = _name.size();                                \
  |  | 1183|    330|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    330|  return _nameof; }()
  ------------------
  562|    330|      c.fuzz(chardata);                                                        \
  563|    330|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    330|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    330|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    330|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    330|    static const bool do_print_testcase =
  181|    330|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    330|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 330]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    330|    do {
  189|       |      // step 0 - is the input valid?
  190|    330|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    330|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 330]
  |  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|    330|      const auto [output_length, length_agree] =
  204|    330|          calculate_length(from, inputisvalid);
  205|    330|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 330]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    330|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 239, False: 91]
  |  Branch (208:28): [True: 0, False: 239]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    330|      const auto [written, outputs_agree] =
  215|    330|          do_conversion(from, output_length, inputisvalid);
  216|    330|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 330]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    330|      return;
  221|    330|    } 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|    330|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    330|  validation_result verify_valid_input(FromSpan src) const {
  231|    330|    validation_result ret{};
  232|       |
  233|    330|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    330|    const auto implementations = get_supported_implementations();
  235|    330|    std::vector<simdutf::result> results;
  236|    330|    results.reserve(implementations.size());
  237|       |
  238|    990|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 990, False: 330]
  ------------------
  239|    990|      results.push_back(
  240|    990|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    990|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    990|      const bool validation2 =
  245|    990|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    990|                      src.data(), src.size());
  247|    990|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 990]
  ------------------
  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|    990|    }
  258|       |
  259|    330|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    330|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 330]
  ------------------
  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|    330|    } else {
  273|    330|      ret.implementations_agree = true;
  274|    330|    }
  275|    330|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    330|      return r.error == simdutf::SUCCESS;
  277|    330|    });
  278|    330|    return ret;
  279|    330|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    660|    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|    512|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    512|      return r.error == simdutf::SUCCESS;
  277|    512|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    330|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    330|    length_result ret{};
  344|       |
  345|    330|    const auto implementations = get_supported_implementations();
  346|    330|    std::vector<std::size_t> results;
  347|    330|    results.reserve(implementations.size());
  348|       |
  349|    990|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 990, False: 330]
  ------------------
  350|    990|      const auto len = invoke_lengthcalc(impl, src);
  351|    990|      results.push_back(len);
  352|    990|      ret.length.push_back(len);
  353|    990|    }
  354|       |
  355|    330|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    330|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 330]
  ------------------
  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|    330|    } else {
  375|    330|      ret.implementations_agree = true;
  376|    330|    }
  377|    330|    return ret;
  378|    330|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    990|                                FromSpan src) const {
  331|    990|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    990|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    660|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    330|                                  const bool inputisvalid) const {
  383|    330|    conversion_result ret{};
  384|       |
  385|    330|    const auto implementations = get_supported_implementations();
  386|       |
  387|    330|    std::vector<result<ConversionResult>> results;
  388|    330|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    330|    std::vector<std::vector<ToType>> outputbuffers;
  393|    330|    outputbuffers.reserve(implementations.size());
  394|  1.32k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 990, False: 330]
  ------------------
  395|    990|      auto impl = implementations[i];
  396|    990|      const ToType canary1{42};
  397|    990|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    990|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    990|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    990|      const auto success = [](const ConversionResult& r) -> bool {
  402|    990|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    990|          return r != 0;
  404|    990|        } else {
  405|    990|          return r.error == simdutf::error_code::SUCCESS;
  406|    990|        }
  407|    990|      }(implret1);
  408|    990|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    990|      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|    990|        const ToType canary2{25};
  414|    990|        const auto outputbuffer_first_run = outputbuffer;
  415|    990|        std::ranges::fill(outputbuffer, canary2);
  416|    990|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    990|                                          src.size(), outputbuffer.data());
  418|       |
  419|    990|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 990]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    990|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 273, False: 717]
  |  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|    990|      }
  441|    990|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 273, False: 717]
  ------------------
  442|    990|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    330|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 239, False: 91]
  ------------------
  447|    717|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 717, False: 239]
  ------------------
  448|    717|        e.outputhash.clear();
  449|    717|      }
  450|    239|    }
  451|       |
  452|    330|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    330|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 330]
  ------------------
  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|    330|    } else {
  474|    330|      ret.implementations_agree = true;
  475|    330|    }
  476|    330|    return ret;
  477|    330|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    990|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    990|        } else {
  405|    990|          return r.error == simdutf::error_code::SUCCESS;
  406|    990|        }
  407|    990|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    660|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_32clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    357|    +[](std::span<const char> chardata) {                                      \
  555|    357|      const auto c =                                                           \
  556|    357|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    357|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    357|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    357|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    357|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    357|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    357|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    357|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    357|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    357|  constexpr auto _size = _name.size();                                \
  |  | 1183|    357|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    357|  return _nameof; }()
  ------------------
  561|    357|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    357|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    357|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    357|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    357|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    357|  constexpr auto _size = _name.size();                                \
  |  | 1183|    357|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    357|  return _nameof; }()
  ------------------
  562|    357|      c.fuzz(chardata);                                                        \
  563|    357|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    357|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    357|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    357|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    357|    static const bool do_print_testcase =
  181|    357|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    357|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 357]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    357|    do {
  189|       |      // step 0 - is the input valid?
  190|    357|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    357|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 357]
  |  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|    357|      const auto [output_length, length_agree] =
  204|    357|          calculate_length(from, inputisvalid);
  205|    357|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 357]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    357|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 268, False: 89]
  |  Branch (208:28): [True: 0, False: 268]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    357|      const auto [written, outputs_agree] =
  215|    357|          do_conversion(from, output_length, inputisvalid);
  216|    357|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 357]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    357|      return;
  221|    357|    } 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|    357|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    357|  validation_result verify_valid_input(FromSpan src) const {
  231|    357|    validation_result ret{};
  232|       |
  233|    357|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    357|    const auto implementations = get_supported_implementations();
  235|    357|    std::vector<simdutf::result> results;
  236|    357|    results.reserve(implementations.size());
  237|       |
  238|  1.07k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.07k, False: 357]
  ------------------
  239|  1.07k|      results.push_back(
  240|  1.07k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.07k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.07k|      const bool validation2 =
  245|  1.07k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.07k|                      src.data(), src.size());
  247|  1.07k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.07k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  1.07k|    }
  258|       |
  259|    357|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    357|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 357]
  ------------------
  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|    357|    } else {
  273|    357|      ret.implementations_agree = true;
  274|    357|    }
  275|    357|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    357|      return r.error == simdutf::SUCCESS;
  277|    357|    });
  278|    357|    return ret;
  279|    357|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    714|    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|    535|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    535|      return r.error == simdutf::SUCCESS;
  277|    535|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    357|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    357|    length_result ret{};
  344|       |
  345|    357|    const auto implementations = get_supported_implementations();
  346|    357|    std::vector<std::size_t> results;
  347|    357|    results.reserve(implementations.size());
  348|       |
  349|  1.07k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.07k, False: 357]
  ------------------
  350|  1.07k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.07k|      results.push_back(len);
  352|  1.07k|      ret.length.push_back(len);
  353|  1.07k|    }
  354|       |
  355|    357|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    357|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 357]
  ------------------
  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|    357|    } else {
  375|    357|      ret.implementations_agree = true;
  376|    357|    }
  377|    357|    return ret;
  378|    357|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.07k|                                FromSpan src) const {
  331|  1.07k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.07k|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    714|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    357|                                  const bool inputisvalid) const {
  383|    357|    conversion_result ret{};
  384|       |
  385|    357|    const auto implementations = get_supported_implementations();
  386|       |
  387|    357|    std::vector<result<ConversionResult>> results;
  388|    357|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    357|    std::vector<std::vector<ToType>> outputbuffers;
  393|    357|    outputbuffers.reserve(implementations.size());
  394|  1.42k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.07k, False: 357]
  ------------------
  395|  1.07k|      auto impl = implementations[i];
  396|  1.07k|      const ToType canary1{42};
  397|  1.07k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.07k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.07k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.07k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.07k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.07k|          return r != 0;
  404|  1.07k|        } else {
  405|  1.07k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.07k|        }
  407|  1.07k|      }(implret1);
  408|  1.07k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.07k|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|  1.07k|        const ToType canary2{25};
  414|  1.07k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.07k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.07k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.07k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.07k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.07k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.07k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 267, False: 804]
  |  Branch (423:29): [True: 267, False: 0]
  ------------------
  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|  1.07k|      }
  441|  1.07k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 267, False: 804]
  ------------------
  442|  1.07k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    357|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 268, False: 89]
  ------------------
  447|    804|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 804, False: 268]
  ------------------
  448|    804|        e.outputhash.clear();
  449|    804|      }
  450|    268|    }
  451|       |
  452|    357|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    357|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 357]
  ------------------
  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|    357|    } else {
  474|    357|      ret.implementations_agree = true;
  475|    357|    }
  476|    357|    return ret;
  477|    357|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|  1.07k|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|  1.07k|        } else {
  405|  1.07k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.07k|        }
  407|  1.07k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    714|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_33clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    462|    +[](std::span<const char> chardata) {                                      \
  555|    462|      const auto c =                                                           \
  556|    462|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    462|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    462|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    462|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    462|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    462|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    462|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    462|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    462|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    462|  constexpr auto _size = _name.size();                                \
  |  | 1183|    462|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    462|  return _nameof; }()
  ------------------
  561|    462|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    462|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    462|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    462|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    462|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    462|  constexpr auto _size = _name.size();                                \
  |  | 1183|    462|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    462|  return _nameof; }()
  ------------------
  562|    462|      c.fuzz(chardata);                                                        \
  563|    462|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    462|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    462|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    462|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    462|    static const bool do_print_testcase =
  181|    462|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    462|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 462]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    462|    do {
  189|       |      // step 0 - is the input valid?
  190|    462|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    462|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 462]
  |  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|    462|      const auto [output_length, length_agree] =
  204|    462|          calculate_length(from, inputisvalid);
  205|    462|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 462]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    462|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 345, False: 117]
  |  Branch (208:28): [True: 0, False: 345]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    462|      const auto [written, outputs_agree] =
  215|    462|          do_conversion(from, output_length, inputisvalid);
  216|    462|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 462]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    462|      return;
  221|    462|    } 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|    462|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    462|  validation_result verify_valid_input(FromSpan src) const {
  231|    462|    validation_result ret{};
  232|       |
  233|    462|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    462|    const auto implementations = get_supported_implementations();
  235|    462|    std::vector<simdutf::result> results;
  236|    462|    results.reserve(implementations.size());
  237|       |
  238|  1.38k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.38k, False: 462]
  ------------------
  239|  1.38k|      results.push_back(
  240|  1.38k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.38k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.38k|      const bool validation2 =
  245|  1.38k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.38k|                      src.data(), src.size());
  247|  1.38k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.38k]
  ------------------
  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.38k|    }
  258|       |
  259|    462|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    462|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 462]
  ------------------
  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|    462|    } else {
  273|    462|      ret.implementations_agree = true;
  274|    462|    }
  275|    462|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    462|      return r.error == simdutf::SUCCESS;
  277|    462|    });
  278|    462|    return ret;
  279|    462|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    924|    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|    696|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    696|      return r.error == simdutf::SUCCESS;
  277|    696|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    462|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    462|    length_result ret{};
  344|       |
  345|    462|    const auto implementations = get_supported_implementations();
  346|    462|    std::vector<std::size_t> results;
  347|    462|    results.reserve(implementations.size());
  348|       |
  349|  1.38k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.38k, False: 462]
  ------------------
  350|  1.38k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.38k|      results.push_back(len);
  352|  1.38k|      ret.length.push_back(len);
  353|  1.38k|    }
  354|       |
  355|    462|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    462|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 462]
  ------------------
  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|    462|    } else {
  375|    462|      ret.implementations_agree = true;
  376|    462|    }
  377|    462|    return ret;
  378|    462|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.38k|                                FromSpan src) const {
  331|  1.38k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.38k|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    924|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    462|                                  const bool inputisvalid) const {
  383|    462|    conversion_result ret{};
  384|       |
  385|    462|    const auto implementations = get_supported_implementations();
  386|       |
  387|    462|    std::vector<result<ConversionResult>> results;
  388|    462|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    462|    std::vector<std::vector<ToType>> outputbuffers;
  393|    462|    outputbuffers.reserve(implementations.size());
  394|  1.84k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.38k, False: 462]
  ------------------
  395|  1.38k|      auto impl = implementations[i];
  396|  1.38k|      const ToType canary1{42};
  397|  1.38k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.38k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.38k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.38k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.38k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.38k|          return r != 0;
  404|  1.38k|        } else {
  405|  1.38k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.38k|        }
  407|  1.38k|      }(implret1);
  408|  1.38k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.38k|      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.38k|        const ToType canary2{25};
  414|  1.38k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.38k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.38k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.38k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.38k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.38k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.38k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 351, False: 1.03k]
  |  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.38k|      }
  441|  1.38k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 351, False: 1.03k]
  ------------------
  442|  1.38k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    462|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 345, False: 117]
  ------------------
  447|  1.03k|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 1.03k, False: 345]
  ------------------
  448|  1.03k|        e.outputhash.clear();
  449|  1.03k|      }
  450|    345|    }
  451|       |
  452|    462|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    462|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 462]
  ------------------
  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|    462|    } else {
  474|    462|      ret.implementations_agree = true;
  475|    462|    }
  476|    462|    return ret;
  477|    462|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|  1.38k|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|  1.38k|        } else {
  405|  1.38k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.38k|        }
  407|  1.38k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    924|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_34clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    261|    +[](std::span<const char> chardata) {                                      \
  555|    261|      const auto c =                                                           \
  556|    261|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    261|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    261|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    261|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    261|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    261|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    261|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    261|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    261|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    261|  constexpr auto _size = _name.size();                                \
  |  | 1183|    261|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    261|  return _nameof; }()
  ------------------
  561|    261|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    261|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    261|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    261|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    261|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    261|  constexpr auto _size = _name.size();                                \
  |  | 1183|    261|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    261|  return _nameof; }()
  ------------------
  562|    261|      c.fuzz(chardata);                                                        \
  563|    261|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    261|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    261|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    261|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    261|    static const bool do_print_testcase =
  181|    261|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    261|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 261]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    261|    do {
  189|       |      // step 0 - is the input valid?
  190|    261|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    261|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 261]
  |  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|    261|                    From == UtfEncodings::UTF8) {
  198|    261|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 261]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    261|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    261|      const auto [output_length, length_agree] =
  204|    261|          calculate_length(from, inputisvalid);
  205|    261|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 261]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    261|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 148, False: 113]
  |  Branch (208:28): [True: 0, False: 148]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    261|      const auto [written, outputs_agree] =
  215|    261|          do_conversion(from, output_length, inputisvalid);
  216|    261|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 261]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    261|      return;
  221|    261|    } 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|    261|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    261|  validation_result verify_valid_input(FromSpan src) const {
  231|    261|    validation_result ret{};
  232|       |
  233|    261|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    261|    const auto implementations = get_supported_implementations();
  235|    261|    std::vector<simdutf::result> results;
  236|    261|    results.reserve(implementations.size());
  237|       |
  238|    783|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 783, False: 261]
  ------------------
  239|    783|      results.push_back(
  240|    783|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    783|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    783|      const bool validation2 =
  245|    783|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    783|                      src.data(), src.size());
  247|    783|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 783]
  ------------------
  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|    783|    }
  258|       |
  259|    261|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    261|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 261]
  ------------------
  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|    261|    } else {
  273|    261|      ret.implementations_agree = true;
  274|    261|    }
  275|    261|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    261|      return r.error == simdutf::SUCCESS;
  277|    261|    });
  278|    261|    return ret;
  279|    261|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    522|    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|    487|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    487|      return r.error == simdutf::SUCCESS;
  277|    487|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    261|  bool count_the_input(FromSpan src) const {
  290|    261|    const auto implementations = get_supported_implementations();
  291|    261|    std::vector<std::size_t> results;
  292|    261|    results.reserve(implementations.size());
  293|       |
  294|    783|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 783, False: 261]
  ------------------
  295|    783|      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|    783|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|    783|        ret = impl->count_utf8(src.data(), src.size());
  302|    783|      }
  303|    783|      results.push_back(ret);
  304|    783|    }
  305|    261|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    261|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 261]
  ------------------
  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|    261|    return true;
  321|    261|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    522|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    261|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    261|    length_result ret{};
  344|       |
  345|    261|    const auto implementations = get_supported_implementations();
  346|    261|    std::vector<std::size_t> results;
  347|    261|    results.reserve(implementations.size());
  348|       |
  349|    783|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 783, False: 261]
  ------------------
  350|    783|      const auto len = invoke_lengthcalc(impl, src);
  351|    783|      results.push_back(len);
  352|    783|      ret.length.push_back(len);
  353|    783|    }
  354|       |
  355|    261|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    261|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 261]
  ------------------
  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|    261|    } else {
  375|    261|      ret.implementations_agree = true;
  376|    261|    }
  377|    261|    return ret;
  378|    261|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    783|                                FromSpan src) const {
  331|    783|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    783|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    522|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    261|                                  const bool inputisvalid) const {
  383|    261|    conversion_result ret{};
  384|       |
  385|    261|    const auto implementations = get_supported_implementations();
  386|       |
  387|    261|    std::vector<result<ConversionResult>> results;
  388|    261|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    261|    std::vector<std::vector<ToType>> outputbuffers;
  393|    261|    outputbuffers.reserve(implementations.size());
  394|  1.04k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 783, False: 261]
  ------------------
  395|    783|      auto impl = implementations[i];
  396|    783|      const ToType canary1{42};
  397|    783|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    783|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    783|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    783|      const auto success = [](const ConversionResult& r) -> bool {
  402|    783|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    783|          return r != 0;
  404|    783|        } else {
  405|    783|          return r.error == simdutf::error_code::SUCCESS;
  406|    783|        }
  407|    783|      }(implret1);
  408|    783|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    783|      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|    783|        const ToType canary2{25};
  414|    783|        const auto outputbuffer_first_run = outputbuffer;
  415|    783|        std::ranges::fill(outputbuffer, canary2);
  416|    783|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    783|                                          src.size(), outputbuffer.data());
  418|       |
  419|    783|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 783]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    783|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 339, False: 444]
  |  Branch (423:29): [True: 315, False: 24]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    315|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    315|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 315]
  ------------------
  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|    315|        }
  440|    783|      }
  441|    783|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 315, False: 468]
  ------------------
  442|    783|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    261|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 148, False: 113]
  ------------------
  447|    444|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 444, False: 148]
  ------------------
  448|    444|        e.outputhash.clear();
  449|    444|      }
  450|    148|    }
  451|       |
  452|    261|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    261|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 261]
  ------------------
  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|    261|    } else {
  474|    261|      ret.implementations_agree = true;
  475|    261|    }
  476|    261|    return ret;
  477|    261|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    783|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    783|        } else {
  405|    783|          return r.error == simdutf::error_code::SUCCESS;
  406|    783|        }
  407|    783|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    522|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_35clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    386|    +[](std::span<const char> chardata) {                                      \
  555|    386|      const auto c =                                                           \
  556|    386|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    386|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    386|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    386|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    386|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    386|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    386|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    386|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    386|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    386|  constexpr auto _size = _name.size();                                \
  |  | 1183|    386|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    386|  return _nameof; }()
  ------------------
  561|    386|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    386|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    386|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    386|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    386|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    386|  constexpr auto _size = _name.size();                                \
  |  | 1183|    386|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    386|  return _nameof; }()
  ------------------
  562|    386|      c.fuzz(chardata);                                                        \
  563|    386|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    386|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    386|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    386|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    386|    static const bool do_print_testcase =
  181|    386|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    386|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 386]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    386|    do {
  189|       |      // step 0 - is the input valid?
  190|    386|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    386|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 386]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    386|                    From == UtfEncodings::UTF8) {
  198|    386|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 386]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    386|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    386|      const auto [output_length, length_agree] =
  204|    386|          calculate_length(from, inputisvalid);
  205|    386|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 386]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    386|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 211, False: 175]
  |  Branch (208:28): [True: 0, False: 211]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    386|      const auto [written, outputs_agree] =
  215|    386|          do_conversion(from, output_length, inputisvalid);
  216|    386|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 386]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    386|      return;
  221|    386|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    386|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    386|  validation_result verify_valid_input(FromSpan src) const {
  231|    386|    validation_result ret{};
  232|       |
  233|    386|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    386|    const auto implementations = get_supported_implementations();
  235|    386|    std::vector<simdutf::result> results;
  236|    386|    results.reserve(implementations.size());
  237|       |
  238|  1.15k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.15k, False: 386]
  ------------------
  239|  1.15k|      results.push_back(
  240|  1.15k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.15k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.15k|      const bool validation2 =
  245|  1.15k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.15k|                      src.data(), src.size());
  247|  1.15k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.15k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  1.15k|    }
  258|       |
  259|    386|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    386|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 386]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    386|    } else {
  273|    386|      ret.implementations_agree = true;
  274|    386|    }
  275|    386|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    386|      return r.error == simdutf::SUCCESS;
  277|    386|    });
  278|    386|    return ret;
  279|    386|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    772|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKS7_E_clESI_:
  275|    736|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    736|      return r.error == simdutf::SUCCESS;
  277|    736|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    386|  bool count_the_input(FromSpan src) const {
  290|    386|    const auto implementations = get_supported_implementations();
  291|    386|    std::vector<std::size_t> results;
  292|    386|    results.reserve(implementations.size());
  293|       |
  294|  1.15k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.15k, False: 386]
  ------------------
  295|  1.15k|      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.15k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.15k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.15k|      }
  303|  1.15k|      results.push_back(ret);
  304|  1.15k|    }
  305|    386|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    386|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 386]
  ------------------
  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|    386|    return true;
  321|    386|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    772|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    386|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    386|    length_result ret{};
  344|       |
  345|    386|    const auto implementations = get_supported_implementations();
  346|    386|    std::vector<std::size_t> results;
  347|    386|    results.reserve(implementations.size());
  348|       |
  349|  1.15k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.15k, False: 386]
  ------------------
  350|  1.15k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.15k|      results.push_back(len);
  352|  1.15k|      ret.length.push_back(len);
  353|  1.15k|    }
  354|       |
  355|    386|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    386|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 386]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    386|    } else {
  375|    386|      ret.implementations_agree = true;
  376|    386|    }
  377|    386|    return ret;
  378|    386|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.15k|                                FromSpan src) const {
  331|  1.15k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.15k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    772|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    386|                                  const bool inputisvalid) const {
  383|    386|    conversion_result ret{};
  384|       |
  385|    386|    const auto implementations = get_supported_implementations();
  386|       |
  387|    386|    std::vector<result<ConversionResult>> results;
  388|    386|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    386|    std::vector<std::vector<ToType>> outputbuffers;
  393|    386|    outputbuffers.reserve(implementations.size());
  394|  1.54k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.15k, False: 386]
  ------------------
  395|  1.15k|      auto impl = implementations[i];
  396|  1.15k|      const ToType canary1{42};
  397|  1.15k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.15k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.15k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.15k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.15k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.15k|          return r != 0;
  404|  1.15k|        } else {
  405|  1.15k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.15k|        }
  407|  1.15k|      }(implret1);
  408|  1.15k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.15k|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|  1.15k|        const ToType canary2{25};
  414|  1.15k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.15k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.15k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.15k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.15k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.15k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.15k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 525, False: 633]
  |  Branch (423:29): [True: 525, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    525|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    525|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 525]
  ------------------
  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|    525|        }
  440|  1.15k|      }
  441|  1.15k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 525, False: 633]
  ------------------
  442|  1.15k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    386|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 211, False: 175]
  ------------------
  447|    633|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 633, False: 211]
  ------------------
  448|    633|        e.outputhash.clear();
  449|    633|      }
  450|    211|    }
  451|       |
  452|    386|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    386|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 386]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    386|    } else {
  474|    386|      ret.implementations_agree = true;
  475|    386|    }
  476|    386|    return ret;
  477|    386|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|  1.15k|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|  1.15k|        } else {
  405|  1.15k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.15k|        }
  407|  1.15k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    772|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_36clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    297|    +[](std::span<const char> chardata) {                                      \
  555|    297|      const auto c =                                                           \
  556|    297|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    297|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    297|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    297|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    297|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    297|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    297|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    297|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    297|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    297|  constexpr auto _size = _name.size();                                \
  |  | 1183|    297|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    297|  return _nameof; }()
  ------------------
  561|    297|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    297|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    297|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    297|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    297|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    297|  constexpr auto _size = _name.size();                                \
  |  | 1183|    297|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    297|  return _nameof; }()
  ------------------
  562|    297|      c.fuzz(chardata);                                                        \
  563|    297|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    297|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    297|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    297|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    297|    static const bool do_print_testcase =
  181|    297|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    297|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 297]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    297|    do {
  189|       |      // step 0 - is the input valid?
  190|    297|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    297|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 297]
  |  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|    297|                    From == UtfEncodings::UTF8) {
  198|    297|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 297]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    297|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    297|      const auto [output_length, length_agree] =
  204|    297|          calculate_length(from, inputisvalid);
  205|    297|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 297]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    297|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 170, False: 127]
  |  Branch (208:28): [True: 0, False: 170]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    297|      const auto [written, outputs_agree] =
  215|    297|          do_conversion(from, output_length, inputisvalid);
  216|    297|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 297]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    297|      return;
  221|    297|    } 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|    297|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    297|  validation_result verify_valid_input(FromSpan src) const {
  231|    297|    validation_result ret{};
  232|       |
  233|    297|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    297|    const auto implementations = get_supported_implementations();
  235|    297|    std::vector<simdutf::result> results;
  236|    297|    results.reserve(implementations.size());
  237|       |
  238|    891|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 891, False: 297]
  ------------------
  239|    891|      results.push_back(
  240|    891|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    891|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    891|      const bool validation2 =
  245|    891|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    891|                      src.data(), src.size());
  247|    891|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 891]
  ------------------
  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|    891|    }
  258|       |
  259|    297|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    297|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 297]
  ------------------
  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|    297|    } else {
  273|    297|      ret.implementations_agree = true;
  274|    297|    }
  275|    297|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    297|      return r.error == simdutf::SUCCESS;
  277|    297|    });
  278|    297|    return ret;
  279|    297|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    594|    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|    551|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    551|      return r.error == simdutf::SUCCESS;
  277|    551|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    297|  bool count_the_input(FromSpan src) const {
  290|    297|    const auto implementations = get_supported_implementations();
  291|    297|    std::vector<std::size_t> results;
  292|    297|    results.reserve(implementations.size());
  293|       |
  294|    891|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 891, False: 297]
  ------------------
  295|    891|      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|    891|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|    891|        ret = impl->count_utf8(src.data(), src.size());
  302|    891|      }
  303|    891|      results.push_back(ret);
  304|    891|    }
  305|    297|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    297|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 297]
  ------------------
  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|    297|    return true;
  321|    297|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    594|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    297|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    297|    length_result ret{};
  344|       |
  345|    297|    const auto implementations = get_supported_implementations();
  346|    297|    std::vector<std::size_t> results;
  347|    297|    results.reserve(implementations.size());
  348|       |
  349|    891|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 891, False: 297]
  ------------------
  350|    891|      const auto len = invoke_lengthcalc(impl, src);
  351|    891|      results.push_back(len);
  352|    891|      ret.length.push_back(len);
  353|    891|    }
  354|       |
  355|    297|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    297|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 297]
  ------------------
  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|    297|    } else {
  375|    297|      ret.implementations_agree = true;
  376|    297|    }
  377|    297|    return ret;
  378|    297|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    891|                                FromSpan src) const {
  331|    891|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    891|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    594|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    297|                                  const bool inputisvalid) const {
  383|    297|    conversion_result ret{};
  384|       |
  385|    297|    const auto implementations = get_supported_implementations();
  386|       |
  387|    297|    std::vector<result<ConversionResult>> results;
  388|    297|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    297|    std::vector<std::vector<ToType>> outputbuffers;
  393|    297|    outputbuffers.reserve(implementations.size());
  394|  1.18k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 891, False: 297]
  ------------------
  395|    891|      auto impl = implementations[i];
  396|    891|      const ToType canary1{42};
  397|    891|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    891|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    891|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    891|      const auto success = [](const ConversionResult& r) -> bool {
  402|    891|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    891|          return r != 0;
  404|    891|        } else {
  405|    891|          return r.error == simdutf::error_code::SUCCESS;
  406|    891|        }
  407|    891|      }(implret1);
  408|    891|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    891|      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|    891|        const ToType canary2{25};
  414|    891|        const auto outputbuffer_first_run = outputbuffer;
  415|    891|        std::ranges::fill(outputbuffer, canary2);
  416|    891|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    891|                                          src.size(), outputbuffer.data());
  418|       |
  419|    891|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 891]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    891|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 381, False: 510]
  |  Branch (423:29): [True: 381, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    381|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    381|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 381]
  ------------------
  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|    381|        }
  440|    891|      }
  441|    891|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 381, False: 510]
  ------------------
  442|    891|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    297|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 170, False: 127]
  ------------------
  447|    510|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 510, False: 170]
  ------------------
  448|    510|        e.outputhash.clear();
  449|    510|      }
  450|    170|    }
  451|       |
  452|    297|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    297|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 297]
  ------------------
  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|    297|    } else {
  474|    297|      ret.implementations_agree = true;
  475|    297|    }
  476|    297|    return ret;
  477|    297|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    891|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    891|        } else {
  405|    891|          return r.error == simdutf::error_code::SUCCESS;
  406|    891|        }
  407|    891|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    594|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_37clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    395|    +[](std::span<const char> chardata) {                                      \
  555|    395|      const auto c =                                                           \
  556|    395|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    395|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    395|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    395|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    395|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    395|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    395|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    395|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    395|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    395|  constexpr auto _size = _name.size();                                \
  |  | 1183|    395|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    395|  return _nameof; }()
  ------------------
  561|    395|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    395|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    395|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    395|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    395|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    395|  constexpr auto _size = _name.size();                                \
  |  | 1183|    395|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    395|  return _nameof; }()
  ------------------
  562|    395|      c.fuzz(chardata);                                                        \
  563|    395|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    395|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    395|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    395|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    395|    static const bool do_print_testcase =
  181|    395|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    395|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 395]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    395|    do {
  189|       |      // step 0 - is the input valid?
  190|    395|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    395|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 395]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    395|                    From == UtfEncodings::UTF8) {
  198|    395|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 395]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    395|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    395|      const auto [output_length, length_agree] =
  204|    395|          calculate_length(from, inputisvalid);
  205|    395|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 395]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    395|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 222, False: 173]
  |  Branch (208:28): [True: 0, False: 222]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    395|      const auto [written, outputs_agree] =
  215|    395|          do_conversion(from, output_length, inputisvalid);
  216|    395|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 395]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    395|      return;
  221|    395|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    395|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    395|  validation_result verify_valid_input(FromSpan src) const {
  231|    395|    validation_result ret{};
  232|       |
  233|    395|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    395|    const auto implementations = get_supported_implementations();
  235|    395|    std::vector<simdutf::result> results;
  236|    395|    results.reserve(implementations.size());
  237|       |
  238|  1.18k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.18k, False: 395]
  ------------------
  239|  1.18k|      results.push_back(
  240|  1.18k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.18k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.18k|      const bool validation2 =
  245|  1.18k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.18k|                      src.data(), src.size());
  247|  1.18k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.18k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  1.18k|    }
  258|       |
  259|    395|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    395|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 395]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    395|    } else {
  273|    395|      ret.implementations_agree = true;
  274|    395|    }
  275|    395|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    395|      return r.error == simdutf::SUCCESS;
  277|    395|    });
  278|    395|    return ret;
  279|    395|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    790|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKS7_E_clESI_:
  275|    741|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    741|      return r.error == simdutf::SUCCESS;
  277|    741|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    395|  bool count_the_input(FromSpan src) const {
  290|    395|    const auto implementations = get_supported_implementations();
  291|    395|    std::vector<std::size_t> results;
  292|    395|    results.reserve(implementations.size());
  293|       |
  294|  1.18k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.18k, False: 395]
  ------------------
  295|  1.18k|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|       |      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|       |        ret = impl->count_utf16le(src.data(), src.size());
  300|  1.18k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.18k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.18k|      }
  303|  1.18k|      results.push_back(ret);
  304|  1.18k|    }
  305|    395|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    395|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 395]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    395|    return true;
  321|    395|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    790|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    395|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    395|    length_result ret{};
  344|       |
  345|    395|    const auto implementations = get_supported_implementations();
  346|    395|    std::vector<std::size_t> results;
  347|    395|    results.reserve(implementations.size());
  348|       |
  349|  1.18k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.18k, False: 395]
  ------------------
  350|  1.18k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.18k|      results.push_back(len);
  352|  1.18k|      ret.length.push_back(len);
  353|  1.18k|    }
  354|       |
  355|    395|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    395|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 395]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    395|    } else {
  375|    395|      ret.implementations_agree = true;
  376|    395|    }
  377|    395|    return ret;
  378|    395|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.18k|                                FromSpan src) const {
  331|  1.18k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.18k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    790|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    395|                                  const bool inputisvalid) const {
  383|    395|    conversion_result ret{};
  384|       |
  385|    395|    const auto implementations = get_supported_implementations();
  386|       |
  387|    395|    std::vector<result<ConversionResult>> results;
  388|    395|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    395|    std::vector<std::vector<ToType>> outputbuffers;
  393|    395|    outputbuffers.reserve(implementations.size());
  394|  1.58k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.18k, False: 395]
  ------------------
  395|  1.18k|      auto impl = implementations[i];
  396|  1.18k|      const ToType canary1{42};
  397|  1.18k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.18k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.18k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.18k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.18k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.18k|          return r != 0;
  404|  1.18k|        } else {
  405|  1.18k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.18k|        }
  407|  1.18k|      }(implret1);
  408|  1.18k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.18k|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|  1.18k|        const ToType canary2{25};
  414|  1.18k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.18k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.18k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.18k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.18k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.18k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.18k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 519, False: 666]
  |  Branch (423:29): [True: 519, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    519|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    519|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 519]
  ------------------
  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|    519|        }
  440|  1.18k|      }
  441|  1.18k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 519, False: 666]
  ------------------
  442|  1.18k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    395|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 222, False: 173]
  ------------------
  447|    666|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 666, False: 222]
  ------------------
  448|    666|        e.outputhash.clear();
  449|    666|      }
  450|    222|    }
  451|       |
  452|    395|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    395|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 395]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    395|    } else {
  474|    395|      ret.implementations_agree = true;
  475|    395|    }
  476|    395|    return ret;
  477|    395|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|  1.18k|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|  1.18k|        } else {
  405|  1.18k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.18k|        }
  407|  1.18k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    790|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_38clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     50|    +[](std::span<const char> chardata) {                                      \
  555|     50|      const auto c =                                                           \
  556|     50|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     50|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     50|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     50|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     50|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     50|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     50|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     50|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     50|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     50|  constexpr auto _size = _name.size();                                \
  |  | 1183|     50|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     50|  return _nameof; }()
  ------------------
  561|     50|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     50|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     50|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     50|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     50|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     50|  constexpr auto _size = _name.size();                                \
  |  | 1183|     50|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     50|  return _nameof; }()
  ------------------
  562|     50|      c.fuzz(chardata);                                                        \
  563|     50|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE4fuzzENSt3__14spanIS5_Lm18446744073709551615EEE:
  175|     50|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     50|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     50|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     50|    static const bool do_print_testcase =
  181|     50|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     50|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 50]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     50|    do {
  189|       |      // step 0 - is the input valid?
  190|     50|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     50|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 50]
  |  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|     50|      const auto [output_length, length_agree] =
  204|     50|          calculate_length(from, inputisvalid);
  205|     50|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 50]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     50|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 0, False: 50]
  |  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|     50|      const auto [written, outputs_agree] =
  215|     50|          do_conversion(from, output_length, inputisvalid);
  216|     50|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 50]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     50|      return;
  221|     50|    } 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|     50|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE18verify_valid_inputIvQeqT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  283|     50|  validation_result verify_valid_input(FromSpan) const {
  284|       |    // all latin1 input is valid. there is no simdutf validation function for
  285|       |    // it.
  286|     50|    return validation_result{.valid = true, .implementations_agree = true};
  287|     50|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     50|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     50|    length_result ret{};
  344|       |
  345|     50|    const auto implementations = get_supported_implementations();
  346|     50|    std::vector<std::size_t> results;
  347|     50|    results.reserve(implementations.size());
  348|       |
  349|    150|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 150, False: 50]
  ------------------
  350|    150|      const auto len = invoke_lengthcalc(impl, src);
  351|    150|      results.push_back(len);
  352|    150|      ret.length.push_back(len);
  353|    150|    }
  354|       |
  355|     50|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     50|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 50]
  ------------------
  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|     50|    } else {
  375|     50|      ret.implementations_agree = true;
  376|     50|    }
  377|     50|    return ret;
  378|     50|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    150|                                FromSpan src) const {
  339|    150|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    150|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    100|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     50|                                  const bool inputisvalid) const {
  383|     50|    conversion_result ret{};
  384|       |
  385|     50|    const auto implementations = get_supported_implementations();
  386|       |
  387|     50|    std::vector<result<ConversionResult>> results;
  388|     50|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     50|    std::vector<std::vector<ToType>> outputbuffers;
  393|     50|    outputbuffers.reserve(implementations.size());
  394|    200|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 150, False: 50]
  ------------------
  395|    150|      auto impl = implementations[i];
  396|    150|      const ToType canary1{42};
  397|    150|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    150|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    150|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    150|      const auto success = [](const ConversionResult& r) -> bool {
  402|    150|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    150|          return r != 0;
  404|    150|        } else {
  405|    150|          return r.error == simdutf::error_code::SUCCESS;
  406|    150|        }
  407|    150|      }(implret1);
  408|    150|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    150|      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|    150|        const ToType canary2{25};
  414|    150|        const auto outputbuffer_first_run = outputbuffer;
  415|    150|        std::ranges::fill(outputbuffer, canary2);
  416|    150|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    150|                                          src.size(), outputbuffer.data());
  418|       |
  419|    150|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 150]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    150|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 150, False: 0]
  |  Branch (423:29): [True: 144, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    144|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    144|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 144]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    144|        }
  440|    150|      }
  441|    150|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 144, False: 6]
  ------------------
  442|    150|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     50|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 0, False: 50]
  ------------------
  447|      0|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 0, False: 0]
  ------------------
  448|      0|        e.outputhash.clear();
  449|      0|      }
  450|      0|    }
  451|       |
  452|     50|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     50|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 50]
  ------------------
  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|     50|    } else {
  474|     50|      ret.implementations_agree = true;
  475|     50|    }
  476|     50|    return ret;
  477|     50|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    150|      const auto success = [](const ConversionResult& r) -> bool {
  402|    150|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    150|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    150|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    100|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_39clENSt3__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_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE4fuzzENSt3__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_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE18verify_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_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE16calculate_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_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE17invoke_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_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    110|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_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_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_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_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_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$_40clENSt3__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_1EMN7simdutf14implementationEKDoFmmEMS2_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_1EMN7simdutf14implementationEKDoFmmEMS2_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_1EMN7simdutf14implementationEKDoFmmEMS2_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_1EMN7simdutf14implementationEKDoFmmEMS2_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_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|     88|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_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_1EMN7simdutf14implementationEKDoFmmEMS2_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_1EMN7simdutf14implementationEKDoFmmEMS2_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$_41clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    242|    +[](std::span<const char> chardata) {                                      \
  555|    242|      const auto c =                                                           \
  556|    242|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    242|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    242|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    242|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    242|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    242|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    242|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    242|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    242|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    242|  constexpr auto _size = _name.size();                                \
  |  | 1183|    242|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    242|  return _nameof; }()
  ------------------
  561|    242|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    242|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    242|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    242|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    242|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    242|  constexpr auto _size = _name.size();                                \
  |  | 1183|    242|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    242|  return _nameof; }()
  ------------------
  562|    242|      c.fuzz(chardata);                                                        \
  563|    242|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    242|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    242|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    242|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    242|    static const bool do_print_testcase =
  181|    242|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    242|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 242]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    242|    do {
  189|       |      // step 0 - is the input valid?
  190|    242|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    242|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 242]
  |  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|    242|      const auto [output_length, length_agree] =
  204|    242|          calculate_length(from, inputisvalid);
  205|    242|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 242]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    242|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 0, False: 242]
  |  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|    242|      const auto [written, outputs_agree] =
  215|    242|          do_conversion(from, output_length, inputisvalid);
  216|    242|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 242]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    242|      return;
  221|    242|    } 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|    242|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQeqT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  283|    242|  validation_result verify_valid_input(FromSpan) const {
  284|       |    // all latin1 input is valid. there is no simdutf validation function for
  285|       |    // it.
  286|    242|    return validation_result{.valid = true, .implementations_agree = true};
  287|    242|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    242|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    242|    length_result ret{};
  344|       |
  345|    242|    const auto implementations = get_supported_implementations();
  346|    242|    std::vector<std::size_t> results;
  347|    242|    results.reserve(implementations.size());
  348|       |
  349|    726|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 726, False: 242]
  ------------------
  350|    726|      const auto len = invoke_lengthcalc(impl, src);
  351|    726|      results.push_back(len);
  352|    726|      ret.length.push_back(len);
  353|    726|    }
  354|       |
  355|    242|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    242|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 242]
  ------------------
  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|    242|    } else {
  375|    242|      ret.implementations_agree = true;
  376|    242|    }
  377|    242|    return ret;
  378|    242|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    726|                                FromSpan src) const {
  331|    726|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    726|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    484|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    242|                                  const bool inputisvalid) const {
  383|    242|    conversion_result ret{};
  384|       |
  385|    242|    const auto implementations = get_supported_implementations();
  386|       |
  387|    242|    std::vector<result<ConversionResult>> results;
  388|    242|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    242|    std::vector<std::vector<ToType>> outputbuffers;
  393|    242|    outputbuffers.reserve(implementations.size());
  394|    968|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 726, False: 242]
  ------------------
  395|    726|      auto impl = implementations[i];
  396|    726|      const ToType canary1{42};
  397|    726|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    726|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    726|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    726|      const auto success = [](const ConversionResult& r) -> bool {
  402|    726|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    726|          return r != 0;
  404|    726|        } else {
  405|    726|          return r.error == simdutf::error_code::SUCCESS;
  406|    726|        }
  407|    726|      }(implret1);
  408|    726|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    726|      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|    726|        const ToType canary2{25};
  414|    726|        const auto outputbuffer_first_run = outputbuffer;
  415|    726|        std::ranges::fill(outputbuffer, canary2);
  416|    726|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    726|                                          src.size(), outputbuffer.data());
  418|       |
  419|    726|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 726]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    726|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 726, False: 0]
  |  Branch (423:29): [True: 720, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    720|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    720|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 720]
  ------------------
  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|    720|        }
  440|    726|      }
  441|    726|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 720, False: 6]
  ------------------
  442|    726|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    242|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 0, False: 242]
  ------------------
  447|      0|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 0, False: 0]
  ------------------
  448|      0|        e.outputhash.clear();
  449|      0|      }
  450|      0|    }
  451|       |
  452|    242|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    242|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 242]
  ------------------
  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|    242|    } else {
  474|    242|      ret.implementations_agree = true;
  475|    242|    }
  476|    242|    return ret;
  477|    242|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    726|      const auto success = [](const ConversionResult& r) -> bool {
  402|    726|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    726|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    726|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    484|    auto neq = [](const auto& a, const auto& b) { return a != b; };

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

_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.10k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt25EE4dataEv:
  233|  1.10k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt25EE4sizeEv:
  235|  1.10k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_0clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     96|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     96|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     96|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     96|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     96|  constexpr auto _size = _name.size();                                \
 1183|     96|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     96|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_0clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     96|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     96|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     96|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     96|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     96|  constexpr auto _size = _name.size();                                \
 1183|     96|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     96|  return _nameof; }()
_ZNK6nameof7cstringILt30EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    358|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt30EE4dataEv:
  233|    358|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt30EE4sizeEv:
  235|    358|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_1clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    224|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    224|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    224|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    224|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    224|  constexpr auto _size = _name.size();                                \
 1183|    224|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    224|  return _nameof; }()
_ZNK6nameof7cstringILt24EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  3.09k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt24EE4dataEv:
  233|  3.09k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt24EE4sizeEv:
  235|  3.09k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_1clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    224|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    224|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    224|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    224|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    224|  constexpr auto _size = _name.size();                                \
 1183|    224|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    224|  return _nameof; }()
_ZNK6nameof7cstringILt29EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    900|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt29EE4dataEv:
  233|    900|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt29EE4sizeEv:
  235|    900|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_2clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     65|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     65|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     65|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     65|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     65|  constexpr auto _size = _name.size();                                \
 1183|     65|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     65|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_2clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     65|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     65|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     65|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     65|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     65|  constexpr auto _size = _name.size();                                \
 1183|     65|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     65|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_3clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    205|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    205|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    205|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    205|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    205|  constexpr auto _size = _name.size();                                \
 1183|    205|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    205|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_3clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    205|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    205|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    205|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    205|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    205|  constexpr auto _size = _name.size();                                \
 1183|    205|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    205|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_4clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     61|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     61|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     61|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     61|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     61|  constexpr auto _size = _name.size();                                \
 1183|     61|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     61|  return _nameof; }()
_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|     61|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     61|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     61|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     61|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     61|  constexpr auto _size = _name.size();                                \
 1183|     61|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     61|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_5clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    136|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    136|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    136|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    136|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    136|  constexpr auto _size = _name.size();                                \
 1183|    136|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    136|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_5clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    136|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    136|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    136|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    136|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    136|  constexpr auto _size = _name.size();                                \
 1183|    136|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    136|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_6clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    100|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    100|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    100|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    100|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    100|  constexpr auto _size = _name.size();                                \
 1183|    100|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    100|  return _nameof; }()
_ZNK6nameof7cstringILt22EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  4.40k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt22EE4dataEv:
  233|  4.40k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt22EE4sizeEv:
  235|  4.40k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_6clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    100|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    100|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    100|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    100|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    100|  constexpr auto _size = _name.size();                                \
 1183|    100|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    100|  return _nameof; }()
_ZNK6nameof7cstringILt27EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    326|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt27EE4dataEv:
  233|    326|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt27EE4sizeEv:
  235|    326|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_7clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    240|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    240|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    240|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    240|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    240|  constexpr auto _size = _name.size();                                \
 1183|    240|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    240|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_7clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    240|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    240|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    240|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    240|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    240|  constexpr auto _size = _name.size();                                \
 1183|    240|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    240|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_8clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    231|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    231|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    231|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    231|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    231|  constexpr auto _size = _name.size();                                \
 1183|    231|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    231|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_8clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    231|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    231|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    231|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    231|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    231|  constexpr auto _size = _name.size();                                \
 1183|    231|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    231|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_9clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    226|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    226|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    226|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    226|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    226|  constexpr auto _size = _name.size();                                \
 1183|    226|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    226|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_9clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    226|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    226|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    226|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    226|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    226|  constexpr auto _size = _name.size();                                \
 1183|    226|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    226|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_10clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     56|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     56|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     56|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     56|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     56|  constexpr auto _size = _name.size();                                \
 1183|     56|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     56|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_10clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     56|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     56|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     56|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     56|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     56|  constexpr auto _size = _name.size();                                \
 1183|     56|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     56|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_11clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    141|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    141|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    141|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    141|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    141|  constexpr auto _size = _name.size();                                \
 1183|    141|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    141|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_11clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    141|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    141|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    141|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    141|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    141|  constexpr auto _size = _name.size();                                \
 1183|    141|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    141|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_12clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    179|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    179|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    179|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    179|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    179|  constexpr auto _size = _name.size();                                \
 1183|    179|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    179|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_12clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    179|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    179|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    179|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    179|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    179|  constexpr auto _size = _name.size();                                \
 1183|    179|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    179|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_13clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     75|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     75|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     75|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     75|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     75|  constexpr auto _size = _name.size();                                \
 1183|     75|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     75|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_13clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     75|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     75|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     75|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     75|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     75|  constexpr auto _size = _name.size();                                \
 1183|     75|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     75|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_14clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    154|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    154|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    154|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    154|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    154|  constexpr auto _size = _name.size();                                \
 1183|    154|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    154|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_14clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    154|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    154|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    154|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    154|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    154|  constexpr auto _size = _name.size();                                \
 1183|    154|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    154|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_15clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    246|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    246|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    246|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    246|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    246|  constexpr auto _size = _name.size();                                \
 1183|    246|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    246|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_15clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    246|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    246|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    246|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    246|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    246|  constexpr auto _size = _name.size();                                \
 1183|    246|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    246|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_16clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    103|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    103|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    103|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    103|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    103|  constexpr auto _size = _name.size();                                \
 1183|    103|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    103|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_16clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    103|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    103|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    103|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    103|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    103|  constexpr auto _size = _name.size();                                \
 1183|    103|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    103|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_17clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    213|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    213|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    213|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    213|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    213|  constexpr auto _size = _name.size();                                \
 1183|    213|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    213|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_17clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    213|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    213|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    213|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    213|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    213|  constexpr auto _size = _name.size();                                \
 1183|    213|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    213|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_18clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    240|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    240|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    240|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    240|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    240|  constexpr auto _size = _name.size();                                \
 1183|    240|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    240|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_18clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    240|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    240|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    240|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    240|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    240|  constexpr auto _size = _name.size();                                \
 1183|    240|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    240|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_19clENSt3__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$_19clENSt3__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; }()
_ZNK6nameof7cstringILt21EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    751|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt21EE4dataEv:
  233|    751|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt21EE4sizeEv:
  235|    751|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_20clENSt3__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$_20clENSt3__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$_21clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    379|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    379|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    379|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    379|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    379|  constexpr auto _size = _name.size();                                \
 1183|    379|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    379|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_21clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    379|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    379|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    379|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    379|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    379|  constexpr auto _size = _name.size();                                \
 1183|    379|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    379|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_22clENSt3__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$_22clENSt3__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$_23clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    409|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    409|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    409|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    409|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    409|  constexpr auto _size = _name.size();                                \
 1183|    409|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    409|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_23clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    409|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    409|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    409|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    409|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    409|  constexpr auto _size = _name.size();                                \
 1183|    409|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    409|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_24clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    115|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    115|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    115|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    115|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    115|  constexpr auto _size = _name.size();                                \
 1183|    115|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    115|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_24clENSt3__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; }()
_ZNK6nameof7cstringILt37EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    228|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt37EE4dataEv:
  233|    228|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt37EE4sizeEv:
  235|    228|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_25clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    211|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    211|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    211|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    211|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    211|  constexpr auto _size = _name.size();                                \
 1183|    211|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    211|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_25clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    211|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    211|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    211|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    211|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    211|  constexpr auto _size = _name.size();                                \
 1183|    211|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    211|  return _nameof; }()
_ZNK6nameof7cstringILt36EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  1.09k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt36EE4dataEv:
  233|  1.09k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt36EE4sizeEv:
  235|  1.09k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_26clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    324|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    324|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    324|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    324|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    324|  constexpr auto _size = _name.size();                                \
 1183|    324|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    324|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_26clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    324|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    324|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    324|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    324|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    324|  constexpr auto _size = _name.size();                                \
 1183|    324|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    324|  return _nameof; }()
_ZNK6nameof7cstringILt35EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  1.56k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt35EE4dataEv:
  233|  1.56k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt35EE4sizeEv:
  235|  1.56k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_27clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    113|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    113|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    113|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    113|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    113|  constexpr auto _size = _name.size();                                \
 1183|    113|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    113|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_27clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    113|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    113|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    113|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    113|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    113|  constexpr auto _size = _name.size();                                \
 1183|    113|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    113|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_28clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    201|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    201|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    201|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    201|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    201|  constexpr auto _size = _name.size();                                \
 1183|    201|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    201|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_28clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    201|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    201|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    201|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    201|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    201|  constexpr auto _size = _name.size();                                \
 1183|    201|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    201|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_29clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    327|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    327|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    327|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    327|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    327|  constexpr auto _size = _name.size();                                \
 1183|    327|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    327|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_29clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    327|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    327|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    327|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    327|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    327|  constexpr auto _size = _name.size();                                \
 1183|    327|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    327|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_30clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    227|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    227|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    227|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    227|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    227|  constexpr auto _size = _name.size();                                \
 1183|    227|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    227|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_30clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    227|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    227|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    227|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    227|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    227|  constexpr auto _size = _name.size();                                \
 1183|    227|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    227|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_31clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    330|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    330|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    330|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    330|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    330|  constexpr auto _size = _name.size();                                \
 1183|    330|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    330|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_31clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    330|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    330|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    330|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    330|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    330|  constexpr auto _size = _name.size();                                \
 1183|    330|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    330|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_32clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    357|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    357|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    357|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    357|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    357|  constexpr auto _size = _name.size();                                \
 1183|    357|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    357|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_32clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    357|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    357|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    357|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    357|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    357|  constexpr auto _size = _name.size();                                \
 1183|    357|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    357|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_33clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    462|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    462|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    462|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    462|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    462|  constexpr auto _size = _name.size();                                \
 1183|    462|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    462|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_33clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    462|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    462|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    462|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    462|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    462|  constexpr auto _size = _name.size();                                \
 1183|    462|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    462|  return _nameof; }()
_ZNK6nameof7cstringILt33EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    857|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt33EE4dataEv:
  233|    857|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt33EE4sizeEv:
  235|    857|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_34clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    261|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    261|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    261|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    261|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    261|  constexpr auto _size = _name.size();                                \
 1183|    261|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    261|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_34clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    261|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    261|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    261|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    261|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    261|  constexpr auto _size = _name.size();                                \
 1183|    261|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    261|  return _nameof; }()
_ZNK6nameof7cstringILt34EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    261|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt34EE4dataEv:
  233|    261|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt34EE4sizeEv:
  235|    261|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_35clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    386|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    386|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    386|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    386|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    386|  constexpr auto _size = _name.size();                                \
 1183|    386|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    386|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_35clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    386|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    386|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    386|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    386|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    386|  constexpr auto _size = _name.size();                                \
 1183|    386|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    386|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_36clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    297|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    297|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    297|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    297|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    297|  constexpr auto _size = _name.size();                                \
 1183|    297|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    297|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_36clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    297|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    297|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    297|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    297|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    297|  constexpr auto _size = _name.size();                                \
 1183|    297|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    297|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_37clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    395|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    395|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    395|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    395|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    395|  constexpr auto _size = _name.size();                                \
 1183|    395|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    395|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_37clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    395|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    395|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    395|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    395|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    395|  constexpr auto _size = _name.size();                                \
 1183|    395|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    395|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_38clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     50|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     50|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     50|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     50|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     50|  constexpr auto _size = _name.size();                                \
 1183|     50|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     50|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_38clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     50|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     50|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     50|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     50|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     50|  constexpr auto _size = _name.size();                                \
 1183|     50|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     50|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_39clENSt3__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$_39clENSt3__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$_40clENSt3__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$_40clENSt3__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$_41clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    242|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    242|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    242|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    242|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    242|  constexpr auto _size = _name.size();                                \
 1183|    242|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    242|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_41clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    242|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    242|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    242|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    242|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    242|  constexpr auto _size = _name.size();                                \
 1183|    242|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    242|  return _nameof; }()

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

_ZNK7simdutf14implementation4nameEv:
 5121|      4|  virtual std::string_view name() const noexcept { return _name; }
_ZNK7simdutf14implementation25required_instruction_setsEv:
 5172|      8|  virtual uint32_t required_instruction_sets() const {
 5173|      8|    return _required_instruction_sets;
 5174|      8|  }
_ZNK7simdutf14implementation24utf16_length_from_latin1Em:
 6362|    297|  utf16_length_from_latin1(size_t length) const noexcept {
 6363|    297|    return length;
 6364|    297|  }
_ZNK7simdutf14implementation24latin1_length_from_utf32Em:
 6550|    990|  latin1_length_from_utf32(size_t length) const noexcept {
 6551|    990|    return length;
 6552|    990|  }
_ZNK7simdutf14implementation24latin1_length_from_utf16Em:
 6587|  1.07k|  latin1_length_from_utf16(size_t length) const noexcept {
 6588|  1.07k|    return length;
 6589|  1.07k|  }
_ZNK7simdutf14implementation24utf32_length_from_latin1Em:
 6620|    150|  utf32_length_from_latin1(size_t length) const noexcept {
 6621|    150|    return length;
 6622|    150|  }
_ZN7simdutf14implementationC2EPKcS2_j:
 7058|      4|      : _name(name), _description(description),
 7059|      4|        _required_instruction_sets(required_instruction_sets) {}
_ZN7simdutf8internal29available_implementation_listC2Ev:
 7090|      1|  simdutf_really_inline available_implementation_list() {}

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

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

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

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

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

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

_ZN7simdutf6scalar5utf168validateILNS_10endiannessE0EEEbPKDsm:
   22|  3.87k|validate(const char16_t *data, size_t len) noexcept {
   23|  3.87k|  uint64_t pos = 0;
   24|  18.7M|  while (pos < len) {
  ------------------
  |  Branch (24:10): [True: 18.7M, False: 2.64k]
  ------------------
   25|  18.7M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   26|  18.7M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (26:9): [True: 18.3k, False: 18.7M]
  ------------------
   27|  18.3k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 234, False: 18.0k]
  ------------------
   28|    234|        return false;
   29|    234|      }
   30|  18.0k|      char16_t diff = char16_t(word - 0xD800);
   31|  18.0k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (31:11): [True: 412, False: 17.6k]
  ------------------
   32|    412|        return false;
   33|    412|      }
   34|  17.6k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (34:28): [Folded, False: 17.6k]
  ------------------
   35|  17.6k|                               ? u16_swap_bytes(data[pos + 1])
   36|  17.6k|                               : data[pos + 1];
   37|  17.6k|      char16_t diff2 = char16_t(next_word - 0xDC00);
   38|  17.6k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (38:11): [True: 586, False: 17.0k]
  ------------------
   39|    586|        return false;
   40|    586|      }
   41|  17.0k|      pos += 2;
   42|  18.7M|    } else {
   43|  18.7M|      pos++;
   44|  18.7M|    }
   45|  18.7M|  }
   46|  2.64k|  return true;
   47|  3.87k|}
_ZN7simdutf6scalar5utf168validateILNS_10endiannessE1EEEbPKDsm:
   22|  3.79k|validate(const char16_t *data, size_t len) noexcept {
   23|  3.79k|  uint64_t pos = 0;
   24|  22.2M|  while (pos < len) {
  ------------------
  |  Branch (24:10): [True: 22.2M, False: 2.57k]
  ------------------
   25|  22.2M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   26|  22.2M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (26:9): [True: 17.5k, False: 22.2M]
  ------------------
   27|  17.5k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 243, False: 17.2k]
  ------------------
   28|    243|        return false;
   29|    243|      }
   30|  17.2k|      char16_t diff = char16_t(word - 0xD800);
   31|  17.2k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (31:11): [True: 420, False: 16.8k]
  ------------------
   32|    420|        return false;
   33|    420|      }
   34|  16.8k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (34:28): [True: 16.8k, Folded]
  ------------------
   35|  16.8k|                               ? u16_swap_bytes(data[pos + 1])
   36|  16.8k|                               : data[pos + 1];
   37|  16.8k|      char16_t diff2 = char16_t(next_word - 0xDC00);
   38|  16.8k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (38:11): [True: 552, False: 16.3k]
  ------------------
   39|    552|        return false;
   40|    552|      }
   41|  16.3k|      pos += 2;
   42|  22.2M|    } else {
   43|  22.2M|      pos++;
   44|  22.2M|    }
   45|  22.2M|  }
   46|  2.57k|  return true;
   47|  3.79k|}
_ZN7simdutf6scalar5utf1620validate_with_errorsILNS_10endiannessE0EEENS_6resultEPKDsm:
   51|  4.12k|validate_with_errors(const char16_t *data, size_t len) noexcept {
   52|  4.12k|  size_t pos = 0;
   53|  18.7M|  while (pos < len) {
  ------------------
  |  Branch (53:10): [True: 18.7M, False: 2.64k]
  ------------------
   54|  18.7M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   55|  18.7M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (55:9): [True: 18.6k, False: 18.7M]
  ------------------
   56|  18.6k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (56:11): [True: 234, False: 18.3k]
  ------------------
   57|    234|        return result(error_code::SURROGATE, pos);
   58|    234|      }
   59|  18.3k|      char16_t diff = char16_t(word - 0xD800);
   60|  18.3k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (60:11): [True: 540, False: 17.8k]
  ------------------
   61|    540|        return result(error_code::SURROGATE, pos);
   62|    540|      }
   63|  17.8k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (63:28): [Folded, False: 17.8k]
  ------------------
   64|  17.8k|                               ? u16_swap_bytes(data[pos + 1])
   65|  17.8k|                               : data[pos + 1];
   66|  17.8k|      char16_t diff2 = uint16_t(next_word - 0xDC00);
   67|  17.8k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (67:11): [True: 711, False: 17.1k]
  ------------------
   68|    711|        return result(error_code::SURROGATE, pos);
   69|    711|      }
   70|  17.1k|      pos += 2;
   71|  18.7M|    } else {
   72|  18.7M|      pos++;
   73|  18.7M|    }
   74|  18.7M|  }
   75|  2.64k|  return result(error_code::SUCCESS, pos);
   76|  4.12k|}
_ZN7simdutf6scalar5utf1620validate_with_errorsILNS_10endiannessE1EEENS_6resultEPKDsm:
   51|  4.00k|validate_with_errors(const char16_t *data, size_t len) noexcept {
   52|  4.00k|  size_t pos = 0;
   53|  22.2M|  while (pos < len) {
  ------------------
  |  Branch (53:10): [True: 22.2M, False: 2.57k]
  ------------------
   54|  22.2M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   55|  22.2M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (55:9): [True: 17.8k, False: 22.2M]
  ------------------
   56|  17.8k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (56:11): [True: 243, False: 17.5k]
  ------------------
   57|    243|        return result(error_code::SURROGATE, pos);
   58|    243|      }
   59|  17.5k|      char16_t diff = char16_t(word - 0xD800);
   60|  17.5k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (60:11): [True: 507, False: 17.0k]
  ------------------
   61|    507|        return result(error_code::SURROGATE, pos);
   62|    507|      }
   63|  17.0k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (63:28): [True: 17.0k, Folded]
  ------------------
   64|  17.0k|                               ? u16_swap_bytes(data[pos + 1])
   65|  17.0k|                               : data[pos + 1];
   66|  17.0k|      char16_t diff2 = uint16_t(next_word - 0xDC00);
   67|  17.0k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (67:11): [True: 678, False: 16.3k]
  ------------------
   68|    678|        return result(error_code::SURROGATE, pos);
   69|    678|      }
   70|  16.3k|      pos += 2;
   71|  22.2M|    } else {
   72|  22.2M|      pos++;
   73|  22.2M|    }
   74|  22.2M|  }
   75|  2.57k|  return result(error_code::SUCCESS, pos);
   76|  4.00k|}
_ZN7simdutf6scalar5utf1617count_code_pointsILNS_10endiannessE0EEEmPKDsm:
   79|  4.99k|simdutf_constexpr23 size_t count_code_points(const char16_t *p, size_t len) {
   80|       |  // We are not BOM aware.
   81|  4.99k|  size_t counter{0};
   82|  26.3M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (82:22): [True: 26.3M, False: 4.99k]
  ------------------
   83|  26.3M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
   84|  26.3M|    counter += ((word & 0xFC00) != 0xDC00);
   85|  26.3M|  }
   86|  4.99k|  return counter;
   87|  4.99k|}
_ZN7simdutf6scalar5utf1617count_code_pointsILNS_10endiannessE1EEEmPKDsm:
   79|  4.93k|simdutf_constexpr23 size_t count_code_points(const char16_t *p, size_t len) {
   80|       |  // We are not BOM aware.
   81|  4.93k|  size_t counter{0};
   82|  27.9M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (82:22): [True: 27.9M, False: 4.93k]
  ------------------
   83|  27.9M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
   84|  27.9M|    counter += ((word & 0xFC00) != 0xDC00);
   85|  27.9M|  }
   86|  4.93k|  return counter;
   87|  4.93k|}
_ZN7simdutf6scalar5utf1622utf8_length_from_utf16ILNS_10endiannessE0EEEmPKDsm:
   91|  2.33k|                                                  size_t len) {
   92|       |  // We are not BOM aware.
   93|  2.33k|  size_t counter{0};
   94|  16.1M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (94:22): [True: 16.1M, False: 2.33k]
  ------------------
   95|  16.1M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
   96|  16.1M|    counter++; // ASCII
   97|  16.1M|    counter += static_cast<size_t>(
   98|  16.1M|        word >
   99|  16.1M|        0x7F); // non-ASCII is at least 2 bytes, surrogates are 2*2 == 4 bytes
  100|  16.1M|    counter += static_cast<size_t>((word > 0x7FF && word <= 0xD7FF) ||
  ------------------
  |  Branch (100:37): [True: 3.21M, False: 12.9M]
  |  Branch (100:53): [True: 2.90M, False: 303k]
  ------------------
  101|  13.2M|                                   (word >= 0xE000)); // three-byte
  ------------------
  |  Branch (101:36): [True: 236k, False: 13.0M]
  ------------------
  102|  16.1M|  }
  103|  2.33k|  return counter;
  104|  2.33k|}
_ZN7simdutf6scalar5utf1622utf8_length_from_utf16ILNS_10endiannessE1EEEmPKDsm:
   91|  2.18k|                                                  size_t len) {
   92|       |  // We are not BOM aware.
   93|  2.18k|  size_t counter{0};
   94|  16.5M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (94:22): [True: 16.5M, False: 2.18k]
  ------------------
   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.64M, False: 12.9M]
  |  Branch (100:53): [True: 3.48M, False: 166k]
  ------------------
  101|  13.1M|                                   (word >= 0xE000)); // three-byte
  ------------------
  |  Branch (101:36): [True: 146k, False: 12.9M]
  ------------------
  102|  16.5M|  }
  103|  2.18k|  return counter;
  104|  2.18k|}
_ZN7simdutf6scalar5utf1623utf32_length_from_utf16ILNS_10endiannessE0EEEmPKDsm:
  108|    420|                                                   size_t len) {
  109|       |  // We are not BOM aware.
  110|    420|  size_t counter{0};
  111|  4.85M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (111:22): [True: 4.85M, False: 420]
  ------------------
  112|  4.85M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
  113|  4.85M|    counter += ((word & 0xFC00) != 0xDC00);
  114|  4.85M|  }
  115|    420|  return counter;
  116|    420|}
_ZN7simdutf6scalar5utf1623utf32_length_from_utf16ILNS_10endiannessE1EEEmPKDsm:
  108|    448|                                                   size_t len) {
  109|       |  // We are not BOM aware.
  110|    448|  size_t counter{0};
  111|  6.29M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (111:22): [True: 6.29M, False: 448]
  ------------------
  112|  6.29M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
  113|  6.29M|    counter += ((word & 0xFC00) != 0xDC00);
  114|  6.29M|  }
  115|    448|  return counter;
  116|    448|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf16_to_latin17convertILNS_10endiannessE0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEEmS8_mS9_:
   17|    304|                                   OutputPtr latin_output) {
   18|    304|  if (len == 0) {
  ------------------
  |  Branch (18:7): [True: 6, False: 298]
  ------------------
   19|      6|    return 0;
   20|      6|  }
   21|    298|  size_t pos = 0;
   22|    298|  const auto latin_output_start = latin_output;
   23|    298|  uint16_t word = 0;
   24|    298|  uint16_t too_large = 0;
   25|       |
   26|  3.88M|  while (pos < len) {
  ------------------
  |  Branch (26:10): [True: 3.88M, False: 298]
  ------------------
   27|  3.88M|    word = !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (27:12): [Folded, False: 3.88M]
  ------------------
   28|  3.88M|    too_large |= word;
   29|  3.88M|    *latin_output++ = char(word & 0xFF);
   30|  3.88M|    pos++;
   31|  3.88M|  }
   32|    298|  if ((too_large & 0xFF00) != 0) {
  ------------------
  |  Branch (32:7): [True: 188, False: 110]
  ------------------
   33|    188|    return 0;
   34|    188|  }
   35|       |
   36|    110|  return latin_output - latin_output_start;
   37|    298|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf16_to_latin17convertILNS_10endiannessE1EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEEmS8_mS9_:
   17|    242|                                   OutputPtr latin_output) {
   18|    242|  if (len == 0) {
  ------------------
  |  Branch (18:7): [True: 6, False: 236]
  ------------------
   19|      6|    return 0;
   20|      6|  }
   21|    236|  size_t pos = 0;
   22|    236|  const auto latin_output_start = latin_output;
   23|    236|  uint16_t word = 0;
   24|    236|  uint16_t too_large = 0;
   25|       |
   26|  1.06M|  while (pos < len) {
  ------------------
  |  Branch (26:10): [True: 1.06M, False: 236]
  ------------------
   27|  1.06M|    word = !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (27:12): [True: 1.06M, Folded]
  ------------------
   28|  1.06M|    too_large |= word;
   29|  1.06M|    *latin_output++ = char(word & 0xFF);
   30|  1.06M|    pos++;
   31|  1.06M|  }
   32|    236|  if ((too_large & 0xFF00) != 0) {
  ------------------
  |  Branch (32:7): [True: 138, False: 98]
  ------------------
   33|    138|    return 0;
   34|    138|  }
   35|       |
   36|     98|  return latin_output - latin_output_start;
   37|    236|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf16_to_latin119convert_with_errorsILNS_10endiannessE0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEENS_6resultES8_mS9_:
   45|    444|                                               OutputPtr latin_output) {
   46|    444|  if (len == 0) {
  ------------------
  |  Branch (46:7): [True: 4, False: 440]
  ------------------
   47|      4|    return result(error_code::SUCCESS, 0);
   48|      4|  }
   49|    440|  size_t pos = 0;
   50|    440|  auto start = latin_output;
   51|    440|  uint16_t word;
   52|       |
   53|   395k|  while (pos < len) {
  ------------------
  |  Branch (53:10): [True: 395k, False: 202]
  ------------------
   54|       |#if SIMDUTF_CPLUSPLUS23
   55|       |    if !consteval
   56|       |#endif
   57|   395k|    {
   58|   395k|      if (pos + 16 <= len) { // if it is safe to read 32 more bytes, check that
  ------------------
  |  Branch (58:11): [True: 393k, False: 1.87k]
  ------------------
   59|       |                             // they are Latin1
   60|   393k|        uint64_t v1, v2, v3, v4;
   61|   393k|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   62|   393k|        ::memcpy(&v2, data + pos + 4, sizeof(uint64_t));
   63|   393k|        ::memcpy(&v3, data + pos + 8, sizeof(uint64_t));
   64|   393k|        ::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|   393k|        if (((v1 | v2 | v3 | v4) & 0xFF00FF00FF00FF00) == 0) {
  ------------------
  |  Branch (79:13): [True: 393k, False: 186]
  ------------------
   80|   393k|          size_t final_pos = pos + 16;
   81|  6.68M|          while (pos < final_pos) {
  ------------------
  |  Branch (81:18): [True: 6.29M, False: 393k]
  ------------------
   82|  6.29M|            *latin_output++ = !match_system(big_endian)
  ------------------
  |  Branch (82:31): [Folded, False: 6.29M]
  ------------------
   83|  6.29M|                                  ? char(u16_swap_bytes(data[pos]))
   84|  6.29M|                                  : char(data[pos]);
   85|  6.29M|            pos++;
   86|  6.29M|          }
   87|   393k|          continue;
   88|   393k|        }
   89|   393k|      }
   90|   395k|    }
   91|       |
   92|  2.05k|    word = !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (92:12): [Folded, False: 2.05k]
  ------------------
   93|  2.05k|    if ((word & 0xFF00) == 0) {
  ------------------
  |  Branch (93:9): [True: 1.82k, False: 238]
  ------------------
   94|  1.82k|      *latin_output++ = char(word & 0xFF);
   95|  1.82k|      pos++;
   96|  1.82k|    } else {
   97|    238|      return result(error_code::TOO_LARGE, pos);
   98|    238|    }
   99|  2.05k|  }
  100|    202|  return result(error_code::SUCCESS, latin_output - start);
  101|    440|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf16_to_latin119convert_with_errorsILNS_10endiannessE1EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEENS_6resultES8_mS9_:
   45|    414|                                               OutputPtr latin_output) {
   46|    414|  if (len == 0) {
  ------------------
  |  Branch (46:7): [True: 4, False: 410]
  ------------------
   47|      4|    return result(error_code::SUCCESS, 0);
   48|      4|  }
   49|    410|  size_t pos = 0;
   50|    410|  auto start = latin_output;
   51|    410|  uint16_t word;
   52|       |
   53|   459k|  while (pos < len) {
  ------------------
  |  Branch (53:10): [True: 459k, False: 152]
  ------------------
   54|       |#if SIMDUTF_CPLUSPLUS23
   55|       |    if !consteval
   56|       |#endif
   57|   459k|    {
   58|   459k|      if (pos + 16 <= len) { // if it is safe to read 32 more bytes, check that
  ------------------
  |  Branch (58:11): [True: 457k, False: 1.36k]
  ------------------
   59|       |                             // they are Latin1
   60|   457k|        uint64_t v1, v2, v3, v4;
   61|   457k|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   62|   457k|        ::memcpy(&v2, data + pos + 4, sizeof(uint64_t));
   63|   457k|        ::memcpy(&v3, data + pos + 8, sizeof(uint64_t));
   64|   457k|        ::memcpy(&v4, data + pos + 12, sizeof(uint64_t));
   65|       |
   66|   457k|        if constexpr (!match_system(big_endian)) {
   67|   457k|          v1 = (v1 >> 8) | (v1 << (64 - 8));
   68|   457k|        }
   69|   457k|        if constexpr (!match_system(big_endian)) {
   70|   457k|          v2 = (v2 >> 8) | (v2 << (64 - 8));
   71|   457k|        }
   72|   457k|        if constexpr (!match_system(big_endian)) {
   73|   457k|          v3 = (v3 >> 8) | (v3 << (64 - 8));
   74|   457k|        }
   75|   457k|        if constexpr (!match_system(big_endian)) {
   76|   457k|          v4 = (v4 >> 8) | (v4 << (64 - 8));
   77|   457k|        }
   78|       |
   79|   457k|        if (((v1 | v2 | v3 | v4) & 0xFF00FF00FF00FF00) == 0) {
  ------------------
  |  Branch (79:13): [True: 457k, False: 252]
  ------------------
   80|   457k|          size_t final_pos = pos + 16;
   81|  7.77M|          while (pos < final_pos) {
  ------------------
  |  Branch (81:18): [True: 7.31M, False: 457k]
  ------------------
   82|  7.31M|            *latin_output++ = !match_system(big_endian)
  ------------------
  |  Branch (82:31): [True: 7.31M, Folded]
  ------------------
   83|  7.31M|                                  ? char(u16_swap_bytes(data[pos]))
   84|  7.31M|                                  : char(data[pos]);
   85|  7.31M|            pos++;
   86|  7.31M|          }
   87|   457k|          continue;
   88|   457k|        }
   89|   457k|      }
   90|   459k|    }
   91|       |
   92|  1.61k|    word = !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (92:12): [True: 1.61k, Folded]
  ------------------
   93|  1.61k|    if ((word & 0xFF00) == 0) {
  ------------------
  |  Branch (93:9): [True: 1.35k, False: 258]
  ------------------
   94|  1.35k|      *latin_output++ = char(word & 0xFF);
   95|  1.35k|      pos++;
   96|  1.35k|    } else {
   97|    258|      return result(error_code::TOO_LARGE, pos);
   98|    258|    }
   99|  1.61k|  }
  100|    152|  return result(error_code::SUCCESS, latin_output - start);
  101|    410|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf327convertILNS_10endiannessE0EEEmPKDsmPDi:
   11|    786|                                   char32_t *utf32_output) {
   12|    786|  size_t pos = 0;
   13|    786|  char32_t *start{utf32_output};
   14|   742k|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 742k, False: 450]
  ------------------
   15|   742k|    uint16_t word =
   16|   742k|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (16:9): [Folded, False: 742k]
  ------------------
   17|   742k|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (17:9): [True: 740k, False: 2.10k]
  ------------------
   18|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   19|   740k|      *utf32_output++ = char32_t(word);
   20|   740k|      pos++;
   21|   740k|    } else {
   22|       |      // must be a surrogate pair
   23|  2.10k|      uint16_t diff = uint16_t(word - 0xD800);
   24|  2.10k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (24:11): [True: 126, False: 1.97k]
  ------------------
   25|    126|        return 0;
   26|    126|      }
   27|  1.97k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 84, False: 1.89k]
  ------------------
   28|     84|        return 0;
   29|     84|      } // minimal bound checking
   30|  1.89k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (30:28): [Folded, False: 1.89k]
  ------------------
   31|  1.89k|                               ? u16_swap_bytes(data[pos + 1])
   32|  1.89k|                               : data[pos + 1];
   33|  1.89k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   34|  1.89k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (34:11): [True: 126, False: 1.76k]
  ------------------
   35|    126|        return 0;
   36|    126|      }
   37|  1.76k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   38|  1.76k|      *utf32_output++ = char32_t(value);
   39|  1.76k|      pos += 2;
   40|  1.76k|    }
   41|   742k|  }
   42|    450|  return utf32_output - start;
   43|    786|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf327convertILNS_10endiannessE1EEEmPKDsmPDi:
   11|    894|                                   char32_t *utf32_output) {
   12|    894|  size_t pos = 0;
   13|    894|  char32_t *start{utf32_output};
   14|  1.06M|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 1.05M, False: 542]
  ------------------
   15|  1.05M|    uint16_t word =
   16|  1.05M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (16:9): [True: 1.05M, Folded]
  ------------------
   17|  1.05M|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (17:9): [True: 1.05M, False: 2.23k]
  ------------------
   18|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   19|  1.05M|      *utf32_output++ = char32_t(word);
   20|  1.05M|      pos++;
   21|  1.05M|    } else {
   22|       |      // must be a surrogate pair
   23|  2.23k|      uint16_t diff = uint16_t(word - 0xD800);
   24|  2.23k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (24:11): [True: 114, False: 2.11k]
  ------------------
   25|    114|        return 0;
   26|    114|      }
   27|  2.11k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 120, False: 1.99k]
  ------------------
   28|    120|        return 0;
   29|    120|      } // minimal bound checking
   30|  1.99k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (30:28): [True: 1.99k, Folded]
  ------------------
   31|  1.99k|                               ? u16_swap_bytes(data[pos + 1])
   32|  1.99k|                               : data[pos + 1];
   33|  1.99k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   34|  1.99k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (34:11): [True: 118, False: 1.87k]
  ------------------
   35|    118|        return 0;
   36|    118|      }
   37|  1.87k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   38|  1.87k|      *utf32_output++ = char32_t(value);
   39|  1.87k|      pos += 2;
   40|  1.87k|    }
   41|  1.05M|  }
   42|    542|  return utf32_output - start;
   43|    894|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf3219convert_with_errorsILNS_10endiannessE0EEENS_6resultEPKDsmPDi:
   47|    872|                                               char32_t *utf32_output) {
   48|    872|  size_t pos = 0;
   49|    872|  char32_t *start{utf32_output};
   50|  2.51M|  while (pos < len) {
  ------------------
  |  Branch (50:10): [True: 2.51M, False: 524]
  ------------------
   51|  2.51M|    uint16_t word =
   52|  2.51M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (52:9): [Folded, False: 2.51M]
  ------------------
   53|  2.51M|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (53:9): [True: 2.50M, False: 11.1k]
  ------------------
   54|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   55|  2.50M|      *utf32_output++ = char32_t(word);
   56|  2.50M|      pos++;
   57|  2.50M|    } else {
   58|       |      // must be a surrogate pair
   59|  11.1k|      uint16_t diff = uint16_t(word - 0xD800);
   60|  11.1k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (60:11): [True: 102, False: 11.0k]
  ------------------
   61|    102|        return result(error_code::SURROGATE, pos);
   62|    102|      }
   63|  11.0k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (63:11): [True: 90, False: 10.9k]
  ------------------
   64|     90|        return result(error_code::SURROGATE, pos);
   65|     90|      } // minimal bound checking
   66|  10.9k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (66:28): [Folded, False: 10.9k]
  ------------------
   67|  10.9k|                               ? u16_swap_bytes(data[pos + 1])
   68|  10.9k|                               : data[pos + 1];
   69|  10.9k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   70|  10.9k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (70:11): [True: 156, False: 10.7k]
  ------------------
   71|    156|        return result(error_code::SURROGATE, pos);
   72|    156|      }
   73|  10.7k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   74|  10.7k|      *utf32_output++ = char32_t(value);
   75|  10.7k|      pos += 2;
   76|  10.7k|    }
   77|  2.51M|  }
   78|    524|  return result(error_code::SUCCESS, utf32_output - start);
   79|    872|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf3219convert_with_errorsILNS_10endiannessE1EEENS_6resultEPKDsmPDi:
   47|    910|                                               char32_t *utf32_output) {
   48|    910|  size_t pos = 0;
   49|    910|  char32_t *start{utf32_output};
   50|  2.53M|  while (pos < len) {
  ------------------
  |  Branch (50:10): [True: 2.53M, False: 466]
  ------------------
   51|  2.53M|    uint16_t word =
   52|  2.53M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (52:9): [True: 2.53M, Folded]
  ------------------
   53|  2.53M|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (53:9): [True: 2.52M, False: 11.5k]
  ------------------
   54|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   55|  2.52M|      *utf32_output++ = char32_t(word);
   56|  2.52M|      pos++;
   57|  2.52M|    } else {
   58|       |      // must be a surrogate pair
   59|  11.5k|      uint16_t diff = uint16_t(word - 0xD800);
   60|  11.5k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (60:11): [True: 178, False: 11.3k]
  ------------------
   61|    178|        return result(error_code::SURROGATE, pos);
   62|    178|      }
   63|  11.3k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (63:11): [True: 90, False: 11.2k]
  ------------------
   64|     90|        return result(error_code::SURROGATE, pos);
   65|     90|      } // minimal bound checking
   66|  11.2k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (66:28): [True: 11.2k, Folded]
  ------------------
   67|  11.2k|                               ? u16_swap_bytes(data[pos + 1])
   68|  11.2k|                               : data[pos + 1];
   69|  11.2k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   70|  11.2k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (70:11): [True: 176, False: 11.0k]
  ------------------
   71|    176|        return result(error_code::SURROGATE, pos);
   72|    176|      }
   73|  11.0k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   74|  11.0k|      *utf32_output++ = char32_t(value);
   75|  11.0k|      pos += 2;
   76|  11.0k|    }
   77|  2.53M|  }
   78|    466|  return result(error_code::SUCCESS, utf32_output - start);
   79|    910|}

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

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf87convertILNS_10endiannessE0EPKDsPcQsr7simdutf6detailE18indexes_into_utf16IT0_EEEmS8_mT1_:
   17|  1.91k|                                   OutputPtr utf8_output) {
   18|  1.91k|  size_t pos = 0;
   19|  1.91k|  const auto start = utf8_output;
   20|  3.08M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 3.07M, False: 1.51k]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  3.07M|    {
   25|       |      // try to convert the next block of 8 bytes
   26|  3.07M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (26:11): [True: 3.07M, False: 3.32k]
  ------------------
   27|       |                            // they are ascii
   28|  3.07M|        uint64_t v;
   29|  3.07M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   30|       |        if constexpr (!match_system(big_endian)) {
   31|       |          v = (v >> 8) | (v << (64 - 8));
   32|       |        }
   33|  3.07M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (33:13): [True: 2.06M, False: 1.01M]
  ------------------
   34|  2.06M|          size_t final_pos = pos + 4;
   35|  10.3M|          while (pos < final_pos) {
  ------------------
  |  Branch (35:18): [True: 8.25M, False: 2.06M]
  ------------------
   36|  8.25M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (36:30): [Folded, False: 8.25M]
  ------------------
   37|  8.25M|                                 ? char(u16_swap_bytes(data[pos]))
   38|  8.25M|                                 : char(data[pos]);
   39|  8.25M|            pos++;
   40|  8.25M|          }
   41|  2.06M|          continue;
   42|  2.06M|        }
   43|  3.07M|      }
   44|  3.07M|    }
   45|  1.01M|    uint16_t word =
   46|  1.01M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (46:9): [Folded, False: 1.01M]
  ------------------
   47|  1.01M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (47:9): [True: 203k, False: 812k]
  ------------------
   48|       |      // will generate one UTF-8 bytes
   49|   203k|      *utf8_output++ = char(word);
   50|   203k|      pos++;
   51|   812k|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (51:16): [True: 352k, False: 459k]
  ------------------
   52|       |      // will generate two UTF-8 bytes
   53|       |      // we have 0b110XXXXX 0b10XXXXXX
   54|   352k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   55|   352k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   56|   352k|      pos++;
   57|   459k|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (57:16): [True: 452k, False: 6.79k]
  ------------------
   58|       |      // will generate three UTF-8 bytes
   59|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   60|   452k|      *utf8_output++ = char((word >> 12) | 0b11100000);
   61|   452k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   62|   452k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   63|   452k|      pos++;
   64|   452k|    } else {
   65|       |      // must be a surrogate pair
   66|  6.79k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (66:11): [True: 54, False: 6.73k]
  ------------------
   67|     54|        return 0;
   68|     54|      }
   69|  6.73k|      uint16_t diff = uint16_t(word - 0xD800);
   70|  6.73k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (70:11): [True: 136, False: 6.60k]
  ------------------
   71|    136|        return 0;
   72|    136|      }
   73|  6.60k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (73:28): [Folded, False: 6.60k]
  ------------------
   74|  6.60k|                               ? u16_swap_bytes(data[pos + 1])
   75|  6.60k|                               : data[pos + 1];
   76|  6.60k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   77|  6.60k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (77:11): [True: 208, False: 6.39k]
  ------------------
   78|    208|        return 0;
   79|    208|      }
   80|  6.39k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   81|       |      // will generate four UTF-8 bytes
   82|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   83|  6.39k|      *utf8_output++ = char((value >> 18) | 0b11110000);
   84|  6.39k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
   85|  6.39k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
   86|  6.39k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
   87|  6.39k|      pos += 2;
   88|  6.39k|    }
   89|  1.01M|  }
   90|  1.51k|  return utf8_output - start;
   91|  1.91k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf87convertILNS_10endiannessE1EPKDsPcQsr7simdutf6detailE18indexes_into_utf16IT0_EEEmS8_mT1_:
   17|  1.74k|                                   OutputPtr utf8_output) {
   18|  1.74k|  size_t pos = 0;
   19|  1.74k|  const auto start = utf8_output;
   20|  4.21M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 4.21M, False: 1.47k]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  4.21M|    {
   25|       |      // try to convert the next block of 8 bytes
   26|  4.21M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (26:11): [True: 4.21M, False: 3.26k]
  ------------------
   27|       |                            // they are ascii
   28|  4.21M|        uint64_t v;
   29|  4.21M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   30|  4.21M|        if constexpr (!match_system(big_endian)) {
   31|  4.21M|          v = (v >> 8) | (v << (64 - 8));
   32|  4.21M|        }
   33|  4.21M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (33:13): [True: 1.68M, False: 2.52M]
  ------------------
   34|  1.68M|          size_t final_pos = pos + 4;
   35|  8.42M|          while (pos < final_pos) {
  ------------------
  |  Branch (35:18): [True: 6.74M, False: 1.68M]
  ------------------
   36|  6.74M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (36:30): [True: 6.74M, Folded]
  ------------------
   37|  6.74M|                                 ? char(u16_swap_bytes(data[pos]))
   38|  6.74M|                                 : char(data[pos]);
   39|  6.74M|            pos++;
   40|  6.74M|          }
   41|  1.68M|          continue;
   42|  1.68M|        }
   43|  4.21M|      }
   44|  4.21M|    }
   45|  2.53M|    uint16_t word =
   46|  2.53M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (46:9): [True: 2.53M, Folded]
  ------------------
   47|  2.53M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (47:9): [True: 287k, False: 2.24M]
  ------------------
   48|       |      // will generate one UTF-8 bytes
   49|   287k|      *utf8_output++ = char(word);
   50|   287k|      pos++;
   51|  2.24M|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (51:16): [True: 96.7k, False: 2.14M]
  ------------------
   52|       |      // will generate two UTF-8 bytes
   53|       |      // we have 0b110XXXXX 0b10XXXXXX
   54|  96.7k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   55|  96.7k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   56|  96.7k|      pos++;
   57|  2.14M|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (57:16): [True: 2.14M, False: 5.22k]
  ------------------
   58|       |      // will generate three UTF-8 bytes
   59|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   60|  2.14M|      *utf8_output++ = char((word >> 12) | 0b11100000);
   61|  2.14M|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   62|  2.14M|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   63|  2.14M|      pos++;
   64|  2.14M|    } else {
   65|       |      // must be a surrogate pair
   66|  5.22k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (66:11): [True: 42, False: 5.18k]
  ------------------
   67|     42|        return 0;
   68|     42|      }
   69|  5.18k|      uint16_t diff = uint16_t(word - 0xD800);
   70|  5.18k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (70:11): [True: 78, False: 5.10k]
  ------------------
   71|     78|        return 0;
   72|     78|      }
   73|  5.10k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (73:28): [True: 5.10k, Folded]
  ------------------
   74|  5.10k|                               ? u16_swap_bytes(data[pos + 1])
   75|  5.10k|                               : data[pos + 1];
   76|  5.10k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   77|  5.10k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (77:11): [True: 146, False: 4.96k]
  ------------------
   78|    146|        return 0;
   79|    146|      }
   80|  4.96k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   81|       |      // will generate four UTF-8 bytes
   82|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   83|  4.96k|      *utf8_output++ = char((value >> 18) | 0b11110000);
   84|  4.96k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
   85|  4.96k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
   86|  4.96k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
   87|  4.96k|      pos += 2;
   88|  4.96k|    }
   89|  2.53M|  }
   90|  1.47k|  return utf8_output - start;
   91|  1.74k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf819convert_with_errorsILNS_10endiannessE0ELb0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT1_Esr7simdutf6detailE26index_assignable_from_charIT2_EEENS_11full_resultES8_mS9_m:
  101|  1.68k|                                                    size_t utf8_len = 0) {
  102|  1.68k|  if (check_output && utf8_len == 0) {
  ------------------
  |  Branch (102:7): [Folded, False: 1.68k]
  |  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.68k|  size_t pos = 0;
  107|  1.68k|  auto start = utf8_output;
  108|  1.68k|  auto end = utf8_output + utf8_len;
  109|       |
  110|  5.76M|  while (pos < len) {
  ------------------
  |  Branch (110:10): [True: 5.76M, False: 1.24k]
  ------------------
  111|       |#if SIMDUTF_CPLUSPLUS23
  112|       |    if !consteval
  113|       |#endif
  114|  5.76M|    {
  115|       |      // try to convert the next block of 8 bytes
  116|  5.76M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (116:11): [True: 5.76M, False: 2.94k]
  ------------------
  117|       |                            // they are ascii
  118|  5.76M|        uint64_t v;
  119|  5.76M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
  120|       |        if constexpr (!match_system(big_endian))
  121|       |          v = (v >> 8) | (v << (64 - 8));
  122|  5.76M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (122:13): [True: 1.52M, False: 4.23M]
  ------------------
  123|  1.52M|          size_t final_pos = pos + 4;
  124|  7.64M|          while (pos < final_pos) {
  ------------------
  |  Branch (124:18): [True: 6.11M, False: 1.52M]
  ------------------
  125|  6.11M|            if (check_output && size_t(end - utf8_output) < 1) {
  ------------------
  |  Branch (125:17): [Folded, False: 6.11M]
  |  Branch (125:33): [True: 0, False: 0]
  ------------------
  126|      0|              return full_result(error_code::OUTPUT_BUFFER_TOO_SMALL, pos,
  127|      0|                                 utf8_output - start);
  128|      0|            }
  129|  6.11M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (129:30): [Folded, False: 6.11M]
  ------------------
  130|  6.11M|                                 ? char(u16_swap_bytes(data[pos]))
  131|  6.11M|                                 : char(data[pos]);
  132|  6.11M|            pos++;
  133|  6.11M|          }
  134|  1.52M|          continue;
  135|  1.52M|        }
  136|  5.76M|      }
  137|  5.76M|    }
  138|       |
  139|  4.23M|    uint16_t word =
  140|  4.23M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (140:9): [Folded, False: 4.23M]
  ------------------
  141|  4.23M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (141:9): [True: 234k, False: 4.00M]
  ------------------
  142|       |      // will generate one UTF-8 bytes
  143|   234k|      if (check_output && size_t(end - utf8_output) < 1) {
  ------------------
  |  Branch (143:11): [Folded, False: 234k]
  |  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|   234k|      *utf8_output++ = char(word);
  148|   234k|      pos++;
  149|  4.00M|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (149:16): [True: 1.15M, False: 2.85M]
  ------------------
  150|       |      // will generate two UTF-8 bytes
  151|       |      // we have 0b110XXXXX 0b10XXXXXX
  152|  1.15M|      if (check_output && size_t(end - utf8_output) < 2) {
  ------------------
  |  Branch (152:11): [Folded, False: 1.15M]
  |  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.15M|      *utf8_output++ = char((word >> 6) | 0b11000000);
  157|  1.15M|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  158|  1.15M|      pos++;
  159|       |
  160|  2.85M|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (160:16): [True: 2.84M, False: 5.18k]
  ------------------
  161|       |      // will generate three UTF-8 bytes
  162|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
  163|  2.84M|      if (check_output && size_t(end - utf8_output) < 3) {
  ------------------
  |  Branch (163:11): [Folded, False: 2.84M]
  |  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.84M|      *utf8_output++ = char((word >> 12) | 0b11100000);
  168|  2.84M|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  169|  2.84M|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  170|  2.84M|      pos++;
  171|  2.84M|    } else {
  172|       |
  173|  5.18k|      if (check_output && size_t(end - utf8_output) < 4) {
  ------------------
  |  Branch (173:11): [Folded, False: 5.18k]
  |  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|  5.18k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (178:11): [True: 84, False: 5.09k]
  ------------------
  179|     84|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  180|     84|      }
  181|  5.09k|      uint16_t diff = uint16_t(word - 0xD800);
  182|  5.09k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (182:11): [True: 148, False: 4.94k]
  ------------------
  183|    148|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  184|    148|      }
  185|  4.94k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (185:28): [Folded, False: 4.94k]
  ------------------
  186|  4.94k|                               ? u16_swap_bytes(data[pos + 1])
  187|  4.94k|                               : data[pos + 1];
  188|  4.94k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
  189|  4.94k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (189:11): [True: 210, False: 4.73k]
  ------------------
  190|    210|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  191|    210|      }
  192|  4.73k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
  193|       |      // will generate four UTF-8 bytes
  194|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
  195|  4.73k|      *utf8_output++ = char((value >> 18) | 0b11110000);
  196|  4.73k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  197|  4.73k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  198|  4.73k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
  199|  4.73k|      pos += 2;
  200|  4.73k|    }
  201|  4.23M|  }
  202|  1.24k|  return full_result(error_code::SUCCESS, pos, utf8_output - start);
  203|  1.68k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf819convert_with_errorsILNS_10endiannessE1ELb0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT1_Esr7simdutf6detailE26index_assignable_from_charIT2_EEENS_11full_resultES8_mS9_m:
  101|  1.60k|                                                    size_t utf8_len = 0) {
  102|  1.60k|  if (check_output && utf8_len == 0) {
  ------------------
  |  Branch (102:7): [Folded, False: 1.60k]
  |  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.60k|  size_t pos = 0;
  107|  1.60k|  auto start = utf8_output;
  108|  1.60k|  auto end = utf8_output + utf8_len;
  109|       |
  110|  3.47M|  while (pos < len) {
  ------------------
  |  Branch (110:10): [True: 3.46M, False: 1.13k]
  ------------------
  111|       |#if SIMDUTF_CPLUSPLUS23
  112|       |    if !consteval
  113|       |#endif
  114|  3.46M|    {
  115|       |      // try to convert the next block of 8 bytes
  116|  3.46M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (116:11): [True: 3.46M, False: 2.71k]
  ------------------
  117|       |                            // they are ascii
  118|  3.46M|        uint64_t v;
  119|  3.46M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
  120|       |        if constexpr (!match_system(big_endian))
  121|  3.46M|          v = (v >> 8) | (v << (64 - 8));
  122|  3.46M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (122:13): [True: 1.91M, False: 1.55M]
  ------------------
  123|  1.91M|          size_t final_pos = pos + 4;
  124|  9.57M|          while (pos < final_pos) {
  ------------------
  |  Branch (124:18): [True: 7.65M, False: 1.91M]
  ------------------
  125|  7.65M|            if (check_output && size_t(end - utf8_output) < 1) {
  ------------------
  |  Branch (125:17): [Folded, False: 7.65M]
  |  Branch (125:33): [True: 0, False: 0]
  ------------------
  126|      0|              return full_result(error_code::OUTPUT_BUFFER_TOO_SMALL, pos,
  127|      0|                                 utf8_output - start);
  128|      0|            }
  129|  7.65M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (129:30): [True: 7.65M, Folded]
  ------------------
  130|  7.65M|                                 ? char(u16_swap_bytes(data[pos]))
  131|  7.65M|                                 : char(data[pos]);
  132|  7.65M|            pos++;
  133|  7.65M|          }
  134|  1.91M|          continue;
  135|  1.91M|        }
  136|  3.46M|      }
  137|  3.46M|    }
  138|       |
  139|  1.55M|    uint16_t word =
  140|  1.55M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (140:9): [True: 1.55M, Folded]
  ------------------
  141|  1.55M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (141:9): [True: 271k, False: 1.28M]
  ------------------
  142|       |      // will generate one UTF-8 bytes
  143|   271k|      if (check_output && size_t(end - utf8_output) < 1) {
  ------------------
  |  Branch (143:11): [Folded, False: 271k]
  |  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|   271k|      *utf8_output++ = char(word);
  148|   271k|      pos++;
  149|  1.28M|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (149:16): [True: 128k, False: 1.15M]
  ------------------
  150|       |      // will generate two UTF-8 bytes
  151|       |      // we have 0b110XXXXX 0b10XXXXXX
  152|   128k|      if (check_output && size_t(end - utf8_output) < 2) {
  ------------------
  |  Branch (152:11): [Folded, False: 128k]
  |  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|   128k|      *utf8_output++ = char((word >> 6) | 0b11000000);
  157|   128k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  158|   128k|      pos++;
  159|       |
  160|  1.15M|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (160:16): [True: 1.14M, False: 7.83k]
  ------------------
  161|       |      // will generate three UTF-8 bytes
  162|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
  163|  1.14M|      if (check_output && size_t(end - utf8_output) < 3) {
  ------------------
  |  Branch (163:11): [Folded, False: 1.14M]
  |  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.14M|      *utf8_output++ = char((word >> 12) | 0b11100000);
  168|  1.14M|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  169|  1.14M|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  170|  1.14M|      pos++;
  171|  1.14M|    } else {
  172|       |
  173|  7.83k|      if (check_output && size_t(end - utf8_output) < 4) {
  ------------------
  |  Branch (173:11): [Folded, False: 7.83k]
  |  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|  7.83k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (178:11): [True: 66, False: 7.76k]
  ------------------
  179|     66|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  180|     66|      }
  181|  7.76k|      uint16_t diff = uint16_t(word - 0xD800);
  182|  7.76k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (182:11): [True: 180, False: 7.58k]
  ------------------
  183|    180|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  184|    180|      }
  185|  7.58k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (185:28): [True: 7.58k, Folded]
  ------------------
  186|  7.58k|                               ? u16_swap_bytes(data[pos + 1])
  187|  7.58k|                               : data[pos + 1];
  188|  7.58k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
  189|  7.58k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (189:11): [True: 228, False: 7.35k]
  ------------------
  190|    228|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  191|    228|      }
  192|  7.35k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
  193|       |      // will generate four UTF-8 bytes
  194|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
  195|  7.35k|      *utf8_output++ = char((value >> 18) | 0b11110000);
  196|  7.35k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  197|  7.35k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  198|  7.35k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
  199|  7.35k|      pos += 2;
  200|  7.35k|    }
  201|  1.55M|  }
  202|  1.13k|  return full_result(error_code::SUCCESS, pos, utf8_output - start);
  203|  1.60k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf813convert_validILNS_10endiannessE0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEEmS8_mS9_:
   17|    384|                                         OutputPtr utf8_output) {
   18|    384|  size_t pos = 0;
   19|    384|  auto start = utf8_output;
   20|  1.50M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 1.50M, False: 384]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  1.50M|    {
   25|       |      // try to convert the next block of 4 ASCII characters
   26|  1.50M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (26:11): [True: 1.50M, False: 786]
  ------------------
   27|       |                            // they are ascii
   28|  1.50M|        uint64_t v;
   29|  1.50M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   30|       |        if constexpr (!match_system(big_endian)) {
   31|       |          v = (v >> 8) | (v << (64 - 8));
   32|       |        }
   33|  1.50M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (33:13): [True: 1.17M, False: 334k]
  ------------------
   34|  1.17M|          size_t final_pos = pos + 4;
   35|  5.87M|          while (pos < final_pos) {
  ------------------
  |  Branch (35:18): [True: 4.69M, False: 1.17M]
  ------------------
   36|  4.69M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (36:30): [Folded, False: 4.69M]
  ------------------
   37|  4.69M|                                 ? char(u16_swap_bytes(data[pos]))
   38|  4.69M|                                 : char(data[pos]);
   39|  4.69M|            pos++;
   40|  4.69M|          }
   41|  1.17M|          continue;
   42|  1.17M|        }
   43|  1.50M|      }
   44|  1.50M|    }
   45|       |
   46|   334k|    uint16_t word =
   47|   334k|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (47:9): [Folded, False: 334k]
  ------------------
   48|   334k|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (48:9): [True: 152k, False: 182k]
  ------------------
   49|       |      // will generate one UTF-8 bytes
   50|   152k|      *utf8_output++ = char(word);
   51|   152k|      pos++;
   52|   182k|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (52:16): [True: 50.8k, False: 131k]
  ------------------
   53|       |      // will generate two UTF-8 bytes
   54|       |      // we have 0b110XXXXX 0b10XXXXXX
   55|  50.8k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   56|  50.8k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   57|  50.8k|      pos++;
   58|   131k|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (58:16): [True: 129k, False: 2.62k]
  ------------------
   59|       |      // will generate three UTF-8 bytes
   60|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   61|   129k|      *utf8_output++ = char((word >> 12) | 0b11100000);
   62|   129k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   63|   129k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   64|   129k|      pos++;
   65|   129k|    } else {
   66|       |      // must be a surrogate pair
   67|  2.62k|      uint16_t diff = uint16_t(word - 0xD800);
   68|  2.62k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (68:11): [True: 0, False: 2.62k]
  ------------------
   69|      0|        return 0;
   70|      0|      } // minimal bound checking
   71|  2.62k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (71:28): [Folded, False: 2.62k]
  ------------------
   72|  2.62k|                               ? u16_swap_bytes(data[pos + 1])
   73|  2.62k|                               : data[pos + 1];
   74|  2.62k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   75|  2.62k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   76|       |      // will generate four UTF-8 bytes
   77|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   78|  2.62k|      *utf8_output++ = char((value >> 18) | 0b11110000);
   79|  2.62k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
   80|  2.62k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
   81|  2.62k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
   82|  2.62k|      pos += 2;
   83|  2.62k|    }
   84|   334k|  }
   85|    384|  return utf8_output - start;
   86|    384|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf813convert_validILNS_10endiannessE1EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEEmS8_mS9_:
   17|    414|                                         OutputPtr utf8_output) {
   18|    414|  size_t pos = 0;
   19|    414|  auto start = utf8_output;
   20|  2.91M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 2.91M, False: 414]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  2.91M|    {
   25|       |      // try to convert the next block of 4 ASCII characters
   26|  2.91M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (26:11): [True: 2.91M, False: 858]
  ------------------
   27|       |                            // they are ascii
   28|  2.91M|        uint64_t v;
   29|  2.91M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   30|  2.91M|        if constexpr (!match_system(big_endian)) {
   31|  2.91M|          v = (v >> 8) | (v << (64 - 8));
   32|  2.91M|        }
   33|  2.91M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (33:13): [True: 1.77M, False: 1.13M]
  ------------------
   34|  1.77M|          size_t final_pos = pos + 4;
   35|  8.87M|          while (pos < final_pos) {
  ------------------
  |  Branch (35:18): [True: 7.10M, False: 1.77M]
  ------------------
   36|  7.10M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (36:30): [True: 7.10M, Folded]
  ------------------
   37|  7.10M|                                 ? char(u16_swap_bytes(data[pos]))
   38|  7.10M|                                 : char(data[pos]);
   39|  7.10M|            pos++;
   40|  7.10M|          }
   41|  1.77M|          continue;
   42|  1.77M|        }
   43|  2.91M|      }
   44|  2.91M|    }
   45|       |
   46|  1.13M|    uint16_t word =
   47|  1.13M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (47:9): [True: 1.13M, Folded]
  ------------------
   48|  1.13M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (48:9): [True: 266k, False: 869k]
  ------------------
   49|       |      // will generate one UTF-8 bytes
   50|   266k|      *utf8_output++ = char(word);
   51|   266k|      pos++;
   52|   869k|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (52:16): [True: 116k, False: 753k]
  ------------------
   53|       |      // will generate two UTF-8 bytes
   54|       |      // we have 0b110XXXXX 0b10XXXXXX
   55|   116k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   56|   116k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   57|   116k|      pos++;
   58|   753k|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (58:16): [True: 750k, False: 2.83k]
  ------------------
   59|       |      // will generate three UTF-8 bytes
   60|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   61|   750k|      *utf8_output++ = char((word >> 12) | 0b11100000);
   62|   750k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   63|   750k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   64|   750k|      pos++;
   65|   750k|    } else {
   66|       |      // must be a surrogate pair
   67|  2.83k|      uint16_t diff = uint16_t(word - 0xD800);
   68|  2.83k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (68:11): [True: 0, False: 2.83k]
  ------------------
   69|      0|        return 0;
   70|      0|      } // minimal bound checking
   71|  2.83k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (71:28): [True: 2.83k, Folded]
  ------------------
   72|  2.83k|                               ? u16_swap_bytes(data[pos + 1])
   73|  2.83k|                               : data[pos + 1];
   74|  2.83k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   75|  2.83k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   76|       |      // will generate four UTF-8 bytes
   77|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   78|  2.83k|      *utf8_output++ = char((value >> 18) | 0b11110000);
   79|  2.83k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
   80|  2.83k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
   81|  2.83k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
   82|  2.83k|      pos += 2;
   83|  2.83k|    }
   84|  1.13M|  }
   85|    414|  return utf8_output - start;
   86|    414|}

_ZN7simdutf6scalar5utf328validateEPKDim:
   25|  5.57k|                                                        size_t len) noexcept {
   26|  5.57k|  return validate(reinterpret_cast<const uint32_t *>(buf), len);
   27|  5.57k|}
_ZN7simdutf6scalar5utf3220validate_with_errorsEPKDim:
   49|  7.66k|validate_with_errors(const char32_t *buf, size_t len) noexcept {
   50|  7.66k|  return validate_with_errors(reinterpret_cast<const uint32_t *>(buf), len);
   51|  7.66k|}
_ZN7simdutf6scalar5utf3222utf8_length_from_utf32EPKDim:
   54|  2.71k|                                                         size_t len) {
   55|       |  // We are not BOM aware.
   56|  2.71k|  size_t counter{0};
   57|  2.46M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (57:22): [True: 2.46M, False: 2.71k]
  ------------------
   58|       |    // credit: @ttsugriy  for the vectorizable approach
   59|  2.46M|    counter++;                                     // ASCII
   60|  2.46M|    counter += static_cast<size_t>(p[i] > 0x7F);   // two-byte
   61|  2.46M|    counter += static_cast<size_t>(p[i] > 0x7FF);  // three-byte
   62|  2.46M|    counter += static_cast<size_t>(p[i] > 0xFFFF); // four-bytes
   63|  2.46M|  }
   64|  2.71k|  return counter;
   65|  2.71k|}
_ZN7simdutf6scalar5utf3223utf16_length_from_utf32EPKDim:
   68|  4.01k|utf16_length_from_utf32(const char32_t *p, size_t len) {
   69|       |  // We are not BOM aware.
   70|  4.01k|  size_t counter{0};
   71|  4.24M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (71:22): [True: 4.24M, False: 4.01k]
  ------------------
   72|  4.24M|    counter++;                                     // non-surrogate word
   73|  4.24M|    counter += static_cast<size_t>(p[i] > 0xFFFF); // surrogate pair
   74|  4.24M|  }
   75|  4.01k|  return counter;
   76|  4.01k|}
_ZN7simdutf6scalar5utf328validateIPKjQsr7simdutf6detailE19indexes_into_uint32IT_EEEbS5_m:
   13|  5.57k|                                                      size_t len) noexcept {
   14|  5.57k|  uint64_t pos = 0;
   15|  1.11M|  for (; pos < len; pos++) {
  ------------------
  |  Branch (15:10): [True: 1.10M, False: 2.43k]
  ------------------
   16|  1.10M|    uint32_t word = data[pos];
   17|  1.10M|    if (word > 0x10FFFF || (word >= 0xD800 && word <= 0xDFFF)) {
  ------------------
  |  Branch (17:9): [True: 2.67k, False: 1.10M]
  |  Branch (17:29): [True: 33.9k, False: 1.07M]
  |  Branch (17:47): [True: 459, False: 33.4k]
  ------------------
   18|  3.13k|      return false;
   19|  3.13k|    }
   20|  1.10M|  }
   21|  2.43k|  return true;
   22|  5.57k|}
_ZN7simdutf6scalar5utf3220validate_with_errorsIPKjQsr7simdutf6detailE19indexes_into_uint32IT_EEENS_6resultES5_m:
   34|  7.66k|validate_with_errors(InputPtr data, size_t len) noexcept {
   35|  7.66k|  size_t pos = 0;
   36|  1.11M|  for (; pos < len; pos++) {
  ------------------
  |  Branch (36:10): [True: 1.11M, False: 2.43k]
  ------------------
   37|  1.11M|    uint32_t word = data[pos];
   38|  1.11M|    if (word > 0x10FFFF) {
  ------------------
  |  Branch (38:9): [True: 4.38k, False: 1.10M]
  ------------------
   39|  4.38k|      return result(error_code::TOO_LARGE, pos);
   40|  4.38k|    }
   41|  1.10M|    if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (41:9): [True: 35.3k, False: 1.07M]
  |  Branch (41:27): [True: 849, False: 34.4k]
  ------------------
   42|    849|      return result(error_code::SURROGATE, pos);
   43|    849|    }
   44|  1.10M|  }
   45|  2.43k|  return result(error_code::SUCCESS, pos);
   46|  7.66k|}

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

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf167convertILNS_10endiannessE0EEEmPKDimPDs:
   11|  1.68k|                                   char16_t *utf16_output) {
   12|  1.68k|  size_t pos = 0;
   13|  1.68k|  char16_t *start{utf16_output};
   14|   495k|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 494k, False: 874]
  ------------------
   15|   494k|    uint32_t word = data[pos];
   16|   494k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (16:9): [True: 479k, False: 15.2k]
  ------------------
   17|   479k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (17:11): [True: 1.66k, False: 478k]
  |  Branch (17:29): [True: 176, False: 1.48k]
  ------------------
   18|    176|        return 0;
   19|    176|      }
   20|       |      // will not generate a surrogate pair
   21|   479k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (21:25): [Folded, False: 479k]
  ------------------
   22|   479k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   23|   479k|                            : char16_t(word);
   24|   479k|    } else {
   25|       |      // will generate a surrogate pair
   26|  15.2k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (26:11): [True: 636, False: 14.5k]
  ------------------
   27|    636|        return 0;
   28|    636|      }
   29|  14.5k|      word -= 0x10000;
   30|  14.5k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   31|  14.5k|      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|  14.5k|      *utf16_output++ = char16_t(high_surrogate);
   37|  14.5k|      *utf16_output++ = char16_t(low_surrogate);
   38|  14.5k|    }
   39|   494k|    pos++;
   40|   494k|  }
   41|    874|  return utf16_output - start;
   42|  1.68k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf167convertILNS_10endiannessE1EEEmPKDimPDs:
   11|  1.32k|                                   char16_t *utf16_output) {
   12|  1.32k|  size_t pos = 0;
   13|  1.32k|  char16_t *start{utf16_output};
   14|  39.2k|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 38.5k, False: 630]
  ------------------
   15|  38.5k|    uint32_t word = data[pos];
   16|  38.5k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (16:9): [True: 33.4k, False: 5.12k]
  ------------------
   17|  33.4k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (17:11): [True: 1.02k, False: 32.4k]
  |  Branch (17:29): [True: 94, False: 926]
  ------------------
   18|     94|        return 0;
   19|     94|      }
   20|       |      // will not generate a surrogate pair
   21|  33.3k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (21:25): [True: 33.3k, Folded]
  ------------------
   22|  33.3k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   23|  33.3k|                            : char16_t(word);
   24|  33.3k|    } else {
   25|       |      // will generate a surrogate pair
   26|  5.12k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (26:11): [True: 598, False: 4.52k]
  ------------------
   27|    598|        return 0;
   28|    598|      }
   29|  4.52k|      word -= 0x10000;
   30|  4.52k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   31|  4.52k|      uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   32|  4.52k|      if constexpr (!match_system(big_endian)) {
   33|  4.52k|        high_surrogate = u16_swap_bytes(high_surrogate);
   34|  4.52k|        low_surrogate = u16_swap_bytes(low_surrogate);
   35|  4.52k|      }
   36|  4.52k|      *utf16_output++ = char16_t(high_surrogate);
   37|  4.52k|      *utf16_output++ = char16_t(low_surrogate);
   38|  4.52k|    }
   39|  37.8k|    pos++;
   40|  37.8k|  }
   41|    630|  return utf16_output - start;
   42|  1.32k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf1619convert_with_errorsILNS_10endiannessE0EEENS_6resultEPKDimPDs:
   46|  2.11k|                                               char16_t *utf16_output) {
   47|  2.11k|  size_t pos = 0;
   48|  2.11k|  char16_t *start{utf16_output};
   49|  75.6k|  while (pos < len) {
  ------------------
  |  Branch (49:10): [True: 75.1k, False: 504]
  ------------------
   50|  75.1k|    uint32_t word = data[pos];
   51|  75.1k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (51:9): [True: 66.6k, False: 8.55k]
  ------------------
   52|  66.6k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (52:11): [True: 1.75k, False: 64.8k]
  |  Branch (52:29): [True: 330, False: 1.42k]
  ------------------
   53|    330|        return result(error_code::SURROGATE, pos);
   54|    330|      }
   55|       |      // will not generate a surrogate pair
   56|  66.2k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (56:25): [Folded, False: 66.2k]
  ------------------
   57|  66.2k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   58|  66.2k|                            : char16_t(word);
   59|  66.2k|    } else {
   60|       |      // will generate a surrogate pair
   61|  8.55k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (61:11): [True: 1.27k, False: 7.27k]
  ------------------
   62|  1.27k|        return result(error_code::TOO_LARGE, pos);
   63|  1.27k|      }
   64|  7.27k|      word -= 0x10000;
   65|  7.27k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   66|  7.27k|      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.27k|      *utf16_output++ = char16_t(high_surrogate);
   72|  7.27k|      *utf16_output++ = char16_t(low_surrogate);
   73|  7.27k|    }
   74|  73.5k|    pos++;
   75|  73.5k|  }
   76|    504|  return result(error_code::SUCCESS, utf16_output - start);
   77|  2.11k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf1619convert_with_errorsILNS_10endiannessE1EEENS_6resultEPKDimPDs:
   46|  1.95k|                                               char16_t *utf16_output) {
   47|  1.95k|  size_t pos = 0;
   48|  1.95k|  char16_t *start{utf16_output};
   49|  82.6k|  while (pos < len) {
  ------------------
  |  Branch (49:10): [True: 82.1k, False: 520]
  ------------------
   50|  82.1k|    uint32_t word = data[pos];
   51|  82.1k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (51:9): [True: 78.1k, False: 4.01k]
  ------------------
   52|  78.1k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (52:11): [True: 1.71k, False: 76.3k]
  |  Branch (52:29): [True: 252, False: 1.46k]
  ------------------
   53|    252|        return result(error_code::SURROGATE, pos);
   54|    252|      }
   55|       |      // will not generate a surrogate pair
   56|  77.8k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (56:25): [True: 77.8k, Folded]
  ------------------
   57|  77.8k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   58|  77.8k|                            : char16_t(word);
   59|  77.8k|    } else {
   60|       |      // will generate a surrogate pair
   61|  4.01k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (61:11): [True: 1.18k, False: 2.82k]
  ------------------
   62|  1.18k|        return result(error_code::TOO_LARGE, pos);
   63|  1.18k|      }
   64|  2.82k|      word -= 0x10000;
   65|  2.82k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   66|  2.82k|      uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   67|  2.82k|      if constexpr (!match_system(big_endian)) {
   68|  2.82k|        high_surrogate = u16_swap_bytes(high_surrogate);
   69|  2.82k|        low_surrogate = u16_swap_bytes(low_surrogate);
   70|  2.82k|      }
   71|  2.82k|      *utf16_output++ = char16_t(high_surrogate);
   72|  2.82k|      *utf16_output++ = char16_t(low_surrogate);
   73|  2.82k|    }
   74|  80.6k|    pos++;
   75|  80.6k|  }
   76|    520|  return result(error_code::SUCCESS, utf16_output - start);
   77|  1.95k|}

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

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf32_to_utf87convertIPKDiPcQaasr7simdutf6detailE18indexes_into_utf32IT_Esr7simdutf6detailE26index_assignable_from_charIT0_EEEmS7_mS8_:
   17|  1.83k|                                   OutputPtr utf8_output) {
   18|  1.83k|  size_t pos = 0;
   19|  1.83k|  auto start = utf8_output;
   20|  81.8k|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 81.1k, False: 694]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  81.1k|    { // try to convert the next block of 2 ASCII characters
   25|  81.1k|      if (pos + 2 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 80.2k, False: 938]
  ------------------
   26|       |                            // they are ascii
   27|  80.2k|        uint64_t v;
   28|  80.2k|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   29|  80.2k|        if ((v & 0xFFFFFF80FFFFFF80) == 0) {
  ------------------
  |  Branch (29:13): [True: 54.1k, False: 26.0k]
  ------------------
   30|  54.1k|          *utf8_output++ = char(data[pos]);
   31|  54.1k|          *utf8_output++ = char(data[pos + 1]);
   32|  54.1k|          pos += 2;
   33|  54.1k|          continue;
   34|  54.1k|        }
   35|  80.2k|      }
   36|  81.1k|    }
   37|       |
   38|  26.9k|    uint32_t word = data[pos];
   39|  26.9k|    if ((word & 0xFFFFFF80) == 0) {
  ------------------
  |  Branch (39:9): [True: 3.43k, False: 23.5k]
  ------------------
   40|       |      // will generate one UTF-8 bytes
   41|  3.43k|      *utf8_output++ = char(word);
   42|  3.43k|      pos++;
   43|  23.5k|    } else if ((word & 0xFFFFF800) == 0) {
  ------------------
  |  Branch (43:16): [True: 9.70k, False: 13.8k]
  ------------------
   44|       |      // will generate two UTF-8 bytes
   45|       |      // we have 0b110XXXXX 0b10XXXXXX
   46|  9.70k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   47|  9.70k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   48|  9.70k|      pos++;
   49|  13.8k|    } else if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (49:16): [True: 8.89k, False: 4.95k]
  ------------------
   50|       |      // will generate three UTF-8 bytes
   51|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   52|  8.89k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (52:11): [True: 6.27k, False: 2.62k]
  |  Branch (52:29): [True: 192, False: 6.07k]
  ------------------
   53|    192|        return 0;
   54|    192|      }
   55|  8.70k|      *utf8_output++ = char((word >> 12) | 0b11100000);
   56|  8.70k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   57|  8.70k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   58|  8.70k|      pos++;
   59|  8.70k|    } else {
   60|       |      // will generate four UTF-8 bytes
   61|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   62|  4.95k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (62:11): [True: 944, False: 4.01k]
  ------------------
   63|    944|        return 0;
   64|    944|      }
   65|  4.01k|      *utf8_output++ = char((word >> 18) | 0b11110000);
   66|  4.01k|      *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000);
   67|  4.01k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   68|  4.01k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   69|  4.01k|      pos++;
   70|  4.01k|    }
   71|  26.9k|  }
   72|    694|  return utf8_output - start;
   73|  1.83k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf32_to_utf819convert_with_errorsIPKDiPcQaasr7simdutf6detailE18indexes_into_utf32IT_Esr7simdutf6detailE26index_assignable_from_charIT0_EEENS_6resultES7_mS8_:
   81|  2.76k|                                               OutputPtr utf8_output) {
   82|  2.76k|  size_t pos = 0;
   83|  2.76k|  auto start = utf8_output;
   84|   273k|  while (pos < len) {
  ------------------
  |  Branch (84:10): [True: 272k, False: 694]
  ------------------
   85|       |#if SIMDUTF_CPLUSPLUS23
   86|       |    if !consteval
   87|       |#endif
   88|   272k|    { // try to convert the next block of 2 ASCII characters
   89|   272k|      if (pos + 2 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (89:11): [True: 271k, False: 1.10k]
  ------------------
   90|       |                            // they are ascii
   91|   271k|        uint64_t v;
   92|   271k|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   93|   271k|        if ((v & 0xFFFFFF80FFFFFF80) == 0) {
  ------------------
  |  Branch (93:13): [True: 217k, False: 54.1k]
  ------------------
   94|   217k|          *utf8_output++ = char(data[pos]);
   95|   217k|          *utf8_output++ = char(data[pos + 1]);
   96|   217k|          pos += 2;
   97|   217k|          continue;
   98|   217k|        }
   99|   271k|      }
  100|   272k|    }
  101|       |
  102|  55.2k|    uint32_t word = data[pos];
  103|  55.2k|    if ((word & 0xFFFFFF80) == 0) {
  ------------------
  |  Branch (103:9): [True: 5.58k, False: 49.6k]
  ------------------
  104|       |      // will generate one UTF-8 bytes
  105|  5.58k|      *utf8_output++ = char(word);
  106|  5.58k|      pos++;
  107|  49.6k|    } else if ((word & 0xFFFFF800) == 0) {
  ------------------
  |  Branch (107:16): [True: 28.5k, False: 21.1k]
  ------------------
  108|       |      // will generate two UTF-8 bytes
  109|       |      // we have 0b110XXXXX 0b10XXXXXX
  110|  28.5k|      *utf8_output++ = char((word >> 6) | 0b11000000);
  111|  28.5k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  112|  28.5k|      pos++;
  113|  28.5k|    } else if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (113:16): [True: 9.40k, False: 11.7k]
  ------------------
  114|       |      // will generate three UTF-8 bytes
  115|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
  116|  9.40k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (116:11): [True: 6.20k, False: 3.20k]
  |  Branch (116:29): [True: 342, False: 5.85k]
  ------------------
  117|    342|        return result(error_code::SURROGATE, pos);
  118|    342|      }
  119|  9.05k|      *utf8_output++ = char((word >> 12) | 0b11100000);
  120|  9.05k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  121|  9.05k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  122|  9.05k|      pos++;
  123|  11.7k|    } else {
  124|       |      // will generate four UTF-8 bytes
  125|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
  126|  11.7k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (126:11): [True: 1.72k, False: 10.0k]
  ------------------
  127|  1.72k|        return result(error_code::TOO_LARGE, pos);
  128|  1.72k|      }
  129|  10.0k|      *utf8_output++ = char((word >> 18) | 0b11110000);
  130|  10.0k|      *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000);
  131|  10.0k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  132|  10.0k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  133|  10.0k|      pos++;
  134|  10.0k|    }
  135|  55.2k|  }
  136|    694|  return result(error_code::SUCCESS, utf8_output - start);
  137|  2.76k|}

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

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

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf8_to_latin130rewind_and_convert_with_errorsEmPKcmPc:
  176|  1.03k|                                             char *latin1_output) {
  177|  1.03k|  size_t extra_len{0};
  178|       |  // We potentially need to go back in time and find a leading byte.
  179|       |  // In theory '3' would be sufficient, but sometimes the error can go back
  180|       |  // quite far.
  181|  1.03k|  size_t how_far_back = prior_bytes;
  182|       |  // size_t how_far_back = 3; // 3 bytes in the past + current position
  183|       |  // if(how_far_back >= prior_bytes) { how_far_back = prior_bytes; }
  184|  1.03k|  bool found_leading_bytes{false};
  185|       |  // important: it is i <= how_far_back and not 'i < how_far_back'.
  186|  1.13k|  for (size_t i = 0; i <= how_far_back; i++) {
  ------------------
  |  Branch (186:22): [True: 1.04k, False: 92]
  ------------------
  187|  1.04k|    unsigned char byte = buf[-static_cast<std::ptrdiff_t>(i)];
  188|  1.04k|    found_leading_bytes = ((byte & 0b11000000) != 0b10000000);
  189|  1.04k|    if (found_leading_bytes) {
  ------------------
  |  Branch (189:9): [True: 944, False: 96]
  ------------------
  190|    944|      if (i > 0 && byte < 128) {
  ------------------
  |  Branch (190:11): [True: 4, False: 940]
  |  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|    940|      buf -= i;
  196|    940|      extra_len = i;
  197|    940|      break;
  198|    944|    }
  199|  1.04k|  }
  200|       |  //
  201|       |  // It is possible for this function to return a negative count in its result.
  202|       |  // C++ Standard Section 18.1 defines size_t is in <cstddef> which is described
  203|       |  // in C Standard as <stddef.h>. C Standard Section 4.1.5 defines size_t as an
  204|       |  // unsigned integral type of the result of the sizeof operator
  205|       |  //
  206|       |  // An unsigned type will simply wrap round arithmetically (well defined).
  207|       |  //
  208|  1.03k|  if (!found_leading_bytes) {
  ------------------
  |  Branch (208:7): [True: 92, False: 940]
  ------------------
  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|     92|    return result(error_code::TOO_LONG, 0 - how_far_back);
  214|     92|  }
  215|    940|  result res = convert_with_errors(buf, len + extra_len, latin1_output);
  216|    940|  if (res.error) {
  ------------------
  |  Branch (216:7): [True: 528, False: 412]
  ------------------
  217|    528|    res.count -= extra_len;
  218|    528|  }
  219|    940|  return res;
  220|  1.03k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf8_to_latin119convert_with_errorsIPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEENS_6resultES6_mPc:
   92|  1.46k|                                               char *latin_output) {
   93|  1.46k|  size_t pos = 0;
   94|  1.46k|  char *start{latin_output};
   95|       |
   96|  1.73M|  while (pos < len) {
  ------------------
  |  Branch (96:10): [True: 1.73M, False: 622]
  ------------------
   97|       |#if SIMDUTF_CPLUSPLUS23
   98|       |    if !consteval
   99|       |#endif
  100|  1.73M|    {
  101|       |      // try to convert the next block of 16 ASCII bytes
  102|  1.73M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (102:11): [True: 1.72M, False: 6.43k]
  ------------------
  103|       |                             // they are ascii
  104|  1.72M|        uint64_t v1;
  105|  1.72M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
  106|  1.72M|        uint64_t v2;
  107|  1.72M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  108|  1.72M|        uint64_t v{v1 | v2}; // We are only interested in these bits: 1000 1000
  109|       |                             // 1000 1000...etc
  110|  1.72M|        if ((v & 0x8080808080808080) ==
  ------------------
  |  Branch (110:13): [True: 1.38M, False: 344k]
  ------------------
  111|  1.72M|            0) { // if NONE of these are set, e.g. all of them are zero, then
  112|       |                 // everything is ASCII
  113|  1.38M|          size_t final_pos = pos + 16;
  114|  23.4M|          while (pos < final_pos) {
  ------------------
  |  Branch (114:18): [True: 22.1M, False: 1.38M]
  ------------------
  115|  22.1M|            *latin_output++ = char(data[pos]);
  116|  22.1M|            pos++;
  117|  22.1M|          }
  118|  1.38M|          continue;
  119|  1.38M|        }
  120|  1.72M|      }
  121|  1.73M|    }
  122|       |    // suppose it is not an all ASCII byte sequence
  123|   351k|    uint8_t leading_byte = data[pos]; // leading byte
  124|   351k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (124:9): [True: 307k, False: 43.6k]
  ------------------
  125|       |      // converting one ASCII byte !!!
  126|   307k|      *latin_output++ = char(leading_byte);
  127|   307k|      pos++;
  128|   307k|    } else if ((leading_byte & 0b11100000) ==
  ------------------
  |  Branch (128:16): [True: 43.1k, False: 516]
  ------------------
  129|  43.6k|               0b11000000) { // the first three bits indicate:
  130|       |      // We have a two-byte UTF-8
  131|  43.1k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (131:11): [True: 48, False: 43.0k]
  ------------------
  132|     48|        return result(error_code::TOO_SHORT, pos);
  133|     48|      } // minimal bound checking
  134|  43.0k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (134:11): [True: 216, False: 42.8k]
  ------------------
  135|    216|        return result(error_code::TOO_SHORT, pos);
  136|    216|      } // 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|  42.8k|      uint32_t code_point =
  140|  42.8k|          (leading_byte & 0b00011111) << 6 |
  141|  42.8k|          (data[pos + 1] &
  142|  42.8k|           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|  42.8k|      if (code_point < 0x80) {
  ------------------
  |  Branch (147:11): [True: 12, False: 42.8k]
  ------------------
  148|     12|        return result(error_code::OVERLONG, pos);
  149|     12|      }
  150|  42.8k|      if (0xFF < code_point) {
  ------------------
  |  Branch (150:11): [True: 48, False: 42.7k]
  ------------------
  151|     48|        return result(error_code::TOO_LARGE, pos);
  152|     48|      } // We only care about the range 129-255 which is Non-ASCII latin1
  153|       |        // characters
  154|  42.7k|      *latin_output++ = char(code_point);
  155|  42.7k|      pos += 2;
  156|  42.7k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (156:16): [True: 84, False: 432]
  ------------------
  157|       |      // We have a three-byte UTF-8
  158|     84|      return result(error_code::TOO_LARGE, pos);
  159|    432|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (159:16): [True: 72, False: 360]
  ------------------
  160|       |      // we have a 4-byte UTF-8 word.
  161|     72|      return result(error_code::TOO_LARGE, pos);
  162|    360|    } else {
  163|       |      // we either have too many continuation bytes or an invalid leading byte
  164|    360|      if ((leading_byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (164:11): [True: 144, False: 216]
  ------------------
  165|    144|        return result(error_code::TOO_LONG, pos);
  166|    144|      }
  167|       |
  168|    216|      return result(error_code::HEADER_BITS, pos);
  169|    360|    }
  170|   351k|  }
  171|    622|  return result(error_code::SUCCESS, latin_output - start);
  172|  1.46k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf8_to_latin17convertIPKcPcQaasr7simdutf6detailE22indexes_into_byte_likeIT_Esr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mS8_:
   17|  1.28k|                                   OutputPtr latin_output) {
   18|  1.28k|  size_t pos = 0;
   19|  1.28k|  auto start = latin_output;
   20|       |
   21|  1.59M|  while (pos < len) {
  ------------------
  |  Branch (21:10): [True: 1.59M, False: 556]
  ------------------
   22|       |#if SIMDUTF_CPLUSPLUS23
   23|       |    if !consteval
   24|       |#endif
   25|  1.59M|    {
   26|       |      // try to convert the next block of 16 ASCII bytes
   27|  1.59M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (27:11): [True: 1.58M, False: 4.47k]
  ------------------
   28|       |                             // they are ascii
   29|  1.58M|        uint64_t v1;
   30|  1.58M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   31|  1.58M|        uint64_t v2;
   32|  1.58M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   33|  1.58M|        uint64_t v{v1 | v2}; // We are only interested in these bits: 1000 1000
   34|       |                             // 1000 1000 .... etc
   35|  1.58M|        if ((v & 0x8080808080808080) ==
  ------------------
  |  Branch (35:13): [True: 1.44M, False: 138k]
  ------------------
   36|  1.58M|            0) { // if NONE of these are set, e.g. all of them are zero, then
   37|       |                 // everything is ASCII
   38|  1.44M|          size_t final_pos = pos + 16;
   39|  24.5M|          while (pos < final_pos) {
  ------------------
  |  Branch (39:18): [True: 23.1M, False: 1.44M]
  ------------------
   40|  23.1M|            *latin_output++ = char(data[pos]);
   41|  23.1M|            pos++;
   42|  23.1M|          }
   43|  1.44M|          continue;
   44|  1.44M|        }
   45|  1.58M|      }
   46|  1.59M|    }
   47|       |
   48|       |    // suppose it is not an all ASCII byte sequence
   49|   143k|    uint8_t leading_byte = data[pos]; // leading byte
   50|   143k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (50:9): [True: 125k, False: 17.4k]
  ------------------
   51|       |      // converting one ASCII byte !!!
   52|   125k|      *latin_output++ = char(leading_byte);
   53|   125k|      pos++;
   54|   125k|    } else if ((leading_byte & 0b11100000) ==
  ------------------
  |  Branch (54:16): [True: 16.9k, False: 498]
  ------------------
   55|  17.4k|               0b11000000) { // the first three bits indicate:
   56|       |      // We have a two-byte UTF-8
   57|  16.9k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (57:11): [True: 60, False: 16.8k]
  ------------------
   58|     60|        return 0;
   59|     60|      } // minimal bound checking
   60|  16.8k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (60:11): [True: 104, False: 16.7k]
  ------------------
   61|    104|        return 0;
   62|    104|      } // 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|  16.7k|      uint32_t code_point =
   66|  16.7k|          (leading_byte & 0b00011111) << 6 |
   67|  16.7k|          (data[pos + 1] &
   68|  16.7k|           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|  16.7k|      if (code_point < 0x80 || 0xFF < code_point) {
  ------------------
  |  Branch (73:11): [True: 14, False: 16.7k]
  |  Branch (73:32): [True: 56, False: 16.7k]
  ------------------
   74|     70|        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|     70|      }
   78|  16.7k|      *latin_output++ = char(code_point);
   79|  16.7k|      pos += 2;
   80|  16.7k|    } else {
   81|    498|      return 0;
   82|    498|    }
   83|   143k|  }
   84|    556|  return latin_output - start;
   85|  1.28k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf167convertILNS_10endiannessE0EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mPDs:
   16|  1.70k|                                   char16_t *utf16_output) {
   17|  1.70k|  size_t pos = 0;
   18|  1.70k|  char16_t *start{utf16_output};
   19|  2.16M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 2.16M, False: 740]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|       |    // try to convert the next block of 16 ASCII bytes
   24|  2.16M|    {
   25|  2.16M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 2.16M, False: 5.06k]
  ------------------
   26|       |                             // they are ascii
   27|  2.16M|        uint64_t v1;
   28|  2.16M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   29|  2.16M|        uint64_t v2;
   30|  2.16M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   31|  2.16M|        uint64_t v{v1 | v2};
   32|  2.16M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (32:13): [True: 1.17M, False: 984k]
  ------------------
   33|  1.17M|          size_t final_pos = pos + 16;
   34|  20.0M|          while (pos < final_pos) {
  ------------------
  |  Branch (34:18): [True: 18.8M, False: 1.17M]
  ------------------
   35|  18.8M|            *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (35:31): [Folded, False: 18.8M]
  ------------------
   36|  18.8M|                                  ? char16_t(u16_swap_bytes(data[pos]))
   37|  18.8M|                                  : char16_t(data[pos]);
   38|  18.8M|            pos++;
   39|  18.8M|          }
   40|  1.17M|          continue;
   41|  1.17M|        }
   42|  2.16M|      }
   43|  2.16M|    }
   44|       |
   45|   989k|    uint8_t leading_byte = data[pos]; // leading byte
   46|   989k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (46:9): [True: 805k, False: 183k]
  ------------------
   47|       |      // converting one ASCII byte !!!
   48|   805k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (48:25): [Folded, False: 805k]
  ------------------
   49|   805k|                            ? char16_t(u16_swap_bytes(leading_byte))
   50|   805k|                            : char16_t(leading_byte);
   51|   805k|      pos++;
   52|   805k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (52:16): [True: 110k, False: 73.0k]
  ------------------
   53|       |      // We have a two-byte UTF-8, it should become
   54|       |      // a single UTF-16 word.
   55|   110k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (55:11): [True: 42, False: 110k]
  ------------------
   56|     42|        return 0;
   57|     42|      } // minimal bound checking
   58|   110k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (58:11): [True: 92, False: 110k]
  ------------------
   59|     92|        return 0;
   60|     92|      }
   61|       |      // range check
   62|   110k|      uint32_t code_point =
   63|   110k|          (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
   64|   110k|      if (code_point < 0x80) {
  ------------------
  |  Branch (64:11): [True: 18, False: 110k]
  ------------------
   65|     18|        return 0;
   66|     18|      }
   67|       |      if constexpr (!match_system(big_endian)) {
   68|       |        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
   69|       |      }
   70|   110k|      *utf16_output++ = char16_t(code_point);
   71|   110k|      pos += 2;
   72|   110k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (72:16): [True: 64.4k, False: 8.57k]
  ------------------
   73|       |      // We have a three-byte UTF-8, it should become
   74|       |      // a single UTF-16 word.
   75|  64.4k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (75:11): [True: 36, False: 64.4k]
  ------------------
   76|     36|        return 0;
   77|     36|      } // minimal bound checking
   78|       |
   79|  64.4k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (79:11): [True: 50, False: 64.3k]
  ------------------
   80|     50|        return 0;
   81|     50|      }
   82|  64.3k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (82:11): [True: 52, False: 64.3k]
  ------------------
   83|     52|        return 0;
   84|     52|      }
   85|       |      // range check
   86|  64.3k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
   87|  64.3k|                            (data[pos + 1] & 0b00111111) << 6 |
   88|  64.3k|                            (data[pos + 2] & 0b00111111);
   89|  64.3k|      if (code_point < 0x800 || (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (89:11): [True: 54, False: 64.2k]
  |  Branch (89:34): [True: 740, False: 63.5k]
  |  Branch (89:57): [True: 10, False: 730]
  ------------------
   90|     64|        return 0;
   91|     64|      }
   92|       |      if constexpr (!match_system(big_endian)) {
   93|       |        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
   94|       |      }
   95|  64.2k|      *utf16_output++ = char16_t(code_point);
   96|  64.2k|      pos += 3;
   97|  64.2k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (97:16): [True: 8.16k, False: 408]
  ------------------
   98|       |      // we have a 4-byte UTF-8 word.
   99|  8.16k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (99:11): [True: 30, False: 8.13k]
  ------------------
  100|     30|        return 0;
  101|     30|      } // minimal bound checking
  102|  8.13k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (102:11): [True: 58, False: 8.07k]
  ------------------
  103|     58|        return 0;
  104|     58|      }
  105|  8.07k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (105:11): [True: 18, False: 8.05k]
  ------------------
  106|     18|        return 0;
  107|     18|      }
  108|  8.05k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (108:11): [True: 36, False: 8.02k]
  ------------------
  109|     36|        return 0;
  110|     36|      }
  111|       |
  112|       |      // range check
  113|  8.02k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  114|  8.02k|                            (data[pos + 1] & 0b00111111) << 12 |
  115|  8.02k|                            (data[pos + 2] & 0b00111111) << 6 |
  116|  8.02k|                            (data[pos + 3] & 0b00111111);
  117|  8.02k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (117:11): [True: 16, False: 8.00k]
  |  Branch (117:35): [True: 44, False: 7.96k]
  ------------------
  118|     60|        return 0;
  119|     60|      }
  120|  7.96k|      code_point -= 0x10000;
  121|  7.96k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
  122|  7.96k|      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|  7.96k|      *utf16_output++ = char16_t(high_surrogate);
  128|  7.96k|      *utf16_output++ = char16_t(low_surrogate);
  129|  7.96k|      pos += 4;
  130|  7.96k|    } else {
  131|    408|      return 0;
  132|    408|    }
  133|   989k|  }
  134|    740|  return utf16_output - start;
  135|  1.70k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf167convertILNS_10endiannessE1EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mPDs:
   16|  1.59k|                                   char16_t *utf16_output) {
   17|  1.59k|  size_t pos = 0;
   18|  1.59k|  char16_t *start{utf16_output};
   19|  1.27M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 1.27M, False: 608]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|       |    // try to convert the next block of 16 ASCII bytes
   24|  1.27M|    {
   25|  1.27M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 1.27M, False: 4.23k]
  ------------------
   26|       |                             // they are ascii
   27|  1.27M|        uint64_t v1;
   28|  1.27M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   29|  1.27M|        uint64_t v2;
   30|  1.27M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   31|  1.27M|        uint64_t v{v1 | v2};
   32|  1.27M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (32:13): [True: 947k, False: 324k]
  ------------------
   33|   947k|          size_t final_pos = pos + 16;
   34|  16.1M|          while (pos < final_pos) {
  ------------------
  |  Branch (34:18): [True: 15.1M, False: 947k]
  ------------------
   35|  15.1M|            *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (35:31): [True: 15.1M, Folded]
  ------------------
   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|   947k|          continue;
   41|   947k|        }
   42|  1.27M|      }
   43|  1.27M|    }
   44|       |
   45|   329k|    uint8_t leading_byte = data[pos]; // leading byte
   46|   329k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (46:9): [True: 270k, False: 58.1k]
  ------------------
   47|       |      // converting one ASCII byte !!!
   48|   270k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (48:25): [True: 270k, Folded]
  ------------------
   49|   270k|                            ? char16_t(u16_swap_bytes(leading_byte))
   50|   270k|                            : char16_t(leading_byte);
   51|   270k|      pos++;
   52|   270k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (52:16): [True: 33.7k, False: 24.3k]
  ------------------
   53|       |      // We have a two-byte UTF-8, it should become
   54|       |      // a single UTF-16 word.
   55|  33.7k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (55:11): [True: 42, False: 33.7k]
  ------------------
   56|     42|        return 0;
   57|     42|      } // minimal bound checking
   58|  33.7k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (58:11): [True: 80, False: 33.6k]
  ------------------
   59|     80|        return 0;
   60|     80|      }
   61|       |      // range check
   62|  33.6k|      uint32_t code_point =
   63|  33.6k|          (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
   64|  33.6k|      if (code_point < 0x80) {
  ------------------
  |  Branch (64:11): [True: 20, False: 33.6k]
  ------------------
   65|     20|        return 0;
   66|     20|      }
   67|  33.6k|      if constexpr (!match_system(big_endian)) {
   68|  33.6k|        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
   69|  33.6k|      }
   70|  33.6k|      *utf16_output++ = char16_t(code_point);
   71|  33.6k|      pos += 2;
   72|  33.6k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (72:16): [True: 21.5k, False: 2.79k]
  ------------------
   73|       |      // We have a three-byte UTF-8, it should become
   74|       |      // a single UTF-16 word.
   75|  21.5k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (75:11): [True: 30, False: 21.5k]
  ------------------
   76|     30|        return 0;
   77|     30|      } // minimal bound checking
   78|       |
   79|  21.5k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (79:11): [True: 78, False: 21.4k]
  ------------------
   80|     78|        return 0;
   81|     78|      }
   82|  21.4k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (82:11): [True: 46, False: 21.4k]
  ------------------
   83|     46|        return 0;
   84|     46|      }
   85|       |      // range check
   86|  21.4k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
   87|  21.4k|                            (data[pos + 1] & 0b00111111) << 6 |
   88|  21.4k|                            (data[pos + 2] & 0b00111111);
   89|  21.4k|      if (code_point < 0x800 || (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (89:11): [True: 40, False: 21.3k]
  |  Branch (89:34): [True: 398, False: 20.9k]
  |  Branch (89:57): [True: 20, False: 378]
  ------------------
   90|     60|        return 0;
   91|     60|      }
   92|  21.3k|      if constexpr (!match_system(big_endian)) {
   93|  21.3k|        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
   94|  21.3k|      }
   95|  21.3k|      *utf16_output++ = char16_t(code_point);
   96|  21.3k|      pos += 3;
   97|  21.3k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (97:16): [True: 2.40k, False: 386]
  ------------------
   98|       |      // we have a 4-byte UTF-8 word.
   99|  2.40k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (99:11): [True: 30, False: 2.37k]
  ------------------
  100|     30|        return 0;
  101|     30|      } // minimal bound checking
  102|  2.37k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (102:11): [True: 62, False: 2.31k]
  ------------------
  103|     62|        return 0;
  104|     62|      }
  105|  2.31k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (105:11): [True: 42, False: 2.27k]
  ------------------
  106|     42|        return 0;
  107|     42|      }
  108|  2.27k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (108:11): [True: 30, False: 2.24k]
  ------------------
  109|     30|        return 0;
  110|     30|      }
  111|       |
  112|       |      // range check
  113|  2.24k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  114|  2.24k|                            (data[pos + 1] & 0b00111111) << 12 |
  115|  2.24k|                            (data[pos + 2] & 0b00111111) << 6 |
  116|  2.24k|                            (data[pos + 3] & 0b00111111);
  117|  2.24k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (117:11): [True: 48, False: 2.19k]
  |  Branch (117:35): [True: 36, False: 2.15k]
  ------------------
  118|     84|        return 0;
  119|     84|      }
  120|  2.15k|      code_point -= 0x10000;
  121|  2.15k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
  122|  2.15k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
  123|  2.15k|      if constexpr (!match_system(big_endian)) {
  124|  2.15k|        high_surrogate = u16_swap_bytes(high_surrogate);
  125|  2.15k|        low_surrogate = u16_swap_bytes(low_surrogate);
  126|  2.15k|      }
  127|  2.15k|      *utf16_output++ = char16_t(high_surrogate);
  128|  2.15k|      *utf16_output++ = char16_t(low_surrogate);
  129|  2.15k|      pos += 4;
  130|  2.15k|    } else {
  131|    386|      return 0;
  132|    386|    }
  133|   329k|  }
  134|    608|  return utf16_output - start;
  135|  1.59k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1619convert_with_errorsILNS_10endiannessE0EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEENS_6resultES7_mPDs:
  142|  1.70k|                                               char16_t *utf16_output) {
  143|  1.70k|  size_t pos = 0;
  144|  1.70k|  char16_t *start{utf16_output};
  145|  2.99M|  while (pos < len) {
  ------------------
  |  Branch (145:10): [True: 2.99M, False: 754]
  ------------------
  146|       |#if SIMDUTF_CPLUSPLUS23
  147|       |    if !consteval
  148|       |#endif
  149|  2.99M|    {
  150|       |      // try to convert the next block of 16 ASCII bytes
  151|  2.99M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (151:11): [True: 2.98M, False: 6.11k]
  ------------------
  152|       |                             // they are ascii
  153|  2.98M|        uint64_t v1;
  154|  2.98M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
  155|  2.98M|        uint64_t v2;
  156|  2.98M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  157|  2.98M|        uint64_t v{v1 | v2};
  158|  2.98M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (158:13): [True: 1.37M, False: 1.61M]
  ------------------
  159|  1.37M|          size_t final_pos = pos + 16;
  160|  23.3M|          while (pos < final_pos) {
  ------------------
  |  Branch (160:18): [True: 21.9M, False: 1.37M]
  ------------------
  161|  21.9M|            const char16_t byte = uint8_t(data[pos]);
  162|  21.9M|            *utf16_output++ =
  163|  21.9M|                !match_system(big_endian) ? u16_swap_bytes(byte) : byte;
  ------------------
  |  Branch (163:17): [Folded, False: 21.9M]
  ------------------
  164|  21.9M|            pos++;
  165|  21.9M|          }
  166|  1.37M|          continue;
  167|  1.37M|        }
  168|  2.98M|      }
  169|  2.99M|    }
  170|       |
  171|  1.61M|    auto leading_byte = uint8_t(data[pos]); // leading byte
  172|  1.61M|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (172:9): [True: 1.33M, False: 287k]
  ------------------
  173|       |      // converting one ASCII byte !!!
  174|  1.33M|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (174:25): [Folded, False: 1.33M]
  ------------------
  175|  1.33M|                            ? char16_t(u16_swap_bytes(leading_byte))
  176|  1.33M|                            : char16_t(leading_byte);
  177|  1.33M|      pos++;
  178|  1.33M|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (178:16): [True: 194k, False: 93.5k]
  ------------------
  179|       |      // We have a two-byte UTF-8, it should become
  180|       |      // a single UTF-16 word.
  181|   194k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (181:11): [True: 60, False: 194k]
  ------------------
  182|     60|        return result(error_code::TOO_SHORT, pos);
  183|     60|      } // minimal bound checking
  184|   194k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (184:11): [True: 102, False: 194k]
  ------------------
  185|    102|        return result(error_code::TOO_SHORT, pos);
  186|    102|      }
  187|       |      // range check
  188|   194k|      uint32_t code_point = (leading_byte & 0b00011111) << 6 |
  189|   194k|                            (uint8_t(data[pos + 1]) & 0b00111111);
  190|   194k|      if (code_point < 0x80) {
  ------------------
  |  Branch (190:11): [True: 24, False: 193k]
  ------------------
  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|   193k|      *utf16_output++ = char16_t(code_point);
  197|   193k|      pos += 2;
  198|   193k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (198:16): [True: 74.4k, False: 19.0k]
  ------------------
  199|       |      // We have a three-byte UTF-8, it should become
  200|       |      // a single UTF-16 word.
  201|  74.4k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (201:11): [True: 30, False: 74.4k]
  ------------------
  202|     30|        return result(error_code::TOO_SHORT, pos);
  203|     30|      } // minimal bound checking
  204|       |
  205|  74.4k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (205:11): [True: 72, False: 74.3k]
  ------------------
  206|     72|        return result(error_code::TOO_SHORT, pos);
  207|     72|      }
  208|  74.3k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (208:11): [True: 36, False: 74.3k]
  ------------------
  209|     36|        return result(error_code::TOO_SHORT, pos);
  210|     36|      }
  211|       |      // range check
  212|  74.3k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
  213|  74.3k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 6 |
  214|  74.3k|                            (uint8_t(data[pos + 2]) & 0b00111111);
  215|  74.3k|      if (code_point < 0x800) {
  ------------------
  |  Branch (215:11): [True: 30, False: 74.3k]
  ------------------
  216|     30|        return result(error_code::OVERLONG, pos);
  217|     30|      }
  218|  74.3k|      if (0xd7ff < code_point && code_point < 0xe000) {
  ------------------
  |  Branch (218:11): [True: 3.05k, False: 71.2k]
  |  Branch (218:34): [True: 18, False: 3.03k]
  ------------------
  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|  74.3k|      *utf16_output++ = char16_t(code_point);
  225|  74.3k|      pos += 3;
  226|  74.3k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (226:16): [True: 18.6k, False: 402]
  ------------------
  227|       |      // we have a 4-byte UTF-8 word.
  228|  18.6k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (228:11): [True: 24, False: 18.6k]
  ------------------
  229|     24|        return result(error_code::TOO_SHORT, pos);
  230|     24|      } // minimal bound checking
  231|  18.6k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (231:11): [True: 48, False: 18.5k]
  ------------------
  232|     48|        return result(error_code::TOO_SHORT, pos);
  233|     48|      }
  234|  18.5k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (234:11): [True: 24, False: 18.5k]
  ------------------
  235|     24|        return result(error_code::TOO_SHORT, pos);
  236|     24|      }
  237|  18.5k|      if ((uint8_t(data[pos + 3]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (237:11): [True: 12, False: 18.5k]
  ------------------
  238|     12|        return result(error_code::TOO_SHORT, pos);
  239|     12|      }
  240|       |
  241|       |      // range check
  242|  18.5k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  243|  18.5k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 12 |
  244|  18.5k|                            (uint8_t(data[pos + 2]) & 0b00111111) << 6 |
  245|  18.5k|                            (uint8_t(data[pos + 3]) & 0b00111111);
  246|  18.5k|      if (code_point <= 0xffff) {
  ------------------
  |  Branch (246:11): [True: 36, False: 18.5k]
  ------------------
  247|     36|        return result(error_code::OVERLONG, pos);
  248|     36|      }
  249|  18.5k|      if (0x10ffff < code_point) {
  ------------------
  |  Branch (249:11): [True: 30, False: 18.4k]
  ------------------
  250|     30|        return result(error_code::TOO_LARGE, pos);
  251|     30|      }
  252|  18.4k|      code_point -= 0x10000;
  253|  18.4k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
  254|  18.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|  18.4k|      *utf16_output++ = char16_t(high_surrogate);
  260|  18.4k|      *utf16_output++ = char16_t(low_surrogate);
  261|  18.4k|      pos += 4;
  262|  18.4k|    } else {
  263|       |      // we either have too many continuation bytes or an invalid leading byte
  264|    402|      if ((leading_byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (264:11): [True: 186, False: 216]
  ------------------
  265|    186|        return result(error_code::TOO_LONG, pos);
  266|    216|      } else {
  267|    216|        return result(error_code::HEADER_BITS, pos);
  268|    216|      }
  269|    402|    }
  270|  1.61M|  }
  271|    754|  return result(error_code::SUCCESS, utf16_output - start);
  272|  1.70k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1619convert_with_errorsILNS_10endiannessE1EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEENS_6resultES7_mPDs:
  142|  2.23k|                                               char16_t *utf16_output) {
  143|  2.23k|  size_t pos = 0;
  144|  2.23k|  char16_t *start{utf16_output};
  145|  3.31M|  while (pos < len) {
  ------------------
  |  Branch (145:10): [True: 3.31M, False: 1.04k]
  ------------------
  146|       |#if SIMDUTF_CPLUSPLUS23
  147|       |    if !consteval
  148|       |#endif
  149|  3.31M|    {
  150|       |      // try to convert the next block of 16 ASCII bytes
  151|  3.31M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (151:11): [True: 3.30M, False: 9.74k]
  ------------------
  152|       |                             // they are ascii
  153|  3.30M|        uint64_t v1;
  154|  3.30M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
  155|  3.30M|        uint64_t v2;
  156|  3.30M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  157|  3.30M|        uint64_t v{v1 | v2};
  158|  3.30M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (158:13): [True: 1.66M, False: 1.64M]
  ------------------
  159|  1.66M|          size_t final_pos = pos + 16;
  160|  28.2M|          while (pos < final_pos) {
  ------------------
  |  Branch (160:18): [True: 26.6M, False: 1.66M]
  ------------------
  161|  26.6M|            const char16_t byte = uint8_t(data[pos]);
  162|  26.6M|            *utf16_output++ =
  163|  26.6M|                !match_system(big_endian) ? u16_swap_bytes(byte) : byte;
  ------------------
  |  Branch (163:17): [True: 26.6M, Folded]
  ------------------
  164|  26.6M|            pos++;
  165|  26.6M|          }
  166|  1.66M|          continue;
  167|  1.66M|        }
  168|  3.30M|      }
  169|  3.31M|    }
  170|       |
  171|  1.65M|    auto leading_byte = uint8_t(data[pos]); // leading byte
  172|  1.65M|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (172:9): [True: 1.35M, False: 291k]
  ------------------
  173|       |      // converting one ASCII byte !!!
  174|  1.35M|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (174:25): [True: 1.35M, Folded]
  ------------------
  175|  1.35M|                            ? char16_t(u16_swap_bytes(leading_byte))
  176|  1.35M|                            : char16_t(leading_byte);
  177|  1.35M|      pos++;
  178|  1.35M|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (178:16): [True: 182k, False: 109k]
  ------------------
  179|       |      // We have a two-byte UTF-8, it should become
  180|       |      // a single UTF-16 word.
  181|   182k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (181:11): [True: 72, False: 182k]
  ------------------
  182|     72|        return result(error_code::TOO_SHORT, pos);
  183|     72|      } // minimal bound checking
  184|   182k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (184:11): [True: 156, False: 182k]
  ------------------
  185|    156|        return result(error_code::TOO_SHORT, pos);
  186|    156|      }
  187|       |      // range check
  188|   182k|      uint32_t code_point = (leading_byte & 0b00011111) << 6 |
  189|   182k|                            (uint8_t(data[pos + 1]) & 0b00111111);
  190|   182k|      if (code_point < 0x80) {
  ------------------
  |  Branch (190:11): [True: 12, False: 182k]
  ------------------
  191|     12|        return result(error_code::OVERLONG, pos);
  192|     12|      }
  193|   182k|      if constexpr (!match_system(big_endian)) {
  194|   182k|        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
  195|   182k|      }
  196|   182k|      *utf16_output++ = char16_t(code_point);
  197|   182k|      pos += 2;
  198|   182k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (198:16): [True: 99.5k, False: 9.62k]
  ------------------
  199|       |      // We have a three-byte UTF-8, it should become
  200|       |      // a single UTF-16 word.
  201|  99.5k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (201:11): [True: 42, False: 99.4k]
  ------------------
  202|     42|        return result(error_code::TOO_SHORT, pos);
  203|     42|      } // minimal bound checking
  204|       |
  205|  99.4k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (205:11): [True: 78, False: 99.4k]
  ------------------
  206|     78|        return result(error_code::TOO_SHORT, pos);
  207|     78|      }
  208|  99.4k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (208:11): [True: 24, False: 99.3k]
  ------------------
  209|     24|        return result(error_code::TOO_SHORT, pos);
  210|     24|      }
  211|       |      // range check
  212|  99.3k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
  213|  99.3k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 6 |
  214|  99.3k|                            (uint8_t(data[pos + 2]) & 0b00111111);
  215|  99.3k|      if (code_point < 0x800) {
  ------------------
  |  Branch (215:11): [True: 30, False: 99.3k]
  ------------------
  216|     30|        return result(error_code::OVERLONG, pos);
  217|     30|      }
  218|  99.3k|      if (0xd7ff < code_point && code_point < 0xe000) {
  ------------------
  |  Branch (218:11): [True: 2.53k, False: 96.8k]
  |  Branch (218:34): [True: 24, False: 2.50k]
  ------------------
  219|     24|        return result(error_code::SURROGATE, pos);
  220|     24|      }
  221|  99.3k|      if constexpr (!match_system(big_endian)) {
  222|  99.3k|        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
  223|  99.3k|      }
  224|  99.3k|      *utf16_output++ = char16_t(code_point);
  225|  99.3k|      pos += 3;
  226|  99.3k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (226:16): [True: 9.16k, False: 452]
  ------------------
  227|       |      // we have a 4-byte UTF-8 word.
  228|  9.16k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (228:11): [True: 78, False: 9.09k]
  ------------------
  229|     78|        return result(error_code::TOO_SHORT, pos);
  230|     78|      } // minimal bound checking
  231|  9.09k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (231:11): [True: 66, False: 9.02k]
  ------------------
  232|     66|        return result(error_code::TOO_SHORT, pos);
  233|     66|      }
  234|  9.02k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (234:11): [True: 66, False: 8.95k]
  ------------------
  235|     66|        return result(error_code::TOO_SHORT, pos);
  236|     66|      }
  237|  8.95k|      if ((uint8_t(data[pos + 3]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (237:11): [True: 18, False: 8.94k]
  ------------------
  238|     18|        return result(error_code::TOO_SHORT, pos);
  239|     18|      }
  240|       |
  241|       |      // range check
  242|  8.94k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  243|  8.94k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 12 |
  244|  8.94k|                            (uint8_t(data[pos + 2]) & 0b00111111) << 6 |
  245|  8.94k|                            (uint8_t(data[pos + 3]) & 0b00111111);
  246|  8.94k|      if (code_point <= 0xffff) {
  ------------------
  |  Branch (246:11): [True: 48, False: 8.89k]
  ------------------
  247|     48|        return result(error_code::OVERLONG, pos);
  248|     48|      }
  249|  8.89k|      if (0x10ffff < code_point) {
  ------------------
  |  Branch (249:11): [True: 24, False: 8.86k]
  ------------------
  250|     24|        return result(error_code::TOO_LARGE, pos);
  251|     24|      }
  252|  8.86k|      code_point -= 0x10000;
  253|  8.86k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
  254|  8.86k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
  255|  8.86k|      if constexpr (!match_system(big_endian)) {
  256|  8.86k|        high_surrogate = u16_swap_bytes(high_surrogate);
  257|  8.86k|        low_surrogate = u16_swap_bytes(low_surrogate);
  258|  8.86k|      }
  259|  8.86k|      *utf16_output++ = char16_t(high_surrogate);
  260|  8.86k|      *utf16_output++ = char16_t(low_surrogate);
  261|  8.86k|      pos += 4;
  262|  8.86k|    } else {
  263|       |      // we either have too many continuation bytes or an invalid leading byte
  264|    452|      if ((leading_byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (264:11): [True: 176, False: 276]
  ------------------
  265|    176|        return result(error_code::TOO_LONG, pos);
  266|    276|      } else {
  267|    276|        return result(error_code::HEADER_BITS, pos);
  268|    276|      }
  269|    452|    }
  270|  1.65M|  }
  271|  1.04k|  return result(error_code::SUCCESS, utf16_output - start);
  272|  2.23k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1630rewind_and_convert_with_errorsILNS_10endiannessE0EEENS_6resultEmPKcmPDs:
  292|  1.18k|                                             char16_t *utf16_output) {
  293|  1.18k|  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.18k|  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.18k|  bool found_leading_bytes{false};
  301|       |  // important: it is i <= how_far_back and not 'i < how_far_back'.
  302|  1.25k|  for (size_t i = 0; i <= how_far_back; i++) {
  ------------------
  |  Branch (302:22): [True: 1.20k, False: 52]
  ------------------
  303|  1.20k|    unsigned char byte = buf[-static_cast<std::ptrdiff_t>(i)];
  304|  1.20k|    found_leading_bytes = ((byte & 0b11000000) != 0b10000000);
  305|  1.20k|    if (found_leading_bytes) {
  ------------------
  |  Branch (305:9): [True: 1.12k, False: 72]
  ------------------
  306|  1.12k|      if (i > 0 && byte < 128) {
  ------------------
  |  Branch (306:11): [True: 20, False: 1.10k]
  |  Branch (306:20): [True: 20, False: 0]
  ------------------
  307|       |        // If we had to go back and the leading byte is ascii
  308|       |        // then we can stop right away.
  309|     20|        return result(error_code::TOO_LONG, 0 - i + 1);
  310|     20|      }
  311|  1.10k|      buf -= i;
  312|  1.10k|      extra_len = i;
  313|  1.10k|      break;
  314|  1.12k|    }
  315|  1.20k|  }
  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.16k|  if (!found_leading_bytes) {
  ------------------
  |  Branch (324:7): [True: 52, False: 1.10k]
  ------------------
  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.10k|  result res = convert_with_errors<endian>(buf, len + extra_len, utf16_output);
  332|  1.10k|  if (res.error) {
  ------------------
  |  Branch (332:7): [True: 608, False: 500]
  ------------------
  333|    608|    res.count -= extra_len;
  334|    608|  }
  335|  1.10k|  return res;
  336|  1.16k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1630rewind_and_convert_with_errorsILNS_10endiannessE1EEENS_6resultEmPKcmPDs:
  292|  1.53k|                                             char16_t *utf16_output) {
  293|  1.53k|  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.53k|  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.53k|  bool found_leading_bytes{false};
  301|       |  // important: it is i <= how_far_back and not 'i < how_far_back'.
  302|  1.61k|  for (size_t i = 0; i <= how_far_back; i++) {
  ------------------
  |  Branch (302:22): [True: 1.54k, False: 68]
  ------------------
  303|  1.54k|    unsigned char byte = buf[-static_cast<std::ptrdiff_t>(i)];
  304|  1.54k|    found_leading_bytes = ((byte & 0b11000000) != 0b10000000);
  305|  1.54k|    if (found_leading_bytes) {
  ------------------
  |  Branch (305:9): [True: 1.46k, False: 76]
  ------------------
  306|  1.46k|      if (i > 0 && byte < 128) {
  ------------------
  |  Branch (306:11): [True: 8, False: 1.46k]
  |  Branch (306:20): [True: 8, False: 0]
  ------------------
  307|       |        // If we had to go back and the leading byte is ascii
  308|       |        // then we can stop right away.
  309|      8|        return result(error_code::TOO_LONG, 0 - i + 1);
  310|      8|      }
  311|  1.46k|      buf -= i;
  312|  1.46k|      extra_len = i;
  313|  1.46k|      break;
  314|  1.46k|    }
  315|  1.54k|  }
  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.52k|  if (!found_leading_bytes) {
  ------------------
  |  Branch (324:7): [True: 68, False: 1.46k]
  ------------------
  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|     68|    return result(error_code::TOO_LONG, 0 - how_far_back);
  330|     68|  }
  331|  1.46k|  result res = convert_with_errors<endian>(buf, len + extra_len, utf16_output);
  332|  1.46k|  if (res.error) {
  ------------------
  |  Branch (332:7): [True: 768, False: 692]
  ------------------
  333|    768|    res.count -= extra_len;
  334|    768|  }
  335|  1.46k|  return res;
  336|  1.52k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1613convert_validILNS_10endiannessE0EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mPDs:
   16|  1.29k|                                         char16_t *utf16_output) {
   17|  1.29k|  size_t pos = 0;
   18|  1.29k|  char16_t *start{utf16_output};
   19|  4.03M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 4.02M, False: 1.29k]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|  4.02M|    {                       // try to convert the next block of 8 ASCII bytes
   24|  4.02M|      if (pos + 8 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (24:11): [True: 4.02M, False: 4.01k]
  ------------------
   25|       |                            // they are ascii
   26|  4.02M|        uint64_t v;
   27|  4.02M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   28|  4.02M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (28:13): [True: 2.75M, False: 1.27M]
  ------------------
   29|  2.75M|          size_t final_pos = pos + 8;
   30|  24.8M|          while (pos < final_pos) {
  ------------------
  |  Branch (30:18): [True: 22.0M, False: 2.75M]
  ------------------
   31|  22.0M|            const char16_t byte = uint8_t(data[pos]);
   32|  22.0M|            *utf16_output++ =
   33|  22.0M|                !match_system(big_endian) ? u16_swap_bytes(byte) : byte;
  ------------------
  |  Branch (33:17): [Folded, False: 22.0M]
  ------------------
   34|  22.0M|            pos++;
   35|  22.0M|          }
   36|  2.75M|          continue;
   37|  2.75M|        }
   38|  4.02M|      }
   39|  4.02M|    }
   40|       |
   41|  1.27M|    auto leading_byte = uint8_t(data[pos]); // leading byte
   42|  1.27M|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (42:9): [True: 865k, False: 408k]
  ------------------
   43|       |      // converting one ASCII byte !!!
   44|   865k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (44:25): [Folded, False: 865k]
  ------------------
   45|   865k|                            ? char16_t(u16_swap_bytes(leading_byte))
   46|   865k|                            : char16_t(leading_byte);
   47|   865k|      pos++;
   48|   865k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (48:16): [True: 233k, False: 175k]
  ------------------
   49|       |      // We have a two-byte UTF-8, it should become
   50|       |      // a single UTF-16 word.
   51|   233k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (51:11): [True: 0, False: 233k]
  ------------------
   52|      0|        break;
   53|      0|      } // minimal bound checking
   54|   233k|      uint16_t code_point = uint16_t(((leading_byte & 0b00011111) << 6) |
   55|   233k|                                     (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|   233k|      *utf16_output++ = char16_t(code_point);
   60|   233k|      pos += 2;
   61|   233k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (61:16): [True: 162k, False: 12.7k]
  ------------------
   62|       |      // We have a three-byte UTF-8, it should become
   63|       |      // a single UTF-16 word.
   64|   162k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (64:11): [True: 0, False: 162k]
  ------------------
   65|      0|        break;
   66|      0|      } // minimal bound checking
   67|   162k|      uint16_t code_point =
   68|   162k|          uint16_t(((leading_byte & 0b00001111) << 12) |
   69|   162k|                   ((uint8_t(data[pos + 1]) & 0b00111111) << 6) |
   70|   162k|                   (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|   162k|      *utf16_output++ = char16_t(code_point);
   75|   162k|      pos += 3;
   76|   162k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (76:16): [True: 12.7k, False: 0]
  ------------------
   77|       |      // we have a 4-byte UTF-8 word.
   78|  12.7k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (78:11): [True: 0, False: 12.7k]
  ------------------
   79|      0|        break;
   80|      0|      } // minimal bound checking
   81|  12.7k|      uint32_t code_point = ((leading_byte & 0b00000111) << 18) |
   82|  12.7k|                            ((uint8_t(data[pos + 1]) & 0b00111111) << 12) |
   83|  12.7k|                            ((uint8_t(data[pos + 2]) & 0b00111111) << 6) |
   84|  12.7k|                            (uint8_t(data[pos + 3]) & 0b00111111);
   85|  12.7k|      code_point -= 0x10000;
   86|  12.7k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
   87|  12.7k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
   88|       |      if constexpr (!match_system(big_endian)) {
   89|       |        high_surrogate = u16_swap_bytes(high_surrogate);
   90|       |        low_surrogate = u16_swap_bytes(low_surrogate);
   91|       |      }
   92|  12.7k|      *utf16_output++ = char16_t(high_surrogate);
   93|  12.7k|      *utf16_output++ = char16_t(low_surrogate);
   94|  12.7k|      pos += 4;
   95|  12.7k|    } else {
   96|       |      // we may have a continuation but we do not do error checking
   97|      0|      return 0;
   98|      0|    }
   99|  1.27M|  }
  100|  1.29k|  return utf16_output - start;
  101|  1.29k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1613convert_validILNS_10endiannessE1EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mPDs:
   16|  1.38k|                                         char16_t *utf16_output) {
   17|  1.38k|  size_t pos = 0;
   18|  1.38k|  char16_t *start{utf16_output};
   19|  2.95M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 2.95M, False: 1.38k]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|  2.95M|    {                       // try to convert the next block of 8 ASCII bytes
   24|  2.95M|      if (pos + 8 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (24:11): [True: 2.95M, False: 4.49k]
  ------------------
   25|       |                            // they are ascii
   26|  2.95M|        uint64_t v;
   27|  2.95M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   28|  2.95M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (28:13): [True: 2.59M, False: 361k]
  ------------------
   29|  2.59M|          size_t final_pos = pos + 8;
   30|  23.3M|          while (pos < final_pos) {
  ------------------
  |  Branch (30:18): [True: 20.7M, False: 2.59M]
  ------------------
   31|  20.7M|            const char16_t byte = uint8_t(data[pos]);
   32|  20.7M|            *utf16_output++ =
   33|  20.7M|                !match_system(big_endian) ? u16_swap_bytes(byte) : byte;
  ------------------
  |  Branch (33:17): [True: 20.7M, Folded]
  ------------------
   34|  20.7M|            pos++;
   35|  20.7M|          }
   36|  2.59M|          continue;
   37|  2.59M|        }
   38|  2.95M|      }
   39|  2.95M|    }
   40|       |
   41|   366k|    auto leading_byte = uint8_t(data[pos]); // leading byte
   42|   366k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (42:9): [True: 222k, False: 144k]
  ------------------
   43|       |      // converting one ASCII byte !!!
   44|   222k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (44:25): [True: 222k, Folded]
  ------------------
   45|   222k|                            ? char16_t(u16_swap_bytes(leading_byte))
   46|   222k|                            : char16_t(leading_byte);
   47|   222k|      pos++;
   48|   222k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (48:16): [True: 106k, False: 37.6k]
  ------------------
   49|       |      // We have a two-byte UTF-8, it should become
   50|       |      // a single UTF-16 word.
   51|   106k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (51:11): [True: 0, False: 106k]
  ------------------
   52|      0|        break;
   53|      0|      } // minimal bound checking
   54|   106k|      uint16_t code_point = uint16_t(((leading_byte & 0b00011111) << 6) |
   55|   106k|                                     (uint8_t(data[pos + 1]) & 0b00111111));
   56|   106k|      if constexpr (!match_system(big_endian)) {
   57|   106k|        code_point = u16_swap_bytes(uint16_t(code_point));
   58|   106k|      }
   59|   106k|      *utf16_output++ = char16_t(code_point);
   60|   106k|      pos += 2;
   61|   106k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (61:16): [True: 27.1k, False: 10.5k]
  ------------------
   62|       |      // We have a three-byte UTF-8, it should become
   63|       |      // a single UTF-16 word.
   64|  27.1k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (64:11): [True: 0, False: 27.1k]
  ------------------
   65|      0|        break;
   66|      0|      } // minimal bound checking
   67|  27.1k|      uint16_t code_point =
   68|  27.1k|          uint16_t(((leading_byte & 0b00001111) << 12) |
   69|  27.1k|                   ((uint8_t(data[pos + 1]) & 0b00111111) << 6) |
   70|  27.1k|                   (uint8_t(data[pos + 2]) & 0b00111111));
   71|  27.1k|      if constexpr (!match_system(big_endian)) {
   72|  27.1k|        code_point = u16_swap_bytes(uint16_t(code_point));
   73|  27.1k|      }
   74|  27.1k|      *utf16_output++ = char16_t(code_point);
   75|  27.1k|      pos += 3;
   76|  27.1k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (76:16): [True: 10.5k, False: 0]
  ------------------
   77|       |      // we have a 4-byte UTF-8 word.
   78|  10.5k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (78:11): [True: 0, False: 10.5k]
  ------------------
   79|      0|        break;
   80|      0|      } // minimal bound checking
   81|  10.5k|      uint32_t code_point = ((leading_byte & 0b00000111) << 18) |
   82|  10.5k|                            ((uint8_t(data[pos + 1]) & 0b00111111) << 12) |
   83|  10.5k|                            ((uint8_t(data[pos + 2]) & 0b00111111) << 6) |
   84|  10.5k|                            (uint8_t(data[pos + 3]) & 0b00111111);
   85|  10.5k|      code_point -= 0x10000;
   86|  10.5k|      uint16_t high_surrogate = uint16_t(0xD800 + (code_point >> 10));
   87|  10.5k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
   88|  10.5k|      if constexpr (!match_system(big_endian)) {
   89|  10.5k|        high_surrogate = u16_swap_bytes(high_surrogate);
   90|  10.5k|        low_surrogate = u16_swap_bytes(low_surrogate);
   91|  10.5k|      }
   92|  10.5k|      *utf16_output++ = char16_t(high_surrogate);
   93|  10.5k|      *utf16_output++ = char16_t(low_surrogate);
   94|  10.5k|      pos += 4;
   95|  10.5k|    } else {
   96|       |      // we may have a continuation but we do not do error checking
   97|      0|      return 0;
   98|      0|    }
   99|   366k|  }
  100|  1.38k|  return utf16_output - start;
  101|  1.38k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf3230rewind_and_convert_with_errorsEmPKcmPDi:
  249|  1.57k|                                             char32_t *utf32_output) {
  250|  1.57k|  size_t extra_len{0};
  251|       |  // We potentially need to go back in time and find a leading byte.
  252|  1.57k|  size_t how_far_back = 3; // 3 bytes in the past + current position
  253|  1.57k|  if (how_far_back > prior_bytes) {
  ------------------
  |  Branch (253:7): [True: 852, False: 720]
  ------------------
  254|    852|    how_far_back = prior_bytes;
  255|    852|  }
  256|  1.57k|  bool found_leading_bytes{false};
  257|       |  // important: it is i <= how_far_back and not 'i < how_far_back'.
  258|  1.64k|  for (size_t i = 0; i <= how_far_back; i++) {
  ------------------
  |  Branch (258:22): [True: 1.57k, False: 64]
  ------------------
  259|  1.57k|    unsigned char byte = buf[-static_cast<std::ptrdiff_t>(i)];
  260|  1.57k|    found_leading_bytes = ((byte & 0b11000000) != 0b10000000);
  261|  1.57k|    if (found_leading_bytes) {
  ------------------
  |  Branch (261:9): [True: 1.50k, False: 68]
  ------------------
  262|  1.50k|      if (i > 0 && byte < 128) {
  ------------------
  |  Branch (262:11): [True: 4, False: 1.50k]
  |  Branch (262:20): [True: 4, False: 0]
  ------------------
  263|       |        // If we had to go back and the leading byte is ascii
  264|       |        // then we can stop right away.
  265|      4|        return result(error_code::TOO_LONG, 0 - i + 1);
  266|      4|      }
  267|  1.50k|      buf -= i;
  268|  1.50k|      extra_len = i;
  269|  1.50k|      break;
  270|  1.50k|    }
  271|  1.57k|  }
  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: 64, False: 1.50k]
  ------------------
  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|     64|    return result(error_code::TOO_LONG, 0 - how_far_back);
  286|     64|  }
  287|       |
  288|  1.50k|  result res = convert_with_errors(buf, len + extra_len, utf32_output);
  289|  1.50k|  if (res.error) {
  ------------------
  |  Branch (289:7): [True: 820, False: 684]
  ------------------
  290|    820|    res.count -= extra_len;
  291|    820|  }
  292|  1.50k|  return res;
  293|  1.56k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf3219convert_with_errorsIPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEENS_6resultES6_mPDi:
  121|  2.29k|                                               char32_t *utf32_output) {
  122|  2.29k|  size_t pos = 0;
  123|  2.29k|  char32_t *start{utf32_output};
  124|  2.75M|  while (pos < len) {
  ------------------
  |  Branch (124:10): [True: 2.75M, False: 1.03k]
  ------------------
  125|       |#if SIMDUTF_CPLUSPLUS23
  126|       |    if !consteval
  127|       |#endif
  128|  2.75M|    {
  129|       |      // try to convert the next block of 16 ASCII bytes
  130|  2.75M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (130:11): [True: 2.74M, False: 8.72k]
  ------------------
  131|       |                             // they are ascii
  132|  2.74M|        uint64_t v1;
  133|  2.74M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
  134|  2.74M|        uint64_t v2;
  135|  2.74M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  136|  2.74M|        uint64_t v{v1 | v2};
  137|  2.74M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (137:13): [True: 1.73M, False: 1.01M]
  ------------------
  138|  1.73M|          size_t final_pos = pos + 16;
  139|  29.5M|          while (pos < final_pos) {
  ------------------
  |  Branch (139:18): [True: 27.7M, False: 1.73M]
  ------------------
  140|  27.7M|            *utf32_output++ = uint8_t(data[pos]);
  141|  27.7M|            pos++;
  142|  27.7M|          }
  143|  1.73M|          continue;
  144|  1.73M|        }
  145|  2.74M|      }
  146|  2.75M|    }
  147|  1.02M|    auto leading_byte = uint8_t(data[pos]); // leading byte
  148|  1.02M|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (148:9): [True: 768k, False: 253k]
  ------------------
  149|       |      // converting one ASCII byte !!!
  150|   768k|      *utf32_output++ = char32_t(leading_byte);
  151|   768k|      pos++;
  152|   768k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (152:16): [True: 179k, False: 73.3k]
  ------------------
  153|       |      // We have a two-byte UTF-8
  154|   179k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (154:11): [True: 78, False: 179k]
  ------------------
  155|     78|        return result(error_code::TOO_SHORT, pos);
  156|     78|      } // minimal bound checking
  157|   179k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (157:11): [True: 180, False: 179k]
  ------------------
  158|    180|        return result(error_code::TOO_SHORT, pos);
  159|    180|      }
  160|       |      // range check
  161|   179k|      uint32_t code_point = (leading_byte & 0b00011111) << 6 |
  162|   179k|                            (uint8_t(data[pos + 1]) & 0b00111111);
  163|   179k|      if (code_point < 0x80) {
  ------------------
  |  Branch (163:11): [True: 18, False: 179k]
  ------------------
  164|     18|        return result(error_code::OVERLONG, pos);
  165|     18|      }
  166|   179k|      *utf32_output++ = char32_t(code_point);
  167|   179k|      pos += 2;
  168|   179k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (168:16): [True: 57.9k, False: 15.4k]
  ------------------
  169|       |      // We have a three-byte UTF-8
  170|  57.9k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (170:11): [True: 54, False: 57.9k]
  ------------------
  171|     54|        return result(error_code::TOO_SHORT, pos);
  172|     54|      } // minimal bound checking
  173|       |
  174|  57.9k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (174:11): [True: 72, False: 57.8k]
  ------------------
  175|     72|        return result(error_code::TOO_SHORT, pos);
  176|     72|      }
  177|  57.8k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (177:11): [True: 66, False: 57.7k]
  ------------------
  178|     66|        return result(error_code::TOO_SHORT, pos);
  179|     66|      }
  180|       |      // range check
  181|  57.7k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
  182|  57.7k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 6 |
  183|  57.7k|                            (uint8_t(data[pos + 2]) & 0b00111111);
  184|  57.7k|      if (code_point < 0x800) {
  ------------------
  |  Branch (184:11): [True: 36, False: 57.7k]
  ------------------
  185|     36|        return result(error_code::OVERLONG, pos);
  186|     36|      }
  187|  57.7k|      if (0xd7ff < code_point && code_point < 0xe000) {
  ------------------
  |  Branch (187:11): [True: 3.24k, False: 54.4k]
  |  Branch (187:34): [True: 18, False: 3.22k]
  ------------------
  188|     18|        return result(error_code::SURROGATE, pos);
  189|     18|      }
  190|  57.7k|      *utf32_output++ = char32_t(code_point);
  191|  57.7k|      pos += 3;
  192|  57.7k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (192:16): [True: 14.9k, False: 484]
  ------------------
  193|       |      // we have a 4-byte UTF-8 word.
  194|  14.9k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (194:11): [True: 24, False: 14.9k]
  ------------------
  195|     24|        return result(error_code::TOO_SHORT, pos);
  196|     24|      } // minimal bound checking
  197|  14.9k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (197:11): [True: 66, False: 14.8k]
  ------------------
  198|     66|        return result(error_code::TOO_SHORT, pos);
  199|     66|      }
  200|  14.8k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (200:11): [True: 42, False: 14.8k]
  ------------------
  201|     42|        return result(error_code::TOO_SHORT, pos);
  202|     42|      }
  203|  14.8k|      if ((uint8_t(data[pos + 3]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (203:11): [True: 42, False: 14.7k]
  ------------------
  204|     42|        return result(error_code::TOO_SHORT, pos);
  205|     42|      }
  206|       |
  207|       |      // range check
  208|  14.7k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  209|  14.7k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 12 |
  210|  14.7k|                            (uint8_t(data[pos + 2]) & 0b00111111) << 6 |
  211|  14.7k|                            (uint8_t(data[pos + 3]) & 0b00111111);
  212|  14.7k|      if (code_point <= 0xffff) {
  ------------------
  |  Branch (212:11): [True: 42, False: 14.7k]
  ------------------
  213|     42|        return result(error_code::OVERLONG, pos);
  214|     42|      }
  215|  14.7k|      if (0x10ffff < code_point) {
  ------------------
  |  Branch (215:11): [True: 42, False: 14.6k]
  ------------------
  216|     42|        return result(error_code::TOO_LARGE, pos);
  217|     42|      }
  218|  14.6k|      *utf32_output++ = char32_t(code_point);
  219|  14.6k|      pos += 4;
  220|  14.6k|    } else {
  221|       |      // we either have too many continuation bytes or an invalid leading byte
  222|    484|      if ((leading_byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (222:11): [True: 220, False: 264]
  ------------------
  223|    220|        return result(error_code::TOO_LONG, pos);
  224|    264|      } else {
  225|    264|        return result(error_code::HEADER_BITS, pos);
  226|    264|      }
  227|    484|    }
  228|  1.02M|  }
  229|  1.03k|  return result(error_code::SUCCESS, utf32_output - start);
  230|  2.29k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf327convertIPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEEmS6_mPDi:
   16|  1.79k|                                   char32_t *utf32_output) {
   17|  1.79k|  size_t pos = 0;
   18|  1.79k|  char32_t *start{utf32_output};
   19|  2.38M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 2.38M, False: 836]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|  2.38M|    {
   24|       |      // try to convert the next block of 16 ASCII bytes
   25|  2.38M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 2.38M, False: 5.52k]
  ------------------
   26|       |                             // they are ascii
   27|  2.38M|        uint64_t v1;
   28|  2.38M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   29|  2.38M|        uint64_t v2;
   30|  2.38M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   31|  2.38M|        uint64_t v{v1 | v2};
   32|  2.38M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (32:13): [True: 1.40M, False: 975k]
  ------------------
   33|  1.40M|          size_t final_pos = pos + 16;
   34|  23.9M|          while (pos < final_pos) {
  ------------------
  |  Branch (34:18): [True: 22.4M, False: 1.40M]
  ------------------
   35|  22.4M|            *utf32_output++ = uint8_t(data[pos]);
   36|  22.4M|            pos++;
   37|  22.4M|          }
   38|  1.40M|          continue;
   39|  1.40M|        }
   40|  2.38M|      }
   41|  2.38M|    }
   42|   981k|    auto leading_byte = uint8_t(data[pos]); // leading byte
   43|   981k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (43:9): [True: 814k, False: 166k]
  ------------------
   44|       |      // converting one ASCII byte !!!
   45|   814k|      *utf32_output++ = char32_t(leading_byte);
   46|   814k|      pos++;
   47|   814k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (47:16): [True: 96.7k, False: 70.2k]
  ------------------
   48|       |      // We have a two-byte UTF-8
   49|  96.7k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (49:11): [True: 54, False: 96.6k]
  ------------------
   50|     54|        return 0;
   51|     54|      } // minimal bound checking
   52|  96.6k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (52:11): [True: 104, False: 96.5k]
  ------------------
   53|    104|        return 0;
   54|    104|      }
   55|       |      // range check
   56|  96.5k|      uint32_t code_point = (leading_byte & 0b00011111) << 6 |
   57|  96.5k|                            (uint8_t(data[pos + 1]) & 0b00111111);
   58|  96.5k|      if (code_point < 0x80) {
  ------------------
  |  Branch (58:11): [True: 18, False: 96.5k]
  ------------------
   59|     18|        return 0;
   60|     18|      }
   61|  96.5k|      *utf32_output++ = char32_t(code_point);
   62|  96.5k|      pos += 2;
   63|  96.5k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (63:16): [True: 63.7k, False: 6.51k]
  ------------------
   64|       |      // We have a three-byte UTF-8
   65|  63.7k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (65:11): [True: 36, False: 63.7k]
  ------------------
   66|     36|        return 0;
   67|     36|      } // minimal bound checking
   68|       |
   69|  63.7k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (69:11): [True: 76, False: 63.6k]
  ------------------
   70|     76|        return 0;
   71|     76|      }
   72|  63.6k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (72:11): [True: 30, False: 63.6k]
  ------------------
   73|     30|        return 0;
   74|     30|      }
   75|       |      // range check
   76|  63.6k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
   77|  63.6k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 6 |
   78|  63.6k|                            (uint8_t(data[pos + 2]) & 0b00111111);
   79|  63.6k|      if (code_point < 0x800 || (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (79:11): [True: 40, False: 63.5k]
  |  Branch (79:34): [True: 1.67k, False: 61.9k]
  |  Branch (79:57): [True: 14, False: 1.65k]
  ------------------
   80|     54|        return 0;
   81|     54|      }
   82|  63.5k|      *utf32_output++ = char32_t(code_point);
   83|  63.5k|      pos += 3;
   84|  63.5k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (84:16): [True: 6.18k, False: 334]
  ------------------
   85|       |      // we have a 4-byte UTF-8 word.
   86|  6.18k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (86:11): [True: 24, False: 6.15k]
  ------------------
   87|     24|        return 0;
   88|     24|      } // minimal bound checking
   89|  6.15k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (89:11): [True: 62, False: 6.09k]
  ------------------
   90|     62|        return 0;
   91|     62|      }
   92|  6.09k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (92:11): [True: 42, False: 6.05k]
  ------------------
   93|     42|        return 0;
   94|     42|      }
   95|  6.05k|      if ((uint8_t(data[pos + 3]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (95:11): [True: 22, False: 6.03k]
  ------------------
   96|     22|        return 0;
   97|     22|      }
   98|       |
   99|       |      // range check
  100|  6.03k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  101|  6.03k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 12 |
  102|  6.03k|                            (uint8_t(data[pos + 2]) & 0b00111111) << 6 |
  103|  6.03k|                            (uint8_t(data[pos + 3]) & 0b00111111);
  104|  6.03k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (104:11): [True: 52, False: 5.98k]
  |  Branch (104:35): [True: 46, False: 5.93k]
  ------------------
  105|     98|        return 0;
  106|     98|      }
  107|  5.93k|      *utf32_output++ = char32_t(code_point);
  108|  5.93k|      pos += 4;
  109|  5.93k|    } else {
  110|    334|      return 0;
  111|    334|    }
  112|   981k|  }
  113|    836|  return utf32_output - start;
  114|  1.79k|}

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

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

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

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

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

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

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

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

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoderC2Ev:
  114|  2.90k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoderC2Ev:
  114|  2.90k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder7convertILNS_10endiannessE0EEEmPKcmPDs:
  130|    784|                                       char16_t *utf16_output) {
  131|    784|    size_t pos = 0;
  132|    784|    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|    784|    size_t leading_byte = 0;
  140|    784|    size_t margin = size;
  141|  7.74k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (141:12): [True: 7.49k, False: 250]
  |  Branch (141:26): [True: 6.95k, False: 534]
  ------------------
  142|  6.95k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  143|  6.95k|    }
  144|       |    // If the input is long enough, then we have that margin-1 is the eight last
  145|       |    // leading byte.
  146|    784|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  147|   577k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (147:12): [True: 576k, False: 758]
  ------------------
  148|   576k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  149|   576k|      if (input.is_ascii()) {
  ------------------
  |  Branch (149:11): [True: 478k, False: 97.8k]
  ------------------
  150|   478k|        input.store_ascii_as_utf16<endian>(utf16_output);
  151|   478k|        utf16_output += 64;
  152|   478k|        pos += 64;
  153|   478k|      } else {
  154|       |        // you might think that a for-loop would work, but under Visual Studio,
  155|       |        // it is not good enough.
  156|  97.8k|        static_assert(
  157|  97.8k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  158|  97.8k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  159|  97.8k|            "We support either two or four chunks per 64-byte block.");
  160|  97.8k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  161|  97.8k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  162|  97.8k|          this->check_utf8_bytes(input.chunks[0], zero);
  163|  97.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|  97.8k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  171|  97.8k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (171:13): [True: 26, False: 97.7k]
  ------------------
  172|     26|          return 0; // error
  173|     26|        }
  174|  97.7k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  175|  97.7k|        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|  97.7k|        size_t max_starting_point = (pos + 64) - 12;
  180|       |        // Next loop is going to run at least five times.
  181|   962k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (181:16): [True: 864k, False: 97.7k]
  ------------------
  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|   864k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  192|   864k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  193|   864k|          pos += consumed;
  194|   864k|          utf8_end_of_code_point_mask >>= consumed;
  195|   864k|        }
  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|  97.7k|      }
  201|   576k|    }
  202|    758|    if (errors()) {
  ------------------
  |  Branch (202:9): [True: 296, False: 462]
  ------------------
  203|    296|      return 0;
  204|    296|    }
  205|    462|    if (pos < size) {
  ------------------
  |  Branch (205:9): [True: 460, False: 2]
  ------------------
  206|    460|      size_t howmany = scalar::utf8_to_utf16::convert<endian>(
  207|    460|          in + pos, size - pos, utf16_output);
  208|    460|      if (howmany == 0) {
  ------------------
  |  Branch (208:11): [True: 214, False: 246]
  ------------------
  209|    214|        return 0;
  210|    214|      }
  211|    246|      utf16_output += howmany;
  212|    246|    }
  213|    248|    return utf16_output - start;
  214|    462|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  119|   894k|                                              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|   894k|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  124|   894k|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  125|   894k|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  126|   894k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1619check_special_casesENS1_4simd5simd8IhEES5_:
    8|   894k|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|   894k|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   16|       |                                               // 11______ 11______
   17|   894k|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   18|   894k|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   19|   894k|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   20|   894k|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   21|   894k|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   22|   894k|  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|   894k|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   31|       |  // 11110101 1000____
   32|       |  // 1111011_ 1000____
   33|       |  // 11111___ 1000____
   34|   894k|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   35|       |
   36|   894k|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   37|       |      // 0_______ ________ <ASCII in byte 1>
   38|   894k|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   39|   894k|      TOO_LONG,
   40|       |      // 10______ ________ <continuation in byte 1>
   41|   894k|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   42|       |      // 1100____ ________ <two byte lead in byte 1>
   43|   894k|      TOO_SHORT | OVERLONG_2,
   44|       |      // 1101____ ________ <two byte lead in byte 1>
   45|   894k|      TOO_SHORT,
   46|       |      // 1110____ ________ <three byte lead in byte 1>
   47|   894k|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   48|       |      // 1111____ ________ <four+ byte lead in byte 1>
   49|   894k|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   50|   894k|  constexpr const uint8_t CARRY =
   51|   894k|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   52|   894k|  const simd8<uint8_t> byte_1_low =
   53|   894k|      (prev1 & 0x0F)
   54|   894k|          .lookup_16<uint8_t>(
   55|       |              // ____0000 ________
   56|   894k|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   57|       |              // ____0001 ________
   58|   894k|              CARRY | OVERLONG_2,
   59|       |              // ____001_ ________
   60|   894k|              CARRY, CARRY,
   61|       |
   62|       |              // ____0100 ________
   63|   894k|              CARRY | TOO_LARGE,
   64|       |              // ____0101 ________
   65|   894k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   66|       |              // ____011_ ________
   67|   894k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   68|   894k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|       |
   70|       |              // ____1___ ________
   71|   894k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   72|   894k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|   894k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|   894k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|   894k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|       |              // ____1101 ________
   77|   894k|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   78|   894k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   79|   894k|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   80|   894k|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   81|       |      // ________ 0_______ <ASCII in byte 2>
   82|   894k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   83|   894k|      TOO_SHORT, TOO_SHORT,
   84|       |
   85|       |      // ________ 1000____
   86|   894k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   87|   894k|          OVERLONG_4,
   88|       |      // ________ 1001____
   89|   894k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   90|       |      // ________ 101_____
   91|   894k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   92|   894k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|       |
   94|       |      // ________ 11______
   95|   894k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   96|   894k|  return (byte_1_high & byte_1_low & byte_2_high);
   97|   894k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1623check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  101|   894k|                        const simd8<uint8_t> sc) {
  102|   894k|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  103|   894k|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  104|   894k|  simd8<uint8_t> must23 =
  105|   894k|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  106|   894k|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  107|   894k|  return must23_80 ^ sc;
  108|   894k|}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder6errorsEv:
  324|   198k|  simdutf_really_inline bool errors() const {
  325|   198k|    return this->error.any_bits_set_anywhere();
  326|   198k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder7convertILNS_10endiannessE1EEEmPKcmPDs:
  130|    758|                                       char16_t *utf16_output) {
  131|    758|    size_t pos = 0;
  132|    758|    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|    758|    size_t leading_byte = 0;
  140|    758|    size_t margin = size;
  141|  6.83k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (141:12): [True: 6.59k, False: 234]
  |  Branch (141:26): [True: 6.07k, False: 524]
  ------------------
  142|  6.07k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  143|  6.07k|    }
  144|       |    // If the input is long enough, then we have that margin-1 is the eight last
  145|       |    // leading byte.
  146|    758|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  147|   574k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (147:12): [True: 573k, False: 738]
  ------------------
  148|   573k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  149|   573k|      if (input.is_ascii()) {
  ------------------
  |  Branch (149:11): [True: 419k, False: 153k]
  ------------------
  150|   419k|        input.store_ascii_as_utf16<endian>(utf16_output);
  151|   419k|        utf16_output += 64;
  152|   419k|        pos += 64;
  153|   419k|      } else {
  154|       |        // you might think that a for-loop would work, but under Visual Studio,
  155|       |        // it is not good enough.
  156|   153k|        static_assert(
  157|   153k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  158|   153k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  159|   153k|            "We support either two or four chunks per 64-byte block.");
  160|   153k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  161|   153k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  162|   153k|          this->check_utf8_bytes(input.chunks[0], zero);
  163|   153k|          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|   153k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  171|   153k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (171:13): [True: 20, False: 153k]
  ------------------
  172|     20|          return 0; // error
  173|     20|        }
  174|   153k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  175|   153k|        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|   153k|        size_t max_starting_point = (pos + 64) - 12;
  180|       |        // Next loop is going to run at least five times.
  181|  1.52M|        while (pos < max_starting_point) {
  ------------------
  |  Branch (181:16): [True: 1.37M, False: 153k]
  ------------------
  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.37M|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  192|  1.37M|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  193|  1.37M|          pos += consumed;
  194|  1.37M|          utf8_end_of_code_point_mask >>= consumed;
  195|  1.37M|        }
  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|   153k|      }
  201|   573k|    }
  202|    738|    if (errors()) {
  ------------------
  |  Branch (202:9): [True: 316, False: 422]
  ------------------
  203|    316|      return 0;
  204|    316|    }
  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: 218, False: 202]
  ------------------
  209|    218|        return 0;
  210|    218|      }
  211|    202|      utf16_output += howmany;
  212|    202|    }
  213|    204|    return utf16_output - start;
  214|    422|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder19convert_with_errorsILNS_10endiannessE0EEENS_6resultEPKcmPDs:
  218|    594|                                                   char16_t *utf16_output) {
  219|    594|    size_t pos = 0;
  220|    594|    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|    594|    size_t leading_byte = 0;
  228|    594|    size_t margin = size;
  229|  5.04k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (229:12): [True: 4.81k, False: 230]
  |  Branch (229:26): [True: 4.44k, False: 364]
  ------------------
  230|  4.44k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  231|  4.44k|    }
  232|       |    // If the input is long enough, then we have that margin-1 is the eight last
  233|       |    // leading byte.
  234|    594|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  235|   387k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (235:12): [True: 387k, False: 512]
  ------------------
  236|   387k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  237|   387k|      if (input.is_ascii()) {
  ------------------
  |  Branch (237:11): [True: 294k, False: 92.8k]
  ------------------
  238|   294k|        input.store_ascii_as_utf16<endian>(utf16_output);
  239|   294k|        utf16_output += 64;
  240|   294k|        pos += 64;
  241|   294k|      } else {
  242|       |        // you might think that a for-loop would work, but under Visual Studio,
  243|       |        // it is not good enough.
  244|  92.8k|        static_assert(
  245|  92.8k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  246|  92.8k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  247|  92.8k|            "We support either two or four chunks per 64-byte block.");
  248|  92.8k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  249|  92.8k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  250|  92.8k|          this->check_utf8_bytes(input.chunks[0], zero);
  251|  92.8k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  252|       |        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  253|       |          this->check_utf8_bytes(input.chunks[0], zero);
  254|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  255|       |          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  256|       |          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  257|       |        }
  258|  92.8k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  259|  92.8k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (259:13): [True: 82, False: 92.7k]
  |  Branch (259:25): [True: 0, False: 92.7k]
  ------------------
  260|       |          // rewind_and_convert_with_errors will seek a potential error from
  261|       |          // in+pos onward, with the ability to go back up to pos bytes, and
  262|       |          // read size-pos bytes forward.
  263|     82|          result res =
  264|     82|              scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  265|     82|                  pos, in + pos, size - pos, utf16_output);
  266|     82|          res.count += pos;
  267|     82|          return res;
  268|     82|        }
  269|  92.7k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  270|  92.7k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  271|       |        // We process in blocks of up to 12 bytes except possibly
  272|       |        // for fast paths which may process up to 16 bytes. For the
  273|       |        // slow path to work, we should have at least 12 input bytes left.
  274|  92.7k|        size_t max_starting_point = (pos + 64) - 12;
  275|       |        // Next loop is going to run at least five times.
  276|   911k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (276:16): [True: 819k, False: 92.7k]
  ------------------
  277|       |          // Performance note: our ability to compute 'consumed' and
  278|       |          // then shift and recompute is critical. If there is a
  279|       |          // latency of, say, 4 cycles on getting 'consumed', then
  280|       |          // the inner loop might have a total latency of about 6 cycles.
  281|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  282|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  283|       |          // for this section of the code. Hence, there is a limit
  284|       |          // to how much we can further increase this latency before
  285|       |          // it seriously harms performance.
  286|   819k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  287|   819k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  288|   819k|          pos += consumed;
  289|   819k|          utf8_end_of_code_point_mask >>= consumed;
  290|   819k|        }
  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|  92.7k|      }
  296|   387k|    }
  297|    512|    if (errors()) {
  ------------------
  |  Branch (297:9): [True: 0, False: 512]
  ------------------
  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|    512|    if (pos < size) {
  ------------------
  |  Branch (307:9): [True: 508, 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|    508|      result res =
  312|    508|          scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  313|    508|              pos, in + pos, size - pos, utf16_output);
  314|    508|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (314:11): [True: 258, False: 250]
  ------------------
  315|    258|        res.count += pos;
  316|    258|        return res;
  317|    258|      } else { // In case of success, we want the number of word written
  318|    250|        utf16_output += res.count;
  319|    250|      }
  320|    508|    }
  321|    254|    return result(error_code::SUCCESS, utf16_output - start);
  322|    512|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder19convert_with_errorsILNS_10endiannessE1EEENS_6resultEPKcmPDs:
  218|    772|                                                   char16_t *utf16_output) {
  219|    772|    size_t pos = 0;
  220|    772|    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|    772|    size_t leading_byte = 0;
  228|    772|    size_t margin = size;
  229|  6.85k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (229:12): [True: 6.58k, False: 264]
  |  Branch (229:26): [True: 6.08k, False: 508]
  ------------------
  230|  6.08k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  231|  6.08k|    }
  232|       |    // If the input is long enough, then we have that margin-1 is the eight last
  233|       |    // leading byte.
  234|    772|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  235|   462k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (235:12): [True: 462k, False: 706]
  ------------------
  236|   462k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  237|   462k|      if (input.is_ascii()) {
  ------------------
  |  Branch (237:11): [True: 358k, False: 103k]
  ------------------
  238|   358k|        input.store_ascii_as_utf16<endian>(utf16_output);
  239|   358k|        utf16_output += 64;
  240|   358k|        pos += 64;
  241|   358k|      } else {
  242|       |        // you might think that a for-loop would work, but under Visual Studio,
  243|       |        // it is not good enough.
  244|   103k|        static_assert(
  245|   103k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  246|   103k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  247|   103k|            "We support either two or four chunks per 64-byte block.");
  248|   103k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  249|   103k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  250|   103k|          this->check_utf8_bytes(input.chunks[0], zero);
  251|   103k|          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|   103k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  259|   103k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (259:13): [True: 66, False: 103k]
  |  Branch (259:25): [True: 0, False: 103k]
  ------------------
  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|     66|          result res =
  264|     66|              scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  265|     66|                  pos, in + pos, size - pos, utf16_output);
  266|     66|          res.count += pos;
  267|     66|          return res;
  268|     66|        }
  269|   103k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  270|   103k|        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|   103k|        size_t max_starting_point = (pos + 64) - 12;
  275|       |        // Next loop is going to run at least five times.
  276|  1.02M|        while (pos < max_starting_point) {
  ------------------
  |  Branch (276:16): [True: 917k, False: 103k]
  ------------------
  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|   917k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  287|   917k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  288|   917k|          pos += consumed;
  289|   917k|          utf8_end_of_code_point_mask >>= consumed;
  290|   917k|        }
  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|   103k|      }
  296|   462k|    }
  297|    706|    if (errors()) {
  ------------------
  |  Branch (297:9): [True: 0, False: 706]
  ------------------
  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|    706|    if (pos < size) {
  ------------------
  |  Branch (307:9): [True: 702, 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|    702|      result res =
  312|    702|          scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  313|    702|              pos, in + pos, size - pos, utf16_output);
  314|    702|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (314:11): [True: 356, False: 346]
  ------------------
  315|    356|        res.count += pos;
  316|    356|        return res;
  317|    356|      } else { // In case of success, we want the number of word written
  318|    346|        utf16_output += res.count;
  319|    346|      }
  320|    702|    }
  321|    350|    return result(error_code::SUCCESS, utf16_output - start);
  322|    706|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder7convertILNS_10endiannessE0EEEmPKcmPDs:
  130|    784|                                       char16_t *utf16_output) {
  131|    784|    size_t pos = 0;
  132|    784|    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|    784|    size_t leading_byte = 0;
  140|    784|    size_t margin = size;
  141|  7.74k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (141:12): [True: 7.49k, False: 250]
  |  Branch (141:26): [True: 6.95k, False: 534]
  ------------------
  142|  6.95k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  143|  6.95k|    }
  144|       |    // If the input is long enough, then we have that margin-1 is the eight last
  145|       |    // leading byte.
  146|    784|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  147|   577k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (147:12): [True: 576k, False: 758]
  ------------------
  148|   576k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  149|   576k|      if (input.is_ascii()) {
  ------------------
  |  Branch (149:11): [True: 478k, False: 97.8k]
  ------------------
  150|   478k|        input.store_ascii_as_utf16<endian>(utf16_output);
  151|   478k|        utf16_output += 64;
  152|   478k|        pos += 64;
  153|   478k|      } else {
  154|       |        // you might think that a for-loop would work, but under Visual Studio,
  155|       |        // it is not good enough.
  156|  97.8k|        static_assert(
  157|  97.8k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  158|  97.8k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  159|  97.8k|            "We support either two or four chunks per 64-byte block.");
  160|  97.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|  97.8k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  165|  97.8k|          this->check_utf8_bytes(input.chunks[0], zero);
  166|  97.8k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  167|  97.8k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  168|  97.8k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  169|  97.8k|        }
  170|  97.8k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  171|  97.8k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (171:13): [True: 26, False: 97.7k]
  ------------------
  172|     26|          return 0; // error
  173|     26|        }
  174|  97.7k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  175|  97.7k|        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|  97.7k|        size_t max_starting_point = (pos + 64) - 12;
  180|       |        // Next loop is going to run at least five times.
  181|   962k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (181:16): [True: 864k, False: 97.7k]
  ------------------
  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|   864k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  192|   864k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  193|   864k|          pos += consumed;
  194|   864k|          utf8_end_of_code_point_mask >>= consumed;
  195|   864k|        }
  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|  97.7k|      }
  201|   576k|    }
  202|    758|    if (errors()) {
  ------------------
  |  Branch (202:9): [True: 296, False: 462]
  ------------------
  203|    296|      return 0;
  204|    296|    }
  205|    462|    if (pos < size) {
  ------------------
  |  Branch (205:9): [True: 460, False: 2]
  ------------------
  206|    460|      size_t howmany = scalar::utf8_to_utf16::convert<endian>(
  207|    460|          in + pos, size - pos, utf16_output);
  208|    460|      if (howmany == 0) {
  ------------------
  |  Branch (208:11): [True: 214, False: 246]
  ------------------
  209|    214|        return 0;
  210|    214|      }
  211|    246|      utf16_output += howmany;
  212|    246|    }
  213|    248|    return utf16_output - start;
  214|    462|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  119|  1.78M|                                              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.78M|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  124|  1.78M|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  125|  1.78M|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  126|  1.78M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1619check_special_casesENS1_4simd5simd8IhEES5_:
    8|  1.78M|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.78M|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   16|       |                                               // 11______ 11______
   17|  1.78M|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   18|  1.78M|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   19|  1.78M|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   20|  1.78M|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   21|  1.78M|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   22|  1.78M|  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.78M|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   31|       |  // 11110101 1000____
   32|       |  // 1111011_ 1000____
   33|       |  // 11111___ 1000____
   34|  1.78M|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   35|       |
   36|  1.78M|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   37|       |      // 0_______ ________ <ASCII in byte 1>
   38|  1.78M|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   39|  1.78M|      TOO_LONG,
   40|       |      // 10______ ________ <continuation in byte 1>
   41|  1.78M|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   42|       |      // 1100____ ________ <two byte lead in byte 1>
   43|  1.78M|      TOO_SHORT | OVERLONG_2,
   44|       |      // 1101____ ________ <two byte lead in byte 1>
   45|  1.78M|      TOO_SHORT,
   46|       |      // 1110____ ________ <three byte lead in byte 1>
   47|  1.78M|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   48|       |      // 1111____ ________ <four+ byte lead in byte 1>
   49|  1.78M|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   50|  1.78M|  constexpr const uint8_t CARRY =
   51|  1.78M|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   52|  1.78M|  const simd8<uint8_t> byte_1_low =
   53|  1.78M|      (prev1 & 0x0F)
   54|  1.78M|          .lookup_16<uint8_t>(
   55|       |              // ____0000 ________
   56|  1.78M|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   57|       |              // ____0001 ________
   58|  1.78M|              CARRY | OVERLONG_2,
   59|       |              // ____001_ ________
   60|  1.78M|              CARRY, CARRY,
   61|       |
   62|       |              // ____0100 ________
   63|  1.78M|              CARRY | TOO_LARGE,
   64|       |              // ____0101 ________
   65|  1.78M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   66|       |              // ____011_ ________
   67|  1.78M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   68|  1.78M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|       |
   70|       |              // ____1___ ________
   71|  1.78M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   72|  1.78M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|  1.78M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|  1.78M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|  1.78M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|       |              // ____1101 ________
   77|  1.78M|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   78|  1.78M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   79|  1.78M|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   80|  1.78M|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   81|       |      // ________ 0_______ <ASCII in byte 2>
   82|  1.78M|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   83|  1.78M|      TOO_SHORT, TOO_SHORT,
   84|       |
   85|       |      // ________ 1000____
   86|  1.78M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   87|  1.78M|          OVERLONG_4,
   88|       |      // ________ 1001____
   89|  1.78M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   90|       |      // ________ 101_____
   91|  1.78M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   92|  1.78M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|       |
   94|       |      // ________ 11______
   95|  1.78M|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   96|  1.78M|  return (byte_1_high & byte_1_low & byte_2_high);
   97|  1.78M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1623check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  101|  1.78M|                        const simd8<uint8_t> sc) {
  102|  1.78M|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  103|  1.78M|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  104|  1.78M|  simd8<uint8_t> must23 =
  105|  1.78M|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  106|  1.78M|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  107|  1.78M|  return must23_80 ^ sc;
  108|  1.78M|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder6errorsEv:
  324|   198k|  simdutf_really_inline bool errors() const {
  325|   198k|    return this->error.any_bits_set_anywhere();
  326|   198k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder7convertILNS_10endiannessE1EEEmPKcmPDs:
  130|    758|                                       char16_t *utf16_output) {
  131|    758|    size_t pos = 0;
  132|    758|    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|    758|    size_t leading_byte = 0;
  140|    758|    size_t margin = size;
  141|  6.83k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (141:12): [True: 6.59k, False: 234]
  |  Branch (141:26): [True: 6.07k, False: 524]
  ------------------
  142|  6.07k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  143|  6.07k|    }
  144|       |    // If the input is long enough, then we have that margin-1 is the eight last
  145|       |    // leading byte.
  146|    758|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  147|   574k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (147:12): [True: 573k, False: 738]
  ------------------
  148|   573k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  149|   573k|      if (input.is_ascii()) {
  ------------------
  |  Branch (149:11): [True: 419k, False: 153k]
  ------------------
  150|   419k|        input.store_ascii_as_utf16<endian>(utf16_output);
  151|   419k|        utf16_output += 64;
  152|   419k|        pos += 64;
  153|   419k|      } else {
  154|       |        // you might think that a for-loop would work, but under Visual Studio,
  155|       |        // it is not good enough.
  156|   153k|        static_assert(
  157|   153k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  158|   153k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  159|   153k|            "We support either two or four chunks per 64-byte block.");
  160|   153k|        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|   153k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  165|   153k|          this->check_utf8_bytes(input.chunks[0], zero);
  166|   153k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  167|   153k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  168|   153k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  169|   153k|        }
  170|   153k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  171|   153k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (171:13): [True: 20, False: 153k]
  ------------------
  172|     20|          return 0; // error
  173|     20|        }
  174|   153k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  175|   153k|        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|   153k|        size_t max_starting_point = (pos + 64) - 12;
  180|       |        // Next loop is going to run at least five times.
  181|  1.52M|        while (pos < max_starting_point) {
  ------------------
  |  Branch (181:16): [True: 1.37M, False: 153k]
  ------------------
  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.37M|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  192|  1.37M|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  193|  1.37M|          pos += consumed;
  194|  1.37M|          utf8_end_of_code_point_mask >>= consumed;
  195|  1.37M|        }
  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|   153k|      }
  201|   573k|    }
  202|    738|    if (errors()) {
  ------------------
  |  Branch (202:9): [True: 316, False: 422]
  ------------------
  203|    316|      return 0;
  204|    316|    }
  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: 218, False: 202]
  ------------------
  209|    218|        return 0;
  210|    218|      }
  211|    202|      utf16_output += howmany;
  212|    202|    }
  213|    204|    return utf16_output - start;
  214|    422|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder19convert_with_errorsILNS_10endiannessE0EEENS_6resultEPKcmPDs:
  218|    594|                                                   char16_t *utf16_output) {
  219|    594|    size_t pos = 0;
  220|    594|    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|    594|    size_t leading_byte = 0;
  228|    594|    size_t margin = size;
  229|  5.04k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (229:12): [True: 4.81k, False: 230]
  |  Branch (229:26): [True: 4.44k, False: 364]
  ------------------
  230|  4.44k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  231|  4.44k|    }
  232|       |    // If the input is long enough, then we have that margin-1 is the eight last
  233|       |    // leading byte.
  234|    594|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  235|   387k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (235:12): [True: 387k, False: 512]
  ------------------
  236|   387k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  237|   387k|      if (input.is_ascii()) {
  ------------------
  |  Branch (237:11): [True: 294k, False: 92.8k]
  ------------------
  238|   294k|        input.store_ascii_as_utf16<endian>(utf16_output);
  239|   294k|        utf16_output += 64;
  240|   294k|        pos += 64;
  241|   294k|      } else {
  242|       |        // you might think that a for-loop would work, but under Visual Studio,
  243|       |        // it is not good enough.
  244|  92.8k|        static_assert(
  245|  92.8k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  246|  92.8k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  247|  92.8k|            "We support either two or four chunks per 64-byte block.");
  248|  92.8k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  249|       |        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  250|       |          this->check_utf8_bytes(input.chunks[0], zero);
  251|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  252|  92.8k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  253|  92.8k|          this->check_utf8_bytes(input.chunks[0], zero);
  254|  92.8k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  255|  92.8k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  256|  92.8k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  257|  92.8k|        }
  258|  92.8k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  259|  92.8k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (259:13): [True: 82, False: 92.7k]
  |  Branch (259:25): [True: 0, False: 92.7k]
  ------------------
  260|       |          // rewind_and_convert_with_errors will seek a potential error from
  261|       |          // in+pos onward, with the ability to go back up to pos bytes, and
  262|       |          // read size-pos bytes forward.
  263|     82|          result res =
  264|     82|              scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  265|     82|                  pos, in + pos, size - pos, utf16_output);
  266|     82|          res.count += pos;
  267|     82|          return res;
  268|     82|        }
  269|  92.7k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  270|  92.7k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  271|       |        // We process in blocks of up to 12 bytes except possibly
  272|       |        // for fast paths which may process up to 16 bytes. For the
  273|       |        // slow path to work, we should have at least 12 input bytes left.
  274|  92.7k|        size_t max_starting_point = (pos + 64) - 12;
  275|       |        // Next loop is going to run at least five times.
  276|   911k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (276:16): [True: 819k, False: 92.7k]
  ------------------
  277|       |          // Performance note: our ability to compute 'consumed' and
  278|       |          // then shift and recompute is critical. If there is a
  279|       |          // latency of, say, 4 cycles on getting 'consumed', then
  280|       |          // the inner loop might have a total latency of about 6 cycles.
  281|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  282|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  283|       |          // for this section of the code. Hence, there is a limit
  284|       |          // to how much we can further increase this latency before
  285|       |          // it seriously harms performance.
  286|   819k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  287|   819k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  288|   819k|          pos += consumed;
  289|   819k|          utf8_end_of_code_point_mask >>= consumed;
  290|   819k|        }
  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|  92.7k|      }
  296|   387k|    }
  297|    512|    if (errors()) {
  ------------------
  |  Branch (297:9): [True: 0, False: 512]
  ------------------
  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|    512|    if (pos < size) {
  ------------------
  |  Branch (307:9): [True: 508, 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|    508|      result res =
  312|    508|          scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  313|    508|              pos, in + pos, size - pos, utf16_output);
  314|    508|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (314:11): [True: 258, False: 250]
  ------------------
  315|    258|        res.count += pos;
  316|    258|        return res;
  317|    258|      } else { // In case of success, we want the number of word written
  318|    250|        utf16_output += res.count;
  319|    250|      }
  320|    508|    }
  321|    254|    return result(error_code::SUCCESS, utf16_output - start);
  322|    512|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder19convert_with_errorsILNS_10endiannessE1EEENS_6resultEPKcmPDs:
  218|    772|                                                   char16_t *utf16_output) {
  219|    772|    size_t pos = 0;
  220|    772|    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|    772|    size_t leading_byte = 0;
  228|    772|    size_t margin = size;
  229|  6.85k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (229:12): [True: 6.58k, False: 264]
  |  Branch (229:26): [True: 6.08k, False: 508]
  ------------------
  230|  6.08k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  231|  6.08k|    }
  232|       |    // If the input is long enough, then we have that margin-1 is the eight last
  233|       |    // leading byte.
  234|    772|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  235|   462k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (235:12): [True: 462k, False: 706]
  ------------------
  236|   462k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  237|   462k|      if (input.is_ascii()) {
  ------------------
  |  Branch (237:11): [True: 358k, False: 103k]
  ------------------
  238|   358k|        input.store_ascii_as_utf16<endian>(utf16_output);
  239|   358k|        utf16_output += 64;
  240|   358k|        pos += 64;
  241|   358k|      } else {
  242|       |        // you might think that a for-loop would work, but under Visual Studio,
  243|       |        // it is not good enough.
  244|   103k|        static_assert(
  245|   103k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  246|   103k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  247|   103k|            "We support either two or four chunks per 64-byte block.");
  248|   103k|        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|   103k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  253|   103k|          this->check_utf8_bytes(input.chunks[0], zero);
  254|   103k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  255|   103k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  256|   103k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  257|   103k|        }
  258|   103k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  259|   103k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (259:13): [True: 66, False: 103k]
  |  Branch (259:25): [True: 0, False: 103k]
  ------------------
  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|     66|          result res =
  264|     66|              scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  265|     66|                  pos, in + pos, size - pos, utf16_output);
  266|     66|          res.count += pos;
  267|     66|          return res;
  268|     66|        }
  269|   103k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  270|   103k|        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|   103k|        size_t max_starting_point = (pos + 64) - 12;
  275|       |        // Next loop is going to run at least five times.
  276|  1.02M|        while (pos < max_starting_point) {
  ------------------
  |  Branch (276:16): [True: 917k, False: 103k]
  ------------------
  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|   917k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  287|   917k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  288|   917k|          pos += consumed;
  289|   917k|          utf8_end_of_code_point_mask >>= consumed;
  290|   917k|        }
  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|   103k|      }
  296|   462k|    }
  297|    706|    if (errors()) {
  ------------------
  |  Branch (297:9): [True: 0, False: 706]
  ------------------
  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|    706|    if (pos < size) {
  ------------------
  |  Branch (307:9): [True: 702, 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|    702|      result res =
  312|    702|          scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  313|    702|              pos, in + pos, size - pos, utf16_output);
  314|    702|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (314:11): [True: 356, False: 346]
  ------------------
  315|    356|        res.count += pos;
  316|    356|        return res;
  317|    356|      } else { // In case of success, we want the number of word written
  318|    346|        utf16_output += res.count;
  319|    346|      }
  320|    702|    }
  321|    350|    return result(error_code::SUCCESS, utf16_output - start);
  322|    706|  }

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3221validating_transcoderC2Ev:
  114|  1.60k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3221validating_transcoder7convertEPKcmPDi:
  129|    818|                                       char32_t *utf32_output) {
  130|    818|    size_t pos = 0;
  131|    818|    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|    818|    size_t leading_byte = 0;
  139|    818|    size_t margin = size;
  140|  7.52k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (140:12): [True: 7.26k, False: 266]
  |  Branch (140:26): [True: 6.70k, False: 552]
  ------------------
  141|  6.70k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  142|  6.70k|    }
  143|       |    // If the input is long enough, then we have that margin-1 is the fourth
  144|       |    // last leading byte.
  145|    818|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  146|   764k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (146:12): [True: 763k, False: 794]
  ------------------
  147|   763k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  148|   763k|      if (input.is_ascii()) {
  ------------------
  |  Branch (148:11): [True: 505k, False: 258k]
  ------------------
  149|   505k|        input.store_ascii_as_utf32(utf32_output);
  150|   505k|        utf32_output += 64;
  151|   505k|        pos += 64;
  152|   505k|      } else {
  153|       |        // you might think that a for-loop would work, but under Visual Studio,
  154|       |        // it is not good enough.
  155|   258k|        static_assert(
  156|   258k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  157|   258k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  158|   258k|            "We support either two or four chunks per 64-byte block.");
  159|   258k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  160|   258k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  161|   258k|          this->check_utf8_bytes(input.chunks[0], zero);
  162|   258k|          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|   258k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  170|   258k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (170:13): [True: 24, False: 258k]
  ------------------
  171|     24|          return 0; // we have an error
  172|     24|        }
  173|   258k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  174|   258k|        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|   258k|        size_t max_starting_point = (pos + 64) - 12;
  179|       |        // Next loop is going to run at least five times.
  180|  2.57M|        while (pos < max_starting_point) {
  ------------------
  |  Branch (180:16): [True: 2.31M, False: 258k]
  ------------------
  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.31M|          size_t consumed = convert_masked_utf8_to_utf32(
  191|  2.31M|              in + pos, utf8_end_of_code_point_mask, utf32_output);
  192|  2.31M|          pos += consumed;
  193|  2.31M|          utf8_end_of_code_point_mask >>= consumed;
  194|  2.31M|        }
  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|   258k|      }
  200|   763k|    }
  201|    794|    if (errors()) {
  ------------------
  |  Branch (201:9): [True: 306, False: 488]
  ------------------
  202|    306|      return 0;
  203|    306|    }
  204|    488|    if (pos < size) {
  ------------------
  |  Branch (204:9): [True: 486, False: 2]
  ------------------
  205|    486|      size_t howmany =
  206|    486|          scalar::utf8_to_utf32::convert(in + pos, size - pos, utf32_output);
  207|    486|      if (howmany == 0) {
  ------------------
  |  Branch (207:11): [True: 208, False: 278]
  ------------------
  208|    208|        return 0;
  209|    208|      }
  210|    278|      utf32_output += howmany;
  211|    278|    }
  212|    280|    return utf32_output - start;
  213|    488|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3221validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  119|   645k|                                              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|   645k|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  124|   645k|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  125|   645k|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  126|   645k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3219check_special_casesENS1_4simd5simd8IhEES5_:
    8|   645k|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|   645k|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   16|       |                                               // 11______ 11______
   17|   645k|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   18|   645k|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   19|   645k|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   20|   645k|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   21|   645k|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   22|   645k|  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|   645k|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   31|       |  // 11110101 1000____
   32|       |  // 1111011_ 1000____
   33|       |  // 11111___ 1000____
   34|   645k|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   35|       |
   36|   645k|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   37|       |      // 0_______ ________ <ASCII in byte 1>
   38|   645k|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   39|   645k|      TOO_LONG,
   40|       |      // 10______ ________ <continuation in byte 1>
   41|   645k|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   42|       |      // 1100____ ________ <two byte lead in byte 1>
   43|   645k|      TOO_SHORT | OVERLONG_2,
   44|       |      // 1101____ ________ <two byte lead in byte 1>
   45|   645k|      TOO_SHORT,
   46|       |      // 1110____ ________ <three byte lead in byte 1>
   47|   645k|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   48|       |      // 1111____ ________ <four+ byte lead in byte 1>
   49|   645k|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   50|   645k|  constexpr const uint8_t CARRY =
   51|   645k|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   52|   645k|  const simd8<uint8_t> byte_1_low =
   53|   645k|      (prev1 & 0x0F)
   54|   645k|          .lookup_16<uint8_t>(
   55|       |              // ____0000 ________
   56|   645k|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   57|       |              // ____0001 ________
   58|   645k|              CARRY | OVERLONG_2,
   59|       |              // ____001_ ________
   60|   645k|              CARRY, CARRY,
   61|       |
   62|       |              // ____0100 ________
   63|   645k|              CARRY | TOO_LARGE,
   64|       |              // ____0101 ________
   65|   645k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   66|       |              // ____011_ ________
   67|   645k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   68|   645k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|       |
   70|       |              // ____1___ ________
   71|   645k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   72|   645k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|   645k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|   645k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|   645k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|       |              // ____1101 ________
   77|   645k|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   78|   645k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   79|   645k|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   80|   645k|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   81|       |      // ________ 0_______ <ASCII in byte 2>
   82|   645k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   83|   645k|      TOO_SHORT, TOO_SHORT,
   84|       |
   85|       |      // ________ 1000____
   86|   645k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   87|   645k|          OVERLONG_4,
   88|       |      // ________ 1001____
   89|   645k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   90|       |      // ________ 101_____
   91|   645k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   92|   645k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|       |
   94|       |      // ________ 11______
   95|   645k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   96|   645k|  return (byte_1_high & byte_1_low & byte_2_high);
   97|   645k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3223check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  101|   645k|                        const simd8<uint8_t> sc) {
  102|   645k|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  103|   645k|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  104|   645k|  simd8<uint8_t> must23 =
  105|   645k|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  106|   645k|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  107|   645k|  return must23_80 ^ sc;
  108|   645k|}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3221validating_transcoder6errorsEv:
  310|  65.3k|  simdutf_really_inline bool errors() const {
  311|  65.3k|    return this->error.any_bits_set_anywhere();
  312|  65.3k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3221validating_transcoder19convert_with_errorsEPKcmPDi:
  216|    790|                                                   char32_t *utf32_output) {
  217|    790|    size_t pos = 0;
  218|    790|    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|    790|    size_t leading_byte = 0;
  226|    790|    size_t margin = size;
  227|  6.67k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (227:12): [True: 6.40k, False: 266]
  |  Branch (227:26): [True: 5.88k, False: 524]
  ------------------
  228|  5.88k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  229|  5.88k|    }
  230|       |    // If the input is long enough, then we have that margin-1 is the fourth
  231|       |    // last leading byte.
  232|    790|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  233|   464k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (233:12): [True: 463k, False: 702]
  ------------------
  234|   463k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  235|   463k|      if (input.is_ascii()) {
  ------------------
  |  Branch (235:11): [True: 399k, False: 63.8k]
  ------------------
  236|   399k|        input.store_ascii_as_utf32(utf32_output);
  237|   399k|        utf32_output += 64;
  238|   399k|        pos += 64;
  239|   399k|      } else {
  240|       |        // you might think that a for-loop would work, but under Visual Studio,
  241|       |        // it is not good enough.
  242|  63.8k|        static_assert(
  243|  63.8k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  244|  63.8k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  245|  63.8k|            "We support either two or four chunks per 64-byte block.");
  246|  63.8k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  247|  63.8k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  248|  63.8k|          this->check_utf8_bytes(input.chunks[0], zero);
  249|  63.8k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  250|       |        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  251|       |          this->check_utf8_bytes(input.chunks[0], zero);
  252|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  253|       |          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  254|       |          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  255|       |        }
  256|  63.8k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  257|  63.8k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (257:13): [True: 88, False: 63.7k]
  |  Branch (257:25): [True: 0, False: 63.7k]
  ------------------
  258|     88|          result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(
  259|     88|              pos, in + pos, size - pos, utf32_output);
  260|     88|          res.count += pos;
  261|     88|          return res;
  262|     88|        }
  263|  63.7k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  264|  63.7k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  265|       |        // We process in blocks of up to 12 bytes except possibly
  266|       |        // for fast paths which may process up to 16 bytes. For the
  267|       |        // slow path to work, we should have at least 12 input bytes left.
  268|  63.7k|        size_t max_starting_point = (pos + 64) - 12;
  269|       |        // Next loop is going to run at least five times.
  270|   616k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (270:16): [True: 553k, False: 63.7k]
  ------------------
  271|       |          // Performance note: our ability to compute 'consumed' and
  272|       |          // then shift and recompute is critical. If there is a
  273|       |          // latency of, say, 4 cycles on getting 'consumed', then
  274|       |          // the inner loop might have a total latency of about 6 cycles.
  275|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  276|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  277|       |          // for this section of the code. Hence, there is a limit
  278|       |          // to how much we can further increase this latency before
  279|       |          // it seriously harms performance.
  280|   553k|          size_t consumed = convert_masked_utf8_to_utf32(
  281|   553k|              in + pos, utf8_end_of_code_point_mask, utf32_output);
  282|   553k|          pos += consumed;
  283|   553k|          utf8_end_of_code_point_mask >>= consumed;
  284|   553k|        }
  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|  63.7k|      }
  290|   463k|    }
  291|    702|    if (errors()) {
  ------------------
  |  Branch (291:9): [True: 0, False: 702]
  ------------------
  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|    702|    if (pos < size) {
  ------------------
  |  Branch (297:9): [True: 698, False: 4]
  ------------------
  298|    698|      result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(
  299|    698|          pos, in + pos, size - pos, utf32_output);
  300|    698|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (300:11): [True: 356, False: 342]
  ------------------
  301|    356|        res.count += pos;
  302|    356|        return res;
  303|    356|      } else { // In case of success, we want the number of word written
  304|    342|        utf32_output += res.count;
  305|    342|      }
  306|    698|    }
  307|    346|    return result(error_code::SUCCESS, utf32_output - start);
  308|    702|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3221validating_transcoderC2Ev:
  114|  1.60k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3221validating_transcoder7convertEPKcmPDi:
  129|    818|                                       char32_t *utf32_output) {
  130|    818|    size_t pos = 0;
  131|    818|    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|    818|    size_t leading_byte = 0;
  139|    818|    size_t margin = size;
  140|  7.52k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (140:12): [True: 7.26k, False: 266]
  |  Branch (140:26): [True: 6.70k, False: 552]
  ------------------
  141|  6.70k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  142|  6.70k|    }
  143|       |    // If the input is long enough, then we have that margin-1 is the fourth
  144|       |    // last leading byte.
  145|    818|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  146|   764k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (146:12): [True: 763k, False: 794]
  ------------------
  147|   763k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  148|   763k|      if (input.is_ascii()) {
  ------------------
  |  Branch (148:11): [True: 505k, False: 258k]
  ------------------
  149|   505k|        input.store_ascii_as_utf32(utf32_output);
  150|   505k|        utf32_output += 64;
  151|   505k|        pos += 64;
  152|   505k|      } else {
  153|       |        // you might think that a for-loop would work, but under Visual Studio,
  154|       |        // it is not good enough.
  155|   258k|        static_assert(
  156|   258k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  157|   258k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  158|   258k|            "We support either two or four chunks per 64-byte block.");
  159|   258k|        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|   258k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  164|   258k|          this->check_utf8_bytes(input.chunks[0], zero);
  165|   258k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  166|   258k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  167|   258k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  168|   258k|        }
  169|   258k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  170|   258k|        if (utf8_continuation_mask & 1) {
  ------------------
  |  Branch (170:13): [True: 24, False: 258k]
  ------------------
  171|     24|          return 0; // we have an error
  172|     24|        }
  173|   258k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  174|   258k|        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|   258k|        size_t max_starting_point = (pos + 64) - 12;
  179|       |        // Next loop is going to run at least five times.
  180|  2.57M|        while (pos < max_starting_point) {
  ------------------
  |  Branch (180:16): [True: 2.31M, False: 258k]
  ------------------
  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.31M|          size_t consumed = convert_masked_utf8_to_utf32(
  191|  2.31M|              in + pos, utf8_end_of_code_point_mask, utf32_output);
  192|  2.31M|          pos += consumed;
  193|  2.31M|          utf8_end_of_code_point_mask >>= consumed;
  194|  2.31M|        }
  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|   258k|      }
  200|   763k|    }
  201|    794|    if (errors()) {
  ------------------
  |  Branch (201:9): [True: 306, False: 488]
  ------------------
  202|    306|      return 0;
  203|    306|    }
  204|    488|    if (pos < size) {
  ------------------
  |  Branch (204:9): [True: 486, False: 2]
  ------------------
  205|    486|      size_t howmany =
  206|    486|          scalar::utf8_to_utf32::convert(in + pos, size - pos, utf32_output);
  207|    486|      if (howmany == 0) {
  ------------------
  |  Branch (207:11): [True: 208, False: 278]
  ------------------
  208|    208|        return 0;
  209|    208|      }
  210|    278|      utf32_output += howmany;
  211|    278|    }
  212|    280|    return utf32_output - start;
  213|    488|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3221validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  119|  1.29M|                                              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.29M|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  124|  1.29M|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  125|  1.29M|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  126|  1.29M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3219check_special_casesENS1_4simd5simd8IhEES5_:
    8|  1.29M|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.29M|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   16|       |                                               // 11______ 11______
   17|  1.29M|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   18|  1.29M|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   19|  1.29M|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   20|  1.29M|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   21|  1.29M|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   22|  1.29M|  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.29M|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   31|       |  // 11110101 1000____
   32|       |  // 1111011_ 1000____
   33|       |  // 11111___ 1000____
   34|  1.29M|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   35|       |
   36|  1.29M|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   37|       |      // 0_______ ________ <ASCII in byte 1>
   38|  1.29M|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   39|  1.29M|      TOO_LONG,
   40|       |      // 10______ ________ <continuation in byte 1>
   41|  1.29M|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   42|       |      // 1100____ ________ <two byte lead in byte 1>
   43|  1.29M|      TOO_SHORT | OVERLONG_2,
   44|       |      // 1101____ ________ <two byte lead in byte 1>
   45|  1.29M|      TOO_SHORT,
   46|       |      // 1110____ ________ <three byte lead in byte 1>
   47|  1.29M|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   48|       |      // 1111____ ________ <four+ byte lead in byte 1>
   49|  1.29M|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   50|  1.29M|  constexpr const uint8_t CARRY =
   51|  1.29M|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   52|  1.29M|  const simd8<uint8_t> byte_1_low =
   53|  1.29M|      (prev1 & 0x0F)
   54|  1.29M|          .lookup_16<uint8_t>(
   55|       |              // ____0000 ________
   56|  1.29M|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   57|       |              // ____0001 ________
   58|  1.29M|              CARRY | OVERLONG_2,
   59|       |              // ____001_ ________
   60|  1.29M|              CARRY, CARRY,
   61|       |
   62|       |              // ____0100 ________
   63|  1.29M|              CARRY | TOO_LARGE,
   64|       |              // ____0101 ________
   65|  1.29M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   66|       |              // ____011_ ________
   67|  1.29M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   68|  1.29M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|       |
   70|       |              // ____1___ ________
   71|  1.29M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   72|  1.29M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|  1.29M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|  1.29M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|  1.29M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|       |              // ____1101 ________
   77|  1.29M|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   78|  1.29M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   79|  1.29M|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   80|  1.29M|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   81|       |      // ________ 0_______ <ASCII in byte 2>
   82|  1.29M|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   83|  1.29M|      TOO_SHORT, TOO_SHORT,
   84|       |
   85|       |      // ________ 1000____
   86|  1.29M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   87|  1.29M|          OVERLONG_4,
   88|       |      // ________ 1001____
   89|  1.29M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   90|       |      // ________ 101_____
   91|  1.29M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   92|  1.29M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|       |
   94|       |      // ________ 11______
   95|  1.29M|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   96|  1.29M|  return (byte_1_high & byte_1_low & byte_2_high);
   97|  1.29M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3223check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  101|  1.29M|                        const simd8<uint8_t> sc) {
  102|  1.29M|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  103|  1.29M|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  104|  1.29M|  simd8<uint8_t> must23 =
  105|  1.29M|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  106|  1.29M|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  107|  1.29M|  return must23_80 ^ sc;
  108|  1.29M|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3221validating_transcoder6errorsEv:
  310|  65.3k|  simdutf_really_inline bool errors() const {
  311|  65.3k|    return this->error.any_bits_set_anywhere();
  312|  65.3k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3221validating_transcoder19convert_with_errorsEPKcmPDi:
  216|    790|                                                   char32_t *utf32_output) {
  217|    790|    size_t pos = 0;
  218|    790|    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|    790|    size_t leading_byte = 0;
  226|    790|    size_t margin = size;
  227|  6.67k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (227:12): [True: 6.40k, False: 266]
  |  Branch (227:26): [True: 5.88k, False: 524]
  ------------------
  228|  5.88k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  229|  5.88k|    }
  230|       |    // If the input is long enough, then we have that margin-1 is the fourth
  231|       |    // last leading byte.
  232|    790|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  233|   464k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (233:12): [True: 463k, False: 702]
  ------------------
  234|   463k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  235|   463k|      if (input.is_ascii()) {
  ------------------
  |  Branch (235:11): [True: 399k, False: 63.8k]
  ------------------
  236|   399k|        input.store_ascii_as_utf32(utf32_output);
  237|   399k|        utf32_output += 64;
  238|   399k|        pos += 64;
  239|   399k|      } else {
  240|       |        // you might think that a for-loop would work, but under Visual Studio,
  241|       |        // it is not good enough.
  242|  63.8k|        static_assert(
  243|  63.8k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  244|  63.8k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  245|  63.8k|            "We support either two or four chunks per 64-byte block.");
  246|  63.8k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  247|       |        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  248|       |          this->check_utf8_bytes(input.chunks[0], zero);
  249|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  250|  63.8k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  251|  63.8k|          this->check_utf8_bytes(input.chunks[0], zero);
  252|  63.8k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  253|  63.8k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  254|  63.8k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  255|  63.8k|        }
  256|  63.8k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  257|  63.8k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (257:13): [True: 88, False: 63.7k]
  |  Branch (257:25): [True: 0, False: 63.7k]
  ------------------
  258|     88|          result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(
  259|     88|              pos, in + pos, size - pos, utf32_output);
  260|     88|          res.count += pos;
  261|     88|          return res;
  262|     88|        }
  263|  63.7k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  264|  63.7k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  265|       |        // We process in blocks of up to 12 bytes except possibly
  266|       |        // for fast paths which may process up to 16 bytes. For the
  267|       |        // slow path to work, we should have at least 12 input bytes left.
  268|  63.7k|        size_t max_starting_point = (pos + 64) - 12;
  269|       |        // Next loop is going to run at least five times.
  270|   616k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (270:16): [True: 553k, False: 63.7k]
  ------------------
  271|       |          // Performance note: our ability to compute 'consumed' and
  272|       |          // then shift and recompute is critical. If there is a
  273|       |          // latency of, say, 4 cycles on getting 'consumed', then
  274|       |          // the inner loop might have a total latency of about 6 cycles.
  275|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  276|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  277|       |          // for this section of the code. Hence, there is a limit
  278|       |          // to how much we can further increase this latency before
  279|       |          // it seriously harms performance.
  280|   553k|          size_t consumed = convert_masked_utf8_to_utf32(
  281|   553k|              in + pos, utf8_end_of_code_point_mask, utf32_output);
  282|   553k|          pos += consumed;
  283|   553k|          utf8_end_of_code_point_mask >>= consumed;
  284|   553k|        }
  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|  63.7k|      }
  290|   463k|    }
  291|    702|    if (errors()) {
  ------------------
  |  Branch (291:9): [True: 0, False: 702]
  ------------------
  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|    702|    if (pos < size) {
  ------------------
  |  Branch (297:9): [True: 698, False: 4]
  ------------------
  298|    698|      result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(
  299|    698|          pos, in + pos, size - pos, utf32_output);
  300|    698|      if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (300:11): [True: 356, False: 342]
  ------------------
  301|    356|        res.count += pos;
  302|    356|        return res;
  303|    356|      } else { // In case of success, we want the number of word written
  304|    342|        utf32_output += res.count;
  305|    342|      }
  306|    698|    }
  307|    346|    return result(error_code::SUCCESS, utf32_output - start);
  308|    702|  }

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

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

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE0EEEKNS_6resultEPKDsm:
   49|  2.75k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  2.75k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.75k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 16, False: 2.74k]
  |  |  ------------------
  ------------------
   51|     16|    return result(error_code::SUCCESS, 0);
   52|     16|  }
   53|       |
   54|  2.74k|  const char16_t *start = input;
   55|  2.74k|  const char16_t *end = input + size;
   56|       |
   57|  2.74k|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|  2.74k|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|  2.74k|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|  2.74k|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|  2.33M|  while (input + simd16<uint16_t>::SIZE * 2 < end) {
  ------------------
  |  Branch (62:10): [True: 2.33M, 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.33M|    auto in0 = simd16<uint16_t>(input);
   67|  2.33M|    auto in1 =
   68|  2.33M|        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.33M|    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.33M|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   76|  2.33M|    const uint16_t surrogates_bitmask =
   77|  2.33M|        static_cast<uint16_t>(surrogates_wordmask.to_bitmask());
   78|  2.33M|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (78:9): [True: 2.31M, False: 21.8k]
  ------------------
   79|  2.31M|      input += 16;
   80|  2.31M|    } else {
   81|       |      // 2. We have some surrogates that have to be distinguished:
   82|       |      //    - low  surrogates: 0b1101'10xx'yyyy'yyyy (0xD800..0xDBFF)
   83|       |      //    - high surrogates: 0b1101'11xx'yyyy'yyyy (0xDC00..0xDFFF)
   84|       |      //
   85|       |      //    Fact: high surrogate has 11th bit set (3rd bit in the higher byte)
   86|       |
   87|       |      // V - non-surrogate code units
   88|       |      //     V = not surrogates_wordmask
   89|  21.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|  21.8k|      const auto vH = (in & v_fc) == v_dc;
   93|  21.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|  21.8k|      const uint16_t L = static_cast<uint16_t>(~H & surrogates_bitmask);
   98|       |
   99|  21.8k|      const uint16_t a = static_cast<uint16_t>(
  100|  21.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|  21.8k|      const uint16_t b = static_cast<uint16_t>(
  104|  21.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|  21.8k|      const uint16_t c = static_cast<uint16_t>(
  107|  21.8k|          V | a | b); // Combine all the masks into the final one.
  108|       |
  109|  21.8k|      if (c == 0xffff) {
  ------------------
  |  Branch (109:11): [True: 16.8k, False: 5.06k]
  ------------------
  110|       |        // The whole input register contains valid UTF-16, i.e.,
  111|       |        // either single code units or proper surrogate pairs.
  112|  16.8k|        input += 16;
  113|  16.8k|      } else if (c == 0x7fff) {
  ------------------
  |  Branch (113:18): [True: 4.86k, False: 204]
  ------------------
  114|       |        // The 15 lower code units of the input register contains valid UTF-16.
  115|       |        // The 15th word may be either a low or high surrogate. It the next
  116|       |        // iteration we 1) check if the low surrogate is followed by a high
  117|       |        // one, 2) reject sole high surrogate.
  118|  4.86k|        input += 15;
  119|  4.86k|      } else {
  120|    204|        return result(error_code::SURROGATE, input - start);
  121|    204|      }
  122|  21.8k|    }
  123|  2.33M|  }
  124|       |
  125|  2.53k|  return result(error_code::SUCCESS, input - start);
  126|  2.74k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE1EEEKNS_6resultEPKDsm:
   49|  2.67k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  2.67k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.67k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 16, False: 2.66k]
  |  |  ------------------
  ------------------
   51|     16|    return result(error_code::SUCCESS, 0);
   52|     16|  }
   53|       |
   54|  2.66k|  const char16_t *start = input;
   55|  2.66k|  const char16_t *end = input + size;
   56|       |
   57|  2.66k|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|  2.66k|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|  2.66k|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|  2.66k|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|  2.77M|  while (input + simd16<uint16_t>::SIZE * 2 < end) {
  ------------------
  |  Branch (62:10): [True: 2.77M, False: 2.50k]
  ------------------
   63|       |    // 0. Load data: since the validation takes into account only higher
   64|       |    //    byte of each word, we compress the two vectors into one which
   65|       |    //    consists only the higher bytes.
   66|  2.77M|    auto in0 = simd16<uint16_t>(input);
   67|  2.77M|    auto in1 =
   68|  2.77M|        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.77M|    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.77M|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   76|  2.77M|    const uint16_t surrogates_bitmask =
   77|  2.77M|        static_cast<uint16_t>(surrogates_wordmask.to_bitmask());
   78|  2.77M|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (78:9): [True: 2.75M, False: 18.5k]
  ------------------
   79|  2.75M|      input += 16;
   80|  2.75M|    } else {
   81|       |      // 2. We have some surrogates that have to be distinguished:
   82|       |      //    - low  surrogates: 0b1101'10xx'yyyy'yyyy (0xD800..0xDBFF)
   83|       |      //    - high surrogates: 0b1101'11xx'yyyy'yyyy (0xDC00..0xDFFF)
   84|       |      //
   85|       |      //    Fact: high surrogate has 11th bit set (3rd bit in the higher byte)
   86|       |
   87|       |      // V - non-surrogate code units
   88|       |      //     V = not surrogates_wordmask
   89|  18.5k|      const uint16_t V = static_cast<uint16_t>(~surrogates_bitmask);
   90|       |
   91|       |      // H - word-mask for high surrogates: the six highest bits are 0b1101'11
   92|  18.5k|      const auto vH = (in & v_fc) == v_dc;
   93|  18.5k|      const uint16_t H = static_cast<uint16_t>(vH.to_bitmask());
   94|       |
   95|       |      // L - word mask for low surrogates
   96|       |      //     L = not H and surrogates_wordmask
   97|  18.5k|      const uint16_t L = static_cast<uint16_t>(~H & surrogates_bitmask);
   98|       |
   99|  18.5k|      const uint16_t a = static_cast<uint16_t>(
  100|  18.5k|          L & (H >> 1)); // A low surrogate must be followed by high one.
  101|       |                         // (A low surrogate placed in the 7th register's word
  102|       |                         // is an exception we handle.)
  103|  18.5k|      const uint16_t b = static_cast<uint16_t>(
  104|  18.5k|          a << 1); // Just mark that the opinput - startite fact is hold,
  105|       |                   // thanks to that we have only two masks for valid case.
  106|  18.5k|      const uint16_t c = static_cast<uint16_t>(
  107|  18.5k|          V | a | b); // Combine all the masks into the final one.
  108|       |
  109|  18.5k|      if (c == 0xffff) {
  ------------------
  |  Branch (109:11): [True: 14.1k, False: 4.33k]
  ------------------
  110|       |        // The whole input register contains valid UTF-16, i.e.,
  111|       |        // either single code units or proper surrogate pairs.
  112|  14.1k|        input += 16;
  113|  14.1k|      } else if (c == 0x7fff) {
  ------------------
  |  Branch (113:18): [True: 4.17k, False: 160]
  ------------------
  114|       |        // The 15 lower code units of the input register contains valid UTF-16.
  115|       |        // The 15th word may be either a low or high surrogate. It the next
  116|       |        // iteration we 1) check if the low surrogate is followed by a high
  117|       |        // one, 2) reject sole high surrogate.
  118|  4.17k|        input += 15;
  119|  4.17k|      } else {
  120|    160|        return result(error_code::SURROGATE, input - start);
  121|    160|      }
  122|  18.5k|    }
  123|  2.77M|  }
  124|       |
  125|  2.50k|  return result(error_code::SUCCESS, input - start);
  126|  2.66k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE0EEEKNS_6resultEPKDsm:
   49|  2.75k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  2.75k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.75k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 16, False: 2.74k]
  |  |  ------------------
  ------------------
   51|     16|    return result(error_code::SUCCESS, 0);
   52|     16|  }
   53|       |
   54|  2.74k|  const char16_t *start = input;
   55|  2.74k|  const char16_t *end = input + size;
   56|       |
   57|  2.74k|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|  2.74k|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|  2.74k|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|  2.74k|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|  2.33M|  while (input + simd16<uint16_t>::SIZE * 2 < end) {
  ------------------
  |  Branch (62:10): [True: 2.33M, False: 2.43k]
  ------------------
   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.33M|    auto in0 = simd16<uint16_t>(input);
   67|  2.33M|    auto in1 =
   68|  2.33M|        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.33M|    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.33M|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   76|  2.33M|    const uint16_t surrogates_bitmask =
   77|  2.33M|        static_cast<uint16_t>(surrogates_wordmask.to_bitmask());
   78|  2.33M|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (78:9): [True: 2.31M, False: 22.3k]
  ------------------
   79|  2.31M|      input += 16;
   80|  2.31M|    } 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|  22.3k|      const uint16_t V = static_cast<uint16_t>(~surrogates_bitmask);
   90|       |
   91|       |      // H - word-mask for high surrogates: the six highest bits are 0b1101'11
   92|  22.3k|      const auto vH = (in & v_fc) == v_dc;
   93|  22.3k|      const uint16_t H = static_cast<uint16_t>(vH.to_bitmask());
   94|       |
   95|       |      // L - word mask for low surrogates
   96|       |      //     L = not H and surrogates_wordmask
   97|  22.3k|      const uint16_t L = static_cast<uint16_t>(~H & surrogates_bitmask);
   98|       |
   99|  22.3k|      const uint16_t a = static_cast<uint16_t>(
  100|  22.3k|          L & (H >> 1)); // A low surrogate must be followed by high one.
  101|       |                         // (A low surrogate placed in the 7th register's word
  102|       |                         // is an exception we handle.)
  103|  22.3k|      const uint16_t b = static_cast<uint16_t>(
  104|  22.3k|          a << 1); // Just mark that the opinput - startite fact is hold,
  105|       |                   // thanks to that we have only two masks for valid case.
  106|  22.3k|      const uint16_t c = static_cast<uint16_t>(
  107|  22.3k|          V | a | b); // Combine all the masks into the final one.
  108|       |
  109|  22.3k|      if (c == 0xffff) {
  ------------------
  |  Branch (109:11): [True: 17.1k, False: 5.23k]
  ------------------
  110|       |        // The whole input register contains valid UTF-16, i.e.,
  111|       |        // either single code units or proper surrogate pairs.
  112|  17.1k|        input += 16;
  113|  17.1k|      } else if (c == 0x7fff) {
  ------------------
  |  Branch (113:18): [True: 4.93k, False: 302]
  ------------------
  114|       |        // The 15 lower code units of the input register contains valid UTF-16.
  115|       |        // The 15th word may be either a low or high surrogate. It the next
  116|       |        // iteration we 1) check if the low surrogate is followed by a high
  117|       |        // one, 2) reject sole high surrogate.
  118|  4.93k|        input += 15;
  119|  4.93k|      } else {
  120|    302|        return result(error_code::SURROGATE, input - start);
  121|    302|      }
  122|  22.3k|    }
  123|  2.33M|  }
  124|       |
  125|  2.43k|  return result(error_code::SUCCESS, input - start);
  126|  2.74k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE1EEEKNS_6resultEPKDsm:
   49|  2.67k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  2.67k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.67k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 16, False: 2.66k]
  |  |  ------------------
  ------------------
   51|     16|    return result(error_code::SUCCESS, 0);
   52|     16|  }
   53|       |
   54|  2.66k|  const char16_t *start = input;
   55|  2.66k|  const char16_t *end = input + size;
   56|       |
   57|  2.66k|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|  2.66k|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|  2.66k|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|  2.66k|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|  2.77M|  while (input + simd16<uint16_t>::SIZE * 2 < end) {
  ------------------
  |  Branch (62:10): [True: 2.77M, False: 2.39k]
  ------------------
   63|       |    // 0. Load data: since the validation takes into account only higher
   64|       |    //    byte of each word, we compress the two vectors into one which
   65|       |    //    consists only the higher bytes.
   66|  2.77M|    auto in0 = simd16<uint16_t>(input);
   67|  2.77M|    auto in1 =
   68|  2.77M|        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.77M|    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.77M|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   76|  2.77M|    const uint16_t surrogates_bitmask =
   77|  2.77M|        static_cast<uint16_t>(surrogates_wordmask.to_bitmask());
   78|  2.77M|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (78:9): [True: 2.75M, False: 19.0k]
  ------------------
   79|  2.75M|      input += 16;
   80|  2.75M|    } else {
   81|       |      // 2. We have some surrogates that have to be distinguished:
   82|       |      //    - low  surrogates: 0b1101'10xx'yyyy'yyyy (0xD800..0xDBFF)
   83|       |      //    - high surrogates: 0b1101'11xx'yyyy'yyyy (0xDC00..0xDFFF)
   84|       |      //
   85|       |      //    Fact: high surrogate has 11th bit set (3rd bit in the higher byte)
   86|       |
   87|       |      // V - non-surrogate code units
   88|       |      //     V = not surrogates_wordmask
   89|  19.0k|      const uint16_t V = static_cast<uint16_t>(~surrogates_bitmask);
   90|       |
   91|       |      // H - word-mask for high surrogates: the six highest bits are 0b1101'11
   92|  19.0k|      const auto vH = (in & v_fc) == v_dc;
   93|  19.0k|      const uint16_t H = static_cast<uint16_t>(vH.to_bitmask());
   94|       |
   95|       |      // L - word mask for low surrogates
   96|       |      //     L = not H and surrogates_wordmask
   97|  19.0k|      const uint16_t L = static_cast<uint16_t>(~H & surrogates_bitmask);
   98|       |
   99|  19.0k|      const uint16_t a = static_cast<uint16_t>(
  100|  19.0k|          L & (H >> 1)); // A low surrogate must be followed by high one.
  101|       |                         // (A low surrogate placed in the 7th register's word
  102|       |                         // is an exception we handle.)
  103|  19.0k|      const uint16_t b = static_cast<uint16_t>(
  104|  19.0k|          a << 1); // Just mark that the opinput - startite fact is hold,
  105|       |                   // thanks to that we have only two masks for valid case.
  106|  19.0k|      const uint16_t c = static_cast<uint16_t>(
  107|  19.0k|          V | a | b); // Combine all the masks into the final one.
  108|       |
  109|  19.0k|      if (c == 0xffff) {
  ------------------
  |  Branch (109:11): [True: 14.4k, False: 4.55k]
  ------------------
  110|       |        // The whole input register contains valid UTF-16, i.e.,
  111|       |        // either single code units or proper surrogate pairs.
  112|  14.4k|        input += 16;
  113|  14.4k|      } else if (c == 0x7fff) {
  ------------------
  |  Branch (113:18): [True: 4.28k, False: 266]
  ------------------
  114|       |        // The 15 lower code units of the input register contains valid UTF-16.
  115|       |        // The 15th word may be either a low or high surrogate. It the next
  116|       |        // iteration we 1) check if the low surrogate is followed by a high
  117|       |        // one, 2) reject sole high surrogate.
  118|  4.28k|        input += 15;
  119|  4.28k|      } else {
  120|    266|        return result(error_code::SURROGATE, input - start);
  121|    266|      }
  122|  19.0k|    }
  123|  2.77M|  }
  124|       |
  125|  2.39k|  return result(error_code::SUCCESS, input - start);
  126|  2.66k|}

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

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

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

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

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_127avx2_convert_utf16_to_utf32ILNS_10endiannessE0EEENSt3__14pairIPKDsPDiEES7_mS8_:
   57|    428|                            char32_t *utf32_output) {
   58|    428|  const char16_t *end = buf + len;
   59|    428|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
   60|    428|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
   61|       |
   62|  79.5k|  while (end - buf >= 16) {
  ------------------
  |  Branch (62:10): [True: 79.2k, False: 318]
  ------------------
   63|  79.2k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
   64|  79.2k|    if (big_endian) {
  ------------------
  |  Branch (64:9): [Folded, False: 79.2k]
  ------------------
   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|  79.2k|    const __m256i surrogates_bytemask =
   75|  79.2k|        _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|  79.2k|    const uint32_t surrogates_bitmask =
   80|  79.2k|        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|  79.2k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (83:9): [True: 74.4k, False: 4.75k]
  ------------------
   84|       |      // case: we extend all sixteen 16-bit code units to sixteen 32-bit code
   85|       |      // units
   86|  74.4k|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
   87|  74.4k|                          _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in)));
   88|  74.4k|      _mm256_storeu_si256(
   89|  74.4k|          reinterpret_cast<__m256i *>(utf32_output + 8),
   90|  74.4k|          _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1)));
   91|  74.4k|      utf32_output += 16;
   92|  74.4k|      buf += 16;
   93|       |      // surrogate pair(s) in a register
   94|  74.4k|    } 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.75k|      size_t forward = 15;
   99|  4.75k|      size_t k = 0;
  100|  4.75k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (100:11): [True: 0, False: 4.75k]
  ------------------
  101|      0|        forward = size_t(end - buf - 1);
  102|      0|      }
  103|  69.7k|      for (; k < forward; k++) {
  ------------------
  |  Branch (103:14): [True: 65.1k, False: 4.64k]
  ------------------
  104|  65.1k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  105|  65.1k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (105:13): [True: 59.5k, False: 5.56k]
  ------------------
  106|       |          // No surrogate pair
  107|  59.5k|          *utf32_output++ = char32_t(word);
  108|  59.5k|        } else {
  109|       |          // must be a surrogate pair
  110|  5.56k|          uint16_t diff = uint16_t(word - 0xD800);
  111|  5.56k|          uint16_t next_word =
  112|  5.56k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  113|  5.56k|          k++;
  114|  5.56k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  115|  5.56k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (115:15): [True: 110, False: 5.45k]
  ------------------
  116|    110|            return std::make_pair(nullptr, utf32_output);
  117|    110|          }
  118|  5.45k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  119|  5.45k|          *utf32_output++ = char32_t(value);
  120|  5.45k|        }
  121|  65.1k|      }
  122|  4.64k|      buf += k;
  123|  4.64k|    }
  124|  79.2k|  } // while
  125|    318|  return std::make_pair(buf, utf32_output);
  126|    428|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_127avx2_convert_utf16_to_utf32ILNS_10endiannessE1EEENSt3__14pairIPKDsPDiEES7_mS8_:
   57|    448|                            char32_t *utf32_output) {
   58|    448|  const char16_t *end = buf + len;
   59|    448|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
   60|    448|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
   61|       |
   62|   379k|  while (end - buf >= 16) {
  ------------------
  |  Branch (62:10): [True: 379k, False: 374]
  ------------------
   63|   379k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
   64|   379k|    if (big_endian) {
  ------------------
  |  Branch (64:9): [True: 379k, Folded]
  ------------------
   65|   379k|      const __m256i swap = _mm256_setr_epi8(
   66|   379k|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   67|   379k|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   68|   379k|      in = _mm256_shuffle_epi8(in, swap);
   69|   379k|    }
   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|   379k|    const __m256i surrogates_bytemask =
   75|   379k|        _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|   379k|    const uint32_t surrogates_bitmask =
   80|   379k|        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|   379k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (83:9): [True: 377k, False: 1.86k]
  ------------------
   84|       |      // case: we extend all sixteen 16-bit code units to sixteen 32-bit code
   85|       |      // units
   86|   377k|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
   87|   377k|                          _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in)));
   88|   377k|      _mm256_storeu_si256(
   89|   377k|          reinterpret_cast<__m256i *>(utf32_output + 8),
   90|   377k|          _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1)));
   91|   377k|      utf32_output += 16;
   92|   377k|      buf += 16;
   93|       |      // surrogate pair(s) in a register
   94|   377k|    } 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.86k|      size_t forward = 15;
   99|  1.86k|      size_t k = 0;
  100|  1.86k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (100:11): [True: 0, False: 1.86k]
  ------------------
  101|      0|        forward = size_t(end - buf - 1);
  102|      0|      }
  103|  26.2k|      for (; k < forward; k++) {
  ------------------
  |  Branch (103:14): [True: 24.4k, False: 1.79k]
  ------------------
  104|  24.4k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  105|  24.4k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (105:13): [True: 21.4k, False: 3.06k]
  ------------------
  106|       |          // No surrogate pair
  107|  21.4k|          *utf32_output++ = char32_t(word);
  108|  21.4k|        } else {
  109|       |          // must be a surrogate pair
  110|  3.06k|          uint16_t diff = uint16_t(word - 0xD800);
  111|  3.06k|          uint16_t next_word =
  112|  3.06k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  113|  3.06k|          k++;
  114|  3.06k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  115|  3.06k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (115:15): [True: 74, False: 2.99k]
  ------------------
  116|     74|            return std::make_pair(nullptr, utf32_output);
  117|     74|          }
  118|  2.99k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  119|  2.99k|          *utf32_output++ = char32_t(value);
  120|  2.99k|        }
  121|  24.4k|      }
  122|  1.79k|      buf += k;
  123|  1.79k|    }
  124|   379k|  } // while
  125|    374|  return std::make_pair(buf, utf32_output);
  126|    448|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_139avx2_convert_utf16_to_utf32_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPDiEEPKDsmS7_:
  138|    402|                                        char32_t *utf32_output) {
  139|    402|  const char16_t *start = buf;
  140|    402|  const char16_t *end = buf + len;
  141|    402|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
  142|    402|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
  143|       |
  144|   158k|  while (end - buf >= 16) {
  ------------------
  |  Branch (144:10): [True: 157k, False: 284]
  ------------------
  145|   157k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
  146|   157k|    if (big_endian) {
  ------------------
  |  Branch (146:9): [Folded, False: 157k]
  ------------------
  147|      0|      const __m256i swap = _mm256_setr_epi8(
  148|      0|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
  149|      0|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
  150|      0|      in = _mm256_shuffle_epi8(in, swap);
  151|      0|    }
  152|       |
  153|       |    // 1. Check if there are any surrogate word in the input chunk.
  154|       |    //    We have also deal with situation when there is a surrogate word
  155|       |    //    at the end of a chunk.
  156|   157k|    const __m256i surrogates_bytemask =
  157|   157k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_d800);
  158|       |
  159|       |    // bitmask = 0x0000 if there are no surrogates
  160|       |    //         = 0xc000 if the last word is a surrogate
  161|   157k|    const uint32_t surrogates_bitmask =
  162|   157k|        static_cast<uint32_t>(_mm256_movemask_epi8(surrogates_bytemask));
  163|       |    // It might seem like checking for surrogates_bitmask == 0xc000 could help.
  164|       |    // However, it is likely an uncommon occurrence.
  165|   157k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (165:9): [True: 151k, False: 6.37k]
  ------------------
  166|       |      // case: we extend all sixteen 16-bit code units to sixteen 32-bit code
  167|       |      // units
  168|   151k|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
  169|   151k|                          _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in)));
  170|   151k|      _mm256_storeu_si256(
  171|   151k|          reinterpret_cast<__m256i *>(utf32_output + 8),
  172|   151k|          _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1)));
  173|   151k|      utf32_output += 16;
  174|   151k|      buf += 16;
  175|       |      // surrogate pair(s) in a register
  176|   151k|    } else {
  177|       |      // Let us do a scalar fallback.
  178|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
  179|       |      // in the presence of surrogate pairs may require non-trivial tables.
  180|  6.37k|      size_t forward = 15;
  181|  6.37k|      size_t k = 0;
  182|  6.37k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (182:11): [True: 0, False: 6.37k]
  ------------------
  183|      0|        forward = size_t(end - buf - 1);
  184|      0|      }
  185|  90.9k|      for (; k < forward; k++) {
  ------------------
  |  Branch (185:14): [True: 84.6k, False: 6.25k]
  ------------------
  186|  84.6k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  187|  84.6k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (187:13): [True: 74.0k, False: 10.6k]
  ------------------
  188|       |          // No surrogate pair
  189|  74.0k|          *utf32_output++ = char32_t(word);
  190|  74.0k|        } else {
  191|       |          // must be a surrogate pair
  192|  10.6k|          uint16_t diff = uint16_t(word - 0xD800);
  193|  10.6k|          uint16_t next_word =
  194|  10.6k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  195|  10.6k|          k++;
  196|  10.6k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  197|  10.6k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (197:15): [True: 118, False: 10.4k]
  ------------------
  198|    118|            return std::make_pair(
  199|    118|                result(error_code::SURROGATE, buf - start + k - 1),
  200|    118|                utf32_output);
  201|    118|          }
  202|  10.4k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  203|  10.4k|          *utf32_output++ = char32_t(value);
  204|  10.4k|        }
  205|  84.6k|      }
  206|  6.25k|      buf += k;
  207|  6.25k|    }
  208|   157k|  } // while
  209|    284|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output);
  210|    402|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_139avx2_convert_utf16_to_utf32_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPDiEEPKDsmS7_:
  138|    422|                                        char32_t *utf32_output) {
  139|    422|  const char16_t *start = buf;
  140|    422|  const char16_t *end = buf + len;
  141|    422|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
  142|    422|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
  143|       |
  144|   159k|  while (end - buf >= 16) {
  ------------------
  |  Branch (144:10): [True: 159k, False: 294]
  ------------------
  145|   159k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
  146|   159k|    if (big_endian) {
  ------------------
  |  Branch (146:9): [True: 159k, Folded]
  ------------------
  147|   159k|      const __m256i swap = _mm256_setr_epi8(
  148|   159k|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
  149|   159k|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
  150|   159k|      in = _mm256_shuffle_epi8(in, swap);
  151|   159k|    }
  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|   159k|    const __m256i surrogates_bytemask =
  157|   159k|        _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|   159k|    const uint32_t surrogates_bitmask =
  162|   159k|        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|   159k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (165:9): [True: 154k, False: 5.14k]
  ------------------
  166|       |      // case: we extend all sixteen 16-bit code units to sixteen 32-bit code
  167|       |      // units
  168|   154k|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
  169|   154k|                          _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in)));
  170|   154k|      _mm256_storeu_si256(
  171|   154k|          reinterpret_cast<__m256i *>(utf32_output + 8),
  172|   154k|          _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1)));
  173|   154k|      utf32_output += 16;
  174|   154k|      buf += 16;
  175|       |      // surrogate pair(s) in a register
  176|   154k|    } else {
  177|       |      // Let us do a scalar fallback.
  178|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
  179|       |      // in the presence of surrogate pairs may require non-trivial tables.
  180|  5.14k|      size_t forward = 15;
  181|  5.14k|      size_t k = 0;
  182|  5.14k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (182:11): [True: 0, False: 5.14k]
  ------------------
  183|      0|        forward = size_t(end - buf - 1);
  184|      0|      }
  185|  71.1k|      for (; k < forward; k++) {
  ------------------
  |  Branch (185:14): [True: 66.1k, False: 5.02k]
  ------------------
  186|  66.1k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  187|  66.1k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (187:13): [True: 55.1k, False: 10.9k]
  ------------------
  188|       |          // No surrogate pair
  189|  55.1k|          *utf32_output++ = char32_t(word);
  190|  55.1k|        } else {
  191|       |          // must be a surrogate pair
  192|  10.9k|          uint16_t diff = uint16_t(word - 0xD800);
  193|  10.9k|          uint16_t next_word =
  194|  10.9k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  195|  10.9k|          k++;
  196|  10.9k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  197|  10.9k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (197:15): [True: 128, False: 10.8k]
  ------------------
  198|    128|            return std::make_pair(
  199|    128|                result(error_code::SURROGATE, buf - start + k - 1),
  200|    128|                utf32_output);
  201|    128|          }
  202|  10.8k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  203|  10.8k|          *utf32_output++ = char32_t(value);
  204|  10.8k|        }
  205|  66.1k|      }
  206|  5.02k|      buf += k;
  207|  5.02k|    }
  208|   159k|  } // while
  209|    294|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output);
  210|    422|}

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

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_127avx2_convert_utf32_to_utf16ILNS_10endiannessE0EEENSt3__14pairIPKDiPDsEES7_mS8_:
    4|    732|                            char16_t *utf16_output) {
    5|    732|  const char32_t *end = buf + len;
    6|       |
    7|    732|  const size_t safety_margin =
    8|    732|      12; // to avoid overruns, see issue
    9|       |          // https://github.com/simdutf/simdutf/issues/92
   10|    732|  __m256i forbidden_bytemask = _mm256_setzero_si256();
   11|       |
   12|    732|  const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000);
   13|    732|  const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800);
   14|    732|  const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800);
   15|       |
   16|  99.9k|  while (end - buf >= std::ptrdiff_t(8 + safety_margin)) {
  ------------------
  |  Branch (16:10): [True: 99.3k, False: 602]
  ------------------
   17|  99.3k|    const __m256i in = _mm256_loadu_si256((__m256i *)buf);
   18|       |
   19|  99.3k|    if (simdutf_likely(_mm256_testz_si256(in, v_ffff0000))) {
  ------------------
  |  |   90|  99.3k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 96.3k, False: 3.04k]
  |  |  ------------------
  ------------------
   20|       |      // no bits set above 16th bit <=> can pack to UTF16
   21|       |      // without surrogate pairs
   22|  96.3k|      forbidden_bytemask = _mm256_or_si256(
   23|  96.3k|          forbidden_bytemask,
   24|  96.3k|          _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800));
   25|       |
   26|  96.3k|      __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),
   27|  96.3k|                                              _mm256_extractf128_si256(in, 1));
   28|  96.3k|      if (big_endian) {
  ------------------
  |  Branch (28:11): [Folded, False: 96.3k]
  ------------------
   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|  96.3k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
   34|  96.3k|      utf16_output += 8;
   35|  96.3k|      buf += 8;
   36|  96.3k|    } else {
   37|  3.04k|      size_t forward = 7;
   38|  3.04k|      size_t k = 0;
   39|  3.04k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (39:11): [True: 0, False: 3.04k]
  ------------------
   40|      0|        forward = size_t(end - buf - 1);
   41|      0|      }
   42|  23.6k|      for (; k < forward; k++) {
  ------------------
  |  Branch (42:14): [True: 20.7k, False: 2.91k]
  ------------------
   43|  20.7k|        uint32_t word = buf[k];
   44|  20.7k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (44:13): [True: 5.02k, False: 15.7k]
  ------------------
   45|       |          // will not generate a surrogate pair
   46|  5.02k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (46:15): [True: 762, False: 4.26k]
  |  Branch (46:33): [True: 6, False: 756]
  ------------------
   47|      6|            return std::make_pair(nullptr, utf16_output);
   48|      6|          }
   49|  5.02k|          *utf16_output++ =
   50|  5.02k|              big_endian
  ------------------
  |  Branch (50:15): [Folded, False: 5.02k]
  ------------------
   51|  5.02k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
   52|  5.02k|                  : char16_t(word);
   53|  15.7k|        } else {
   54|       |          // will generate a surrogate pair
   55|  15.7k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (55:15): [True: 124, False: 15.6k]
  ------------------
   56|    124|            return std::make_pair(nullptr, utf16_output);
   57|    124|          }
   58|  15.6k|          word -= 0x10000;
   59|  15.6k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   60|  15.6k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   61|  15.6k|          if (big_endian) {
  ------------------
  |  Branch (61:15): [Folded, False: 15.6k]
  ------------------
   62|      0|            high_surrogate =
   63|      0|                uint16_t((high_surrogate >> 8) | (high_surrogate << 8));
   64|      0|            low_surrogate =
   65|      0|                uint16_t((low_surrogate >> 8) | (low_surrogate << 8));
   66|      0|          }
   67|  15.6k|          *utf16_output++ = char16_t(high_surrogate);
   68|  15.6k|          *utf16_output++ = char16_t(low_surrogate);
   69|  15.6k|        }
   70|  20.7k|      }
   71|  2.91k|      buf += k;
   72|  2.91k|    }
   73|  99.3k|  }
   74|       |
   75|       |  // check for invalid input
   76|    602|  if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (76:7): [True: 42, False: 560]
  ------------------
   77|     42|    return std::make_pair(nullptr, utf16_output);
   78|     42|  }
   79|       |
   80|    560|  return std::make_pair(buf, utf16_output);
   81|    602|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_127avx2_convert_utf32_to_utf16ILNS_10endiannessE1EEENSt3__14pairIPKDiPDsEES7_mS8_:
    4|    540|                            char16_t *utf16_output) {
    5|    540|  const char32_t *end = buf + len;
    6|       |
    7|    540|  const size_t safety_margin =
    8|    540|      12; // to avoid overruns, see issue
    9|       |          // https://github.com/simdutf/simdutf/issues/92
   10|    540|  __m256i forbidden_bytemask = _mm256_setzero_si256();
   11|       |
   12|    540|  const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000);
   13|    540|  const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800);
   14|    540|  const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800);
   15|       |
   16|  5.61k|  while (end - buf >= std::ptrdiff_t(8 + safety_margin)) {
  ------------------
  |  Branch (16:10): [True: 5.18k, False: 432]
  ------------------
   17|  5.18k|    const __m256i in = _mm256_loadu_si256((__m256i *)buf);
   18|       |
   19|  5.18k|    if (simdutf_likely(_mm256_testz_si256(in, v_ffff0000))) {
  ------------------
  |  |   90|  5.18k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 3.92k, False: 1.25k]
  |  |  ------------------
  ------------------
   20|       |      // no bits set above 16th bit <=> can pack to UTF16
   21|       |      // without surrogate pairs
   22|  3.92k|      forbidden_bytemask = _mm256_or_si256(
   23|  3.92k|          forbidden_bytemask,
   24|  3.92k|          _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800));
   25|       |
   26|  3.92k|      __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),
   27|  3.92k|                                              _mm256_extractf128_si256(in, 1));
   28|  3.92k|      if (big_endian) {
  ------------------
  |  Branch (28:11): [True: 3.92k, Folded]
  ------------------
   29|  3.92k|        const __m128i swap =
   30|  3.92k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   31|  3.92k|        utf16_packed = _mm_shuffle_epi8(utf16_packed, swap);
   32|  3.92k|      }
   33|  3.92k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
   34|  3.92k|      utf16_output += 8;
   35|  3.92k|      buf += 8;
   36|  3.92k|    } else {
   37|  1.25k|      size_t forward = 7;
   38|  1.25k|      size_t k = 0;
   39|  1.25k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (39:11): [True: 0, False: 1.25k]
  ------------------
   40|      0|        forward = size_t(end - buf - 1);
   41|      0|      }
   42|  9.53k|      for (; k < forward; k++) {
  ------------------
  |  Branch (42:14): [True: 8.38k, False: 1.14k]
  ------------------
   43|  8.38k|        uint32_t word = buf[k];
   44|  8.38k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (44:13): [True: 1.90k, False: 6.48k]
  ------------------
   45|       |          // will not generate a surrogate pair
   46|  1.90k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (46:15): [True: 298, False: 1.60k]
  |  Branch (46:33): [True: 6, False: 292]
  ------------------
   47|      6|            return std::make_pair(nullptr, utf16_output);
   48|      6|          }
   49|  1.89k|          *utf16_output++ =
   50|  1.89k|              big_endian
  ------------------
  |  Branch (50:15): [True: 1.89k, Folded]
  ------------------
   51|  1.89k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
   52|  1.89k|                  : char16_t(word);
   53|  6.48k|        } else {
   54|       |          // will generate a surrogate pair
   55|  6.48k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (55:15): [True: 102, False: 6.38k]
  ------------------
   56|    102|            return std::make_pair(nullptr, utf16_output);
   57|    102|          }
   58|  6.38k|          word -= 0x10000;
   59|  6.38k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   60|  6.38k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   61|  6.38k|          if (big_endian) {
  ------------------
  |  Branch (61:15): [True: 6.38k, Folded]
  ------------------
   62|  6.38k|            high_surrogate =
   63|  6.38k|                uint16_t((high_surrogate >> 8) | (high_surrogate << 8));
   64|  6.38k|            low_surrogate =
   65|  6.38k|                uint16_t((low_surrogate >> 8) | (low_surrogate << 8));
   66|  6.38k|          }
   67|  6.38k|          *utf16_output++ = char16_t(high_surrogate);
   68|  6.38k|          *utf16_output++ = char16_t(low_surrogate);
   69|  6.38k|        }
   70|  8.38k|      }
   71|  1.14k|      buf += k;
   72|  1.14k|    }
   73|  5.18k|  }
   74|       |
   75|       |  // check for invalid input
   76|    432|  if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (76:7): [True: 22, False: 410]
  ------------------
   77|     22|    return std::make_pair(nullptr, utf16_output);
   78|     22|  }
   79|       |
   80|    410|  return std::make_pair(buf, utf16_output);
   81|    432|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_139avx2_convert_utf32_to_utf16_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPDsEEPKDimS7_:
   86|    714|                                        char16_t *utf16_output) {
   87|    714|  const char32_t *start = buf;
   88|    714|  const char32_t *end = buf + len;
   89|       |
   90|    714|  const size_t safety_margin =
   91|    714|      12; // to avoid overruns, see issue
   92|       |          // https://github.com/simdutf/simdutf/issues/92
   93|       |
   94|    714|  const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000);
   95|    714|  const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800);
   96|    714|  const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800);
   97|       |
   98|  9.59k|  while (end - buf >= std::ptrdiff_t(8 + safety_margin)) {
  ------------------
  |  Branch (98:10): [True: 9.06k, False: 526]
  ------------------
   99|  9.06k|    const __m256i in = _mm256_loadu_si256((__m256i *)buf);
  100|       |
  101|  9.06k|    if (simdutf_likely(_mm256_testz_si256(in, v_ffff0000))) {
  ------------------
  |  |   90|  9.06k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 7.23k, False: 1.83k]
  |  |  ------------------
  ------------------
  102|       |      // no bits set above 16th bit <=> can pack to UTF16 without surrogate
  103|       |      // pairs
  104|  7.23k|      const __m256i forbidden_bytemask =
  105|  7.23k|          _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800);
  106|  7.23k|      if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) !=
  ------------------
  |  Branch (106:11): [True: 36, False: 7.20k]
  ------------------
  107|  7.23k|          0x0) {
  108|     36|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  109|     36|                              utf16_output);
  110|     36|      }
  111|       |
  112|  7.20k|      __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),
  113|  7.20k|                                              _mm256_extractf128_si256(in, 1));
  114|  7.20k|      if (big_endian) {
  ------------------
  |  Branch (114:11): [Folded, False: 7.20k]
  ------------------
  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|  7.20k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
  120|  7.20k|      utf16_output += 8;
  121|  7.20k|      buf += 8;
  122|  7.20k|    } else {
  123|  1.83k|      size_t forward = 7;
  124|  1.83k|      size_t k = 0;
  125|  1.83k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (125:11): [True: 0, False: 1.83k]
  ------------------
  126|      0|        forward = size_t(end - buf - 1);
  127|      0|      }
  128|  13.8k|      for (; k < forward; k++) {
  ------------------
  |  Branch (128:14): [True: 12.1k, False: 1.67k]
  ------------------
  129|  12.1k|        uint32_t word = buf[k];
  130|  12.1k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (130:13): [True: 5.68k, False: 6.50k]
  ------------------
  131|       |          // will not generate a surrogate pair
  132|  5.68k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (132:15): [True: 626, False: 5.05k]
  |  Branch (132:33): [True: 6, False: 620]
  ------------------
  133|      6|            return std::make_pair(
  134|      6|                result(error_code::SURROGATE, buf - start + k), utf16_output);
  135|      6|          }
  136|  5.67k|          *utf16_output++ =
  137|  5.67k|              big_endian
  ------------------
  |  Branch (137:15): [Folded, False: 5.67k]
  ------------------
  138|  5.67k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
  139|  5.67k|                  : char16_t(word);
  140|  6.50k|        } else {
  141|       |          // will generate a surrogate pair
  142|  6.50k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (142:15): [True: 146, False: 6.35k]
  ------------------
  143|    146|            return std::make_pair(
  144|    146|                result(error_code::TOO_LARGE, buf - start + k), utf16_output);
  145|    146|          }
  146|  6.35k|          word -= 0x10000;
  147|  6.35k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
  148|  6.35k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
  149|  6.35k|          if (big_endian) {
  ------------------
  |  Branch (149:15): [Folded, False: 6.35k]
  ------------------
  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.35k|          *utf16_output++ = char16_t(high_surrogate);
  156|  6.35k|          *utf16_output++ = char16_t(low_surrogate);
  157|  6.35k|        }
  158|  12.1k|      }
  159|  1.67k|      buf += k;
  160|  1.67k|    }
  161|  9.06k|  }
  162|       |
  163|    526|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output);
  164|    714|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_139avx2_convert_utf32_to_utf16_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPDsEEPKDimS7_:
   86|    660|                                        char16_t *utf16_output) {
   87|    660|  const char32_t *start = buf;
   88|    660|  const char32_t *end = buf + len;
   89|       |
   90|    660|  const size_t safety_margin =
   91|    660|      12; // to avoid overruns, see issue
   92|       |          // https://github.com/simdutf/simdutf/issues/92
   93|       |
   94|    660|  const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000);
   95|    660|  const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800);
   96|    660|  const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800);
   97|       |
   98|  10.3k|  while (end - buf >= std::ptrdiff_t(8 + safety_margin)) {
  ------------------
  |  Branch (98:10): [True: 9.89k, False: 476]
  ------------------
   99|  9.89k|    const __m256i in = _mm256_loadu_si256((__m256i *)buf);
  100|       |
  101|  9.89k|    if (simdutf_likely(_mm256_testz_si256(in, v_ffff0000))) {
  ------------------
  |  |   90|  9.89k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 9.12k, False: 762]
  |  |  ------------------
  ------------------
  102|       |      // no bits set above 16th bit <=> can pack to UTF16 without surrogate
  103|       |      // pairs
  104|  9.12k|      const __m256i forbidden_bytemask =
  105|  9.12k|          _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800);
  106|  9.12k|      if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) !=
  ------------------
  |  Branch (106:11): [True: 12, False: 9.11k]
  ------------------
  107|  9.12k|          0x0) {
  108|     12|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  109|     12|                              utf16_output);
  110|     12|      }
  111|       |
  112|  9.11k|      __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),
  113|  9.11k|                                              _mm256_extractf128_si256(in, 1));
  114|  9.11k|      if (big_endian) {
  ------------------
  |  Branch (114:11): [True: 9.11k, Folded]
  ------------------
  115|  9.11k|        const __m128i swap =
  116|  9.11k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  117|  9.11k|        utf16_packed = _mm_shuffle_epi8(utf16_packed, swap);
  118|  9.11k|      }
  119|  9.11k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
  120|  9.11k|      utf16_output += 8;
  121|  9.11k|      buf += 8;
  122|  9.11k|    } else {
  123|    762|      size_t forward = 7;
  124|    762|      size_t k = 0;
  125|    762|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (125:11): [True: 0, False: 762]
  ------------------
  126|      0|        forward = size_t(end - buf - 1);
  127|      0|      }
  128|  5.25k|      for (; k < forward; k++) {
  ------------------
  |  Branch (128:14): [True: 4.66k, False: 590]
  ------------------
  129|  4.66k|        uint32_t word = buf[k];
  130|  4.66k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (130:13): [True: 2.51k, False: 2.15k]
  ------------------
  131|       |          // will not generate a surrogate pair
  132|  2.51k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (132:15): [True: 762, False: 1.75k]
  |  Branch (132:33): [True: 10, False: 752]
  ------------------
  133|     10|            return std::make_pair(
  134|     10|                result(error_code::SURROGATE, buf - start + k), utf16_output);
  135|     10|          }
  136|  2.50k|          *utf16_output++ =
  137|  2.50k|              big_endian
  ------------------
  |  Branch (137:15): [True: 2.50k, Folded]
  ------------------
  138|  2.50k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
  139|  2.50k|                  : char16_t(word);
  140|  2.50k|        } else {
  141|       |          // will generate a surrogate pair
  142|  2.15k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (142:15): [True: 162, False: 1.98k]
  ------------------
  143|    162|            return std::make_pair(
  144|    162|                result(error_code::TOO_LARGE, buf - start + k), utf16_output);
  145|    162|          }
  146|  1.98k|          word -= 0x10000;
  147|  1.98k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
  148|  1.98k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
  149|  1.98k|          if (big_endian) {
  ------------------
  |  Branch (149:15): [True: 1.98k, Folded]
  ------------------
  150|  1.98k|            high_surrogate =
  151|  1.98k|                uint16_t((high_surrogate >> 8) | (high_surrogate << 8));
  152|  1.98k|            low_surrogate =
  153|  1.98k|                uint16_t((low_surrogate >> 8) | (low_surrogate << 8));
  154|  1.98k|          }
  155|  1.98k|          *utf16_output++ = char16_t(high_surrogate);
  156|  1.98k|          *utf16_output++ = char16_t(low_surrogate);
  157|  1.98k|        }
  158|  4.66k|      }
  159|    590|      buf += k;
  160|    590|    }
  161|  9.89k|  }
  162|       |
  163|    476|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output);
  164|    660|}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_utf16_to_utf32ILNS_10endiannessE0EEENSt3__14pairIPKDsPDiEES7_mS8_:
   57|    428|                           char32_t *utf32_output) {
   58|    428|  const char16_t *end = buf + len;
   59|       |
   60|    428|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
   61|    428|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
   62|       |
   63|   154k|  while (end - buf >= 8) {
  ------------------
  |  Branch (63:10): [True: 154k, False: 298]
  ------------------
   64|   154k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   65|       |
   66|   154k|    if (big_endian) {
  ------------------
  |  Branch (66:9): [Folded, False: 154k]
  ------------------
   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|   154k|    const __m128i surrogates_bytemask =
   76|   154k|        _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|   154k|    const uint16_t surrogates_bitmask =
   81|   154k|        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|   154k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (84:9): [True: 149k, False: 4.64k]
  ------------------
   85|       |      // case: no surrogate pair, extend 16-bit code units to 32-bit code units
   86|   149k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
   87|   149k|                       _mm_cvtepu16_epi32(in));
   88|   149k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
   89|   149k|                       _mm_cvtepu16_epi32(_mm_srli_si128(in, 8)));
   90|   149k|      utf32_output += 8;
   91|   149k|      buf += 8;
   92|       |      // surrogate pair(s) in a register
   93|   149k|    } 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.64k|      size_t forward = 15;
   98|  4.64k|      size_t k = 0;
   99|  4.64k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (99:11): [True: 92, False: 4.55k]
  ------------------
  100|     92|        forward = size_t(end - buf - 1);
  101|     92|      }
  102|  67.0k|      for (; k < forward; k++) {
  ------------------
  |  Branch (102:14): [True: 62.5k, False: 4.51k]
  ------------------
  103|  62.5k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  104|  62.5k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (104:13): [True: 56.8k, False: 5.68k]
  ------------------
  105|  56.8k|          *utf32_output++ = char32_t(word);
  106|  56.8k|        } else {
  107|       |          // must be a surrogate pair
  108|  5.68k|          uint16_t diff = uint16_t(word - 0xD800);
  109|  5.68k|          uint16_t next_word =
  110|  5.68k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  111|  5.68k|          k++;
  112|  5.68k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  113|  5.68k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (113:15): [True: 130, False: 5.55k]
  ------------------
  114|    130|            return std::make_pair(nullptr, utf32_output);
  115|    130|          }
  116|  5.55k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  117|  5.55k|          *utf32_output++ = char32_t(value);
  118|  5.55k|        }
  119|  62.5k|      }
  120|  4.51k|      buf += k;
  121|  4.51k|    }
  122|   154k|  } // while
  123|    298|  return std::make_pair(buf, utf32_output);
  124|    428|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_utf16_to_utf32ILNS_10endiannessE1EEENSt3__14pairIPKDsPDiEES7_mS8_:
   57|    448|                           char32_t *utf32_output) {
   58|    448|  const char16_t *end = buf + len;
   59|       |
   60|    448|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
   61|    448|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
   62|       |
   63|   756k|  while (end - buf >= 8) {
  ------------------
  |  Branch (63:10): [True: 756k, False: 346]
  ------------------
   64|   756k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   65|       |
   66|   756k|    if (big_endian) {
  ------------------
  |  Branch (66:9): [True: 756k, Folded]
  ------------------
   67|   756k|      const __m128i swap =
   68|   756k|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   69|   756k|      in = _mm_shuffle_epi8(in, swap);
   70|   756k|    }
   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|   756k|    const __m128i surrogates_bytemask =
   76|   756k|        _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|   756k|    const uint16_t surrogates_bitmask =
   81|   756k|        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|   756k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (84:9): [True: 754k, False: 1.87k]
  ------------------
   85|       |      // case: no surrogate pair, extend 16-bit code units to 32-bit code units
   86|   754k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
   87|   754k|                       _mm_cvtepu16_epi32(in));
   88|   754k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
   89|   754k|                       _mm_cvtepu16_epi32(_mm_srli_si128(in, 8)));
   90|   754k|      utf32_output += 8;
   91|   754k|      buf += 8;
   92|       |      // surrogate pair(s) in a register
   93|   754k|    } 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.87k|      size_t forward = 15;
   98|  1.87k|      size_t k = 0;
   99|  1.87k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (99:11): [True: 96, False: 1.78k]
  ------------------
  100|     96|        forward = size_t(end - buf - 1);
  101|     96|      }
  102|  25.4k|      for (; k < forward; k++) {
  ------------------
  |  Branch (102:14): [True: 23.6k, False: 1.77k]
  ------------------
  103|  23.6k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  104|  23.6k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (104:13): [True: 20.5k, False: 3.19k]
  ------------------
  105|  20.5k|          *utf32_output++ = char32_t(word);
  106|  20.5k|        } else {
  107|       |          // must be a surrogate pair
  108|  3.19k|          uint16_t diff = uint16_t(word - 0xD800);
  109|  3.19k|          uint16_t next_word =
  110|  3.19k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  111|  3.19k|          k++;
  112|  3.19k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  113|  3.19k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (113:15): [True: 102, False: 3.09k]
  ------------------
  114|    102|            return std::make_pair(nullptr, utf32_output);
  115|    102|          }
  116|  3.09k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  117|  3.09k|          *utf32_output++ = char32_t(value);
  118|  3.09k|        }
  119|  23.6k|      }
  120|  1.77k|      buf += k;
  121|  1.77k|    }
  122|   756k|  } // while
  123|    346|  return std::make_pair(buf, utf32_output);
  124|    448|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_138sse_convert_utf16_to_utf32_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPDiEEPKDsmS7_:
  136|    402|                                       char32_t *utf32_output) {
  137|    402|  const char16_t *start = buf;
  138|    402|  const char16_t *end = buf + len;
  139|       |
  140|    402|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
  141|    402|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
  142|       |
  143|   310k|  while (end - buf >= 8) {
  ------------------
  |  Branch (143:10): [True: 309k, False: 262]
  ------------------
  144|   309k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  145|       |
  146|   309k|    if (big_endian) {
  ------------------
  |  Branch (146:9): [Folded, False: 309k]
  ------------------
  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|   309k|    const __m128i surrogates_bytemask =
  156|   309k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_d800);
  157|       |
  158|       |    // bitmask = 0x0000 if there are no surrogates
  159|       |    //         = 0xc000 if the last word is a surrogate
  160|   309k|    const uint16_t surrogates_bitmask =
  161|   309k|        static_cast<uint16_t>(_mm_movemask_epi8(surrogates_bytemask));
  162|       |    // It might seem like checking for surrogates_bitmask == 0xc000 could help.
  163|       |    // However, it is likely an uncommon occurrence.
  164|   309k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (164:9): [True: 303k, False: 6.16k]
  ------------------
  165|       |      // case: no surrogate pair, extend 16-bit code units to 32-bit code units
  166|   303k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
  167|   303k|                       _mm_cvtepu16_epi32(in));
  168|   303k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
  169|   303k|                       _mm_cvtepu16_epi32(_mm_srli_si128(in, 8)));
  170|   303k|      utf32_output += 8;
  171|   303k|      buf += 8;
  172|       |      // surrogate pair(s) in a register
  173|   303k|    } else {
  174|       |      // Let us do a scalar fallback.
  175|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
  176|       |      // in the presence of surrogate pairs may require non-trivial tables.
  177|  6.16k|      size_t forward = 15;
  178|  6.16k|      size_t k = 0;
  179|  6.16k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (179:11): [True: 88, False: 6.07k]
  ------------------
  180|     88|        forward = size_t(end - buf - 1);
  181|     88|      }
  182|  86.8k|      for (; k < forward; k++) {
  ------------------
  |  Branch (182:14): [True: 80.7k, False: 6.02k]
  ------------------
  183|  80.7k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  184|  80.7k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (184:13): [True: 70.0k, False: 10.7k]
  ------------------
  185|  70.0k|          *utf32_output++ = char32_t(word);
  186|  70.0k|        } else {
  187|       |          // must be a surrogate pair
  188|  10.7k|          uint16_t diff = uint16_t(word - 0xD800);
  189|  10.7k|          uint16_t next_word =
  190|  10.7k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  191|  10.7k|          k++;
  192|  10.7k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  193|  10.7k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (193:15): [True: 140, False: 10.5k]
  ------------------
  194|    140|            return std::make_pair(
  195|    140|                result(error_code::SURROGATE, buf - start + k - 1),
  196|    140|                utf32_output);
  197|    140|          }
  198|  10.5k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  199|  10.5k|          *utf32_output++ = char32_t(value);
  200|  10.5k|        }
  201|  80.7k|      }
  202|  6.02k|      buf += k;
  203|  6.02k|    }
  204|   309k|  } // while
  205|    262|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output);
  206|    402|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_138sse_convert_utf16_to_utf32_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPDiEEPKDsmS7_:
  136|    422|                                       char32_t *utf32_output) {
  137|    422|  const char16_t *start = buf;
  138|    422|  const char16_t *end = buf + len;
  139|       |
  140|    422|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
  141|    422|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
  142|       |
  143|   313k|  while (end - buf >= 8) {
  ------------------
  |  Branch (143:10): [True: 313k, False: 256]
  ------------------
  144|   313k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  145|       |
  146|   313k|    if (big_endian) {
  ------------------
  |  Branch (146:9): [True: 313k, Folded]
  ------------------
  147|   313k|      const __m128i swap =
  148|   313k|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  149|   313k|      in = _mm_shuffle_epi8(in, swap);
  150|   313k|    }
  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|   313k|    const __m128i surrogates_bytemask =
  156|   313k|        _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|   313k|    const uint16_t surrogates_bitmask =
  161|   313k|        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|   313k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (164:9): [True: 308k, False: 5.04k]
  ------------------
  165|       |      // case: no surrogate pair, extend 16-bit code units to 32-bit code units
  166|   308k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
  167|   308k|                       _mm_cvtepu16_epi32(in));
  168|   308k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
  169|   308k|                       _mm_cvtepu16_epi32(_mm_srli_si128(in, 8)));
  170|   308k|      utf32_output += 8;
  171|   308k|      buf += 8;
  172|       |      // surrogate pair(s) in a register
  173|   308k|    } 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.04k|      size_t forward = 15;
  178|  5.04k|      size_t k = 0;
  179|  5.04k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (179:11): [True: 98, False: 4.94k]
  ------------------
  180|     98|        forward = size_t(end - buf - 1);
  181|     98|      }
  182|  68.4k|      for (; k < forward; k++) {
  ------------------
  |  Branch (182:14): [True: 63.5k, False: 4.87k]
  ------------------
  183|  63.5k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  184|  63.5k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (184:13): [True: 52.5k, False: 11.0k]
  ------------------
  185|  52.5k|          *utf32_output++ = char32_t(word);
  186|  52.5k|        } else {
  187|       |          // must be a surrogate pair
  188|  11.0k|          uint16_t diff = uint16_t(word - 0xD800);
  189|  11.0k|          uint16_t next_word =
  190|  11.0k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  191|  11.0k|          k++;
  192|  11.0k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  193|  11.0k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (193:15): [True: 166, False: 10.9k]
  ------------------
  194|    166|            return std::make_pair(
  195|    166|                result(error_code::SURROGATE, buf - start + k - 1),
  196|    166|                utf32_output);
  197|    166|          }
  198|  10.9k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  199|  10.9k|          *utf32_output++ = char32_t(value);
  200|  10.9k|        }
  201|  63.5k|      }
  202|  4.87k|      buf += k;
  203|  4.87k|    }
  204|   313k|  } // while
  205|    256|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output);
  206|    422|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_125sse_convert_utf16_to_utf8ILNS_10endiannessE0EEENSt3__14pairIPKDsPcEES7_mS8_:
   56|    876|sse_convert_utf16_to_utf8(const char16_t *buf, size_t len, char *utf8_output) {
   57|       |
   58|    876|  const char16_t *end = buf + len;
   59|       |
   60|    876|  const __m128i v_0000 = _mm_setzero_si128();
   61|    876|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
   62|    876|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
   63|    876|  const size_t safety_margin =
   64|    876|      12; // to avoid overruns, see issue
   65|       |          // https://github.com/simdutf/simdutf/issues/92
   66|       |
   67|   981k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (67:10): [True: 980k, False: 728]
  ------------------
   68|   980k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   69|   980k|    if (big_endian) {
  ------------------
  |  Branch (69:9): [Folded, False: 980k]
  ------------------
   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|   980k|    const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80);
   76|   980k|    if (_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (76:9): [True: 799k, False: 181k]
  ------------------
   77|   799k|      __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
   78|   799k|      if (big_endian) {
  ------------------
  |  Branch (78:11): [Folded, False: 799k]
  ------------------
   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|   799k|      if (!_mm_testz_si128(nextin, v_ff80)) {
  ------------------
  |  Branch (83:11): [True: 35.5k, False: 763k]
  ------------------
   84|       |        // 1. pack the bytes
   85|       |        // obviously suboptimal.
   86|  35.5k|        const __m128i utf8_packed = _mm_packus_epi16(in, in);
   87|       |        // 2. store (16 bytes)
   88|  35.5k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   89|       |        // 3. adjust pointers
   90|  35.5k|        buf += 8;
   91|  35.5k|        utf8_output += 8;
   92|  35.5k|        in = nextin;
   93|   763k|      } else {
   94|       |        // 1. pack the bytes
   95|       |        // obviously suboptimal.
   96|   763k|        const __m128i utf8_packed = _mm_packus_epi16(in, nextin);
   97|       |        // 2. store (16 bytes)
   98|   763k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   99|       |        // 3. adjust pointers
  100|   763k|        buf += 16;
  101|   763k|        utf8_output += 16;
  102|   763k|        continue; // we are done for this round!
  103|   763k|      }
  104|   799k|    }
  105|       |
  106|       |    // no bits set above 7th bit
  107|   216k|    const __m128i one_byte_bytemask =
  108|   216k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000);
  109|   216k|    const uint16_t one_byte_bitmask =
  110|   216k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  111|       |
  112|       |    // no bits set above 11th bit
  113|   216k|    const __m128i one_or_two_bytes_bytemask =
  114|   216k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000);
  115|   216k|    const uint16_t one_or_two_bytes_bitmask =
  116|   216k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  117|       |
  118|   216k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (118:9): [True: 84.6k, False: 131k]
  ------------------
  119|  84.6k|      internal::westmere::write_v_u16_11bits_to_utf8(
  120|  84.6k|          in, utf8_output, one_byte_bytemask, one_byte_bitmask);
  121|  84.6k|      buf += 8;
  122|  84.6k|      continue;
  123|  84.6k|    }
  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|   131k|    const __m128i surrogates_bytemask =
  129|   131k|        _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|   131k|    const uint16_t surrogates_bitmask =
  134|   131k|        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|   131k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (137:9): [True: 125k, False: 6.76k]
  ------------------
  138|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  139|   125k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  140|   125k|                                              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|   125k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  170|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  171|   125k|      const __m128i t0 = _mm_shuffle_epi8(in, dup_even);
  172|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  173|   125k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  169|   125k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  174|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  175|   125k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  169|   125k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  176|       |
  177|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  178|   125k|      const __m128i s0 = _mm_srli_epi16(in, 4);
  179|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  180|   125k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  169|   125k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  181|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  182|   125k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  169|   125k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  183|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  184|   125k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  169|   125k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  185|   125k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  186|   125k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  169|   125k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  187|   125k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  188|   125k|#undef simdutf_vec
  189|       |
  190|       |      // 4. expand code units 16-bit => 32-bit
  191|   125k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  192|   125k|      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|   125k|      const uint16_t mask =
  196|   125k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  197|   125k|      if (mask == 0) {
  ------------------
  |  Branch (197:11): [True: 30.0k, False: 95.0k]
  ------------------
  198|       |        // We only have three-byte code units. Use fast path.
  199|  30.0k|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  200|  30.0k|                                              15, 13, -1, -1, -1, -1);
  201|  30.0k|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  202|  30.0k|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  203|  30.0k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  204|  30.0k|        utf8_output += 12;
  205|  30.0k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  206|  30.0k|        utf8_output += 12;
  207|  30.0k|        buf += 8;
  208|  30.0k|        continue;
  209|  30.0k|      }
  210|  95.0k|      const uint8_t mask0 = uint8_t(mask);
  211|       |
  212|  95.0k|      const uint8_t *row0 =
  213|  95.0k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  214|  95.0k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  215|  95.0k|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  216|       |
  217|  95.0k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  218|       |
  219|  95.0k|      const uint8_t *row1 =
  220|  95.0k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  221|  95.0k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  222|  95.0k|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  223|       |
  224|  95.0k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  225|  95.0k|      utf8_output += row0[0];
  226|  95.0k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  227|  95.0k|      utf8_output += row1[0];
  228|       |
  229|  95.0k|      buf += 8;
  230|       |      // surrogate pair(s) in a register
  231|  95.0k|    } else {
  232|       |      // Let us do a scalar fallback.
  233|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
  234|       |      // in the presence of surrogate pairs may require non-trivial tables.
  235|  6.76k|      size_t forward = 15;
  236|  6.76k|      size_t k = 0;
  237|  6.76k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (237:11): [True: 0, False: 6.76k]
  ------------------
  238|      0|        forward = size_t(end - buf - 1);
  239|      0|      }
  240|  98.6k|      for (; k < forward; k++) {
  ------------------
  |  Branch (240:14): [True: 92.0k, False: 6.62k]
  ------------------
  241|  92.0k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  242|  92.0k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (242:13): [True: 12.7k, False: 79.3k]
  ------------------
  243|  12.7k|          *utf8_output++ = char(word);
  244|  79.3k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (244:20): [True: 4.96k, False: 74.3k]
  ------------------
  245|  4.96k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  246|  4.96k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  247|  74.3k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (247:20): [True: 65.9k, False: 8.43k]
  ------------------
  248|  65.9k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  249|  65.9k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  250|  65.9k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  251|  65.9k|        } else {
  252|       |          // must be a surrogate pair
  253|  8.43k|          uint16_t diff = uint16_t(word - 0xD800);
  254|  8.43k|          uint16_t next_word =
  255|  8.43k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  256|  8.43k|          k++;
  257|  8.43k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  258|  8.43k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (258:15): [True: 148, False: 8.28k]
  ------------------
  259|    148|            return std::make_pair(nullptr, utf8_output);
  260|    148|          }
  261|  8.28k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  262|  8.28k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  263|  8.28k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  264|  8.28k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  265|  8.28k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  266|  8.28k|        }
  267|  92.0k|      }
  268|  6.62k|      buf += k;
  269|  6.62k|    }
  270|   131k|  } // while
  271|       |
  272|    728|  return std::make_pair(buf, utf8_output);
  273|    876|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_125sse_convert_utf16_to_utf8ILNS_10endiannessE1EEENSt3__14pairIPKDsPcEES7_mS8_:
   56|    772|sse_convert_utf16_to_utf8(const char16_t *buf, size_t len, char *utf8_output) {
   57|       |
   58|    772|  const char16_t *end = buf + len;
   59|       |
   60|    772|  const __m128i v_0000 = _mm_setzero_si128();
   61|    772|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
   62|    772|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
   63|    772|  const size_t safety_margin =
   64|    772|      12; // to avoid overruns, see issue
   65|       |          // https://github.com/simdutf/simdutf/issues/92
   66|       |
   67|  1.34M|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (67:10): [True: 1.34M, False: 702]
  ------------------
   68|  1.34M|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   69|  1.34M|    if (big_endian) {
  ------------------
  |  Branch (69:9): [True: 1.34M, Folded]
  ------------------
   70|  1.34M|      const __m128i swap =
   71|  1.34M|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   72|  1.34M|      in = _mm_shuffle_epi8(in, swap);
   73|  1.34M|    }
   74|       |    // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes
   75|  1.34M|    const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80);
   76|  1.34M|    if (_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (76:9): [True: 837k, False: 506k]
  ------------------
   77|   837k|      __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
   78|   837k|      if (big_endian) {
  ------------------
  |  Branch (78:11): [True: 837k, Folded]
  ------------------
   79|   837k|        const __m128i swap =
   80|   837k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   81|   837k|        nextin = _mm_shuffle_epi8(nextin, swap);
   82|   837k|      }
   83|   837k|      if (!_mm_testz_si128(nextin, v_ff80)) {
  ------------------
  |  Branch (83:11): [True: 55.3k, False: 782k]
  ------------------
   84|       |        // 1. pack the bytes
   85|       |        // obviously suboptimal.
   86|  55.3k|        const __m128i utf8_packed = _mm_packus_epi16(in, in);
   87|       |        // 2. store (16 bytes)
   88|  55.3k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   89|       |        // 3. adjust pointers
   90|  55.3k|        buf += 8;
   91|  55.3k|        utf8_output += 8;
   92|  55.3k|        in = nextin;
   93|   782k|      } else {
   94|       |        // 1. pack the bytes
   95|       |        // obviously suboptimal.
   96|   782k|        const __m128i utf8_packed = _mm_packus_epi16(in, nextin);
   97|       |        // 2. store (16 bytes)
   98|   782k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   99|       |        // 3. adjust pointers
  100|   782k|        buf += 16;
  101|   782k|        utf8_output += 16;
  102|   782k|        continue; // we are done for this round!
  103|   782k|      }
  104|   837k|    }
  105|       |
  106|       |    // no bits set above 7th bit
  107|   561k|    const __m128i one_byte_bytemask =
  108|   561k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000);
  109|   561k|    const uint16_t one_byte_bitmask =
  110|   561k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  111|       |
  112|       |    // no bits set above 11th bit
  113|   561k|    const __m128i one_or_two_bytes_bytemask =
  114|   561k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000);
  115|   561k|    const uint16_t one_or_two_bytes_bitmask =
  116|   561k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  117|       |
  118|   561k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (118:9): [True: 56.3k, False: 505k]
  ------------------
  119|  56.3k|      internal::westmere::write_v_u16_11bits_to_utf8(
  120|  56.3k|          in, utf8_output, one_byte_bytemask, one_byte_bitmask);
  121|  56.3k|      buf += 8;
  122|  56.3k|      continue;
  123|  56.3k|    }
  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|   505k|    const __m128i surrogates_bytemask =
  129|   505k|        _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|   505k|    const uint16_t surrogates_bitmask =
  134|   505k|        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|   505k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (137:9): [True: 499k, False: 5.94k]
  ------------------
  138|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  139|   499k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  140|   499k|                                              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|   499k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  170|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  171|   499k|      const __m128i t0 = _mm_shuffle_epi8(in, dup_even);
  172|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  173|   499k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  169|   499k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  174|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  175|   499k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  169|   499k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  176|       |
  177|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  178|   499k|      const __m128i s0 = _mm_srli_epi16(in, 4);
  179|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  180|   499k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  169|   499k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  181|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  182|   499k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  169|   499k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  183|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  184|   499k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  169|   499k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  185|   499k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  186|   499k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  169|   499k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  187|   499k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  188|   499k|#undef simdutf_vec
  189|       |
  190|       |      // 4. expand code units 16-bit => 32-bit
  191|   499k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  192|   499k|      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|   499k|      const uint16_t mask =
  196|   499k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  197|   499k|      if (mask == 0) {
  ------------------
  |  Branch (197:11): [True: 276k, False: 223k]
  ------------------
  198|       |        // We only have three-byte code units. Use fast path.
  199|   276k|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  200|   276k|                                              15, 13, -1, -1, -1, -1);
  201|   276k|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  202|   276k|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  203|   276k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  204|   276k|        utf8_output += 12;
  205|   276k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  206|   276k|        utf8_output += 12;
  207|   276k|        buf += 8;
  208|   276k|        continue;
  209|   276k|      }
  210|   223k|      const uint8_t mask0 = uint8_t(mask);
  211|       |
  212|   223k|      const uint8_t *row0 =
  213|   223k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  214|   223k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  215|   223k|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  216|       |
  217|   223k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  218|       |
  219|   223k|      const uint8_t *row1 =
  220|   223k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  221|   223k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  222|   223k|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  223|       |
  224|   223k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  225|   223k|      utf8_output += row0[0];
  226|   223k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  227|   223k|      utf8_output += row1[0];
  228|       |
  229|   223k|      buf += 8;
  230|       |      // surrogate pair(s) in a register
  231|   223k|    } 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|  5.94k|      size_t forward = 15;
  236|  5.94k|      size_t k = 0;
  237|  5.94k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (237:11): [True: 0, False: 5.94k]
  ------------------
  238|      0|        forward = size_t(end - buf - 1);
  239|      0|      }
  240|  87.3k|      for (; k < forward; k++) {
  ------------------
  |  Branch (240:14): [True: 81.4k, False: 5.87k]
  ------------------
  241|  81.4k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  242|  81.4k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (242:13): [True: 12.1k, False: 69.2k]
  ------------------
  243|  12.1k|          *utf8_output++ = char(word);
  244|  69.2k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (244:20): [True: 2.44k, False: 66.8k]
  ------------------
  245|  2.44k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  246|  2.44k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  247|  66.8k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (247:20): [True: 59.6k, False: 7.21k]
  ------------------
  248|  59.6k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  249|  59.6k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  250|  59.6k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  251|  59.6k|        } else {
  252|       |          // must be a surrogate pair
  253|  7.21k|          uint16_t diff = uint16_t(word - 0xD800);
  254|  7.21k|          uint16_t next_word =
  255|  7.21k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  256|  7.21k|          k++;
  257|  7.21k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  258|  7.21k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (258:15): [True: 70, False: 7.14k]
  ------------------
  259|     70|            return std::make_pair(nullptr, utf8_output);
  260|     70|          }
  261|  7.14k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  262|  7.14k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  263|  7.14k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  264|  7.14k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  265|  7.14k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  266|  7.14k|        }
  267|  81.4k|      }
  268|  5.87k|      buf += k;
  269|  5.87k|    }
  270|   505k|  } // while
  271|       |
  272|    702|  return std::make_pair(buf, utf8_output);
  273|    772|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_137sse_convert_utf16_to_utf8_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
  285|    654|                                      char *utf8_output) {
  286|    654|  const char16_t *start = buf;
  287|    654|  const char16_t *end = buf + len;
  288|       |
  289|    654|  const __m128i v_0000 = _mm_setzero_si128();
  290|    654|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
  291|    654|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
  292|    654|  const size_t safety_margin =
  293|    654|      12; // to avoid overruns, see issue
  294|       |          // https://github.com/simdutf/simdutf/issues/92
  295|       |
  296|   917k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (296:10): [True: 916k, False: 532]
  ------------------
  297|   916k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  298|   916k|    if (big_endian) {
  ------------------
  |  Branch (298:9): [Folded, False: 916k]
  ------------------
  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|   916k|    const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80);
  305|   916k|    if (_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (305:9): [True: 372k, False: 543k]
  ------------------
  306|   372k|      __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  307|   372k|      if (big_endian) {
  ------------------
  |  Branch (307:11): [Folded, False: 372k]
  ------------------
  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|   372k|      if (!_mm_testz_si128(nextin, v_ff80)) {
  ------------------
  |  Branch (312:11): [True: 14.6k, False: 358k]
  ------------------
  313|       |        // 1. pack the bytes
  314|       |        // obviously suboptimal.
  315|  14.6k|        const __m128i utf8_packed = _mm_packus_epi16(in, in);
  316|       |        // 2. store (16 bytes)
  317|  14.6k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  318|       |        // 3. adjust pointers
  319|  14.6k|        buf += 8;
  320|  14.6k|        utf8_output += 8;
  321|  14.6k|        in = nextin;
  322|   358k|      } else {
  323|       |        // 1. pack the bytes
  324|       |        // obviously suboptimal.
  325|   358k|        const __m128i utf8_packed = _mm_packus_epi16(in, nextin);
  326|       |        // 2. store (16 bytes)
  327|   358k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  328|       |        // 3. adjust pointers
  329|   358k|        buf += 16;
  330|   358k|        utf8_output += 16;
  331|   358k|        continue; // we are done for this round!
  332|   358k|      }
  333|   372k|    }
  334|       |
  335|       |    // no bits set above 7th bit
  336|   558k|    const __m128i one_byte_bytemask =
  337|   558k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000);
  338|   558k|    const uint16_t one_byte_bitmask =
  339|   558k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  340|       |
  341|       |    // no bits set above 11th bit
  342|   558k|    const __m128i one_or_two_bytes_bytemask =
  343|   558k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000);
  344|   558k|    const uint16_t one_or_two_bytes_bitmask =
  345|   558k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  346|       |
  347|   558k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (347:9): [True: 146k, False: 411k]
  ------------------
  348|   146k|      internal::westmere::write_v_u16_11bits_to_utf8(
  349|   146k|          in, utf8_output, one_byte_bytemask, one_byte_bitmask);
  350|   146k|      buf += 8;
  351|   146k|      continue;
  352|   146k|    }
  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|   411k|    const __m128i surrogates_bytemask =
  358|   411k|        _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|   411k|    const uint16_t surrogates_bitmask =
  363|   411k|        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|   411k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (366:9): [True: 407k, False: 3.81k]
  ------------------
  367|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  368|   407k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  369|   407k|                                              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|   407k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  399|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  400|   407k|      const __m128i t0 = _mm_shuffle_epi8(in, dup_even);
  401|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  402|   407k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  398|   407k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  403|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  404|   407k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  398|   407k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  405|       |
  406|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  407|   407k|      const __m128i s0 = _mm_srli_epi16(in, 4);
  408|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  409|   407k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  398|   407k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  410|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  411|   407k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  398|   407k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  412|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  413|   407k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  398|   407k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  414|   407k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  415|   407k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  398|   407k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  416|   407k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  417|   407k|#undef simdutf_vec
  418|       |
  419|       |      // 4. expand code units 16-bit => 32-bit
  420|   407k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  421|   407k|      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|   407k|      const uint16_t mask =
  425|   407k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  426|   407k|      if (mask == 0) {
  ------------------
  |  Branch (426:11): [True: 316k, False: 91.0k]
  ------------------
  427|       |        // We only have three-byte code units. Use fast path.
  428|   316k|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  429|   316k|                                              15, 13, -1, -1, -1, -1);
  430|   316k|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  431|   316k|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  432|   316k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  433|   316k|        utf8_output += 12;
  434|   316k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  435|   316k|        utf8_output += 12;
  436|   316k|        buf += 8;
  437|   316k|        continue;
  438|   316k|      }
  439|  91.0k|      const uint8_t mask0 = uint8_t(mask);
  440|       |
  441|  91.0k|      const uint8_t *row0 =
  442|  91.0k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  443|  91.0k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  444|  91.0k|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  445|       |
  446|  91.0k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  447|       |
  448|  91.0k|      const uint8_t *row1 =
  449|  91.0k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  450|  91.0k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  451|  91.0k|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  452|       |
  453|  91.0k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  454|  91.0k|      utf8_output += row0[0];
  455|  91.0k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  456|  91.0k|      utf8_output += row1[0];
  457|       |
  458|  91.0k|      buf += 8;
  459|       |      // surrogate pair(s) in a register
  460|  91.0k|    } else {
  461|       |      // Let us do a scalar fallback.
  462|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
  463|       |      // in the presence of surrogate pairs may require non-trivial tables.
  464|  3.81k|      size_t forward = 15;
  465|  3.81k|      size_t k = 0;
  466|  3.81k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (466:11): [True: 0, False: 3.81k]
  ------------------
  467|      0|        forward = size_t(end - buf - 1);
  468|      0|      }
  469|  55.3k|      for (; k < forward; k++) {
  ------------------
  |  Branch (469:14): [True: 51.6k, False: 3.69k]
  ------------------
  470|  51.6k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  471|  51.6k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (471:13): [True: 10.0k, False: 41.6k]
  ------------------
  472|  10.0k|          *utf8_output++ = char(word);
  473|  41.6k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (473:20): [True: 1.92k, False: 39.7k]
  ------------------
  474|  1.92k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  475|  1.92k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  476|  39.7k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (476:20): [True: 35.2k, False: 4.47k]
  ------------------
  477|  35.2k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  478|  35.2k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  479|  35.2k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  480|  35.2k|        } else {
  481|       |          // must be a surrogate pair
  482|  4.47k|          uint16_t diff = uint16_t(word - 0xD800);
  483|  4.47k|          uint16_t next_word =
  484|  4.47k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  485|  4.47k|          k++;
  486|  4.47k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  487|  4.47k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (487:15): [True: 122, False: 4.35k]
  ------------------
  488|    122|            return std::make_pair(
  489|    122|                result(error_code::SURROGATE, buf - start + k - 1),
  490|    122|                utf8_output);
  491|    122|          }
  492|  4.35k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  493|  4.35k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  494|  4.35k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  495|  4.35k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  496|  4.35k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  497|  4.35k|        }
  498|  51.6k|      }
  499|  3.69k|      buf += k;
  500|  3.69k|    }
  501|   411k|  } // while
  502|       |
  503|    532|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output);
  504|    654|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_137sse_convert_utf16_to_utf8_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
  285|    648|                                      char *utf8_output) {
  286|    648|  const char16_t *start = buf;
  287|    648|  const char16_t *end = buf + len;
  288|       |
  289|    648|  const __m128i v_0000 = _mm_setzero_si128();
  290|    648|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
  291|    648|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
  292|    648|  const size_t safety_margin =
  293|    648|      12; // to avoid overruns, see issue
  294|       |          // https://github.com/simdutf/simdutf/issues/92
  295|       |
  296|   676k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (296:10): [True: 676k, False: 494]
  ------------------
  297|   676k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  298|   676k|    if (big_endian) {
  ------------------
  |  Branch (298:9): [True: 676k, Folded]
  ------------------
  299|   676k|      const __m128i swap =
  300|   676k|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  301|   676k|      in = _mm_shuffle_epi8(in, swap);
  302|   676k|    }
  303|       |    // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes
  304|   676k|    const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80);
  305|   676k|    if (_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (305:9): [True: 469k, False: 207k]
  ------------------
  306|   469k|      __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  307|   469k|      if (big_endian) {
  ------------------
  |  Branch (307:11): [True: 469k, Folded]
  ------------------
  308|   469k|        const __m128i swap =
  309|   469k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  310|   469k|        nextin = _mm_shuffle_epi8(nextin, swap);
  311|   469k|      }
  312|   469k|      if (!_mm_testz_si128(nextin, v_ff80)) {
  ------------------
  |  Branch (312:11): [True: 33.2k, False: 435k]
  ------------------
  313|       |        // 1. pack the bytes
  314|       |        // obviously suboptimal.
  315|  33.2k|        const __m128i utf8_packed = _mm_packus_epi16(in, in);
  316|       |        // 2. store (16 bytes)
  317|  33.2k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  318|       |        // 3. adjust pointers
  319|  33.2k|        buf += 8;
  320|  33.2k|        utf8_output += 8;
  321|  33.2k|        in = nextin;
  322|   435k|      } else {
  323|       |        // 1. pack the bytes
  324|       |        // obviously suboptimal.
  325|   435k|        const __m128i utf8_packed = _mm_packus_epi16(in, nextin);
  326|       |        // 2. store (16 bytes)
  327|   435k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  328|       |        // 3. adjust pointers
  329|   435k|        buf += 16;
  330|   435k|        utf8_output += 16;
  331|   435k|        continue; // we are done for this round!
  332|   435k|      }
  333|   469k|    }
  334|       |
  335|       |    // no bits set above 7th bit
  336|   240k|    const __m128i one_byte_bytemask =
  337|   240k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000);
  338|   240k|    const uint16_t one_byte_bitmask =
  339|   240k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  340|       |
  341|       |    // no bits set above 11th bit
  342|   240k|    const __m128i one_or_two_bytes_bytemask =
  343|   240k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000);
  344|   240k|    const uint16_t one_or_two_bytes_bitmask =
  345|   240k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  346|       |
  347|   240k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (347:9): [True: 44.3k, False: 195k]
  ------------------
  348|  44.3k|      internal::westmere::write_v_u16_11bits_to_utf8(
  349|  44.3k|          in, utf8_output, one_byte_bytemask, one_byte_bitmask);
  350|  44.3k|      buf += 8;
  351|  44.3k|      continue;
  352|  44.3k|    }
  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|   195k|    const __m128i surrogates_bytemask =
  358|   195k|        _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|   195k|    const uint16_t surrogates_bitmask =
  363|   195k|        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|   195k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (366:9): [True: 189k, False: 6.06k]
  ------------------
  367|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  368|   189k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  369|   189k|                                              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|   189k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  399|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  400|   189k|      const __m128i t0 = _mm_shuffle_epi8(in, dup_even);
  401|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  402|   189k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  398|   189k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  403|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  404|   189k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  398|   189k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  405|       |
  406|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  407|   189k|      const __m128i s0 = _mm_srli_epi16(in, 4);
  408|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  409|   189k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  398|   189k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  410|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  411|   189k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  398|   189k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  412|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  413|   189k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  398|   189k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  414|   189k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  415|   189k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  398|   189k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  416|   189k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  417|   189k|#undef simdutf_vec
  418|       |
  419|       |      // 4. expand code units 16-bit => 32-bit
  420|   189k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  421|   189k|      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|   189k|      const uint16_t mask =
  425|   189k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  426|   189k|      if (mask == 0) {
  ------------------
  |  Branch (426:11): [True: 111k, False: 78.4k]
  ------------------
  427|       |        // We only have three-byte code units. Use fast path.
  428|   111k|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  429|   111k|                                              15, 13, -1, -1, -1, -1);
  430|   111k|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  431|   111k|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  432|   111k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  433|   111k|        utf8_output += 12;
  434|   111k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  435|   111k|        utf8_output += 12;
  436|   111k|        buf += 8;
  437|   111k|        continue;
  438|   111k|      }
  439|  78.4k|      const uint8_t mask0 = uint8_t(mask);
  440|       |
  441|  78.4k|      const uint8_t *row0 =
  442|  78.4k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  443|  78.4k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  444|  78.4k|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  445|       |
  446|  78.4k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  447|       |
  448|  78.4k|      const uint8_t *row1 =
  449|  78.4k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  450|  78.4k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  451|  78.4k|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  452|       |
  453|  78.4k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  454|  78.4k|      utf8_output += row0[0];
  455|  78.4k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  456|  78.4k|      utf8_output += row1[0];
  457|       |
  458|  78.4k|      buf += 8;
  459|       |      // surrogate pair(s) in a register
  460|  78.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|  6.06k|      size_t forward = 15;
  465|  6.06k|      size_t k = 0;
  466|  6.06k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (466:11): [True: 0, False: 6.06k]
  ------------------
  467|      0|        forward = size_t(end - buf - 1);
  468|      0|      }
  469|  88.4k|      for (; k < forward; k++) {
  ------------------
  |  Branch (469:14): [True: 82.5k, False: 5.91k]
  ------------------
  470|  82.5k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  471|  82.5k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (471:13): [True: 23.1k, False: 59.3k]
  ------------------
  472|  23.1k|          *utf8_output++ = char(word);
  473|  59.3k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (473:20): [True: 3.85k, False: 55.5k]
  ------------------
  474|  3.85k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  475|  3.85k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  476|  55.5k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (476:20): [True: 48.3k, False: 7.14k]
  ------------------
  477|  48.3k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  478|  48.3k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  479|  48.3k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  480|  48.3k|        } else {
  481|       |          // must be a surrogate pair
  482|  7.14k|          uint16_t diff = uint16_t(word - 0xD800);
  483|  7.14k|          uint16_t next_word =
  484|  7.14k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  485|  7.14k|          k++;
  486|  7.14k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  487|  7.14k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (487:15): [True: 154, False: 6.99k]
  ------------------
  488|    154|            return std::make_pair(
  489|    154|                result(error_code::SURROGATE, buf - start + k - 1),
  490|    154|                utf8_output);
  491|    154|          }
  492|  6.99k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  493|  6.99k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  494|  6.99k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  495|  6.99k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  496|  6.99k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  497|  6.99k|        }
  498|  82.5k|      }
  499|  5.91k|      buf += k;
  500|  5.91k|    }
  501|   195k|  } // while
  502|       |
  503|    494|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output);
  504|    648|}

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

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_utf32_to_utf16ILNS_10endiannessE0EEENSt3__14pairIPKDiPDsEES7_mS8_:
   58|    732|                           char16_t *utf16_output) {
   59|       |
   60|    732|  const char32_t *end = buf + len;
   61|       |
   62|    732|  const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000);
   63|    732|  __m128i forbidden_bytemask = _mm_setzero_si128();
   64|       |
   65|  50.1k|  while (end - buf >= 16 + 8) {
  ------------------
  |  Branch (65:10): [True: 49.4k, False: 688]
  ------------------
   66|  49.4k|    const __m128i *ptr = reinterpret_cast<const __m128i *>(buf);
   67|  49.4k|    const __m128i in0 = _mm_loadu_si128(ptr + 0);
   68|  49.4k|    const __m128i in1 = _mm_loadu_si128(ptr + 1);
   69|  49.4k|    const __m128i in2 = _mm_loadu_si128(ptr + 2);
   70|  49.4k|    const __m128i in3 = _mm_loadu_si128(ptr + 3);
   71|       |
   72|  49.4k|    const __m128i combined =
   73|  49.4k|        _mm_or_si128(_mm_or_si128(in2, in3), _mm_or_si128(in0, in1));
   74|  49.4k|    if (simdutf_likely(_mm_testz_si128(combined, v_ffff0000))) {
  ------------------
  |  |   90|  49.4k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 48.0k, False: 1.39k]
  |  |  ------------------
  ------------------
   75|       |      // No bits set above 16th, directly pack UTF-32 to UTF-16
   76|  48.0k|      __m128i utf16_packed0 = _mm_packus_epi32(in0, in1);
   77|  48.0k|      __m128i utf16_packed1 = _mm_packus_epi32(in2, in3);
   78|       |
   79|  48.0k|      const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
   80|  48.0k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
   81|  48.0k|      forbidden_bytemask = _mm_or_si128(
   82|  48.0k|          forbidden_bytemask,
   83|  48.0k|          _mm_or_si128(
   84|  48.0k|              _mm_cmpeq_epi16(_mm_and_si128(utf16_packed0, v_f800), v_d800),
   85|  48.0k|              _mm_cmpeq_epi16(_mm_and_si128(utf16_packed1, v_f800), v_d800)));
   86|       |
   87|  48.0k|      if (big_endian) {
  ------------------
  |  Branch (87:11): [Folded, False: 48.0k]
  ------------------
   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|  48.0k|      _mm_storeu_si128((__m128i *)utf16_output + 0, utf16_packed0);
   95|  48.0k|      _mm_storeu_si128((__m128i *)utf16_output + 1, utf16_packed1);
   96|  48.0k|      utf16_output += 16;
   97|  48.0k|      buf += 16;
   98|  48.0k|    } else {
   99|  1.39k|      if (!validate_utf32(in0, in1) || !validate_utf32(in2, in3)) {
  ------------------
  |  Branch (99:11): [True: 20, False: 1.37k]
  |  Branch (99:40): [True: 24, False: 1.35k]
  ------------------
  100|     44|        return std::make_pair(nullptr, utf16_output);
  101|     44|      }
  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|  49.4k|  }
  122|       |
  123|       |  // check for invalid input
  124|    688|  if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (124:7): [True: 22, False: 666]
  ------------------
  125|     22|    return std::make_pair(nullptr, utf16_output);
  126|     22|  }
  127|       |
  128|    666|  return std::make_pair(buf, utf16_output);
  129|    688|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114validate_utf32EDv2_xS2_:
   37|  3.87k|simdutf_really_inline bool validate_utf32(const __m128i a, const __m128i b) {
   38|  3.87k|  using vector_u32 = simd32<uint32_t>;
   39|       |
   40|  3.87k|  const auto in0 = vector_u32(a);
   41|  3.87k|  const auto in1 = vector_u32(b);
   42|       |
   43|  3.87k|  const auto standardmax = vector_u32::splat(0x10ffff);
   44|  3.87k|  const auto offset = vector_u32::splat(0xffff2000);
   45|  3.87k|  const auto standardoffsetmax = vector_u32::splat(0xfffff7ff);
   46|       |
   47|  3.87k|  const auto too_large = max(in0, in1) > standardmax;
   48|  3.87k|  const auto surrogate0 = (in0 + offset) > standardoffsetmax;
   49|  3.87k|  const auto surrogate1 = (in1 + offset) > standardoffsetmax;
   50|       |
   51|  3.87k|  const auto combined = too_large | surrogate0 | surrogate1;
   52|  3.87k|  return !combined.any();
   53|  3.87k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_120sse_expand_surrogateILNS_10endiannessE0EEENS1_18expansion_result_tEDv2_x:
    9|  5.41k|expansion_result_t sse_expand_surrogate(const __m128i x) {
   10|  5.41k|  using vector_u32 = simd32<uint32_t>;
   11|  5.41k|  using vector_u8 = simd8<uint8_t>;
   12|       |
   13|  5.41k|  const auto in = vector_u32(x);
   14|       |
   15|  5.41k|  const auto non_surrogate_mask = (in & uint32_t(0xffff0000)) == uint32_t(0);
   16|  5.41k|  const auto mask = (~non_surrogate_mask.to_4bit_bitmask()) & 0xf;
   17|       |
   18|  5.41k|  const auto t0 = in - uint32_t(0x00010000);
   19|  5.41k|  const auto hi = t0.shr<10>() & uint32_t(0x000003ff);
   20|  5.41k|  const auto lo = t0.shl<16>() & uint32_t(0x03ff0000);
   21|  5.41k|  const auto surrogates = (lo | hi) | uint32_t(0xdc00d800);
   22|       |
   23|  5.41k|  const auto merged = as_vector_u8(select(non_surrogate_mask, in, surrogates));
   24|       |
   25|  5.41k|  const auto shuffle = vector_u8::load(
   26|  5.41k|      (byte_order == endianness::LITTLE)
  ------------------
  |  Branch (26:7): [True: 5.41k, Folded]
  ------------------
   27|  5.41k|          ? tables::utf32_to_utf16::pack_utf32_to_utf16le[mask]
   28|  5.41k|          : tables::utf32_to_utf16::pack_utf32_to_utf16be[mask]);
   29|       |
   30|  5.41k|  const size_t u16count = (4 + count_ones(mask));
   31|  5.41k|  const auto compressed = shuffle.lookup_16(merged);
   32|       |
   33|  5.41k|  return {u16count, compressed};
   34|  5.41k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_utf32_to_utf16ILNS_10endiannessE1EEENSt3__14pairIPKDiPDsEES7_mS8_:
   58|    540|                           char16_t *utf16_output) {
   59|       |
   60|    540|  const char32_t *end = buf + len;
   61|       |
   62|    540|  const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000);
   63|    540|  __m128i forbidden_bytemask = _mm_setzero_si128();
   64|       |
   65|  2.99k|  while (end - buf >= 16 + 8) {
  ------------------
  |  Branch (65:10): [True: 2.48k, False: 506]
  ------------------
   66|  2.48k|    const __m128i *ptr = reinterpret_cast<const __m128i *>(buf);
   67|  2.48k|    const __m128i in0 = _mm_loadu_si128(ptr + 0);
   68|  2.48k|    const __m128i in1 = _mm_loadu_si128(ptr + 1);
   69|  2.48k|    const __m128i in2 = _mm_loadu_si128(ptr + 2);
   70|  2.48k|    const __m128i in3 = _mm_loadu_si128(ptr + 3);
   71|       |
   72|  2.48k|    const __m128i combined =
   73|  2.48k|        _mm_or_si128(_mm_or_si128(in2, in3), _mm_or_si128(in0, in1));
   74|  2.48k|    if (simdutf_likely(_mm_testz_si128(combined, v_ffff0000))) {
  ------------------
  |  |   90|  2.48k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 1.92k, False: 558]
  |  |  ------------------
  ------------------
   75|       |      // No bits set above 16th, directly pack UTF-32 to UTF-16
   76|  1.92k|      __m128i utf16_packed0 = _mm_packus_epi32(in0, in1);
   77|  1.92k|      __m128i utf16_packed1 = _mm_packus_epi32(in2, in3);
   78|       |
   79|  1.92k|      const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
   80|  1.92k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
   81|  1.92k|      forbidden_bytemask = _mm_or_si128(
   82|  1.92k|          forbidden_bytemask,
   83|  1.92k|          _mm_or_si128(
   84|  1.92k|              _mm_cmpeq_epi16(_mm_and_si128(utf16_packed0, v_f800), v_d800),
   85|  1.92k|              _mm_cmpeq_epi16(_mm_and_si128(utf16_packed1, v_f800), v_d800)));
   86|       |
   87|  1.92k|      if (big_endian) {
  ------------------
  |  Branch (87:11): [True: 1.92k, Folded]
  ------------------
   88|  1.92k|        const __m128i swap =
   89|  1.92k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   90|  1.92k|        utf16_packed0 = _mm_shuffle_epi8(utf16_packed0, swap);
   91|  1.92k|        utf16_packed1 = _mm_shuffle_epi8(utf16_packed1, swap);
   92|  1.92k|      }
   93|       |
   94|  1.92k|      _mm_storeu_si128((__m128i *)utf16_output + 0, utf16_packed0);
   95|  1.92k|      _mm_storeu_si128((__m128i *)utf16_output + 1, utf16_packed1);
   96|  1.92k|      utf16_output += 16;
   97|  1.92k|      buf += 16;
   98|  1.92k|    } else {
   99|    558|      if (!validate_utf32(in0, in1) || !validate_utf32(in2, in3)) {
  ------------------
  |  Branch (99:11): [True: 20, False: 538]
  |  Branch (99:40): [True: 14, False: 524]
  ------------------
  100|     34|        return std::make_pair(nullptr, utf16_output);
  101|     34|      }
  102|       |
  103|    524|      const auto ret0 = sse_expand_surrogate<big_endian>(in0);
  104|    524|      _mm_storeu_si128((__m128i *)utf16_output, ret0.compressed);
  105|    524|      utf16_output += ret0.u16count;
  106|       |
  107|    524|      const auto ret1 = sse_expand_surrogate<big_endian>(in1);
  108|    524|      _mm_storeu_si128((__m128i *)utf16_output, ret1.compressed);
  109|    524|      utf16_output += ret1.u16count;
  110|       |
  111|    524|      const auto ret2 = sse_expand_surrogate<big_endian>(in2);
  112|    524|      _mm_storeu_si128((__m128i *)utf16_output, ret2.compressed);
  113|    524|      utf16_output += ret2.u16count;
  114|       |
  115|    524|      const auto ret3 = sse_expand_surrogate<big_endian>(in3);
  116|    524|      _mm_storeu_si128((__m128i *)utf16_output, ret3.compressed);
  117|    524|      utf16_output += ret3.u16count;
  118|       |
  119|    524|      buf += 16;
  120|    524|    }
  121|  2.48k|  }
  122|       |
  123|       |  // check for invalid input
  124|    506|  if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (124:7): [True: 8, False: 498]
  ------------------
  125|      8|    return std::make_pair(nullptr, utf16_output);
  126|      8|  }
  127|       |
  128|    498|  return std::make_pair(buf, utf16_output);
  129|    506|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_120sse_expand_surrogateILNS_10endiannessE1EEENS1_18expansion_result_tEDv2_x:
    9|  2.09k|expansion_result_t sse_expand_surrogate(const __m128i x) {
   10|  2.09k|  using vector_u32 = simd32<uint32_t>;
   11|  2.09k|  using vector_u8 = simd8<uint8_t>;
   12|       |
   13|  2.09k|  const auto in = vector_u32(x);
   14|       |
   15|  2.09k|  const auto non_surrogate_mask = (in & uint32_t(0xffff0000)) == uint32_t(0);
   16|  2.09k|  const auto mask = (~non_surrogate_mask.to_4bit_bitmask()) & 0xf;
   17|       |
   18|  2.09k|  const auto t0 = in - uint32_t(0x00010000);
   19|  2.09k|  const auto hi = t0.shr<10>() & uint32_t(0x000003ff);
   20|  2.09k|  const auto lo = t0.shl<16>() & uint32_t(0x03ff0000);
   21|  2.09k|  const auto surrogates = (lo | hi) | uint32_t(0xdc00d800);
   22|       |
   23|  2.09k|  const auto merged = as_vector_u8(select(non_surrogate_mask, in, surrogates));
   24|       |
   25|  2.09k|  const auto shuffle = vector_u8::load(
   26|  2.09k|      (byte_order == endianness::LITTLE)
  ------------------
  |  Branch (26:7): [Folded, False: 2.09k]
  ------------------
   27|  2.09k|          ? tables::utf32_to_utf16::pack_utf32_to_utf16le[mask]
   28|  2.09k|          : tables::utf32_to_utf16::pack_utf32_to_utf16be[mask]);
   29|       |
   30|  2.09k|  const size_t u16count = (4 + count_ones(mask));
   31|  2.09k|  const auto compressed = shuffle.lookup_16(merged);
   32|       |
   33|  2.09k|  return {u16count, compressed};
   34|  2.09k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_138sse_convert_utf32_to_utf16_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPDsEEPKDimS7_:
  134|    714|                                       char16_t *utf16_output) {
  135|    714|  const char32_t *start = buf;
  136|    714|  const char32_t *end = buf + len;
  137|       |
  138|    714|  const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000);
  139|       |
  140|  9.71k|  while (end - buf >= 8) {
  ------------------
  |  Branch (140:10): [True: 9.39k, False: 326]
  ------------------
  141|  9.39k|    const __m128i in = _mm_loadu_si128((__m128i *)buf);
  142|  9.39k|    const __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  143|       |
  144|  9.39k|    const __m128i combined = _mm_or_si128(in, nextin);
  145|  9.39k|    if (simdutf_likely(_mm_testz_si128(combined, v_ffff0000))) {
  ------------------
  |  |   90|  9.39k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 7.29k, False: 2.09k]
  |  |  ------------------
  ------------------
  146|       |      // No bits set above 16th, directly pack UTF-32 to UTF-16
  147|  7.29k|      __m128i utf16_packed = _mm_packus_epi32(in, nextin);
  148|       |
  149|  7.29k|      const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
  150|  7.29k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
  151|  7.29k|      const __m128i forbidden_bytemask =
  152|  7.29k|          _mm_cmpeq_epi16(_mm_and_si128(utf16_packed, v_f800), v_d800);
  153|  7.29k|      if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (153:11): [True: 46, False: 7.25k]
  ------------------
  154|     46|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  155|     46|                              utf16_output);
  156|     46|      }
  157|       |
  158|  7.25k|      if (big_endian) {
  ------------------
  |  Branch (158:11): [Folded, False: 7.25k]
  ------------------
  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|  7.25k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
  165|  7.25k|      utf16_output += 8;
  166|  7.25k|      buf += 8;
  167|  7.25k|    } else {
  168|  2.09k|      size_t forward = 7;
  169|  2.09k|      size_t k = 0;
  170|  2.09k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (170:11): [True: 0, False: 2.09k]
  ------------------
  171|      0|        forward = size_t(end - buf - 1);
  172|      0|      }
  173|  15.0k|      for (; k < forward; k++) {
  ------------------
  |  Branch (173:14): [True: 13.3k, False: 1.75k]
  ------------------
  174|  13.3k|        uint32_t word = buf[k];
  175|  13.3k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (175:13): [True: 6.32k, False: 6.98k]
  ------------------
  176|       |          // will not generate a surrogate pair
  177|  6.32k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (177:15): [True: 808, False: 5.51k]
  |  Branch (177:33): [True: 34, False: 774]
  ------------------
  178|     34|            return std::make_pair(
  179|     34|                result(error_code::SURROGATE, buf - start + k), utf16_output);
  180|     34|          }
  181|  6.29k|          *utf16_output++ =
  182|  6.29k|              big_endian
  ------------------
  |  Branch (182:15): [Folded, False: 6.29k]
  ------------------
  183|  6.29k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
  184|  6.29k|                  : char16_t(word);
  185|  6.98k|        } else {
  186|       |          // will generate a surrogate pair
  187|  6.98k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (187:15): [True: 308, False: 6.67k]
  ------------------
  188|    308|            return std::make_pair(
  189|    308|                result(error_code::TOO_LARGE, buf - start + k), utf16_output);
  190|    308|          }
  191|  6.67k|          word -= 0x10000;
  192|  6.67k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
  193|  6.67k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
  194|  6.67k|          if (big_endian) {
  ------------------
  |  Branch (194:15): [Folded, False: 6.67k]
  ------------------
  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|  6.67k|          *utf16_output++ = char16_t(high_surrogate);
  201|  6.67k|          *utf16_output++ = char16_t(low_surrogate);
  202|  6.67k|        }
  203|  13.3k|      }
  204|  1.75k|      buf += k;
  205|  1.75k|    }
  206|  9.39k|  }
  207|       |
  208|    326|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output);
  209|    714|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_138sse_convert_utf32_to_utf16_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPDsEEPKDimS7_:
  134|    660|                                       char16_t *utf16_output) {
  135|    660|  const char32_t *start = buf;
  136|    660|  const char32_t *end = buf + len;
  137|       |
  138|    660|  const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000);
  139|       |
  140|  10.4k|  while (end - buf >= 8) {
  ------------------
  |  Branch (140:10): [True: 10.1k, False: 310]
  ------------------
  141|  10.1k|    const __m128i in = _mm_loadu_si128((__m128i *)buf);
  142|  10.1k|    const __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  143|       |
  144|  10.1k|    const __m128i combined = _mm_or_si128(in, nextin);
  145|  10.1k|    if (simdutf_likely(_mm_testz_si128(combined, v_ffff0000))) {
  ------------------
  |  |   90|  10.1k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 9.18k, False: 986]
  |  |  ------------------
  ------------------
  146|       |      // No bits set above 16th, directly pack UTF-32 to UTF-16
  147|  9.18k|      __m128i utf16_packed = _mm_packus_epi32(in, nextin);
  148|       |
  149|  9.18k|      const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
  150|  9.18k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
  151|  9.18k|      const __m128i forbidden_bytemask =
  152|  9.18k|          _mm_cmpeq_epi16(_mm_and_si128(utf16_packed, v_f800), v_d800);
  153|  9.18k|      if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (153:11): [True: 26, False: 9.15k]
  ------------------
  154|     26|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  155|     26|                              utf16_output);
  156|     26|      }
  157|       |
  158|  9.15k|      if (big_endian) {
  ------------------
  |  Branch (158:11): [True: 9.15k, Folded]
  ------------------
  159|  9.15k|        const __m128i swap =
  160|  9.15k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  161|  9.15k|        utf16_packed = _mm_shuffle_epi8(utf16_packed, swap);
  162|  9.15k|      }
  163|       |
  164|  9.15k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
  165|  9.15k|      utf16_output += 8;
  166|  9.15k|      buf += 8;
  167|  9.15k|    } else {
  168|    986|      size_t forward = 7;
  169|    986|      size_t k = 0;
  170|    986|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (170:11): [True: 0, False: 986]
  ------------------
  171|      0|        forward = size_t(end - buf - 1);
  172|      0|      }
  173|  6.29k|      for (; k < forward; k++) {
  ------------------
  |  Branch (173:14): [True: 5.63k, False: 662]
  ------------------
  174|  5.63k|        uint32_t word = buf[k];
  175|  5.63k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (175:13): [True: 3.07k, False: 2.56k]
  ------------------
  176|       |          // will not generate a surrogate pair
  177|  3.07k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (177:15): [True: 916, False: 2.15k]
  |  Branch (177:33): [True: 32, False: 884]
  ------------------
  178|     32|            return std::make_pair(
  179|     32|                result(error_code::SURROGATE, buf - start + k), utf16_output);
  180|     32|          }
  181|  3.04k|          *utf16_output++ =
  182|  3.04k|              big_endian
  ------------------
  |  Branch (182:15): [True: 3.04k, Folded]
  ------------------
  183|  3.04k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
  184|  3.04k|                  : char16_t(word);
  185|  3.04k|        } else {
  186|       |          // will generate a surrogate pair
  187|  2.56k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (187:15): [True: 292, False: 2.27k]
  ------------------
  188|    292|            return std::make_pair(
  189|    292|                result(error_code::TOO_LARGE, buf - start + k), utf16_output);
  190|    292|          }
  191|  2.27k|          word -= 0x10000;
  192|  2.27k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
  193|  2.27k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
  194|  2.27k|          if (big_endian) {
  ------------------
  |  Branch (194:15): [True: 2.27k, Folded]
  ------------------
  195|  2.27k|            high_surrogate =
  196|  2.27k|                uint16_t((high_surrogate >> 8) | (high_surrogate << 8));
  197|  2.27k|            low_surrogate =
  198|  2.27k|                uint16_t((low_surrogate >> 8) | (low_surrogate << 8));
  199|  2.27k|          }
  200|  2.27k|          *utf16_output++ = char16_t(high_surrogate);
  201|  2.27k|          *utf16_output++ = char16_t(low_surrogate);
  202|  2.27k|        }
  203|  5.63k|      }
  204|    662|      buf += k;
  205|    662|    }
  206|  10.1k|  }
  207|       |
  208|    310|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output);
  209|    660|}

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

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

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

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

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

