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

_ZN3glz14read_iteratorsITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEELb0ETkNS_10contiguousERKNSt3__16vectorIcNS2_9allocatorIcEEEEEEDaOT1_:
   40|  2.60k|   {
   41|  2.60k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
   42|       |
   43|  2.60k|      auto it = reinterpret_cast<const char*>(buffer.data());
   44|  2.60k|      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.60k|      else {
   50|  2.60k|         end += buffer.size();
   51|  2.60k|      }
   52|       |
   53|  2.60k|      return std::pair{it, end};
   54|  2.60k|   }

_ZN3glz6detail16read_json_stringITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERPKcS4_Qntcl15check_is_paddedT_EEENSt3__117basic_string_viewIcNS6_11char_traitsIcEEEEOT0_T1_:
  110|   514k|   {
  111|   514k|      auto start = it;
  112|   514k|      ++it; // skip quote
  113|  1.61M|      for (const auto end_m7 = end - 7; it < end_m7;) {
  ------------------
  |  Branch (113:41): [True: 1.61M, False: 349]
  ------------------
  114|  1.61M|         uint64_t chunk;
  115|  1.61M|         std::memcpy(&chunk, it, 8);
  116|       |         if constexpr (std::endian::native == std::endian::big) {
  117|       |            chunk = std::byteswap(chunk);
  118|       |         }
  119|  1.61M|         const uint64_t quote = has_quote(chunk);
  120|  1.61M|         if (quote) {
  ------------------
  |  Branch (120:14): [True: 514k, False: 1.10M]
  ------------------
  121|   514k|            it += (countr_zero(quote) >> 3);
  122|       |
  123|   514k|            auto* prev = it - 1;
  124|   515k|            while (*prev == '\\') {
  ------------------
  |  Branch (124:20): [True: 1.19k, False: 514k]
  ------------------
  125|  1.19k|               --prev;
  126|  1.19k|            }
  127|   514k|            if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (127:17): [True: 514k, False: 360]
  ------------------
  128|   514k|               ++it; // add quote
  129|   514k|               return {start, size_t(it - start)};
  130|   514k|            }
  131|    360|            ++it; // skip escaped quote and continue
  132|    360|         }
  133|  1.10M|         else {
  134|  1.10M|            it += 8;
  135|  1.10M|         }
  136|  1.61M|      }
  137|       |
  138|       |      // Tail end of buffer. Should be rare we even get here
  139|    897|      while (it < end) {
  ------------------
  |  Branch (139:14): [True: 793, False: 104]
  ------------------
  140|    793|         if (*it == '"') {
  ------------------
  |  Branch (140:14): [True: 285, False: 508]
  ------------------
  141|    285|            auto* prev = it - 1;
  142|  1.46k|            while (*prev == '\\') {
  ------------------
  |  Branch (142:20): [True: 1.18k, False: 285]
  ------------------
  143|  1.18k|               --prev;
  144|  1.18k|            }
  145|    285|            if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (145:17): [True: 245, False: 40]
  ------------------
  146|    245|               ++it; // add quote
  147|    245|               return {start, size_t(it - start)};
  148|    245|            }
  149|    285|         }
  150|    548|         ++it;
  151|    548|      }
  152|       |
  153|    104|      return {};
  154|    349|   }
_ZN3glz6detail15append_new_lineILb0ELh3ERNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEERmEEvOT1_OT2_l:
   63|   102M|   {
   64|   102M|      dump('\n', b, ix);
   65|       |      if constexpr (use_tabs) {
   66|       |         dumpn('\t', indent, b, ix);
   67|       |      }
   68|   102M|      else {
   69|   102M|         dumpn(' ', indent * indentation_width, b, ix);
   70|   102M|      }
   71|   102M|   };
