LLVMFuzzerTestOneInput:
    7|  1.31k|{
    8|       |   // use a vector with null termination instead of a std::string to avoid
    9|       |   // small string optimization to hide bounds problems
   10|  1.31k|   std::vector<char> buffer{Data, Data + Size};
   11|       |
   12|       |   // non-null terminated
   13|  1.31k|   {
   14|  1.31k|      const auto& input = buffer;
   15|  1.31k|      [[maybe_unused]] auto beautiful = glz::prettify_json(input);
   16|  1.31k|   }
   17|       |
   18|       |   // null terminated
   19|  1.31k|   {
   20|  1.31k|      buffer.push_back('\0');
   21|  1.31k|      const auto& input = buffer;
   22|  1.31k|      [[maybe_unused]] auto beautiful = glz::prettify_json(input);
   23|  1.31k|   }
   24|       |
   25|  1.31k|   return 0;
   26|  1.31k|}

_ZN3glz14read_iteratorsITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEELb0ETkNS_10contiguousERKNSt3__16vectorIcNS2_9allocatorIcEEEEEEDaOT1_:
   40|  2.62k|   {
   41|  2.62k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
   42|       |
   43|  2.62k|      auto it = reinterpret_cast<const char*>(buffer.data());
   44|  2.62k|      auto end = reinterpret_cast<const char*>(buffer.data()); // to be incremented
   45|       |
   46|       |      if constexpr (Padded) {
   47|       |         end += buffer.size() - padding_bytes;
   48|       |      }
   49|  2.62k|      else {
   50|  2.62k|         end += buffer.size();
   51|  2.62k|      }
   52|       |
   53|  2.62k|      return std::pair{it, end};
   54|  2.62k|   }

_ZN3glz6detail16read_json_stringITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERPKcS4_Qntcl15check_is_paddedT_EEENSt3__117basic_string_viewIcNS6_11char_traitsIcEEEEOT0_T1_:
  110|   511k|   {
  111|   511k|      auto start = it;
  112|   511k|      ++it; // skip quote
  113|  1.68M|      for (const auto end_m7 = end - 7; it < end_m7;) {
  ------------------
  |  Branch (113:41): [True: 1.68M, False: 367]
  ------------------
  114|  1.68M|         uint64_t chunk;
  115|  1.68M|         std::memcpy(&chunk, it, 8);
  116|       |         if constexpr (std::endian::native == std::endian::big) {
  117|       |            chunk = std::byteswap(chunk);
  118|       |         }
  119|  1.68M|         const uint64_t quote = has_quote(chunk);
  120|  1.68M|         if (quote) {
  ------------------
  |  Branch (120:14): [True: 511k, False: 1.17M]
  ------------------
  121|   511k|            it += (countr_zero(quote) >> 3);
  122|       |
  123|   511k|            auto* prev = it - 1;
  124|   512k|            while (*prev == '\\') {
  ------------------
  |  Branch (124:20): [True: 1.15k, False: 511k]
  ------------------
  125|  1.15k|               --prev;
  126|  1.15k|            }
  127|   511k|            if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (127:17): [True: 510k, False: 374]
  ------------------
  128|   510k|               ++it; // add quote
  129|   510k|               return {start, size_t(it - start)};
  130|   510k|            }
  131|    374|            ++it; // skip escaped quote and continue
  132|    374|         }
  133|  1.17M|         else {
  134|  1.17M|            it += 8;
  135|  1.17M|         }
  136|  1.68M|      }
  137|       |
  138|       |      // Tail end of buffer. Should be rare we even get here
  139|    952|      while (it < end) {
  ------------------
  |  Branch (139:14): [True: 838, False: 114]
  ------------------
  140|    838|         if (*it == '"') {
  ------------------
  |  Branch (140:14): [True: 291, False: 547]
  ------------------
  141|    291|            auto* prev = it - 1;
  142|  1.48k|            while (*prev == '\\') {
  ------------------
  |  Branch (142:20): [True: 1.19k, False: 291]
  ------------------
  143|  1.19k|               --prev;
  144|  1.19k|            }
  145|    291|            if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (145:17): [True: 253, False: 38]
  ------------------
  146|    253|               ++it; // add quote
  147|    253|               return {start, size_t(it - start)};
  148|    253|            }
  149|    291|         }
  150|    585|         ++it;
  151|    585|      }
  152|       |
  153|    114|      return {};
  154|    367|   }
