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

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

_ZN3glz6detail16read_json_stringITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERPKcS4_Qntcl15check_is_paddedT_EEENSt3__117basic_string_viewIcNS6_11char_traitsIcEEEEOT0_T1_:
  110|   500k|   {
  111|   500k|      auto start = it;
  112|   500k|      ++it; // skip quote
  113|  1.67M|      for (const auto end_m7 = end - 7; it < end_m7;) {
  ------------------
  |  Branch (113:41): [True: 1.67M, False: 375]
  ------------------
  114|  1.67M|         uint64_t chunk;
  115|  1.67M|         std::memcpy(&chunk, it, 8);
  116|       |         if constexpr (std::endian::native == std::endian::big) {
  117|       |            chunk = std::byteswap(chunk);
  118|       |         }
  119|  1.67M|         const uint64_t quote = has_quote(chunk);
  120|  1.67M|         if (quote) {
  ------------------
  |  Branch (120:14): [True: 500k, False: 1.16M]
  ------------------
  121|   500k|            it += (countr_zero(quote) >> 3);
  122|       |
  123|   500k|            auto* prev = it - 1;
  124|   501k|            while (*prev == '\\') {
  ------------------
  |  Branch (124:20): [True: 1.08k, False: 500k]
  ------------------
  125|  1.08k|               --prev;
  126|  1.08k|            }
  127|   500k|            if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (127:17): [True: 500k, False: 321]
  ------------------
  128|   500k|               ++it; // add quote
  129|   500k|               return {start, size_t(it - start)};
  130|   500k|            }
  131|    321|            ++it; // skip escaped quote and continue
  132|    321|         }
  133|  1.16M|         else {
  134|  1.16M|            it += 8;
  135|  1.16M|         }
  136|  1.67M|      }
  137|       |
  138|       |      // Tail end of buffer. Should be rare we even get here
  139|    916|      while (it < end) {
  ------------------
  |  Branch (139:14): [True: 806, False: 110]
  ------------------
  140|    806|         if (*it == '"') {
  ------------------
  |  Branch (140:14): [True: 302, False: 504]
  ------------------
  141|    302|            auto* prev = it - 1;
  142|  1.47k|            while (*prev == '\\') {
  ------------------
  |  Branch (142:20): [True: 1.17k, False: 302]
  ------------------
  143|  1.17k|               --prev;
  144|  1.17k|            }
  145|    302|            if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (145:17): [True: 265, False: 37]
  ------------------
  146|    265|               ++it; // add quote
  147|    265|               return {start, size_t(it - start)};
  148|    265|            }
  149|    302|         }
  150|    541|         ++it;
  151|    541|      }
  152|       |
  153|    110|      return {};
  154|    375|   }
_ZN3glz6detail15append_new_lineILb0ELh3ERNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEERmEEvOT1_OT2_l:
   63|   101M|   {
   64|   101M|      dump('\n', b, ix);
   65|       |      if constexpr (use_tabs) {
   66|       |         dumpn('\t', indent, b, ix);
   67|       |      }
   68|   101M|      else {
   69|   101M|         dumpn(' ', indent * indentation_width, b, ix);
   70|   101M|      }
   71|   101M|   };
_ZN3glz6detail16read_json_numberILb0ERPKcS3_EENSt3__117basic_string_viewIcNS5_11char_traitsIcEEEEOT0_T1_:
  197|   519k|   {
  198|   519k|      auto start = it;
  199|       |      if constexpr (null_terminated) {
  200|       |         while (numeric_table[uint8_t(*it)]) {
  201|       |            ++it;
  202|       |         }
  203|       |      }
  204|   519k|      else {
  205|  3.18M|         while ((it < end) && numeric_table[uint8_t(*it)]) {
  ------------------
  |  Branch (205:17): [True: 3.18M, False: 49]
  |  Branch (205:31): [True: 2.66M, False: 518k]
  ------------------
  206|  2.66M|            ++it;
  207|  2.66M|         }
  208|   519k|      }
  209|   519k|      return {start, size_t(it - start)};
  210|   519k|   }

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

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

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

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