_ZN3glz6detail16read_json_numberILb0ERPKcS3_EENSt3__117basic_string_viewIcNS5_11char_traitsIcEEEEOT0_T1_:
  197|   533k|   {
  198|   533k|      auto start = it;
  199|       |      if constexpr (null_terminated) {
  200|       |         while (numeric_table[uint8_t(*it)]) {
  201|       |            ++it;
  202|       |         }
  203|       |      }
  204|   533k|      else {
  205|  3.28M|         while ((it < end) && numeric_table[uint8_t(*it)]) {
  ------------------
  |  Branch (205:17): [True: 3.28M, False: 49]
  |  Branch (205:31): [True: 2.75M, False: 533k]
  ------------------
  206|  2.75M|            ++it;
  207|  2.75M|         }
  208|   533k|      }
  209|   533k|      return {start, size_t(it - start)};
  210|   533k|   }

_ZN3glz13prettify_jsonITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEENSt3__16vectorIcNS2_9allocatorIcEEEEEENS2_12basic_stringIcNS2_11char_traitsIcEES5_EERKT0_:
  231|  2.60k|   {
  232|  2.60k|      context ctx{};
  233|  2.60k|      std::string out{};
  234|  2.60k|      detail::prettify_json<Opts>(ctx, in, out);
  235|  2.60k|      return out;
  236|  2.60k|   }
_ZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEETkNS_10contiguousERKNSt3__16vectorIcNS3_9allocatorIcEEEETkNS_13output_bufferERNS3_12basic_stringIcNS3_11char_traitsIcEES6_EETkNS_10is_contextERNS_7contextEEEvOT2_OT0_OT1_:
  188|  2.60k|      {
  189|  2.60k|         if constexpr (resizable<Out>) {
  190|  2.60k|            if (in.empty()) {
  ------------------
  |  Branch (190:17): [True: 0, False: 2.60k]
  ------------------
  191|      0|               out.clear();
  192|      0|               return;
  193|      0|            }
  194|  2.60k|            out.resize(in.size() * 2);
  195|  2.60k|         }
  196|      0|         size_t ix = 0;
  197|  2.60k|         auto [it, end] = read_iterators<Opts>(in);
  198|  2.60k|         if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (198:14): [True: 0, False: 2.60k]
  ------------------
  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.60k|         else {
  206|  2.60k|            prettify_json<opt_false<Opts, &opts::null_terminated>>(ctx, it, end, out, ix);
  207|  2.60k|         }
  208|       |
  209|  2.60k|         if constexpr (resizable<Out>) {
  210|  2.60k|            out.resize(ix);
  211|  2.60k|         }
  212|  2.60k|      }