_ZN3glz6detail15append_new_lineILb0ELh3ERNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEERmEEvOT1_OT2_l:
   63|   103M|   {
   64|   103M|      dump('\n', b, ix);
   65|       |      if constexpr (use_tabs) {
   66|       |         dumpn('\t', indent, b, ix);
   67|       |      }
   68|   103M|      else {
   69|   103M|         dumpn(' ', indent * indentation_width, b, ix);
   70|   103M|      }
   71|   103M|   };
_ZN3glz6detail16read_json_numberILb0ERPKcS3_EENSt3__117basic_string_viewIcNS5_11char_traitsIcEEEEOT0_T1_:
  197|   529k|   {
  198|   529k|      auto start = it;
  199|       |      if constexpr (null_terminated) {
  200|       |         while (numeric_table[uint8_t(*it)]) {
  201|       |            ++it;
  202|       |         }
  203|       |      }
  204|   529k|      else {
  205|  3.20M|         while ((it < end) && numeric_table[uint8_t(*it)]) {
  ------------------
  |  Branch (205:17): [True: 3.20M, False: 48]
  |  Branch (205:31): [True: 2.67M, False: 529k]
  ------------------
  206|  2.67M|            ++it;
  207|  2.67M|         }
  208|   529k|      }
  209|   529k|      return {start, size_t(it - start)};
  210|   529k|   }

_ZN3glz13prettify_jsonITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEENSt3__16vectorIcNS2_9allocatorIcEEEEEENS2_12basic_stringIcNS2_11char_traitsIcEES5_EERKT0_:
  231|  2.62k|   {
  232|  2.62k|      context ctx{};
  233|  2.62k|      std::string out{};
  234|  2.62k|      detail::prettify_json<Opts>(ctx, in, out);
  235|  2.62k|      return out;
  236|  2.62k|   }
_ZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_10contiguousERKNSt3__16vectorIcNS3_9allocatorIcEEEETkNS_13output_bufferERNS3_12basic_stringIcNS3_11char_traitsIcEES6_EETkNS_10is_contextERNS_7contextEEEvOT2_OT0_OT1_:
  188|  2.62k|      {
  189|  2.62k|         if constexpr (resizable<Out>) {
  190|  2.62k|            if (in.empty()) {
  ------------------
  |  Branch (190:17): [True: 0, False: 2.62k]
  ------------------
  191|      0|               out.clear();
  192|      0|               return;
  193|      0|            }
  194|  2.62k|            out.resize(in.size() * 2);
  195|  2.62k|         }
  196|      0|         size_t ix = 0;
  197|  2.62k|         auto [it, end] = read_iterators<Opts>(in);
  198|  2.62k|         if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (198:14): [True: 0, False: 2.62k]
  ------------------
  199|      0|            return;
  200|      0|         }
  201|       |
  202|       |         if constexpr (string_t<In>) {
  203|       |            prettify_json<opt_true<Opts, &opts::null_terminated>>(ctx, it, end, out, ix);
  204|       |         }
  205|  2.62k|         else {
  206|  2.62k|            prettify_json<opt_false<Opts, &opts::null_terminated>>(ctx, it, end, out, ix);
  207|  2.62k|         }
  208|       |
  209|  2.62k|         if constexpr (resizable<Out>) {
  210|  2.62k|            out.resize(ix);
  211|  2.62k|         }
  212|  2.62k|      }
_ZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_:
   16|  2.62k|      {
   17|  2.62k|         constexpr bool use_tabs = check_indentation_char(Opts) == '\t';
   18|  2.62k|         constexpr auto indent_width = check_indentation_width(Opts);
   19|       |
   20|  2.62k|         using enum json_type;
   21|       |
   22|  2.62k|         std::vector<json_type> state(64);
   23|  2.62k|         int64_t indent{};
   24|       |
   25|   122M|         while (it < end) {
  ------------------
  |  Branch (25:17): [True: 122M, False: 1.10k]
  ------------------
   26|   122M|            switch (json_types[uint8_t(*it)]) {
   27|   511k|            case String: {
  ------------------
  |  Branch (27:13): [True: 511k, False: 121M]
  ------------------
   28|   511k|               const auto value = read_json_string<Opts>(it, end);
   29|   511k|               dump_maybe_empty(value, b, ix);
   30|   511k|               break;
   31|      0|            }
   32|  52.0M|            case Comma: {
  ------------------
  |  Branch (32:13): [True: 52.0M, False: 70.3M]
  ------------------
   33|  52.0M|               dump(',', b, ix);
   34|  52.0M|               ++it;
   35|  52.0M|               if constexpr (check_new_lines_in_arrays(Opts)) {
   36|  52.0M|                  append_new_line<use_tabs, indent_width>(b, ix, indent);
   37|       |               }
   38|       |               else {
   39|       |                  if (state[indent] == Object_Start) {
   40|       |                     append_new_line<use_tabs, indent_width>(b, ix, indent);
   41|       |                  }
   42|       |                  else {
   43|       |                     if constexpr (use_tabs) {
   44|       |                        dump('\t', b, ix);
   45|       |                     }
   46|       |                     else {
   47|       |                        dump(' ', b, ix);
   48|       |                     }
   49|       |                  }
   50|       |               }
   51|  52.0M|               break;
   52|      0|            }
   53|   529k|            case Number: {
  ------------------
  |  Branch (53:13): [True: 529k, False: 121M]
  ------------------
   54|   529k|               const auto value = read_json_number<Opts.null_terminated>(it, end);
   55|   529k|               dump_not_empty(value, b, ix);
   56|   529k|               break;
   57|      0|            }
   58|  3.44M|            case Colon: {
  ------------------
  |  Branch (58:13): [True: 3.44M, False: 118M]
  ------------------
   59|       |               if constexpr (use_tabs) {
   60|       |                  dump(":\t", b, ix);
   61|       |               }
   62|  3.44M|               else {
   63|  3.44M|                  dump(": ", b, ix);
   64|  3.44M|               }
   65|  3.44M|               ++it;
   66|  3.44M|               break;
   67|      0|            }
   68|  11.7M|            case Array_Start: {
  ------------------
  |  Branch (68:13): [True: 11.7M, False: 110M]
  ------------------
   69|  11.7M|               dump('[', b, ix);
   70|  11.7M|               ++it;
   71|  11.7M|               ++indent;
   72|  11.7M|               if (size_t(indent) >= state.size()) [[unlikely]] {
  ------------------
  |  Branch (72:20): [True: 740, False: 11.7M]
  ------------------
   73|    740|                  state.resize(state.size() * 2);
   74|    740|                  if (state.size() >= max_recursive_depth_limit) [[unlikely]] {
  ------------------
  |  Branch (74:23): [True: 62, False: 678]
  ------------------
   75|     62|                     ctx.error = error_code::exceeded_max_recursive_depth;
   76|     62|                     return;
   77|     62|                  }
   78|    740|               }
   79|  11.7M|               state[indent] = Array_Start;
   80|  11.7M|               if constexpr (check_new_lines_in_arrays(Opts)) {
   81|  11.7M|                  if constexpr (not Opts.null_terminated) {
   82|  11.7M|                     if (it != end && *it != ']') {
  ------------------
  |  Branch (82:26): [True: 11.7M, False: 113]
  |  Branch (82:39): [True: 11.2M, False: 492k]
  ------------------
   83|  11.2M|                        append_new_line<use_tabs, indent_width>(b, ix, indent);
   84|  11.2M|                     }
   85|       |                  }
   86|       |                  else {
   87|       |                     if (*it != ']') {
   88|       |                        append_new_line<use_tabs, indent_width>(b, ix, indent);
   89|       |                     }
   90|       |                  }
   91|  11.7M|               }
   92|  11.7M|               break;
   93|  11.7M|            }
   94|  12.4M|            case Array_End: {
  ------------------
  |  Branch (94:13): [True: 12.4M, False: 109M]
  ------------------
   95|  12.4M|               --indent;
   96|  12.4M|               if (indent < 0) {
  ------------------
  |  Branch (96:20): [True: 10, False: 12.4M]
  ------------------
   97|     10|                  ctx.error = error_code::syntax_error;
   98|     10|                  return;
   99|     10|               }
  100|  12.4M|               if constexpr (check_new_lines_in_arrays(Opts)) {
  101|  12.4M|                  if (it[-1] != '[') {
  ------------------
  |  Branch (101:23): [True: 11.9M, False: 493k]
  ------------------
  102|  11.9M|                     append_new_line<use_tabs, indent_width>(b, ix, indent);
  103|  11.9M|                  }
  104|  12.4M|               }
  105|  12.4M|               dump(']', b, ix);
  106|  12.4M|               ++it;
  107|  12.4M|               break;
  108|  12.4M|            }
  109|  13.1k|            case Null: {
  ------------------
  |  Branch (109:13): [True: 13.1k, False: 122M]
  ------------------
  110|  13.1k|               dump("null", b, ix);
  111|  13.1k|               it += 4;
  112|  13.1k|               break;
  113|  12.4M|            }
  114|  1.63M|            case Bool: {
  ------------------
  |  Branch (114:13): [True: 1.63M, False: 120M]
  ------------------
  115|  1.63M|               if (*it == 't') {
  ------------------
  |  Branch (115:20): [True: 1.62M, False: 8.85k]
  ------------------
  116|  1.62M|                  dump("true", b, ix);
  117|  1.62M|                  it += 4;
  118|  1.62M|                  break;
  119|  1.62M|               }
  120|  8.85k|               else {
  121|  8.85k|                  dump("false", b, ix);
  122|  8.85k|                  it += 5;
  123|  8.85k|                  break;
  124|  8.85k|               }
  125|  1.63M|            }
  126|  20.4M|            case Object_Start: {
  ------------------
  |  Branch (126:13): [True: 20.4M, False: 101M]
  ------------------
  127|  20.4M|               dump('{', b, ix);
  128|  20.4M|               ++it;
  129|  20.4M|               ++indent;
  130|  20.4M|               if (size_t(indent) >= state.size()) [[unlikely]] {
  ------------------
  |  Branch (130:20): [True: 376, False: 20.4M]
  ------------------
  131|    376|                  state.resize(state.size() * 2);
  132|    376|                  if (state.size() >= max_recursive_depth_limit) [[unlikely]] {
  ------------------
  |  Branch (132:23): [True: 52, False: 324]
  ------------------
  133|     52|                     ctx.error = error_code::exceeded_max_recursive_depth;
  134|     52|                     return;
  135|     52|                  }
  136|    376|               }
  137|  20.4M|               state[indent] = Object_Start;
  138|  20.4M|               if constexpr (not Opts.null_terminated) {
  139|  20.4M|                  if (it != end && *it != '}') [[unlikely]] {
  ------------------
  |  Branch (139:23): [True: 20.4M, False: 120]
  |  Branch (139:36): [True: 14.4M, False: 6.02M]
  ------------------
  140|  14.4M|                     append_new_line<use_tabs, indent_width>(b, ix, indent);
  141|  14.4M|                  }
  142|       |               }
  143|       |               else {
  144|       |                  if (*it != '}') {
  145|       |                     append_new_line<use_tabs, indent_width>(b, ix, indent);
  146|       |                  }
  147|       |               }
  148|  20.4M|               break;
  149|  20.4M|            }
  150|  19.5M|            case Object_End: {
  ------------------
  |  Branch (150:13): [True: 19.5M, False: 102M]
  ------------------
  151|  19.5M|               --indent;
  152|  19.5M|               if (indent < 0) {
  ------------------
  |  Branch (152:20): [True: 52, False: 19.5M]
  ------------------
  153|     52|                  ctx.error = error_code::syntax_error;
  154|     52|                  return;
  155|     52|               }
  156|  19.5M|               if (it[-1] != '{') {
  ------------------
  |  Branch (156:20): [True: 13.5M, False: 6.02M]
  ------------------
  157|  13.5M|                  append_new_line<use_tabs, indent_width>(b, ix, indent);
  158|  13.5M|               }
  159|  19.5M|               dump('}', b, ix);
  160|  19.5M|               ++it;
  161|  19.5M|               break;
  162|  19.5M|            }
  163|  1.53k|            case Comment: {
  ------------------
  |  Branch (163:13): [True: 1.53k, False: 122M]
  ------------------
  164|       |               if constexpr (Opts.comments) {
  165|       |                  const auto value = read_jsonc_comment(it, end);
  166|       |                  dump_not_empty(value, b, ix);
  167|       |                  break;
  168|       |               }
  169|  1.53k|               else {
  170|  1.53k|                  [[fallthrough]];
  171|  1.53k|               }
  172|  1.53k|            }
  173|  3.05k|            case Whitespace: {
  ------------------
  |  Branch (173:13): [True: 1.52k, False: 122M]
  ------------------
  174|       |               // Skip whitespace characters that are part of raw JSON content
  175|  3.05k|               ++it;
  176|  3.05k|               break;
  177|  1.53k|            }
  178|  1.34k|            [[unlikely]] default: {
  ------------------
  |  Branch (178:26): [True: 1.34k, False: 122M]
  ------------------
  179|  1.34k|               ctx.error = error_code::syntax_error;
  180|  1.34k|               return;
  181|      0|            }
  182|   122M|            }
  183|   122M|         }
  184|  2.62k|      }