_ZN3glz6detail13prettify_jsonITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS7_RNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEEmEEvOT0_OT1_OT2_OT3_RT4_:
   16|  2.60k|      {
   17|  2.60k|         constexpr bool use_tabs = check_indentation_char(Opts) == '\t';
   18|  2.60k|         constexpr auto indent_width = check_indentation_width(Opts);
   19|       |
   20|  2.60k|         using enum json_type;
   21|       |
   22|  2.60k|         std::vector<json_type> state(64);
   23|  2.60k|         int64_t indent{};
   24|       |
   25|   121M|         while (it < end) {
  ------------------
  |  Branch (25:17): [True: 121M, False: 1.07k]
  ------------------
   26|   121M|            switch (json_types[uint8_t(*it)]) {
   27|   514k|            case String: {
  ------------------
  |  Branch (27:13): [True: 514k, False: 121M]
  ------------------
   28|   514k|               const auto value = read_json_string<Opts>(it, end);
   29|   514k|               dump_maybe_empty(value, b, ix);
   30|   514k|               break;
   31|      0|            }
   32|  51.0M|            case Comma: {
  ------------------
  |  Branch (32:13): [True: 51.0M, False: 70.8M]
  ------------------
   33|  51.0M|               dump(',', b, ix);
   34|  51.0M|               ++it;
   35|  51.0M|               if constexpr (check_new_lines_in_arrays(Opts)) {
   36|  51.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|  51.0M|               break;
   52|      0|            }
   53|   533k|            case Number: {
  ------------------
  |  Branch (53:13): [True: 533k, False: 121M]
  ------------------
   54|   533k|               const auto value = read_json_number<Opts.null_terminated>(it, end);
   55|   533k|               dump_not_empty(value, b, ix);
   56|   533k|               break;
   57|      0|            }
   58|  3.47M|            case Colon: {
  ------------------
  |  Branch (58:13): [True: 3.47M, False: 118M]
  ------------------
   59|       |               if constexpr (use_tabs) {
   60|       |                  dump(":\t", b, ix);
   61|       |               }
   62|  3.47M|               else {
   63|  3.47M|                  dump(": ", b, ix);
   64|  3.47M|               }
   65|  3.47M|               ++it;
   66|  3.47M|               break;
   67|      0|            }
   68|  11.8M|            case Array_Start: {
  ------------------
  |  Branch (68:13): [True: 11.8M, False: 110M]
  ------------------
   69|  11.8M|               dump('[', b, ix);
   70|  11.8M|               ++it;
   71|  11.8M|               ++indent;
   72|  11.8M|               if (size_t(indent) >= state.size()) [[unlikely]] {
  ------------------
  |  Branch (72:20): [True: 738, False: 11.8M]
  ------------------
   73|    738|                  state.resize(state.size() * 2);
   74|    738|                  if (state.size() >= max_recursive_depth_limit) [[unlikely]] {
  ------------------
  |  Branch (74:23): [True: 58, False: 680]
  ------------------
   75|     58|                     ctx.error = error_code::exceeded_max_recursive_depth;
   76|     58|                     return;
   77|     58|                  }
   78|    738|               }
   79|  11.8M|               state[indent] = Array_Start;
   80|  11.8M|               if constexpr (check_new_lines_in_arrays(Opts)) {
   81|  11.8M|                  if constexpr (not Opts.null_terminated) {
   82|  11.8M|                     if (it != end && *it != ']') {
  ------------------
  |  Branch (82:26): [True: 11.8M, False: 119]
  |  Branch (82:39): [True: 11.3M, False: 495k]
  ------------------
   83|  11.3M|                        append_new_line<use_tabs, indent_width>(b, ix, indent);
   84|  11.3M|                     }
   85|       |                  }
   86|       |                  else {
   87|       |                     if (*it != ']') {
   88|       |                        append_new_line<use_tabs, indent_width>(b, ix, indent);
   89|       |                     }
   90|       |                  }
   91|  11.8M|               }
   92|  11.8M|               break;
   93|  11.8M|            }
   94|  12.5M|            case Array_End: {
  ------------------
  |  Branch (94:13): [True: 12.5M, False: 109M]
  ------------------
   95|  12.5M|               --indent;
   96|  12.5M|               if (indent < 0) {
  ------------------
  |  Branch (96:20): [True: 10, False: 12.5M]
  ------------------
   97|     10|                  ctx.error = error_code::syntax_error;
   98|     10|                  return;
   99|     10|               }
  100|  12.5M|               if constexpr (check_new_lines_in_arrays(Opts)) {
  101|  12.5M|                  if (it[-1] != '[') {
  ------------------
  |  Branch (101:23): [True: 12.0M, False: 496k]
  ------------------
  102|  12.0M|                     append_new_line<use_tabs, indent_width>(b, ix, indent);
  103|  12.0M|                  }
  104|  12.5M|               }
  105|  12.5M|               dump(']', b, ix);
  106|  12.5M|               ++it;
  107|  12.5M|               break;
  108|  12.5M|            }
  109|  12.9k|            case Null: {
  ------------------
  |  Branch (109:13): [True: 12.9k, False: 121M]
  ------------------
  110|  12.9k|               dump("null", b, ix);
  111|  12.9k|               it += 4;
  112|  12.9k|               break;
  113|  12.5M|            }
  114|  1.64M|            case Bool: {
  ------------------
  |  Branch (114:13): [True: 1.64M, False: 120M]
  ------------------
  115|  1.64M|               if (*it == 't') {
  ------------------
  |  Branch (115:20): [True: 1.63M, False: 9.19k]
  ------------------
  116|  1.63M|                  dump("true", b, ix);
  117|  1.63M|                  it += 4;
  118|  1.63M|                  break;
  119|  1.63M|               }
  120|  9.19k|               else {
  121|  9.19k|                  dump("false", b, ix);
  122|  9.19k|                  it += 5;
  123|  9.19k|                  break;
  124|  9.19k|               }
  125|  1.64M|            }
  126|  20.5M|            case Object_Start: {
  ------------------
  |  Branch (126:13): [True: 20.5M, False: 101M]
  ------------------
  127|  20.5M|               dump('{', b, ix);
  128|  20.5M|               ++it;
  129|  20.5M|               ++indent;
  130|  20.5M|               if (size_t(indent) >= state.size()) [[unlikely]] {
  ------------------
  |  Branch (130:20): [True: 366, False: 20.5M]
  ------------------
  131|    366|                  state.resize(state.size() * 2);
  132|    366|                  if (state.size() >= max_recursive_depth_limit) [[unlikely]] {
  ------------------
  |  Branch (132:23): [True: 48, False: 318]
  ------------------
  133|     48|                     ctx.error = error_code::exceeded_max_recursive_depth;
  134|     48|                     return;
  135|     48|                  }
  136|    366|               }
  137|  20.5M|               state[indent] = Object_Start;
  138|  20.5M|               if constexpr (not Opts.null_terminated) {
  139|  20.5M|                  if (it != end && *it != '}') [[unlikely]] {
  ------------------
  |  Branch (139:23): [True: 20.5M, False: 116]
  |  Branch (139:36): [True: 14.5M, False: 6.06M]
  ------------------
  140|  14.5M|                     append_new_line<use_tabs, indent_width>(b, ix, indent);
  141|  14.5M|                  }
  142|       |               }
  143|       |               else {
  144|       |                  if (*it != '}') {
  145|       |                     append_new_line<use_tabs, indent_width>(b, ix, indent);
  146|       |                  }
  147|       |               }
  148|  20.5M|               break;
  149|  20.5M|            }
  150|  19.7M|            case Object_End: {
  ------------------
  |  Branch (150:13): [True: 19.7M, False: 102M]
  ------------------
  151|  19.7M|               --indent;
  152|  19.7M|               if (indent < 0) {
  ------------------
  |  Branch (152:20): [True: 48, False: 19.7M]
  ------------------
  153|     48|                  ctx.error = error_code::syntax_error;
  154|     48|                  return;
  155|     48|               }
  156|  19.7M|               if (it[-1] != '{') {
  ------------------
  |  Branch (156:20): [True: 13.6M, False: 6.06M]
  ------------------
  157|  13.6M|                  append_new_line<use_tabs, indent_width>(b, ix, indent);
  158|  13.6M|               }
  159|  19.7M|               dump('}', b, ix);
  160|  19.7M|               ++it;
  161|  19.7M|               break;
  162|  19.7M|            }
  163|  1.50k|            case Comment: {
  ------------------
  |  Branch (163:13): [True: 1.50k, False: 121M]
  ------------------
  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.50k|               else {
  170|  1.50k|                  [[fallthrough]];
  171|  1.50k|               }
  172|  1.50k|            }
  173|  3.07k|            case Whitespace: {
  ------------------
  |  Branch (173:13): [True: 1.56k, False: 121M]
  ------------------
  174|       |               // Skip whitespace characters that are part of raw JSON content
  175|  3.07k|               ++it;
  176|  3.07k|               break;
  177|  1.50k|            }
  178|  1.36k|            [[unlikely]] default: {
  ------------------
  |  Branch (178:26): [True: 1.36k, False: 121M]
  ------------------
  179|  1.36k|               ctx.error = error_code::syntax_error;
  180|  1.36k|               return;
  181|      0|            }
  182|   121M|            }
  183|   121M|         }
  184|  2.60k|      }

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

_ZN3glz16dump_maybe_emptyILb1ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEEvNS1_17basic_string_viewIcS4_EERT0_Rm:
  251|   514k|   {
  252|   514k|      const auto n = str.size();
  253|   514k|      if (n) {
  ------------------
  |  Branch (253:11): [True: 514k, False: 104]
  ------------------
  254|   514k|         if constexpr (vector_like<B>) {
  255|   514k|            if constexpr (Checked) {
  256|   514k|               const auto k = ix + n;
  257|   514k|               if (k > b.size()) [[unlikely]] {
  ------------------
  |  Branch (257:20): [True: 66, False: 514k]
  ------------------
  258|     66|                  b.resize(2 * k);
  259|     66|               }
  260|   514k|            }
  261|   514k|         }
  262|   514k|         std::memcpy(&b[ix], str.data(), n);
  263|   514k|         ix += n;
  264|   514k|      }
  265|   514k|   }
_ZN3glz4dumpILb1ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEETkNS_10byte_sizedEcEEvT1_RT0_Rm:
   82|   218M|   {
   83|   218M|      if constexpr (Checked && vector_like<B>) {
   84|   218M|         if (ix == b.size()) [[unlikely]] {
  ------------------
  |  Branch (84:14): [True: 1.19k, False: 218M]
  ------------------
   85|  1.19k|            b.resize(b.size() == 0 ? 128 : b.size() * 2);
  ------------------
  |  Branch (85:22): [True: 0, False: 1.19k]
  ------------------
   86|  1.19k|         }
   87|   218M|      }
   88|   218M|      assign_maybe_cast(c, b, ix);
   89|   218M|      ++ix;
   90|   218M|   }
_ZN3glz17assign_maybe_castITkNS_10byte_sizedEcNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEEvT_RT0_Rm:
   55|   218M|   {
   56|   218M|      using V = std::decay_t<decltype(b[0])>;
   57|   218M|      using C = std::decay_t<decltype(c)>;
   58|   218M|      if constexpr (std::same_as<V, C>) {
   59|   218M|         b[ix] = c;
   60|       |      }
   61|       |      else {
   62|       |         b[ix] = static_cast<V>(c);
   63|       |      }
   64|   218M|   }
_ZN3glz5dumpnINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEETkNS_10byte_sizedEcEEvT0_mRT_Rm:
  154|   102M|   {
  155|   102M|      if constexpr (vector_like<B>) {
  156|   102M|         const auto k = ix + n;
  157|   102M|         if (k > b.size()) [[unlikely]] {
  ------------------
  |  Branch (157:14): [True: 8.78k, False: 102M]
  ------------------
  158|  8.78k|            b.resize(2 * k);
  159|  8.78k|         }
  160|   102M|      }
  161|   102M|      std::memset(&b[ix], c, n);
  162|   102M|      ix += n;
  163|   102M|   }
_ZN3glz14dump_not_emptyILb1ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEEvNS1_17basic_string_viewIcS4_EERT0_Rm:
  235|   533k|   {
  236|   533k|      const auto n = str.size();
  237|   533k|      if constexpr (vector_like<B>) {
  238|   533k|         if constexpr (Checked) {
  239|   533k|            const auto k = ix + n;
  240|   533k|            if (k > b.size()) [[unlikely]] {
  ------------------
  |  Branch (240:17): [True: 51, False: 533k]
  ------------------
  241|     51|               b.resize(2 * k);
  242|     51|            }
  243|   533k|         }
  244|   533k|      }
  245|   533k|      std::memcpy(&b[ix], str.data(), n);
  246|   533k|      ix += n;
  247|   533k|   }
_ZN3glz4dumpILb1ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEEvNS1_17basic_string_viewIcS4_EERT0_Rm:
  124|  5.13M|   {
  125|  5.13M|      const auto n = str.size();
  126|  5.13M|      if constexpr (vector_like<B>) {
  127|  5.13M|         if constexpr (Checked) {
  128|  5.13M|            const auto k = ix + n;
  129|  5.13M|            if (ix + n > b.size()) [[unlikely]] {
  ------------------
  |  Branch (129:17): [True: 142, False: 5.13M]
  ------------------
  130|    142|               b.resize(2 * k);
  131|    142|            }
  132|  5.13M|         }
  133|  5.13M|      }
  134|  5.13M|      std::memcpy(&b[ix], str.data(), n);
  135|  5.13M|      ix += n;
  136|  5.13M|   }

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