_ZN3glz11countr_zeroEm:
   29|   511k|   {
   30|       |#ifdef _MSC_VER
   31|       |      return std::countr_zero(x);
   32|       |#else
   33|   511k|#if __has_builtin(__builtin_ctzll)
   34|   511k|      return __builtin_ctzll(x);
   35|       |#else
   36|       |      return std::countr_zero(x);
   37|       |#endif
   38|   511k|#endif
   39|   511k|   }

_ZN3glz16dump_maybe_emptyILb1ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEEvNS1_17basic_string_viewIcS4_EERT0_Rm:
  267|   511k|   {
  268|   511k|      const auto n = str.size();
  269|   511k|      if (n) {
  ------------------
  |  Branch (269:11): [True: 510k, False: 114]
  ------------------
  270|   510k|         if constexpr (vector_like<B>) {
  271|   510k|            if constexpr (Checked) {
  272|   510k|               const auto k = ix + n;
  273|   510k|               if (k > b.size()) [[unlikely]] {
  ------------------
  |  Branch (273:20): [True: 66, False: 510k]
  ------------------
  274|     66|                  b.resize(2 * k);
  275|     66|               }
  276|   510k|            }
  277|   510k|         }
  278|   510k|         std::memcpy(&b[ix], str.data(), n);
  279|   510k|         ix += n;
  280|   510k|      }
  281|   511k|   }
_ZN3glz4dumpILb1ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEETkNS_10byte_sizedEcEEvT1_RT0_Rm:
   98|   219M|   {
   99|   219M|      if constexpr (Checked && vector_like<B>) {
  100|   219M|         if (ix == b.size()) [[unlikely]] {
  ------------------
  |  Branch (100:14): [True: 1.19k, False: 219M]
  ------------------
  101|  1.19k|            b.resize(b.size() == 0 ? 128 : b.size() * 2);
  ------------------
  |  Branch (101:22): [True: 0, False: 1.19k]
  ------------------
  102|  1.19k|         }
  103|   219M|      }
  104|   219M|      assign_maybe_cast(c, b, ix);
  105|   219M|      ++ix;
  106|   219M|   }
_ZN3glz17assign_maybe_castITkNS_10byte_sizedEcNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEEvT_RT0_Rm:
   55|   219M|   {
   56|   219M|      using V = std::decay_t<decltype(b[0])>;
   57|   219M|      using C = std::decay_t<decltype(c)>;
   58|   219M|      if constexpr (std::same_as<V, C>) {
   59|   219M|         b[ix] = c;
   60|       |      }
   61|       |      else {
   62|       |         b[ix] = static_cast<V>(c);
   63|       |      }
   64|   219M|   }
_ZN3glz5dumpnINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEETkNS_10byte_sizedEcEEvT0_mRT_Rm:
  170|   103M|   {
  171|   103M|      if constexpr (vector_like<B>) {
  172|   103M|         const auto k = ix + n;
  173|   103M|         if (k > b.size()) [[unlikely]] {
  ------------------
  |  Branch (173:14): [True: 8.86k, False: 103M]
  ------------------
  174|  8.86k|            b.resize(2 * k);
  175|  8.86k|         }
  176|   103M|      }
  177|   103M|      std::memset(data_at(b, ix), c, n);
  178|   103M|      ix += n;
  179|   103M|   }
_ZN3glz7data_atINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEEDaRT_m:
   71|   103M|   {
   72|       |      if constexpr (std::is_pointer_v<std::remove_cvref_t<B>>) {
   73|       |         return b + ix;
   74|       |      }
   75|   103M|      else {
   76|   103M|         static_assert(has_data<std::remove_cvref_t<B>>,
   77|   103M|                       "an output buffer must be contiguous: dump writes through memset and memcpy");
   78|   103M|         return b.data() + ix;
   79|   103M|      }
   80|   103M|   }
_ZN3glz14dump_not_emptyILb1ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEEvNS1_17basic_string_viewIcS4_EERT0_Rm:
  251|   529k|   {
  252|   529k|      const auto n = str.size();
  253|   529k|      if constexpr (vector_like<B>) {
  254|   529k|         if constexpr (Checked) {
  255|   529k|            const auto k = ix + n;
  256|   529k|            if (k > b.size()) [[unlikely]] {
  ------------------
  |  Branch (256:17): [True: 51, False: 529k]
  ------------------
  257|     51|               b.resize(2 * k);
  258|     51|            }
  259|   529k|         }
  260|   529k|      }
  261|   529k|      std::memcpy(&b[ix], str.data(), n);
  262|   529k|      ix += n;
  263|   529k|   }
_ZN3glz4dumpILb1ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEEvNS1_17basic_string_viewIcS4_EERT0_Rm:
  140|  5.09M|   {
  141|  5.09M|      const auto n = str.size();
  142|  5.09M|      if constexpr (vector_like<B>) {
  143|  5.09M|         if constexpr (Checked) {
  144|  5.09M|            const auto k = ix + n;
  145|  5.09M|            if (ix + n > b.size()) [[unlikely]] {
  ------------------
  |  Branch (145:17): [True: 141, False: 5.09M]
  ------------------
  146|    141|               b.resize(2 * k);
  147|    141|            }
  148|  5.09M|         }
  149|  5.09M|      }
  150|  5.09M|      std::memcpy(&b[ix], str.data(), n);
  151|  5.09M|      ix += n;
  152|  5.09M|   }

_ZN3glz9has_quoteEm:
  534|  1.68M|   {
  535|  1.68M|      return has_zero(chunk ^ repeat_byte8('"'));
  536|  1.68M|   }
_ZN3glz8has_zeroEm:
  529|  1.68M|   {
  530|  1.68M|      return (((chunk - 0x0101010101010101u) & ~chunk) & 0x8080808080808080u);
  531|  1.68M|   }

