LLVMFuzzerTestOneInput:
    7|  10.3k|{
    8|       |   // non-null terminated
    9|  10.3k|   {
   10|  10.3k|      const std::vector<char> buffer{Data, Data + Size};
   11|       |
   12|  10.3k|      static constexpr glz::opts opts{.null_terminated = false};
   13|  10.3k|      glz::generic json{};
   14|  10.3k|      auto ec = glz::read<opts>(json, buffer);
   15|  10.3k|      if (!ec) {
  ------------------
  |  Branch (15:11): [True: 2.62k, False: 7.71k]
  ------------------
   16|  2.62k|         [[maybe_unused]] auto s = json.size();
   17|  2.62k|      }
   18|  10.3k|   }
   19|       |
   20|       |   // use a vector with null termination instead of a std::string to avoid
   21|       |   // small string optimization to hide bounds problems
   22|  10.3k|   std::vector<char> buffer{Data, Data + Size};
   23|  10.3k|   buffer.push_back('\0');
   24|       |
   25|       |   // const qualified input buffer
   26|  10.3k|   {
   27|  10.3k|      const auto& input = buffer;
   28|  10.3k|      glz::generic json{};
   29|  10.3k|      auto ec = glz::read_json(json, input);
   30|  10.3k|      if (!ec) {
  ------------------
  |  Branch (30:11): [True: 2.62k, False: 7.71k]
  ------------------
   31|  2.62k|         [[maybe_unused]] auto s = json.size();
   32|  2.62k|      }
   33|  10.3k|   }
   34|       |
   35|       |   // non-const input buffer
   36|  10.3k|   {
   37|  10.3k|      glz::generic json{};
   38|  10.3k|      auto ec = glz::read_json(json, buffer);
   39|  10.3k|      if (!ec) {
  ------------------
  |  Branch (39:11): [True: 2.62k, False: 7.71k]
  ------------------
   40|  2.62k|         [[maybe_unused]] auto s = json.size();
   41|  2.62k|      }
   42|  10.3k|   }
   43|       |
   44|  10.3k|   return 0;
   45|  10.3k|}

_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEED2Ev:
  569|   156k|      {
  570|   156k|         free_data();
  571|   156k|         free_index();
  572|   156k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE9free_dataEv:
  266|   156k|      {
  267|   156k|         destroy_all();
  268|   156k|         ::operator delete(data_);
  269|   156k|         data_ = nullptr;
  270|   156k|         size_ = 0;
  271|   156k|         capacity_ = 0;
  272|   156k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE11destroy_allEv:
  259|   408k|      {
  260|  6.43M|         for (uint32_t i = 0; i < size_; ++i) {
  ------------------
  |  Branch (260:31): [True: 6.02M, False: 408k]
  ------------------
  261|  6.02M|            std::destroy_at(data_ + i);
  262|  6.02M|         }
  263|   408k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE10free_indexEv:
  308|   156k|      {
  309|   156k|         std::free(index_);
  310|   156k|         index_ = nullptr;
  311|   156k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEEC2Ev:
  566|  74.9k|      ordered_small_map() = default;
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEEC2EOS4_:
  610|  82.0k|         : data_(other.data_), size_(other.size_), capacity_(other.capacity_), index_(other.index_)
  611|  82.0k|      {
  612|  82.0k|         other.data_ = nullptr;
  613|  82.0k|         other.size_ = 0;
  614|  82.0k|         other.capacity_ = 0;
  615|  82.0k|         other.index_ = nullptr;
  616|  82.0k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEEixERKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE:
  932|  2.92M|      {
  933|  2.92M|         return subscript_or_insert(key, [&] { emplace_back_impl(key, mapped_type{}); });
  934|  2.92M|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE19subscript_or_insertINSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEZNS4_ixERKSC_EUlvE_EERS3_RKT_OT0_:
  491|  2.92M|      {
  492|  2.92M|         if (size_ <= linear_search_threshold) {
  ------------------
  |  Branch (492:14): [True: 514k, False: 2.41M]
  ------------------
  493|   514k|            auto it = linear_find(key);
  494|   514k|            if (it != end()) return it->second;
  ------------------
  |  Branch (494:17): [True: 28.4k, False: 486k]
  ------------------
  495|   486k|            append_fn();
  496|   486k|            return data_[size_ - 1].second;
  497|   514k|         }
  498|       |
  499|  2.41M|         const uint32_t h = hash_key(key);
  500|  2.41M|         if (try_bloom_insert(h, append_fn)) {
  ------------------
  |  Branch (500:14): [True: 1.73M, False: 679k]
  ------------------
  501|  1.73M|            return data_[size_ - 1].second;
  502|  1.73M|         }
  503|       |
  504|   679k|         auto [it, pos, _] = index_find_or_pos(key, h);
  505|   679k|         if (it != end()) return it->second;
  ------------------
  |  Branch (505:14): [True: 515k, False: 164k]
  ------------------
  506|       |
  507|   164k|         append_fn();
  508|   164k|         bloom_set(h);
  509|   164k|         if (index_size() > 0) {
  ------------------
  |  Branch (509:14): [True: 164k, False: 0]
  ------------------
  510|   164k|            const uint32_t n = index_->size;
  511|   164k|            ensure_index_capacity(static_cast<size_type>(n) + 1);
  512|   164k|            auto* entries = index_entries();
  513|   164k|            if (pos < n) {
  ------------------
  |  Branch (513:17): [True: 159k, False: 4.73k]
  ------------------
  514|   159k|               std::memmove(entries + pos + 1, entries + pos, (n - pos) * sizeof(hash_index_entry));
  515|   159k|            }
  516|   164k|            entries[pos] = {h, size_ - 1};
  517|   164k|            index_->size = size_;
  518|   164k|         }
  519|   164k|         return data_[size_ - 1].second;
  520|   679k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE11linear_findINSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEEEPNS6_4pairISC_S3_EERKT_:
  421|   514k|      {
  422|  2.38M|         for (uint32_t i = 0; i < size_; ++i) {
  ------------------
  |  Branch (422:31): [True: 1.89M, False: 486k]
  ------------------
  423|  1.89M|            if (data_[i].first == key) return data_ + i;
  ------------------
  |  Branch (423:17): [True: 28.4k, False: 1.87M]
  ------------------
  424|  1.89M|         }
  425|   486k|         return data_ + size_;
  426|   514k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE3endEv:
  649|  1.19M|      iterator end() noexcept { return data_ + size_; }
_ZZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEEixERKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEENKUlvE_clEv:
  933|  2.38M|         return subscript_or_insert(key, [&] { emplace_back_impl(key, mapped_type{}); });
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE17emplace_back_implIJRKNSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEES3_EEEvDpOT_:
  243|  2.38M|      {
  244|  2.38M|         grow_if_needed();
  245|  2.38M|         std::construct_at(data_ + size_, std::forward<Args>(args)...);
  246|  2.38M|         ++size_;
  247|  2.38M|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE14grow_if_neededEv:
  217|  2.38M|      {
  218|  2.38M|         if (size_ == capacity_) {
  ------------------
  |  Branch (218:14): [True: 251k, False: 2.13M]
  ------------------
  219|   251k|            if (size_ == max_u32) {
  ------------------
  |  Branch (219:17): [True: 0, False: 251k]
  ------------------
  220|      0|               throw_capacity_overflow();
  221|      0|            }
  222|   251k|            const uint32_t new_cap = next_data_capacity(capacity_);
  223|   251k|            reallocate_data(new_cap);
  224|   251k|         }
  225|  2.38M|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE18next_data_capacityEj:
  120|   251k|      {
  121|   251k|         if (current == 0) return 4;
  ------------------
  |  Branch (121:14): [True: 68.4k, False: 183k]
  ------------------
  122|   183k|         if (current > (max_u32 / 2)) return max_u32;
  ------------------
  |  Branch (122:14): [True: 0, False: 183k]
  ------------------
  123|   183k|         return current * 2;
  124|   183k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE15reallocate_dataEj:
  205|   251k|      {
  206|   251k|         if (new_cap < size_) {
  ------------------
  |  Branch (206:14): [True: 0, False: 251k]
  ------------------
  207|      0|            throw_capacity_overflow();
  208|      0|         }
  209|   251k|         auto* new_data = allocate_and_relocate(new_cap);
  210|   251k|         destroy_all();
  211|   251k|         ::operator delete(data_);
  212|   251k|         data_ = new_data;
  213|   251k|         capacity_ = new_cap;
  214|   251k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE21allocate_and_relocateEj:
  159|   251k|      {
  160|   251k|         auto* new_data = static_cast<value_type*>(::operator new(checked_data_allocation_bytes(new_cap)));
  161|   251k|#if __cpp_exceptions
  162|   251k|         uint32_t constructed = 0;
  163|   251k|         try {
  164|  3.89M|            for (; constructed < size_; ++constructed) {
  ------------------
  |  Branch (164:20): [True: 3.64M, False: 251k]
  ------------------
  165|  3.64M|               std::construct_at(new_data + constructed, std::move_if_noexcept(data_[constructed]));
  166|  3.64M|            }
  167|   251k|         }
  168|   251k|         catch (...) {
  169|      0|            destroy_range(new_data, constructed);
  170|      0|            ::operator delete(new_data);
  171|      0|            throw;
  172|      0|         }
  173|       |#else
  174|       |         for (uint32_t i = 0; i < size_; ++i) {
  175|       |            std::construct_at(new_data + i, std::move_if_noexcept(data_[i]));
  176|       |         }
  177|       |#endif
  178|   251k|         return new_data;
  179|   251k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE29checked_data_allocation_bytesEj:
  134|   251k|      {
  135|   251k|         if (count > ((std::numeric_limits<size_t>::max)() / sizeof(value_type))) {
  ------------------
  |  Branch (135:14): [True: 0, False: 251k]
  ------------------
  136|      0|            GLZ_THROW_OR_ABORT(std::bad_alloc{});
  ------------------
  |  |    8|      0|#define GLZ_THROW_OR_ABORT(EXC) (throw(EXC))
  ------------------
  137|      0|         }
  138|   251k|         return static_cast<size_t>(count) * sizeof(value_type);
  139|   251k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE8hash_keyENSt3__117basic_string_viewIcNS5_11char_traitsIcEEEE:
   97|  8.62M|      static uint32_t hash_key(std::string_view key) noexcept { return sweethash::sweet32(key); }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE16try_bloom_insertIRZNS4_ixERKNSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEEUlvE_EEbjOT_:
  529|  2.41M|      {
  530|  2.41M|         if (index_ && size_ <= bloom_threshold && !bloom_maybe_contains(h)) {
  ------------------
  |  Branch (530:14): [True: 2.36M, False: 49.7k]
  |  Branch (530:24): [True: 2.24M, False: 121k]
  |  Branch (530:52): [True: 1.73M, False: 508k]
  ------------------
  531|       |            // Definitely not present — skip the search
  532|  1.73M|            append_fn();
  533|  1.73M|            bloom_set(h);
  534|       |            // Index is now stale (index_->size < size_), will rebuild on next lookup or false positive
  535|  1.73M|            return true;
  536|  1.73M|         }
  537|   679k|         return false;
  538|  2.41M|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE20bloom_maybe_containsEj:
  285|  2.24M|      {
  286|  2.24M|         const uint32_t a = h & bloom_mask;
  287|  2.24M|         const uint32_t b = (h >> 10) & bloom_mask;
  288|  2.24M|         return (index_->bloom[a >> 3] & (uint8_t(1) << (a & 7))) && (index_->bloom[b >> 3] & (uint8_t(1) << (b & 7)));
  ------------------
  |  Branch (288:17): [True: 656k, False: 1.58M]
  |  Branch (288:70): [True: 508k, False: 148k]
  ------------------
  289|  2.24M|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE17index_find_or_posINSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEEENS4_17index_find_resultERKT_j:
  400|   679k|      {
  401|   679k|         ensure_index();
  402|       |
  403|   679k|         const auto* base = index_entries();
  404|   679k|         const auto* idx_end = base + index_->size;
  405|   679k|         const auto* p = branchless_lower_bound(base, index_->size, h);
  406|   679k|         const size_t pos = static_cast<size_t>(p - base);
  407|       |
  408|       |         // Scan adjacent entries with matching hash
  409|   683k|         for (auto* scan = p; scan != idx_end && scan->key_hash == h; ++scan) {
  ------------------
  |  Branch (409:31): [True: 679k, False: 4.74k]
  |  Branch (409:50): [True: 519k, False: 159k]
  ------------------
  410|   519k|            if (data_[scan->index].first == key) {
  ------------------
  |  Branch (410:17): [True: 515k, False: 4.66k]
  ------------------
  411|   515k|               return {data_ + scan->index, pos, h};
  412|   515k|            }
  413|   519k|         }
  414|       |
  415|   164k|         return {data_ + size_, pos, h};
  416|   679k|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE12ensure_indexEv:
  360|   679k|      {
  361|   679k|         if (size_ <= linear_search_threshold) return;
  ------------------
  |  Branch (361:14): [True: 0, False: 679k]
  ------------------
  362|   679k|         const auto current = index_size();
  363|   679k|         if (current == size_) return; // fully current
  ------------------
  |  Branch (363:14): [True: 400k, False: 278k]
  ------------------
  364|       |
  365|   278k|         if (current == 0 || (size_ - current) > linear_search_threshold) {
  ------------------
  |  Branch (365:14): [True: 49.7k, False: 228k]
  |  Branch (365:30): [True: 95.3k, False: 133k]
  ------------------
  366|   145k|            rebuild_index(); // full rebuild
  367|   145k|            return;
  368|   145k|         }
  369|       |
  370|       |         // Incrementally insert-sort the few new entries
  371|   425k|         for (uint32_t i = current; i < size_; ++i) {
  ------------------
  |  Branch (371:37): [True: 292k, False: 133k]
  ------------------
  372|   292k|            const hash_index_entry entry{hash_key(data_[i].first), i};
  373|   292k|            const auto* base = index_entries();
  374|   292k|            const auto* p = branchless_lower_bound(base, index_->size, entry.key_hash);
  375|   292k|            auto pos = static_cast<size_t>(p - base);
  376|       |
  377|   292k|            const uint32_t m = index_->size;
  378|   292k|            ensure_index_capacity(static_cast<size_type>(m) + 1);
  379|   292k|            auto* entries = index_entries();
  380|   292k|            if (pos < m) {
  ------------------
  |  Branch (380:17): [True: 280k, False: 11.1k]
  ------------------
  381|   280k|               std::memmove(entries + pos + 1, entries + pos, (m - pos) * sizeof(hash_index_entry));
  382|   280k|            }
  383|   292k|            entries[pos] = entry;
  384|   292k|            index_->size = i + 1;
  385|   292k|         }
  386|   133k|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE13rebuild_indexEv:
  343|   145k|      {
  344|   145k|         ensure_index_capacity(static_cast<size_type>(size_));
  345|   145k|         bloom_clear();
  346|   145k|         auto* entries = index_entries();
  347|  6.06M|         for (uint32_t i = 0; i < size_; ++i) {
  ------------------
  |  Branch (347:31): [True: 5.92M, False: 145k]
  ------------------
  348|  5.92M|            const uint32_t h = hash_key(data_[i].first);
  349|  5.92M|            entries[i] = {h, i};
  350|  5.92M|            bloom_set(h);
  351|  5.92M|         }
  352|   145k|         std::sort(entries, entries + size_, [](const auto& a, const auto& b) { return a.key_hash < b.key_hash; });
  353|   145k|         index_->size = size_;
  354|   145k|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE11bloom_clearEv:
  291|   145k|      void bloom_clear() const noexcept { std::memset(index_->bloom, 0, bloom_bytes); }
_ZZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE13rebuild_indexEvENKUlRKT_RKT0_E_clINS4_16hash_index_entryESD_EEDaS7_SA_:
  352|  41.0M|         std::sort(entries, entries + size_, [](const auto& a, const auto& b) { return a.key_hash < b.key_hash; });
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE22branchless_lower_boundEPKNS4_16hash_index_entryEmj:
  440|   971k|      {
  441|  7.15M|         while (len > 1) {
  ------------------
  |  Branch (441:17): [True: 6.17M, False: 971k]
  ------------------
  442|  6.17M|            size_t half = len / 2;
  443|  6.17M|            p += (p[half - 1].key_hash < target) * half;
  444|  6.17M|            len -= half;
  445|  6.17M|         }
  446|       |         // Final element check: advance past it if it's less than target
  447|   971k|         p += (len == 1 && p->key_hash < target);
  ------------------
  |  Branch (447:16): [True: 971k, False: 0]
  |  Branch (447:28): [True: 15.8k, False: 955k]
  ------------------
  448|   971k|         return p;
  449|   971k|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE9bloom_setEj:
  277|  7.82M|      {
  278|  7.82M|         const uint32_t a = h & bloom_mask;
  279|  7.82M|         const uint32_t b = (h >> 10) & bloom_mask;
  280|  7.82M|         index_->bloom[a >> 3] |= uint8_t(1) << (a & 7);
  281|  7.82M|         index_->bloom[b >> 3] |= uint8_t(1) << (b & 7);
  282|  7.82M|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE10index_sizeEv:
  300|   843k|      uint32_t index_size() const noexcept { return index_ ? index_->size : 0; }
  ------------------
  |  Branch (300:53): [True: 793k, False: 49.7k]
  ------------------
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE21ensure_index_capacityEm:
  314|   601k|      {
  315|   601k|         if (needed == 0) return;
  ------------------
  |  Branch (315:14): [True: 0, False: 601k]
  ------------------
  316|   601k|         if (needed > static_cast<size_type>(max_u32)) {
  ------------------
  |  Branch (316:14): [True: 0, False: 601k]
  ------------------
  317|      0|            throw_index_overflow();
  318|      0|         }
  319|   601k|         const auto needed_u32 = static_cast<uint32_t>(needed);
  320|   601k|         if (index_ && index_->capacity >= needed_u32) return;
  ------------------
  |  Branch (320:14): [True: 551k, False: 49.7k]
  |  Branch (320:24): [True: 476k, False: 74.4k]
  ------------------
  321|   124k|         uint32_t cap = index_ ? index_->capacity : 0;
  ------------------
  |  Branch (321:25): [True: 74.4k, False: 49.7k]
  ------------------
  322|   252k|         while (cap < needed_u32) {
  ------------------
  |  Branch (322:17): [True: 128k, False: 124k]
  ------------------
  323|   128k|            const uint32_t next = next_index_capacity(cap);
  324|   128k|            if (next <= cap) {
  ------------------
  |  Branch (324:17): [True: 0, False: 128k]
  ------------------
  325|      0|               throw_index_overflow();
  326|      0|            }
  327|   128k|            cap = next;
  328|   128k|         }
  329|   124k|         auto* block = static_cast<index_header*>(std::realloc(index_, checked_index_allocation_bytes(cap)));
  330|   124k|         if (!block) GLZ_THROW_OR_ABORT(std::bad_alloc{});
  ------------------
  |  |    8|      0|#define GLZ_THROW_OR_ABORT(EXC) (throw(EXC))
  ------------------
  |  Branch (330:14): [True: 0, False: 124k]
  ------------------
  331|   124k|         if (!index_) {
  ------------------
  |  Branch (331:14): [True: 49.7k, False: 74.4k]
  ------------------
  332|  49.7k|            block->size = 0;
  333|  49.7k|            std::memset(block->bloom, 0, bloom_bytes);
  334|  49.7k|         }
  335|   124k|         block->capacity = cap;
  336|   124k|         index_ = block;
  337|   124k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE19next_index_capacityEj:
  127|   128k|      {
  128|   128k|         if (current == 0) return 16;
  ------------------
  |  Branch (128:14): [True: 49.7k, False: 78.7k]
  ------------------
  129|  78.7k|         if (current > (max_u32 / 2)) return max_u32;
  ------------------
  |  Branch (129:14): [True: 0, False: 78.7k]
  ------------------
  130|  78.7k|         return current * 2;
  131|  78.7k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE30checked_index_allocation_bytesEj:
  142|   124k|      {
  143|   124k|         constexpr size_t header = sizeof(index_header);
  144|   124k|         constexpr size_t entry = sizeof(hash_index_entry);
  145|   124k|         if (count > (((std::numeric_limits<size_t>::max)() - header) / entry)) {
  ------------------
  |  Branch (145:14): [True: 0, False: 124k]
  ------------------
  146|      0|            GLZ_THROW_OR_ABORT(std::bad_alloc{});
  ------------------
  |  |    8|      0|#define GLZ_THROW_OR_ABORT(EXC) (throw(EXC))
  ------------------
  147|      0|         }
  148|   124k|         return header + static_cast<size_t>(count) * entry;
  149|   124k|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE13index_entriesEv:
  296|  1.57M|      {
  297|  1.57M|         return static_cast<hash_index_entry*>(static_cast<void*>(index_ + 1));
  298|  1.57M|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE4sizeEv:
  663|     12|      size_type size() const noexcept { return size_; }

_ZN3glz15resize_unfilledINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEEvRT_m:
   63|  2.96M|   {
   64|  2.96M|      if constexpr (requires { b.resize_and_overwrite(n, [](auto*, size_t written) { return written; }); }) {
   65|  2.96M|         b.resize_and_overwrite(n, [](auto*, size_t written) noexcept { return written; });
   66|       |      }
   67|       |      else {
   68|       |         b.resize(n);
   69|       |      }
   70|  2.96M|   }
_ZZN3glz15resize_unfilledINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEEvRT_mENKUlPS8_mE_clIcEEDaSA_m:
   65|  2.96M|         b.resize_and_overwrite(n, [](auto*, size_t written) noexcept { return written; });

_ZN3glz20inert_key_bits_scopeC2IRNS_7contextEEEOT_Pv:
  192|  76.9k|      constexpr inert_key_bits_scope(auto&&, void*) noexcept {}
_ZN3glz10get_memberIRNS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEERKMS4_NSt3__17variantIJDndNS6_12basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEbNS6_6vectorIS4_NSB_IS4_EEEENS3_IS4_EEEEEEEDcOT_OT0_:
  677|  7.79M|   {
  678|  7.79M|      using V = std::decay_t<decltype(element)>;
  679|  7.79M|      if constexpr (std::is_member_object_pointer_v<V>) {
  680|  7.79M|         return value.*element;
  681|       |      }
  682|       |      else if constexpr (std::is_member_function_pointer_v<V>) {
  683|       |         return element;
  684|       |      }
  685|       |      else if constexpr (std::invocable<Element, Value> && not eigen_t<Element>) {
  686|       |         // Eigen places a static_assert inside of the operator()(), so we must target
  687|       |         // matrix types and reject them from the invocable check
  688|       |         // Eigen ought to put the check in the `enable_if` for operator()()
  689|       |         return std::invoke(std::forward<Element>(element), std::forward<Value>(value));
  690|       |      }
  691|       |      else if constexpr (std::is_pointer_v<V> && !std::is_reference_v<Element>) {
  692|       |         if constexpr (std::invocable<decltype(*element), Value>) {
  693|       |            return std::invoke(*element, std::forward<Value>(value));
  694|       |         }
  695|       |         else {
  696|       |            return *element;
  697|       |         }
  698|       |      }
  699|       |      else {
  700|       |         return element;
  701|       |      }
  702|  7.79M|   }

_ZNK3glz9error_ctxcvbEv:
  148|  31.0k|      operator bool() const noexcept { return ec != error_code::none; }
_ZN3glz10call_scopeINS_7contextEEC2ERS1_:
  272|  31.0k|      explicit call_scope(Ctx& c) noexcept : ctx(c), depth(c.depth)
  273|  31.0k|      {
  274|  31.0k|         ctx.error = error_code::none;
  275|  31.0k|         ctx.custom_error_message = {};
  276|  31.0k|      }
_ZN3glz11enter_depthITkNS_10is_contextENS_7contextEEEbRT_:
  344|  1.60M|   {
  345|  1.60M|      if (ctx.depth >= max_recursive_depth_limit) [[unlikely]] {
  ------------------
  |  Branch (345:11): [True: 38, False: 1.60M]
  ------------------
  346|     38|         ctx.error = error_code::exceeded_max_recursive_depth;
  347|     38|         return true;
  348|     38|      }
  349|  1.60M|      ++ctx.depth;
  350|  1.60M|      return false;
  351|  1.60M|   }
_ZN3glz18charge_speculationITkNS_10is_contextENS_7contextEEEbRT_m:
  311|  55.1k|   {
  312|  55.1k|      if constexpr (requires { ctx.speculation_budget; }) {
  313|  55.1k|         if (ctx.speculation_budget == 0) {
  ------------------
  |  Branch (313:14): [True: 0, False: 55.1k]
  ------------------
  314|      0|            return true;
  315|      0|         }
  316|  55.1k|         ctx.speculation_budget = consumed >= ctx.speculation_budget ? 1 : ctx.speculation_budget - consumed;
  ------------------
  |  Branch (316:35): [True: 0, False: 55.1k]
  ------------------
  317|  55.1k|         return ctx.speculation_budget > 1;
  318|       |      }
  319|       |      else {
  320|       |         return true;
  321|       |      }
  322|  55.1k|   }
_ZN3glz21speculation_exhaustedITkNS_10is_contextENS_7contextEEEbRT_:
  328|  3.18k|   {
  329|  3.18k|      if constexpr (requires { ctx.speculation_budget; }) {
  330|  3.18k|         return ctx.speculation_budget == 1; // the latched floor; 0 means unbudgeted
  331|       |      }
  332|       |      else {
  333|       |         return false;
  334|       |      }
  335|  3.18k|   }
_ZN3glz10call_scopeINS_7contextEED2Ev:
  277|  31.0k|      ~call_scope() { ctx.depth = depth; }

_ZN3glz4readITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10contiguousERKNSt3__16vectorIcNS6_9allocatorIcEEEEQaa14read_supportedIT0_XdtT_6formatEEnt18is_input_streamingIT1_EEENS_9error_ctxERSD_OSE_:
  232|  10.3k|   {
  233|  10.3k|      format_context_t<Opts.format> ctx{};
  234|  10.3k|      return read<Opts>(value, buffer, ctx);
  235|  10.3k|   }
_ZN3glz4readITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10contiguousERKNSt3__16vectorIcNS6_9allocatorIcEEEETkNS_10is_contextERNS_7contextEQaa14read_supportedIT0_XdtT_6formatEEnt18is_input_streamingIT1_EEENS_9error_ctxERSF_OSG_OT2_:
  152|  10.3k|   {
  153|  10.3k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
  154|       |
  155|  10.3k|      call_scope scope{ctx};
  156|       |
  157|  10.3k|      if constexpr (Opts.format != NDJSON) {
  158|  10.3k|         if (buffer.size() == 0) [[unlikely]] {
  ------------------
  |  Branch (158:14): [True: 0, False: 10.3k]
  ------------------
  159|      0|            ctx.error = error_code::no_read_input;
  160|      0|            return {0, ctx.error, ctx.custom_error_message};
  161|      0|         }
  162|  10.3k|      }
  163|       |
  164|       |      // The reader used to grow the caller's buffer by `padding_bytes` here and shrink it back on
  165|       |      // the way out, so that its fixed width loads could run off the end of the document into
  166|       |      // defined bytes. Every one of those loads is now bounded against `end` instead (see
  167|       |      // `chunk_min`), which costs the last chunk of the buffer its chunked path and nothing else --
  168|       |      // measurably less than the round trip did. `std::string::resize` is an ABI entry point on
  169|       |      // both libc++ and libstdc++, so neither call inlined and the parse was spilled around both
  170|       |      // for what amounted to a sixteen byte store; the price did not scale with the document, so on
  171|       |      // a small one it was the bulk of the call. A caller who does have that slack can still say so
  172|       |      // and get the unbounded loads back, and nobody else pays for the buffer being touched at all.
  173|  10.3k|      ctx.padded_input = check_is_padded(Opts);
  174|       |
  175|  10.3k|      static constexpr auto ParseOpts = parse_opts_for<Opts, Buf>();
  176|       |
  177|  10.3k|      auto [it, end] = read_iterators<ParseOpts>(buffer);
  178|  10.3k|      auto start = it;
  179|       |
  180|       |      // Bound the speculative re-parsing a variant resolution may do, in bytes, relative to this
  181|       |      // input. Seeded per read so a reused context starts fresh. See charge_speculation.
  182|  10.3k|      if constexpr (requires { ctx.speculation_budget; }) {
  183|  10.3k|         const size_t proportional = max_speculative_parse_factor * size_t(end - it);
  184|  10.3k|         ctx.speculation_budget =
  185|  10.3k|            (proportional > min_speculative_parse_bytes ? proportional : min_speculative_parse_bytes) + 2;
  ------------------
  |  Branch (185:14): [True: 224, False: 10.1k]
  ------------------
  186|  10.3k|      }
  187|       |
  188|       |      // A YAML context marks its outermost parse with stream_begin and seeds its expansion budgets
  189|       |      // there, so clearing it here is what makes those budgets per-read like the one above. A
  190|       |      // reused context would otherwise carry a spent budget into the next document and reject a
  191|       |      // valid one, and would leave stream_begin pointing into the buffer of the previous read.
  192|       |      // Nested YAML parses do not route through glz::read, so they still cannot reseed themselves.
  193|       |      if constexpr (requires { ctx.stream_begin; }) {
  194|       |         ctx.stream_begin = nullptr;
  195|       |      }
  196|       |
  197|       |      // Normalized off before dispatching: no reader branches on it any more, so leaving it set
  198|       |      // would split every instantiation below between callers who declared padding and callers who
  199|       |      // did not, for a flag none of them reads.
  200|  10.3k|      parse<Opts.format>::template op<ParseOpts>(value, ctx, it, end);
  201|       |
  202|  10.3k|      if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (202:11): [True: 7.71k, False: 2.62k]
  ------------------
  203|  7.71k|         goto finish;
  204|  7.71k|      }
  205|       |
  206|       |      // The JSON RFC 8259 defines: JSON-text = ws value ws
  207|       |      // So, trailing whitespace is permitted and sometimes we want to
  208|       |      // validate this, even though this memory will not affect Glaze.
  209|       |      if constexpr (check_validate_trailing_whitespace(Opts)) {
  210|       |         if (it < end) {
  211|       |            skip_ws<ParseOpts>(ctx, it, end);
  212|       |            if (bool(ctx.error)) [[unlikely]] {
  213|       |               goto finish;
  214|       |            }
  215|       |            if (it != end) [[unlikely]] {
  216|       |               ctx.error = error_code::syntax_error;
  217|       |            }
  218|       |         }
  219|       |      }
  220|       |
  221|  10.3k|   finish:
  222|       |      // ParseOpts, not Opts: this reads `null_terminated` to tell a value that ended with the
  223|       |      // buffer from one that ran out, and it has to be told the same thing the parse was.
  224|  10.3k|      finalize_top_level_read<ParseOpts>(ctx, start, it, end);
  225|       |
  226|  10.3k|      return {size_t(it - start), ctx.error, ctx.custom_error_message};
  227|  2.62k|   }
_ZN3glz14read_iteratorsITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10contiguousERKNSt3__16vectorIcNS2_9allocatorIcEEEEEEDaOT0_:
   40|  20.6k|   {
   41|  20.6k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
   42|       |
   43|  20.6k|      auto it = reinterpret_cast<const char*>(buffer.data());
   44|  20.6k|      auto end = it + buffer.size();
   45|       |
   46|  20.6k|      return std::pair{it, end};
   47|  20.6k|   }
_ZN3glz23finalize_top_level_readITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextEEEvOT0_PKcS7_S7_:
  131|  31.0k|   {
  132|  31.0k|      if constexpr (Opts.format == JSON && !check_null_terminated(Opts)) {
  133|       |         // Deliberately not [[unlikely]]: a body that ends with the buffer lands here on every
  134|       |         // successful read, which is the ordinary case for a registry parsing a wire span.
  135|       |         // start < it, not !=, because a streaming origin can be empty or overshoot on an error
  136|       |         // path; neither is an absent value.
  137|  31.0k|         if (ctx.error == error_code::end_reached && ctx.depth == 0 && it == end && start < it) {
  ------------------
  |  Branch (137:14): [True: 1.63k, False: 29.3k]
  |  Branch (137:54): [True: 18, False: 1.61k]
  |  Branch (137:72): [True: 18, False: 0]
  |  Branch (137:85): [True: 18, False: 0]
  ------------------
  138|     18|            context ws_ctx{}; // only written to when skip_ws parses a comment; the result is unused
  139|     18|            const char* consumed = start;
  140|     18|            skip_ws<Opts>(ws_ctx, consumed, it);
  141|     18|            if (consumed == it) {
  ------------------
  |  Branch (141:17): [True: 17, False: 1]
  ------------------
  142|     17|               ctx.error = error_code::no_read_input;
  143|     17|            }
  144|     18|         }
  145|  31.0k|      }
  146|  31.0k|      finalize_read_context(ctx);
  147|  31.0k|   }
_ZN3glz21finalize_read_contextITkNS_10is_contextERNS_7contextEEEvOT_:
  109|  31.0k|   {
  110|  31.0k|      settle_partial_read_complete(ctx);
  111|  31.0k|      settle_end_reached(ctx);
  112|  31.0k|   }
_ZN3glz28settle_partial_read_completeITkNS_10is_contextERNS_7contextEEEvOT_:
  102|  31.0k|   {
  103|  31.0k|      if (ctx.error == error_code::partial_read_complete) {
  ------------------
  |  Branch (103:11): [True: 0, False: 31.0k]
  ------------------
  104|      0|         ctx.error = error_code::none;
  105|      0|      }
  106|  31.0k|   }
_ZN3glz18settle_end_reachedITkNS_10is_contextERNS_7contextEEEvOT_:
   88|  31.0k|   {
   89|  31.0k|      if (ctx.error == error_code::end_reached) {
  ------------------
  |  Branch (89:11): [True: 1.61k, False: 29.4k]
  ------------------
   90|  1.61k|         ctx.error = (ctx.depth == 0) ? error_code::none : error_code::unexpected_end;
  ------------------
  |  Branch (90:22): [True: 1, False: 1.61k]
  ------------------
   91|  1.61k|      }
   92|  31.0k|   }
_ZN3glz4readITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10contiguousERKNSt3__16vectorIcNS6_9allocatorIcEEEETkNS_10is_contextERNS_7contextEQaa14read_supportedIT0_XdtT_6formatEEnt18is_input_streamingIT1_EEENS_9error_ctxERSF_OSG_OT2_:
  152|  10.3k|   {
  153|  10.3k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
  154|       |
  155|  10.3k|      call_scope scope{ctx};
  156|       |
  157|  10.3k|      if constexpr (Opts.format != NDJSON) {
  158|  10.3k|         if (buffer.size() == 0) [[unlikely]] {
  ------------------
  |  Branch (158:14): [True: 0, False: 10.3k]
  ------------------
  159|      0|            ctx.error = error_code::no_read_input;
  160|      0|            return {0, ctx.error, ctx.custom_error_message};
  161|      0|         }
  162|  10.3k|      }
  163|       |
  164|       |      // The reader used to grow the caller's buffer by `padding_bytes` here and shrink it back on
  165|       |      // the way out, so that its fixed width loads could run off the end of the document into
  166|       |      // defined bytes. Every one of those loads is now bounded against `end` instead (see
  167|       |      // `chunk_min`), which costs the last chunk of the buffer its chunked path and nothing else --
  168|       |      // measurably less than the round trip did. `std::string::resize` is an ABI entry point on
  169|       |      // both libc++ and libstdc++, so neither call inlined and the parse was spilled around both
  170|       |      // for what amounted to a sixteen byte store; the price did not scale with the document, so on
  171|       |      // a small one it was the bulk of the call. A caller who does have that slack can still say so
  172|       |      // and get the unbounded loads back, and nobody else pays for the buffer being touched at all.
  173|  10.3k|      ctx.padded_input = check_is_padded(Opts);
  174|       |
  175|  10.3k|      static constexpr auto ParseOpts = parse_opts_for<Opts, Buf>();
  176|       |
  177|  10.3k|      auto [it, end] = read_iterators<ParseOpts>(buffer);
  178|  10.3k|      auto start = it;
  179|       |
  180|       |      // Bound the speculative re-parsing a variant resolution may do, in bytes, relative to this
  181|       |      // input. Seeded per read so a reused context starts fresh. See charge_speculation.
  182|  10.3k|      if constexpr (requires { ctx.speculation_budget; }) {
  183|  10.3k|         const size_t proportional = max_speculative_parse_factor * size_t(end - it);
  184|  10.3k|         ctx.speculation_budget =
  185|  10.3k|            (proportional > min_speculative_parse_bytes ? proportional : min_speculative_parse_bytes) + 2;
  ------------------
  |  Branch (185:14): [True: 226, False: 10.1k]
  ------------------
  186|  10.3k|      }
  187|       |
  188|       |      // A YAML context marks its outermost parse with stream_begin and seeds its expansion budgets
  189|       |      // there, so clearing it here is what makes those budgets per-read like the one above. A
  190|       |      // reused context would otherwise carry a spent budget into the next document and reject a
  191|       |      // valid one, and would leave stream_begin pointing into the buffer of the previous read.
  192|       |      // Nested YAML parses do not route through glz::read, so they still cannot reseed themselves.
  193|       |      if constexpr (requires { ctx.stream_begin; }) {
  194|       |         ctx.stream_begin = nullptr;
  195|       |      }
  196|       |
  197|       |      // Normalized off before dispatching: no reader branches on it any more, so leaving it set
  198|       |      // would split every instantiation below between callers who declared padding and callers who
  199|       |      // did not, for a flag none of them reads.
  200|  10.3k|      parse<Opts.format>::template op<ParseOpts>(value, ctx, it, end);
  201|       |
  202|  10.3k|      if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (202:11): [True: 7.71k, False: 2.62k]
  ------------------
  203|  7.71k|         goto finish;
  204|  7.71k|      }
  205|       |
  206|       |      // The JSON RFC 8259 defines: JSON-text = ws value ws
  207|       |      // So, trailing whitespace is permitted and sometimes we want to
  208|       |      // validate this, even though this memory will not affect Glaze.
  209|       |      if constexpr (check_validate_trailing_whitespace(Opts)) {
  210|       |         if (it < end) {
  211|       |            skip_ws<ParseOpts>(ctx, it, end);
  212|       |            if (bool(ctx.error)) [[unlikely]] {
  213|       |               goto finish;
  214|       |            }
  215|       |            if (it != end) [[unlikely]] {
  216|       |               ctx.error = error_code::syntax_error;
  217|       |            }
  218|       |         }
  219|       |      }
  220|       |
  221|  10.3k|   finish:
  222|       |      // ParseOpts, not Opts: this reads `null_terminated` to tell a value that ended with the
  223|       |      // buffer from one that ran out, and it has to be told the same thing the parse was.
  224|  10.3k|      finalize_top_level_read<ParseOpts>(ctx, start, it, end);
  225|       |
  226|  10.3k|      return {size_t(it - start), ctx.error, ctx.custom_error_message};
  227|  2.62k|   }
_ZN3glz4readITnDaXtlNS_4optsELj10ELb1ELb0ELb1ELb1EEENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10contiguousERNSt3__16vectorIcNS6_9allocatorIcEEEETkNS_10is_contextERNS_7contextEQaa14read_supportedIT0_XdtT_6formatEEnt18is_input_streamingIT1_EEENS_9error_ctxERSE_OSF_OT2_:
  152|  10.3k|   {
  153|  10.3k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
  154|       |
  155|  10.3k|      call_scope scope{ctx};
  156|       |
  157|  10.3k|      if constexpr (Opts.format != NDJSON) {
  158|  10.3k|         if (buffer.size() == 0) [[unlikely]] {
  ------------------
  |  Branch (158:14): [True: 0, False: 10.3k]
  ------------------
  159|      0|            ctx.error = error_code::no_read_input;
  160|      0|            return {0, ctx.error, ctx.custom_error_message};
  161|      0|         }
  162|  10.3k|      }
  163|       |
  164|       |      // The reader used to grow the caller's buffer by `padding_bytes` here and shrink it back on
  165|       |      // the way out, so that its fixed width loads could run off the end of the document into
  166|       |      // defined bytes. Every one of those loads is now bounded against `end` instead (see
  167|       |      // `chunk_min`), which costs the last chunk of the buffer its chunked path and nothing else --
  168|       |      // measurably less than the round trip did. `std::string::resize` is an ABI entry point on
  169|       |      // both libc++ and libstdc++, so neither call inlined and the parse was spilled around both
  170|       |      // for what amounted to a sixteen byte store; the price did not scale with the document, so on
  171|       |      // a small one it was the bulk of the call. A caller who does have that slack can still say so
  172|       |      // and get the unbounded loads back, and nobody else pays for the buffer being touched at all.
  173|  10.3k|      ctx.padded_input = check_is_padded(Opts);
  174|       |
  175|  10.3k|      static constexpr auto ParseOpts = parse_opts_for<Opts, Buf>();
  176|       |
  177|  10.3k|      auto [it, end] = read_iterators<ParseOpts>(buffer);
  178|  10.3k|      auto start = it;
  179|       |
  180|       |      // Bound the speculative re-parsing a variant resolution may do, in bytes, relative to this
  181|       |      // input. Seeded per read so a reused context starts fresh. See charge_speculation.
  182|  10.3k|      if constexpr (requires { ctx.speculation_budget; }) {
  183|  10.3k|         const size_t proportional = max_speculative_parse_factor * size_t(end - it);
  184|  10.3k|         ctx.speculation_budget =
  185|  10.3k|            (proportional > min_speculative_parse_bytes ? proportional : min_speculative_parse_bytes) + 2;
  ------------------
  |  Branch (185:14): [True: 226, False: 10.1k]
  ------------------
  186|  10.3k|      }
  187|       |
  188|       |      // A YAML context marks its outermost parse with stream_begin and seeds its expansion budgets
  189|       |      // there, so clearing it here is what makes those budgets per-read like the one above. A
  190|       |      // reused context would otherwise carry a spent budget into the next document and reject a
  191|       |      // valid one, and would leave stream_begin pointing into the buffer of the previous read.
  192|       |      // Nested YAML parses do not route through glz::read, so they still cannot reseed themselves.
  193|       |      if constexpr (requires { ctx.stream_begin; }) {
  194|       |         ctx.stream_begin = nullptr;
  195|       |      }
  196|       |
  197|       |      // Normalized off before dispatching: no reader branches on it any more, so leaving it set
  198|       |      // would split every instantiation below between callers who declared padding and callers who
  199|       |      // did not, for a flag none of them reads.
  200|  10.3k|      parse<Opts.format>::template op<ParseOpts>(value, ctx, it, end);
  201|       |
  202|  10.3k|      if (bool(ctx.error)) [[unlikely]] {
  ------------------
  |  Branch (202:11): [True: 7.71k, False: 2.62k]
  ------------------
  203|  7.71k|         goto finish;
  204|  7.71k|      }
  205|       |
  206|       |      // The JSON RFC 8259 defines: JSON-text = ws value ws
  207|       |      // So, trailing whitespace is permitted and sometimes we want to
  208|       |      // validate this, even though this memory will not affect Glaze.
  209|       |      if constexpr (check_validate_trailing_whitespace(Opts)) {
  210|       |         if (it < end) {
  211|       |            skip_ws<ParseOpts>(ctx, it, end);
  212|       |            if (bool(ctx.error)) [[unlikely]] {
  213|       |               goto finish;
  214|       |            }
  215|       |            if (it != end) [[unlikely]] {
  216|       |               ctx.error = error_code::syntax_error;
  217|       |            }
  218|       |         }
  219|       |      }
  220|       |
  221|  10.3k|   finish:
  222|       |      // ParseOpts, not Opts: this reads `null_terminated` to tell a value that ended with the
  223|       |      // buffer from one that ran out, and it has to be told the same thing the parse was.
  224|  10.3k|      finalize_top_level_read<ParseOpts>(ctx, start, it, end);
  225|       |
  226|  10.3k|      return {size_t(it - start), ctx.error, ctx.custom_error_message};
  227|  2.62k|   }
_ZN3glz14read_iteratorsITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10contiguousERNSt3__16vectorIcNS2_9allocatorIcEEEEEEDaOT0_:
   40|  10.3k|   {
   41|  10.3k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
   42|       |
   43|  10.3k|      auto it = reinterpret_cast<const char*>(buffer.data());
   44|  10.3k|      auto end = it + buffer.size();
   45|       |
   46|  10.3k|      return std::pair{it, end};
   47|  10.3k|   }

_ZN3glz9sweethash7sweet32ITkNS0_16contiguous_rangeENSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEEjRKT_j:
  270|  8.62M|   {
  271|  8.62M|      return sweet32(static_cast<const void*>(s.data()), s.size(), seed);
  272|  8.62M|   }
_ZN3glz9sweethash7sweet32EPKvmj:
  154|  8.62M|   {
  155|  8.62M|      const uint8_t* p = static_cast<const uint8_t*>(data);
  156|       |
  157|       |      // For inputs <= 8 bytes, use simple hash (tail handler requires len >= 9)
  158|  8.62M|      if (len <= 8) {
  ------------------
  |  Branch (158:11): [True: 6.43M, False: 2.19M]
  ------------------
  159|  6.43M|         uint64_t v = 0;
  160|  6.43M|         switch (len) {
  161|   449k|         case 8:
  ------------------
  |  Branch (161:10): [True: 449k, False: 5.98M]
  ------------------
  162|   449k|            std::memcpy(&v, p, 8);
  163|   449k|            break;
  164|   471k|         case 7:
  ------------------
  |  Branch (164:10): [True: 471k, False: 5.96M]
  ------------------
  165|   471k|            std::memcpy(&v, p, 7);
  166|   471k|            break;
  167|   459k|         case 6:
  ------------------
  |  Branch (167:10): [True: 459k, False: 5.97M]
  ------------------
  168|   459k|            std::memcpy(&v, p, 6);
  169|   459k|            break;
  170|   307k|         case 5:
  ------------------
  |  Branch (170:10): [True: 307k, False: 6.12M]
  ------------------
  171|   307k|            std::memcpy(&v, p, 5);
  172|   307k|            break;
  173|   866k|         case 4:
  ------------------
  |  Branch (173:10): [True: 866k, False: 5.56M]
  ------------------
  174|   866k|            std::memcpy(&v, p, 4);
  175|   866k|            break;
  176|   358k|         case 3:
  ------------------
  |  Branch (176:10): [True: 358k, False: 6.07M]
  ------------------
  177|   358k|            std::memcpy(&v, p, 3);
  178|   358k|            break;
  179|  1.86M|         case 2:
  ------------------
  |  Branch (179:10): [True: 1.86M, False: 4.57M]
  ------------------
  180|  1.86M|            std::memcpy(&v, p, 2);
  181|  1.86M|            break;
  182|  1.52M|         case 1:
  ------------------
  |  Branch (182:10): [True: 1.52M, False: 4.91M]
  ------------------
  183|  1.52M|            v = p[0];
  184|  1.52M|            break;
  185|   136k|         default:
  ------------------
  |  Branch (185:10): [True: 136k, False: 6.29M]
  ------------------
  186|   136k|            break;
  187|  6.43M|         }
  188|  6.43M|         v = v ^ seed ^ (len + 1);
  189|  6.43M|         return static_cast<uint32_t>(v) ^ static_cast<uint32_t>(v >> 32);
  190|  6.43M|      }
  191|       |
  192|       |      // Full hash for inputs > 8 bytes
  193|  2.19M|      uint64_t seed64 = (static_cast<uint64_t>(seed) << 32) | static_cast<uint64_t>(seed);
  194|  2.19M|      uint64_t h = (seed64 ^ prime4) + (len * prime1);
  195|  2.19M|      const uint8_t* const end = p + len;
  196|       |
  197|  2.19M|      if (len >= 32) {
  ------------------
  |  Branch (197:11): [True: 276k, False: 1.92M]
  ------------------
  198|   276k|         uint64_t h1 = h;
  199|   276k|         uint64_t h2 = (seed64 * prime2) ^ prime3;
  200|   276k|         uint64_t h3 = (seed64 * prime3) ^ prime4;
  201|   276k|         uint64_t h4 = (seed64 * prime4) ^ prime5;
  202|       |
  203|  1.96M|         do {
  204|  1.96M|            uint64_t k1, k2, k3, k4;
  205|  1.96M|            std::memcpy(&k1, p, 8);
  206|  1.96M|            std::memcpy(&k2, p + 8, 8);
  207|  1.96M|            std::memcpy(&k3, p + 16, 8);
  208|  1.96M|            std::memcpy(&k4, p + 24, 8);
  209|       |
  210|  1.96M|            k1 = k1 * prime2;
  211|  1.96M|            k1 = k1 ^ (k1 >> 47);
  212|  1.96M|            h1 = h1 ^ k1;
  213|  1.96M|            h1 = h1 * prime1;
  214|       |
  215|  1.96M|            k2 = k2 * prime3;
  216|  1.96M|            k2 = k2 ^ (k2 >> 47);
  217|  1.96M|            h2 = h2 ^ k2;
  218|  1.96M|            h2 = h2 * prime2;
  219|       |
  220|  1.96M|            k3 = k3 * prime4;
  221|  1.96M|            k3 = k3 ^ (k3 >> 47);
  222|  1.96M|            h3 = h3 ^ k3;
  223|  1.96M|            h3 = h3 * prime3;
  224|       |
  225|  1.96M|            k4 = k4 * prime5;
  226|  1.96M|            k4 = k4 ^ (k4 >> 47);
  227|  1.96M|            h4 = h4 ^ k4;
  228|  1.96M|            h4 = h4 * prime4;
  229|       |
  230|  1.96M|            p = p + 32;
  231|  1.96M|            len = len - 32;
  232|  1.96M|         } while (len >= 32);
  ------------------
  |  Branch (232:19): [True: 1.69M, False: 276k]
  ------------------
  233|       |
  234|   276k|         h = h1 + h2 + h3 + h4;
  235|   276k|      }
  236|       |
  237|  5.29M|      while (len >= 8) {
  ------------------
  |  Branch (237:14): [True: 3.09M, False: 2.19M]
  ------------------
  238|  3.09M|         uint64_t k;
  239|  3.09M|         std::memcpy(&k, p, 8);
  240|  3.09M|         k = k * prime2;
  241|  3.09M|         k = k ^ (k >> 47);
  242|  3.09M|         h = h ^ k;
  243|  3.09M|         h = h * prime1;
  244|  3.09M|         p = p + 8;
  245|  3.09M|         len = len - 8;
  246|  3.09M|      }
  247|       |
  248|  2.19M|      if (len > 0) {
  ------------------
  |  Branch (248:11): [True: 2.03M, False: 165k]
  ------------------
  249|  2.03M|         uint64_t k;
  250|  2.03M|         std::memcpy(&k, end - 8, 8);
  251|  2.03M|         k = k * prime2;
  252|  2.03M|         k = k ^ (k >> 47);
  253|  2.03M|         k = k * prime3;
  254|  2.03M|         h = h ^ k;
  255|  2.03M|      }
  256|       |
  257|  2.19M|      h = mix64(h);
  258|  2.19M|      return static_cast<uint32_t>(h) ^ static_cast<uint32_t>(h >> 32);
  259|  8.62M|   }
_ZN3glz9sweethash5mix64Em:
   33|  2.19M|   {
   34|  2.19M|      v = v ^ (v >> 33);
   35|  2.19M|      v = v * prime2;
   36|  2.19M|      v = v ^ (v >> 29);
   37|  2.19M|      v = v * prime3;
   38|  2.19M|      return v;
   39|  2.19M|   }

_ZN3glz12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEC2Ev:
  379|  6.96M|      generic_json() = default;
_ZN3glz12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEED2Ev:
  131|  17.9M|      ~generic_json() = default;
_ZN3glz12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEC2EOS3_:
  382|  10.9M|      generic_json(generic_json&& other) noexcept : data(std::move(other.data)) {}
_ZNK3glz12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEE4sizeEv:
  575|  7.87k|      {
  576|  7.87k|         if (auto* v = get_if<object_t>()) {
  ------------------
  |  Branch (576:20): [True: 12, False: 7.86k]
  ------------------
  577|     12|            return v->size();
  578|     12|         }
  579|  7.86k|         else if (auto* v = get_if<array_t>()) {
  ------------------
  |  Branch (579:25): [True: 42, False: 7.82k]
  ------------------
  580|     42|            return v->size();
  581|     42|         }
  582|  7.82k|         else if (auto* v = get_if<std::string>()) {
  ------------------
  |  Branch (582:25): [True: 828, False: 6.99k]
  ------------------
  583|    828|            return v->size();
  584|    828|         }
  585|  6.99k|         else {
  586|  6.99k|            return 0;
  587|  6.99k|         }
  588|  7.87k|      }
_ZNK3glz12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEE6get_ifINS2_IS3_EEEEPKT_v:
  182|  7.87k|      {
  183|  7.87k|         return std::get_if<T>(&data);
  184|  7.87k|      }
_ZNK3glz12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEE6get_ifINSt3__16vectorIS3_NS5_9allocatorIS3_EEEEEEPKT_v:
  182|  7.86k|      {
  183|  7.86k|         return std::get_if<T>(&data);
  184|  7.86k|      }
_ZNK3glz12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEE6get_ifINSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEEEPKT_v:
  182|  7.82k|      {
  183|  7.82k|         return std::get_if<T>(&data);
  184|  7.82k|      }

_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERNS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
   49|  31.0k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  31.0k|         else {
   60|  31.0k|            using V = std::remove_cvref_t<T>;
   61|  31.0k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  31.0k|                                             end);
   63|  31.0k|         }
   64|  31.0k|      }
_ZN3glz4fromILj10ENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERS4_TkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
  150|  31.0k|      {
  151|  31.0k|         using V = std::decay_t<decltype(get_member(std::declval<Value>(), meta_wrapper_v<T>))>;
  152|  31.0k|         from<JSON, V>::template op<Opts>(get_member(std::forward<Value>(value), meta_wrapper_v<T>),
  153|  31.0k|                                          std::forward<Ctx>(ctx), std::forward<It0>(it), end);
  154|  31.0k|      }
_ZN3glz4fromILj10ENSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSP_EEvOT0_OT1_OT2_T3_:
 3860|  31.0k|      {
 3861|       |         if constexpr (tagging == variant_tagging_kind::adjacent) {
 3862|       |            read_adjacent<Options>(value, ctx, it, end);
 3863|       |         }
 3864|  31.0k|         else {
 3865|  31.0k|            read_deduced<Options>(value, ctx, it, end);
 3866|  31.0k|         }
 3867|  31.0k|      }
_ZN3glz4fromILj10ENSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEEE12read_deducedITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSP_EEvOT0_OT1_OT2_T3_:
 3871|  31.0k|      {
 3872|  31.0k|         constexpr auto Opts = ws_handled_off<Options>();
 3873|  31.0k|         if constexpr (variant_is_auto_deducible<T>()) {
 3874|  31.0k|            if constexpr (not check_ws_handled(Options)) {
 3875|  31.0k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3875:20): [True: 17, False: 31.0k]
  ------------------
 3876|     17|                  return;
 3877|     17|               }
 3878|  31.0k|            }
 3879|       |
 3880|  31.0k|            switch (*it) {
 3881|     37|            case '\0':
  ------------------
  |  Branch (3881:13): [True: 37, False: 30.9k]
  ------------------
 3882|     37|               ctx.error = error_code::unexpected_end;
 3883|     37|               return;
 3884|  14.9k|            case '{': {
  ------------------
  |  Branch (3884:13): [True: 14.9k, False: 16.0k]
  ------------------
 3885|       |               // This branch consumes the brace itself and hands the object to a reader with
 3886|       |               // `opening_handled`, which therefore does not count the level -- but does release it at
 3887|       |               // the closing brace. So the level is taken here, in both buffer modes, and paid back by
 3888|       |               // the reader below.
 3889|  14.9k|               if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (3889:20): [True: 0, False: 14.9k]
  ------------------
 3890|      0|                  return;
 3891|      0|               }
 3892|       |
 3893|  14.9k|               ++it;
 3894|  14.9k|               if constexpr (not Opts.null_terminated) {
 3895|  14.9k|                  if (it == end) [[unlikely]] {
  ------------------
  |  Branch (3895:23): [True: 1, False: 14.9k]
  ------------------
 3896|      1|                     ctx.error = error_code::unexpected_end;
 3897|      1|                     return;
 3898|      1|                  }
 3899|  14.9k|               }
 3900|  14.9k|               using type_counts = variant_type_count<T>;
 3901|  14.9k|               constexpr auto n_object_candidates = variant_object_candidate_count_v<Opts, T>;
 3902|       |               if constexpr (n_object_candidates < 1) {
 3903|       |                  ctx.error = error_code::no_matching_variant_type;
 3904|       |                  return;
 3905|       |               }
 3906|  14.9k|               else if constexpr (n_object_candidates == 1 && tag_v<T>.empty()) {
 3907|  14.9k|                  constexpr auto first_idx = variant_first_object_candidate_v<Opts, T>;
 3908|  14.9k|                  using V = std::variant_alternative_t<first_idx, T>;
 3909|  14.9k|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (3909:23): [True: 14.9k, False: 1]
  ------------------
 3910|  14.9k|                  parse<JSON>::op<opening_handled<Opts>()>(std::get<V>(value), ctx, it, end);
 3911|  14.9k|                  return;
 3912|       |               }
 3913|       |               else {
 3914|       |                  auto possible_types = bit_array<std::variant_size_v<T>>{}.flip();
 3915|       |                  static constexpr auto& deduction_bits = variant_deduction_bits<T>;
 3916|       |                  static constexpr size_t deduction_key_count = variant_deduction_key_count<T>;
 3917|       |                  static constexpr auto tag_literal = string_literal_from_view<tag_v<T>.size()>(tag_v<T>);
 3918|       |
 3919|       |                  // Track if we've encountered a tag and what value it had
 3920|       |                  std::optional<size_t> tag_specified_index{};
 3921|       |
 3922|       |                  if (skip_ws<Opts>(ctx, it, end)) {
 3923|       |                     return;
 3924|       |                  }
 3925|       |                  // Once the reader knows which alternative this object holds it may have to read
 3926|       |                  // it again from here. Anchor the position rather than keep the pointer: the scan
 3927|       |                  // below skips values, and a streaming skip refills, which moves the window out
 3928|       |                  // from under a raw pointer (see rewind_anchor).
 3929|       |                  auto start = make_rewind_anchor(ctx, it);
 3930|       |                  bool first_key = true;
 3931|       |                  // Parse bifurcation for tagged variants:
 3932|       |                  //
 3933|       |                  // Without this optimization, tagged variant parsing always uses two passes:
 3934|       |                  //   1. Scan all keys to find the tag (e.g. "type"), skipping values
 3935|       |                  //   2. Reset `it = start` and re-parse the entire object into the resolved type
 3936|       |                  //
 3937|       |                  // When the tag is the first key, the second pass redundantly re-reads every
 3938|       |                  // field that follows it. This lambda avoids that: if the tag was the first key,
 3939|       |                  // it advances past the trailing comma so the object parser picks up at the
 3940|       |                  // second field. If the tag was found later, it falls back to the full re-parse.
 3941|       |                  //
 3942|       |                  // One exception: if the tag name is also a field on the resolved struct
 3943|       |                  // (contains_tag), we must re-parse regardless so the value is stored in
 3944|       |                  // the struct field. This override is applied inside each std::visit lambda.
 3945|       |                  //
 3946|       |                  // Either way the rewind can fail under a streaming read: the window only holds so
 3947|       |                  // much, and an object wider than it has no start left to return to.
 3948|       |                  auto position_after_tag = [&] {
 3949|       |                     if (first_key) {
 3950|       |                        if (*it == ',') ++it; // skip comma; handles tag-only objects where *it == '}'
 3951|       |                        return true;
 3952|       |                     }
 3953|       |                     return start.rewind(ctx, it, end); // tag came later, re-parse from the beginning
 3954|       |                  };
 3955|       |                  // `first_key` also answers "were we reset to the object start", which is what
 3956|       |                  // position_after_tag does for every key but the first.
 3957|       |                  for (; *it != '}'; first_key = false) {
 3958|       |                     if (!first_key) {
 3959|       |                        if (match_invalid_end<',', Opts>(ctx, it, end)) {
 3960|       |                           return;
 3961|       |                        }
 3962|       |                     }
 3963|       |
 3964|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 3965|       |                        return;
 3966|       |                     }
 3967|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 3968|       |                        return;
 3969|       |                     }
 3970|       |
 3971|       |                     auto* key_start = it;
 3972|       |                     skip_string_view(ctx, it, end);
 3973|       |                     if (bool(ctx.error)) [[unlikely]]
 3974|       |                        return;
 3975|       |                     if (validate_utf8_span<Opts>(ctx, key_start, it)) [[unlikely]]
 3976|       |                        return;
 3977|       |                     const sv key = {key_start, size_t(it - key_start)};
 3978|       |
 3979|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 3980|       |                        return;
 3981|       |                     }
 3982|       |
 3983|       |                     if constexpr (deduction_key_count > 0) {
 3984|       |                        // We first check if a tag is defined and see if the key matches the tag
 3985|       |                        if constexpr (not tag_v<T>.empty()) {
 3986|       |                           if (key == tag_v<T>) {
 3987|       |                              if (parse_ws_colon<Opts>(ctx, it, end)) {
 3988|       |                                 return;
 3989|       |                              }
 3990|       |
 3991|       |                              using id_type = std::decay_t<decltype(ids_v<T>[0])>;
 3992|       |
 3993|       |                              std::conditional_t<std::integral<id_type>, id_type, sv> type_id{};
 3994|       |                              if constexpr (std::integral<id_type>) {
 3995|       |                                 from<JSON, id_type>::template op<ws_handled<Opts>()>(type_id, ctx, it, end);
 3996|       |                              }
 3997|       |                              else {
 3998|       |                                 // The id is turned into an index below and never leaves this
 3999|       |                                 // reader, so the view of the window it borrows cannot outlive it.
 4000|       |                                 parse_transient_string_view<ws_handled<Opts>()>(type_id, ctx, it, end);
 4001|       |                              }
 4002|       |                              if (bool(ctx.error)) [[unlikely]]
 4003|       |                                 return;
 4004|       |                              if (skip_ws<Opts>(ctx, it, end)) {
 4005|       |                                 return;
 4006|       |                              }
 4007|       |                              if (!(*it == ',' || *it == '}')) [[unlikely]] {
 4008|       |                                 ctx.error = error_code::syntax_error;
 4009|       |                                 return;
 4010|       |                              }
 4011|       |
 4012|       |                              size_t type_index;
 4013|       |                              if constexpr (std::integral<id_type>) {
 4014|       |                                 type_index = variant_id_to_index<T>::op(type_id);
 4015|       |                              }
 4016|       |                              else {
 4017|       |                                 type_index = variant_id_to_index<T>::op(
 4018|       |                                    type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4019|       |                              }
 4020|       |                              if (type_index < ids_v<T>.size()) [[likely]] {
 4021|       |                                 // Check if the deduced types include the tag-specified type
 4022|       |                                 // If not, the tag doesn't match the fields
 4023|       |                                 // We're already inside if constexpr (deduction_registry.size()), so we know deduction
 4024|       |                                 // is happening. At this point, possible_types has been narrowed by field deduction.
 4025|       |                                 // Check if the tag-specified type is still possible
 4026|       |                                 const bool type_is_possible = possible_types[type_index];
 4027|       |                                 if (!type_is_possible) {
 4028|       |                                    // Tag specifies a type that doesn't match the fields seen so far
 4029|       |                                    ctx.error = error_code::no_matching_variant_type;
 4030|       |                                    return;
 4031|       |                                 }
 4032|       |
 4033|       |                                 if (!position_after_tag()) return;
 4034|       |                                 tag_specified_index = type_index; // Store the tag-specified type
 4035|       |                                 if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4036|       |                                 std::visit(
 4037|       |                                    [&](auto&& v) {
 4038|       |                                       using V = std::decay_t<decltype(v)>;
 4039|       |                                       constexpr bool is_object =
 4040|       |                                          (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4041|       |                                       if constexpr (variant_unit_alternative<V>) {
 4042|       |                                          // A unit alternative carries no data; its object holds only the
 4043|       |                                          // discriminator. Consume that body through an empty reflected object so
 4044|       |                                          // unknown-key policy and terminator handling match every other alternative.
 4045|       |                                          detail::variant_unit_body unit_body{};
 4046|       |                                          from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4047|       |                                                                                             tag_literal>(unit_body,
 4048|       |                                                                                                          ctx, it, end);
 4049|       |                                       }
 4050|       |                                       else if constexpr (is_object) {
 4051|       |                                          if constexpr (contains_tag<V, tag_literal>()) {
 4052|       |                                             // tag is a struct field, must re-parse
 4053|       |                                             if (!start.rewind(ctx, it, end)) return;
 4054|       |                                          }
 4055|       |                                          from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it,
 4056|       |                                                                                                           end);
 4057|       |                                       }
 4058|       |                                       else if constexpr (is_memory_object<V>) {
 4059|       |                                          if (!v) {
 4060|       |                                             if constexpr (is_specialization_v<V, std::optional>) {
 4061|       |                                                if constexpr (requires { v.emplace(); }) {
 4062|       |                                                   v.emplace();
 4063|       |                                                }
 4064|       |                                                else {
 4065|       |                                                   v = typename V::value_type{};
 4066|       |                                                }
 4067|       |                                             }
 4068|       |                                             else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4069|       |                                                v = std::make_unique<typename V::element_type>();
 4070|       |                                             else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4071|       |                                                v = std::make_shared<typename V::element_type>();
 4072|       |                                             else if constexpr (constructible<V>) {
 4073|       |                                                v = meta_construct_v<V>();
 4074|       |                                             }
 4075|       |                                             else if constexpr (std::is_pointer_v<V> &&
 4076|       |                                                                can_allocate_raw_pointer<Opts,
 4077|       |                                                                                         std::decay_t<decltype(ctx)>>) {
 4078|       |                                                if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4079|       |                                                   return;
 4080|       |                                                }
 4081|       |                                             }
 4082|       |                                             else {
 4083|       |                                                ctx.error = error_code::invalid_nullable_read;
 4084|       |                                                return;
 4085|       |                                                // Cannot read into unset nullable that is not std::optional,
 4086|       |                                                // std::unique_ptr, or std::shared_ptr
 4087|       |                                             }
 4088|       |                                          }
 4089|       |                                          if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4090|       |                                             // tag is a struct field, must re-parse
 4091|       |                                             if (!start.rewind(ctx, it, end)) return;
 4092|       |                                          }
 4093|       |                                          from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4094|       |                                             *v, ctx, it, end);
 4095|       |                                       }
 4096|       |                                       else if constexpr (custom_read<V>) {
 4097|       |                                          // Custom handlers parse the remaining body themselves and do not
 4098|       |                                          // accept the tag template parameter; the tag was already consumed.
 4099|       |                                          // This only works when the tag was the first key. If it came later,
 4100|       |                                          // we were reset to the object start and the custom handler would
 4101|       |                                          // absorb the tag, so error rather than corrupt the value.
 4102|       |                                          if (!first_key) {
 4103|       |                                             ctx.error = error_code::feature_not_supported;
 4104|       |                                             ctx.custom_error_message =
 4105|       |                                                "the tag must be the first key for a custom variant alternative";
 4106|       |                                             return;
 4107|       |                                          }
 4108|       |                                          from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4109|       |                                       }
 4110|       |                                    },
 4111|       |                                    value);
 4112|       |
 4113|       |                                 return; // we've decoded our target type
 4114|       |                              }
 4115|       |                              else [[unlikely]] {
 4116|       |                                 // Check if we have a default type (ids array shorter than variant)
 4117|       |                                 constexpr auto ids_size = ids_v<T>.size();
 4118|       |                                 constexpr auto variant_size = std::variant_size_v<T>;
 4119|       |                                 if constexpr (ids_size < variant_size) {
 4120|       |                                    // Use the first unlabeled type as the default
 4121|       |                                    const auto default_type_index = ids_size;
 4122|       |
 4123|       |                                    if (!position_after_tag()) return;
 4124|       |                                    tag_specified_index = default_type_index; // Store the default type index
 4125|       |                                    if (value.index() != default_type_index)
 4126|       |                                       emplace_runtime_variant(value, default_type_index);
 4127|       |                                    std::visit(
 4128|       |                                       [&](auto&& v) {
 4129|       |                                          using V = std::decay_t<decltype(v)>;
 4130|       |                                          constexpr bool is_object =
 4131|       |                                             (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4132|       |                                          if constexpr (variant_unit_alternative<V>) {
 4133|       |                                             // A unit alternative carries no data; its object holds only the
 4134|       |                                             // discriminator. Consume that body through an empty reflected object so
 4135|       |                                             // unknown-key policy and terminator handling match every other
 4136|       |                                             // alternative.
 4137|       |                                             detail::variant_unit_body unit_body{};
 4138|       |                                             from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4139|       |                                                                                                tag_literal>(
 4140|       |                                                unit_body, ctx, it, end);
 4141|       |                                          }
 4142|       |                                          else if constexpr (is_object) {
 4143|       |                                             if constexpr (contains_tag<V, tag_literal>()) {
 4144|       |                                                // tag is a struct field, must re-parse
 4145|       |                                                if (!start.rewind(ctx, it, end)) return;
 4146|       |                                             }
 4147|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4148|       |                                          }
 4149|       |                                          else if constexpr (is_memory_object<V>) {
 4150|       |                                             if (!v) {
 4151|       |                                                if constexpr (is_specialization_v<V, std::optional>) {
 4152|       |                                                   if constexpr (requires { v.emplace(); }) {
 4153|       |                                                      v.emplace();
 4154|       |                                                   }
 4155|       |                                                   else {
 4156|       |                                                      v = typename V::value_type{};
 4157|       |                                                   }
 4158|       |                                                }
 4159|       |                                                else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4160|       |                                                   v = std::make_unique<typename V::element_type>();
 4161|       |                                                else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4162|       |                                                   v = std::make_shared<typename V::element_type>();
 4163|       |                                                else if constexpr (constructible<V>) {
 4164|       |                                                   v = meta_construct_v<V>();
 4165|       |                                                }
 4166|       |                                                else if constexpr (std::is_pointer_v<V> &&
 4167|       |                                                                   can_allocate_raw_pointer<
 4168|       |                                                                      Opts, std::decay_t<decltype(ctx)>>) {
 4169|       |                                                   if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4170|       |                                                      return;
 4171|       |                                                   }
 4172|       |                                                }
 4173|       |                                                else {
 4174|       |                                                   ctx.error = error_code::invalid_nullable_read;
 4175|       |                                                   return;
 4176|       |                                                }
 4177|       |                                             }
 4178|       |                                             if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4179|       |                                                // tag is a struct field, must re-parse
 4180|       |                                                if (!start.rewind(ctx, it, end)) return;
 4181|       |                                             }
 4182|       |                                             from<JSON, memory_type<V>>::template op<opening_handled<Opts>()>(*v, ctx,
 4183|       |                                                                                                              it, end);
 4184|       |                                          }
 4185|       |                                          else if constexpr (custom_read<V>) {
 4186|       |                                             // Custom handlers parse the remaining body themselves; this only
 4187|       |                                             // works when the tag was the first key (see above). If it came
 4188|       |                                             // later we were reset to the object start, so error rather than
 4189|       |                                             // let the custom handler absorb the tag.
 4190|       |                                             if (!first_key) {
 4191|       |                                                ctx.error = error_code::feature_not_supported;
 4192|       |                                                ctx.custom_error_message =
 4193|       |                                                   "the tag must be the first key for a custom variant alternative";
 4194|       |                                                return;
 4195|       |                                             }
 4196|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4197|       |                                          }
 4198|       |                                       },
 4199|       |                                       value);
 4200|       |
 4201|       |                                    return;
 4202|       |                                 }
 4203|       |                                 else {
 4204|       |                                    ctx.error = error_code::no_matching_variant_type;
 4205|       |                                    ctx.custom_error_message = variant_ids_string_v<T>;
 4206|       |                                    return;
 4207|       |                                 }
 4208|       |                              }
 4209|       |                           }
 4210|       |                        }
 4211|       |
 4212|       |                        // Inline decode_hash lookup for variant deduction
 4213|       |                        using deduction_keys_t = keys_wrapper<variant_deduction_keys<T>>;
 4214|       |                        constexpr auto& DeductionHashInfo = hash_info<deduction_keys_t>;
 4215|       |                        const auto deduction_index =
 4216|       |                           decode_hash_with_size<JSON, deduction_keys_t, DeductionHashInfo, DeductionHashInfo.type>::op(
 4217|       |                              key.data(), key.data() + key.size(), key.size());
 4218|       |                        if (deduction_index < deduction_key_count && variant_deduction_keys<T>[deduction_index] == key)
 4219|       |                           [[likely]] {
 4220|       |                           possible_types &= deduction_bits[deduction_index];
 4221|       |                        }
 4222|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4223|       |                           ctx.error = error_code::unknown_key;
 4224|       |                           return;
 4225|       |                        }
 4226|       |                     }
 4227|       |                     else if constexpr (not tag_v<T>.empty()) {
 4228|       |                        // empty object case for variant, if there are no normal elements
 4229|       |                        if (key == tag_v<T>) {
 4230|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4231|       |                              return;
 4232|       |                           }
 4233|       |
 4234|       |                           // The id is turned into an index below and never leaves this reader,
 4235|       |                           // so the view of the window it borrows cannot outlive that window.
 4236|       |                           std::string_view type_id{};
 4237|       |                           parse_transient_string_view<ws_handled<Opts>()>(type_id, ctx, it, end);
 4238|       |                           if (bool(ctx.error)) [[unlikely]]
 4239|       |                              return;
 4240|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4241|       |                              return;
 4242|       |                           }
 4243|       |
 4244|       |                           const auto type_index = variant_id_to_index<T>::op(
 4245|       |                              type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4246|       |                           if (type_index < ids_v<T>.size()) [[likely]] {
 4247|       |                              if (!position_after_tag()) return;
 4248|       |                              tag_specified_index = type_index; // Store the tag-specified type
 4249|       |                              if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4250|       |                           }
 4251|       |                           else {
 4252|       |                              // Check if we have a default type (ids array shorter than variant)
 4253|       |                              constexpr auto ids_size = ids_v<T>.size();
 4254|       |                              constexpr auto variant_size = std::variant_size_v<T>;
 4255|       |                              if constexpr (ids_size < variant_size) {
 4256|       |                                 // Use the first unlabeled type as the default
 4257|       |                                 if (!position_after_tag()) return;
 4258|       |                                 const auto default_index = ids_size;
 4259|       |                                 tag_specified_index = default_index; // Store the default type index
 4260|       |                                 if (value.index() != default_index) emplace_runtime_variant(value, default_index);
 4261|       |                              }
 4262|       |                              else {
 4263|       |                                 ctx.error = error_code::no_matching_variant_type;
 4264|       |                                 ctx.custom_error_message = variant_ids_string_v<T>;
 4265|       |                                 return;
 4266|       |                              }
 4267|       |                           }
 4268|       |                           // Parse the type (handles tag skipping and unknown keys)
 4269|       |                           std::visit(
 4270|       |                              [&](auto&& v) {
 4271|       |                                 using V = std::decay_t<decltype(v)>;
 4272|       |                                 if constexpr (custom_read<V>) {
 4273|       |                                    // Custom handlers parse the remaining object body themselves and do not
 4274|       |                                    // accept the tag template parameter that reflected objects use to skip an
 4275|       |                                    // interior tag key. That only works when the tag is the first key (it was
 4276|       |                                    // just consumed). If the tag came after other keys, position_after_tag()
 4277|       |                                    // reset us to the object start and the custom handler would absorb the tag
 4278|       |                                    // into its value, so error here rather than corrupt the result.
 4279|       |                                    if (!first_key) {
 4280|       |                                       ctx.error = error_code::feature_not_supported;
 4281|       |                                       ctx.custom_error_message =
 4282|       |                                          "the tag must be the first key for a custom variant alternative";
 4283|       |                                       return;
 4284|       |                                    }
 4285|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4286|       |                                 }
 4287|       |                                 else {
 4288|       |                                    if constexpr (contains_tag<V, tag_literal>()) {
 4289|       |                                       // tag is a struct field, must re-parse
 4290|       |                                       if (!start.rewind(ctx, it, end)) return;
 4291|       |                                    }
 4292|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4293|       |                                 }
 4294|       |                              },
 4295|       |                              value);
 4296|       |                           return;
 4297|       |                        }
 4298|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4299|       |                           ctx.error = error_code::unknown_key;
 4300|       |                           return;
 4301|       |                        }
 4302|       |                        else {
 4303|       |                           // Skip unknown key's value (non-tag key in empty variant)
 4304|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4305|       |                              return;
 4306|       |                           }
 4307|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 4308|       |                           if (bool(ctx.error)) [[unlikely]]
 4309|       |                              return;
 4310|       |                           resync_window_end(ctx, end); // a streaming skip refills
 4311|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4312|       |                              return;
 4313|       |                           }
 4314|       |                           continue; // Continue loop to find the tag
 4315|       |                        }
 4316|       |                     }
 4317|       |                     else if constexpr (Opts.error_on_unknown_keys) {
 4318|       |                        ctx.error = error_code::unknown_key;
 4319|       |                        return;
 4320|       |                     }
 4321|       |
 4322|       |                     auto matching_types = possible_types.popcount();
 4323|       |                     if (matching_types == 0) {
 4324|       |                        ctx.error = error_code::no_matching_variant_type;
 4325|       |                        return;
 4326|       |                     }
 4327|       |                     // Only short-circuit for variants without tags
 4328|       |                     else if constexpr (tag_v<T>.empty()) {
 4329|       |                        if (matching_types == 1) {
 4330|       |                           if (!start.rewind(ctx, it, end)) return;
 4331|       |                           const auto type_index = possible_types.countr_zero();
 4332|       |
 4333|       |                           if (value.index() != static_cast<size_t>(type_index))
 4334|       |                              emplace_runtime_variant(value, type_index);
 4335|       |                           std::visit(
 4336|       |                              [&](auto&& v) {
 4337|       |                                 using V = std::decay_t<decltype(v)>;
 4338|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4339|       |                                 if constexpr (variant_unit_alternative<V>) {
 4340|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4341|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4342|       |                                    // terminator handling match every other alternative.
 4343|       |                                    detail::variant_unit_body unit_body{};
 4344|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4345|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4346|       |                                                                                                    end);
 4347|       |                                 }
 4348|       |                                 else if constexpr (is_object) {
 4349|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4350|       |                                 }
 4351|       |                                 else if constexpr (is_memory_object<V>) {
 4352|       |                                    if (!v) {
 4353|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4354|       |                                          if constexpr (requires { v.emplace(); }) {
 4355|       |                                             v.emplace();
 4356|       |                                          }
 4357|       |                                          else {
 4358|       |                                             v = typename V::value_type{};
 4359|       |                                          }
 4360|       |                                       }
 4361|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4362|       |                                          v = std::make_unique<typename V::element_type>();
 4363|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4364|       |                                          v = std::make_shared<typename V::element_type>();
 4365|       |                                       else if constexpr (constructible<V>) {
 4366|       |                                          v = meta_construct_v<V>();
 4367|       |                                       }
 4368|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4369|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4370|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4371|       |                                             return;
 4372|       |                                          }
 4373|       |                                       }
 4374|       |                                       else {
 4375|       |                                          ctx.error = error_code::invalid_nullable_read;
 4376|       |                                          return;
 4377|       |                                          // Cannot read into unset nullable that is not std::optional,
 4378|       |                                          // std::unique_ptr, or std::shared_ptr
 4379|       |                                       }
 4380|       |                                    }
 4381|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4382|       |                                       *v, ctx, it, end);
 4383|       |                                 }
 4384|       |                                 else if constexpr (custom_read<V>) {
 4385|       |                                    // Custom handlers parse the remaining body themselves.
 4386|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4387|       |                                 }
 4388|       |                              },
 4389|       |                              value);
 4390|       |
 4391|       |                           return; // we've decoded our target type
 4392|       |                        }
 4393|       |                     }
 4394|       |                     // For tagged variants, continue processing to validate tags
 4395|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 4396|       |                        return;
 4397|       |                     }
 4398|       |
 4399|       |                     skip_value<JSON>::op<Opts>(ctx, it, end);
 4400|       |                     if (bool(ctx.error)) [[unlikely]]
 4401|       |                        return;
 4402|       |                     resync_window_end(ctx, end); // a streaming skip refills
 4403|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4404|       |                        return;
 4405|       |                     }
 4406|       |                  }
 4407|       |                  // Only apply ambiguous variant resolution if we have multiple object types
 4408|       |                  if constexpr ((type_counts::n_object + type_counts::n_nullable_object) > 1) {
 4409|       |                     // After parsing all keys, check if we have multiple matching types
 4410|       |                     // If so, choose the one with the fewest fields
 4411|       |                     auto final_matching = possible_types.popcount();
 4412|       |                     if (final_matching == 0) {
 4413|       |                        ctx.error = error_code::no_matching_variant_type;
 4414|       |                     }
 4415|       |                     else if (final_matching == 1) {
 4416|       |                        // Single type remains after field deduction
 4417|       |                        const auto type_index = possible_types.countr_zero();
 4418|       |
 4419|       |                        // Validate against tag if one was specified
 4420|       |                        if (tag_specified_index.has_value() &&
 4421|       |                            tag_specified_index.value() != static_cast<size_t>(type_index)) {
 4422|       |                           ctx.error = error_code::no_matching_variant_type;
 4423|       |                           return;
 4424|       |                        }
 4425|       |
 4426|       |                        if (!start.rewind(ctx, it, end)) return;
 4427|       |                        if (value.index() != static_cast<size_t>(type_index))
 4428|       |                           emplace_runtime_variant(value, type_index);
 4429|       |                        std::visit(
 4430|       |                           [&](auto&& v) {
 4431|       |                              using V = std::decay_t<decltype(v)>;
 4432|       |                              constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4433|       |                              if constexpr (variant_unit_alternative<V>) {
 4434|       |                                 // A unit alternative carries no data; its object holds only the discriminator.
 4435|       |                                 // Consume that body through an empty reflected object so unknown-key policy and
 4436|       |                                 // terminator handling match every other alternative.
 4437|       |                                 detail::variant_unit_body unit_body{};
 4438|       |                                 from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4439|       |                                                                                    tag_literal>(unit_body, ctx, it,
 4440|       |                                                                                                 end);
 4441|       |                              }
 4442|       |                              else if constexpr (is_object) {
 4443|       |                                 from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4444|       |                              }
 4445|       |                              else if constexpr (is_memory_object<V>) {
 4446|       |                                 if (!v) {
 4447|       |                                    if constexpr (is_specialization_v<V, std::optional>) {
 4448|       |                                       if constexpr (requires { v.emplace(); }) {
 4449|       |                                          v.emplace();
 4450|       |                                       }
 4451|       |                                       else {
 4452|       |                                          v = typename V::value_type{};
 4453|       |                                       }
 4454|       |                                    }
 4455|       |                                    else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4456|       |                                       v = std::make_unique<typename V::element_type>();
 4457|       |                                    else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4458|       |                                       v = std::make_shared<typename V::element_type>();
 4459|       |                                    else if constexpr (constructible<V>) {
 4460|       |                                       v = meta_construct_v<V>();
 4461|       |                                    }
 4462|       |                                    else if constexpr (std::is_pointer_v<V> &&
 4463|       |                                                       can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4464|       |                                       if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4465|       |                                          return;
 4466|       |                                       }
 4467|       |                                    }
 4468|       |                                    else {
 4469|       |                                       ctx.error = error_code::invalid_nullable_read;
 4470|       |                                       return;
 4471|       |                                    }
 4472|       |                                 }
 4473|       |                                 from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(*v, ctx,
 4474|       |                                                                                                               it, end);
 4475|       |                              }
 4476|       |                              else if constexpr (custom_read<V>) {
 4477|       |                                 // Custom handlers parse the remaining body themselves.
 4478|       |                                 from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4479|       |                              }
 4480|       |                           },
 4481|       |                           value);
 4482|       |                     }
 4483|       |                     else if (final_matching > 1) {
 4484|       |                        constexpr auto N = std::variant_size_v<T>;
 4485|       |
 4486|       |                        // Compile-time array of field counts for each variant type
 4487|       |                        constexpr auto field_counts = []<size_t... I>(std::index_sequence<I...>) {
 4488|       |                           return std::array<size_t, N> {
 4489|       |                              ([]<size_t J = I>() -> size_t {
 4490|       |                                 using V = std::decay_t<std::variant_alternative_t<J, T>>;
 4491|       |                                 if constexpr (glaze_object_t<V> || reflectable<V>) {
 4492|       |                                    return reflect<V>::size;
 4493|       |                                 }
 4494|       |                                 else if constexpr (is_memory_object<V>) {
 4495|       |                                    using X = memory_type<V>;
 4496|       |                                    if constexpr (glaze_object_t<X> || reflectable<X>) {
 4497|       |                                       return reflect<X>::size;
 4498|       |                                    }
 4499|       |                                    else {
 4500|       |                                       return (std::numeric_limits<size_t>::max)();
 4501|       |                                    }
 4502|       |                                 }
 4503|       |                                 else {
 4504|       |                                    return (std::numeric_limits<size_t>::max)();
 4505|       |                                 }
 4506|       |                              }.template operator()<I>())...
 4507|       |                           };
 4508|       |                        }(std::make_index_sequence<N>{});
 4509|       |
 4510|       |                        // Find the type with minimum field count among the possible types
 4511|       |                        size_t min_fields = (std::numeric_limits<size_t>::max)();
 4512|       |                        size_t chosen_index = N; // Invalid index initially
 4513|       |
 4514|       |                        for (size_t i = 0; i < N; ++i) {
 4515|       |                           if (possible_types[i] && field_counts[i] < min_fields) {
 4516|       |                              min_fields = field_counts[i];
 4517|       |                              chosen_index = i;
 4518|       |                           }
 4519|       |                        }
 4520|       |
 4521|       |                        if (chosen_index < N) {
 4522|       |                           // Validate against tag if one was specified
 4523|       |                           if (tag_specified_index.has_value() && tag_specified_index.value() != chosen_index) {
 4524|       |                              ctx.error = error_code::no_matching_variant_type;
 4525|       |                              return;
 4526|       |                           }
 4527|       |
 4528|       |                           if (!start.rewind(ctx, it, end)) return;
 4529|       |                           if (value.index() != chosen_index) emplace_runtime_variant(value, chosen_index);
 4530|       |                           std::visit(
 4531|       |                              [&](auto&& v) {
 4532|       |                                 using V = std::decay_t<decltype(v)>;
 4533|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4534|       |                                 if constexpr (variant_unit_alternative<V>) {
 4535|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4536|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4537|       |                                    // terminator handling match every other alternative.
 4538|       |                                    detail::variant_unit_body unit_body{};
 4539|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4540|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4541|       |                                                                                                    end);
 4542|       |                                 }
 4543|       |                                 else if constexpr (is_object) {
 4544|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4545|       |                                 }
 4546|       |                                 else if constexpr (is_memory_object<V>) {
 4547|       |                                    if (!v) {
 4548|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4549|       |                                          if constexpr (requires { v.emplace(); }) {
 4550|       |                                             v.emplace();
 4551|       |                                          }
 4552|       |                                          else {
 4553|       |                                             v = typename V::value_type{};
 4554|       |                                          }
 4555|       |                                       }
 4556|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4557|       |                                          v = std::make_unique<typename V::element_type>();
 4558|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4559|       |                                          v = std::make_shared<typename V::element_type>();
 4560|       |                                       else if constexpr (constructible<V>) {
 4561|       |                                          v = meta_construct_v<V>();
 4562|       |                                       }
 4563|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4564|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4565|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4566|       |                                             return;
 4567|       |                                          }
 4568|       |                                       }
 4569|       |                                       else {
 4570|       |                                          ctx.error = error_code::invalid_nullable_read;
 4571|       |                                          return;
 4572|       |                                       }
 4573|       |                                    }
 4574|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4575|       |                                       *v, ctx, it, end);
 4576|       |                                 }
 4577|       |                                 else if constexpr (custom_read<V>) {
 4578|       |                                    // Custom handlers parse the remaining body themselves.
 4579|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4580|       |                                 }
 4581|       |                              },
 4582|       |                              value);
 4583|       |                        }
 4584|       |                        else {
 4585|       |                           ctx.error = error_code::no_matching_variant_type;
 4586|       |                        }
 4587|       |                     }
 4588|       |                  }
 4589|       |                  else {
 4590|       |                     // For variants with 0 or 1 object types, use the original error handling
 4591|       |                     ctx.error = error_code::no_matching_variant_type;
 4592|       |                  }
 4593|       |               }
 4594|      0|               break;
 4595|  14.9k|            }
 4596|  5.01k|            case '[':
  ------------------
  |  Branch (4596:13): [True: 5.01k, False: 26.0k]
  ------------------
 4597|       |               // As with '{' above: the array reader each alternative goes through counts the level.
 4598|  5.01k|               process_variant_alternatives<T, is_variant_array>::template op<Opts>(value, ctx, it, end);
 4599|  5.01k|               break;
 4600|  2.70k|            case '"': {
  ------------------
  |  Branch (4600:13): [True: 2.70k, False: 28.3k]
  ------------------
 4601|  2.70k|               process_variant_alternatives<T, is_variant_str>::template op<Opts>(value, ctx, it, end);
 4602|  2.70k|               break;
 4603|  14.9k|            }
 4604|    126|            case 't':
  ------------------
  |  Branch (4604:13): [True: 126, False: 30.8k]
  ------------------
 4605|    306|            case 'f': {
  ------------------
  |  Branch (4605:13): [True: 180, False: 30.8k]
  ------------------
 4606|    306|               process_variant_alternatives<T, is_variant_bool>::template op<Opts>(value, ctx, it, end);
 4607|    306|               break;
 4608|    126|            }
 4609|    141|            case 'n':
  ------------------
  |  Branch (4609:13): [True: 141, False: 30.8k]
  ------------------
 4610|       |               if constexpr (variant_count_v<T, is_variant_null> == 0) {
 4611|       |                  ctx.error = error_code::no_matching_variant_type;
 4612|       |               }
 4613|    141|               else {
 4614|    141|                  constexpr auto first_idx = variant_first_index_v<T, is_variant_null>;
 4615|    141|                  using V = std::variant_alternative_t<first_idx, T>;
 4616|    141|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4616:23): [True: 0, False: 141]
  ------------------
 4617|    141|                  match<"null", Opts>(ctx, it, end);
 4618|    141|               }
 4619|    141|               break;
 4620|  7.88k|            default: {
  ------------------
  |  Branch (4620:13): [True: 7.88k, False: 23.1k]
  ------------------
 4621|       |               // Not bool, string, object, or array so must be number or null
 4622|  7.88k|               process_variant_alternatives<T, is_variant_num>::template op<Opts>(value, ctx, it, end);
 4623|  7.88k|            }
 4624|  31.0k|            }
 4625|       |         }
 4626|       |         else {
 4627|       |            // For non-auto-deducible variants, try each type until one succeeds
 4628|       |            constexpr auto N = std::variant_size_v<T>;
 4629|       |            bool parsed = false;
 4630|       |            bool exhausted = false; // speculation budget spent; see charge_speculation
 4631|       |
 4632|       |            for_each<N>([&]<size_t I>() {
 4633|       |               if (parsed || exhausted || variant_alternative_exhausted(ctx)) return;
 4634|       |
 4635|       |               auto copy_it = it;
 4636|       |               // A rejected alternative may have bailed out inside a container, which leaves its
 4637|       |               // nesting level counted (see enter_depth), so the depth rewinds with the iterator.
 4638|       |               const auto copy_depth = ctx.depth;
 4639|       |
 4640|       |               // Try parsing as this type
 4641|       |               if (value.index() != I) {
 4642|       |                  emplace_runtime_variant(value, I);
 4643|       |               }
 4644|       |
 4645|       |               std::visit([&](auto&& v) { parse<JSON>::op<Options>(v, ctx, it, end); }, value);
 4646|       |               if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 4647|       |                  exhausted = true; // only rejected attempts are charged; see charge_speculation
 4648|       |               }
 4649|       |
 4650|       |               if (!bool(ctx.error)) {
 4651|       |                  parsed = true;
 4652|       |               }
 4653|       |               else if constexpr (not Options.null_terminated) {
 4654|       |                  // In non-null-terminated mode, if we hit end_reached after advancing the iterator,
 4655|       |                  // it means we successfully parsed the value but couldn't skip trailing whitespace
 4656|       |                  if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 4657|       |                     // We advanced the iterator, so we did parse something -- unless what advanced it
 4658|       |                     // was an abandoned attempt, which is what a spent speculation budget means.
 4659|       |                     parsed = true;
 4660|       |                     ctx.error = error_code::none;
 4661|       |                  }
 4662|       |                  else {
 4663|       |                     // Reset for next attempt (unless this is the last type)
 4664|       |                     it = copy_it;
 4665|       |                     rewind_depth<Options>(ctx, copy_depth);
 4666|       |                     if constexpr (I + 1 < N) {
 4667|       |                        if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4668|       |                           ctx.error = error_code::none; // Clear error for next attempt
 4669|       |                        }
 4670|       |                     }
 4671|       |                  }
 4672|       |               }
 4673|       |               else {
 4674|       |                  // Reset for next attempt (unless this is the last type)
 4675|       |                  it = copy_it;
 4676|       |                  rewind_depth<Options>(ctx, copy_depth);
 4677|       |                  if constexpr (I + 1 < N) {
 4678|       |                     if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4679|       |                        ctx.error = error_code::none; // Clear error for next attempt
 4680|       |                     }
 4681|       |                  }
 4682|       |               }
 4683|       |            });
 4684|       |         }
 4685|  31.0k|      }
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEERNS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES4_EEEETkNS_10is_contextERNS_7contextERPKcSD_EEvOT0_OT1_OT2_T3_:
   49|  76.9k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  76.9k|         else {
   60|  76.9k|            using V = std::remove_cvref_t<T>;
   61|  76.9k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  76.9k|                                             end);
   63|  76.9k|         }
   64|  76.9k|      }
_ZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_:
 2791|  76.9k|      {
 2792|  76.9k|         static constexpr auto num_members = reflect<T>::size;
 2793|       |
 2794|  76.9k|         static constexpr auto Opts = opening_handled_off<ws_handled_off<Options>()>();
 2795|       |         if constexpr (!check_opening_handled(Options)) {
 2796|       |            if constexpr (!check_ws_handled(Options)) {
 2797|       |               if (skip_ws<Opts>(ctx, it, end)) {
 2798|       |                  return;
 2799|       |               }
 2800|       |            }
 2801|       |            if (match_invalid_end<'{', Opts>(ctx, it, end)) {
 2802|       |               return;
 2803|       |            }
 2804|       |            if constexpr (not Opts.null_terminated) {
 2805|       |               if (it == end) [[unlikely]] {
 2806|       |                  ctx.error = error_code::unexpected_end;
 2807|       |                  return;
 2808|       |               }
 2809|       |            }
 2810|       |            // one nesting level (see enter_depth): counted in both modes so the limit binds,
 2811|       |            // released at each syntactic close below
 2812|       |            if (enter_depth(ctx)) [[unlikely]] {
 2813|       |               return;
 2814|       |            }
 2815|       |         }
 2816|  76.9k|         const auto ws_start = it;
 2817|  76.9k|         if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2817:14): [True: 11, False: 76.9k]
  ------------------
 2818|     11|            return;
 2819|     11|         }
 2820|  76.9k|         const size_t ws_size = size_t(it - ws_start);
 2821|       |
 2822|       |         if constexpr ((glaze_object_t<T> || reflectable<T>) && num_members == 0 && Opts.error_on_unknown_keys) {
 2823|       |            if constexpr (not tag.sv().empty()) {
 2824|       |               if (*it == '"') {
 2825|       |                  ++it;
 2826|       |                  if constexpr (not Opts.null_terminated) {
 2827|       |                     if (it == end) [[unlikely]] {
 2828|       |                        ctx.error = error_code::unexpected_end;
 2829|       |                        return;
 2830|       |                     }
 2831|       |                  }
 2832|       |
 2833|       |                  const auto start = it;
 2834|       |                  skip_string_view(ctx, it, end);
 2835|       |                  if (bool(ctx.error)) [[unlikely]]
 2836|       |                     return;
 2837|       |                  if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]]
 2838|       |                     return;
 2839|       |                  const sv key{start, size_t(it - start)};
 2840|       |                  ++it;
 2841|       |                  if constexpr (not Opts.null_terminated) {
 2842|       |                     if (it == end) [[unlikely]] {
 2843|       |                        ctx.error = error_code::unexpected_end;
 2844|       |                        return;
 2845|       |                     }
 2846|       |                  }
 2847|       |
 2848|       |                  if (key == tag.sv()) {
 2849|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 2850|       |                        return;
 2851|       |                     }
 2852|       |
 2853|       |                     parse<JSON>::handle_unknown<Opts>(key, value, ctx, it, end);
 2854|       |                     if (bool(ctx.error)) [[unlikely]]
 2855|       |                        return;
 2856|       |
 2857|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 2858|       |                        return;
 2859|       |                     }
 2860|       |                  }
 2861|       |                  else {
 2862|       |                     ctx.error = error_code::unknown_key;
 2863|       |                     return;
 2864|       |                  }
 2865|       |               }
 2866|       |            }
 2867|       |
 2868|       |            if (*it == '}') [[likely]] {
 2869|       |               --ctx.depth;
 2870|       |               if constexpr (glaze_object_t<T> || reflectable<T>) {
 2871|       |                  if constexpr (has_self_constraint_v<T> && !check_skip_self_constraint(Opts)) {
 2872|       |                     auto wrapper = self_constraint_v<T>(value);
 2873|       |                     from<JSON, decltype(wrapper)>::template op<ws_handled<Opts>()>(wrapper, ctx, it, end);
 2874|       |                     if (bool(ctx.error)) {
 2875|       |                        return;
 2876|       |                     }
 2877|       |                  }
 2878|       |               }
 2879|       |               ++it;
 2880|       |               if constexpr (not Opts.null_terminated) {
 2881|       |                  if (it == end) {
 2882|       |                     ctx.error = error_code::end_reached;
 2883|       |                     return;
 2884|       |                  }
 2885|       |               }
 2886|       |               if constexpr (Opts.partial_read) {
 2887|       |                  ctx.error = error_code::partial_read_complete;
 2888|       |               }
 2889|       |               return;
 2890|       |            }
 2891|       |            ctx.error = error_code::unknown_key;
 2892|       |            return;
 2893|       |         }
 2894|  76.9k|         else {
 2895|  76.9k|            decltype(auto) fields = [&]() -> decltype(auto) {
 2896|  76.9k|               if constexpr ((glaze_object_t<T> || reflectable<T>) &&
 2897|  76.9k|                             (Opts.error_on_missing_keys || Opts.partial_read)) {
 2898|  76.9k|                  return bit_array<num_members>{};
 2899|  76.9k|               }
 2900|  76.9k|               else {
 2901|  76.9k|                  return nullptr;
 2902|  76.9k|               }
 2903|  76.9k|            }();
 2904|       |
 2905|       |            // A file include merges an external document into this object, so with
 2906|       |            // error_on_missing_keys the keys have to be counted across both documents (see
 2907|       |            // context::key_bits). While this object parses, its bits are published for its
 2908|       |            // includer members to hand down; and if this parse is itself an included document,
 2909|       |            // it claims the bits of the object that included us and merges into them at the
 2910|       |            // closing brace instead of running a check of its own.
 2911|  76.9k|            static constexpr bool tracks_include_keys = [] {
 2912|       |               // Nested so that reflecting over the members is only asked for when it can matter
 2913|  76.9k|               if constexpr ((glaze_object_t<T> || reflectable<T>) && Opts.error_on_missing_keys) {
 2914|  76.9k|                  return has_includer_member<T>;
 2915|  76.9k|               }
 2916|  76.9k|               else {
 2917|  76.9k|                  return false;
 2918|  76.9k|               }
 2919|  76.9k|            }();
 2920|  76.9k|            [[maybe_unused]] bit_array<num_members>* include_bits{};
 2921|       |            if constexpr (tracks_include_keys) {
 2922|       |               if (ctx.include_key_type == &include_key_tag<T>) {
 2923|       |                  include_bits = static_cast<bit_array<num_members>*>(ctx.include_key_bits);
 2924|       |                  ctx.include_key_bits = nullptr;
 2925|       |                  ctx.include_key_type = nullptr;
 2926|       |               }
 2927|       |            }
 2928|  76.9k|            [[maybe_unused]] const std::conditional_t<tracks_include_keys,
 2929|  76.9k|                                                      key_bits_scope<std::remove_reference_t<decltype(ctx)>>,
 2930|  76.9k|                                                      inert_key_bits_scope> published_bits{
 2931|  76.9k|               ctx, [&]() -> void* {
 2932|  76.9k|                  if constexpr (tracks_include_keys) {
 2933|  76.9k|                     return &fields;
 2934|  76.9k|                  }
 2935|  76.9k|                  else {
 2936|  76.9k|                     return nullptr;
 2937|  76.9k|                  }
 2938|  76.9k|               }()};
 2939|       |
 2940|  76.9k|            size_t read_count{}; // for partial_read
 2941|       |
 2942|  76.9k|            bool first = true;
 2943|  3.01M|            while (true) {
  ------------------
  |  Branch (2943:20): [True: 2.94M, Folded]
  ------------------
 2944|       |               if constexpr ((glaze_object_t<T> || reflectable<T>) && Opts.partial_read) {
 2945|       |                  static constexpr bit_array<num_members> all_fields = [] {
 2946|       |                     bit_array<num_members> arr{};
 2947|       |                     for (size_t i = 0; i < num_members; ++i) {
 2948|       |                        arr[i] = true;
 2949|       |                     }
 2950|       |                     return arr;
 2951|       |                  }();
 2952|       |
 2953|       |                  if ((all_fields & fields) == all_fields) {
 2954|       |                     ctx.error = error_code::partial_read_complete;
 2955|       |                     --ctx.depth; // as above: an early success still closes this level
 2956|       |                     return;
 2957|       |                  }
 2958|       |               }
 2959|       |
 2960|       |               // Streaming refill point: at start of each iteration, ensure buffer has data
 2961|       |               if constexpr (has_streaming_state<decltype(ctx)>) {
 2962|       |                  if (ctx.stream.enabled()) {
 2963|       |                     const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 2964|       |                     const size_t remaining = ctx.stream.size() - consumed;
 2965|       |                     // Refill when less than half of buffer remains to ensure space for next key-value pair
 2966|       |                     if (remaining <= ctx.stream.size() / 2 || it >= end) {
 2967|       |                        const char* new_it;
 2968|       |                        const char* new_end;
 2969|       |                        ctx.stream.consume_and_refill(consumed, new_it, new_end);
 2970|       |                        it = new_it;
 2971|       |                        end = new_end;
 2972|       |                        if (it >= end && ctx.stream.at_eof()) {
 2973|       |                           ctx.error = error_code::unexpected_end;
 2974|       |                           return;
 2975|       |                        }
 2976|       |                     }
 2977|       |                  }
 2978|       |               }
 2979|       |
 2980|  2.94M|               if (*it == '}') {
  ------------------
  |  Branch (2980:20): [True: 5.73k, False: 2.93M]
  ------------------
 2981|  5.73k|                  --ctx.depth;
 2982|       |                  if constexpr ((glaze_object_t<T> || reflectable<T>) && Opts.error_on_missing_keys) {
 2983|       |                     const bool defer_to_includer = [&] {
 2984|       |                        if constexpr (tracks_include_keys) {
 2985|       |                           if (include_bits) {
 2986|       |                              // An included document is a fragment: hand the keys it supplied to
 2987|       |                              // the object that included it, which checks the union of both.
 2988|       |                              *include_bits |= fields;
 2989|       |                              return true;
 2990|       |                           }
 2991|       |                        }
 2992|       |                        return false;
 2993|       |                     }();
 2994|       |                     constexpr auto req_fields = required_fields<T, Opts>();
 2995|       |                     if (not defer_to_includer && (req_fields & fields) != req_fields) {
 2996|       |                        for (size_t i = 0; i < num_members; ++i) {
 2997|       |                           if (not fields[i] && req_fields[i]) {
 2998|       |                              ctx.custom_error_message = reflect<T>::keys[i];
 2999|       |                              // We just return the first missing key in order to avoid heap allocations
 3000|       |                              break;
 3001|       |                           }
 3002|       |                        }
 3003|       |
 3004|       |                        ctx.error = error_code::missing_key;
 3005|       |                        return;
 3006|       |                     }
 3007|       |                  }
 3008|       |                  if constexpr (glaze_object_t<T> || reflectable<T>) {
 3009|       |                     if constexpr (has_self_constraint_v<T> && !check_skip_self_constraint(Opts)) {
 3010|       |                        auto wrapper = self_constraint_v<T>(value);
 3011|       |                        from<JSON, decltype(wrapper)>::template op<ws_handled<Opts>()>(wrapper, ctx, it, end);
 3012|       |                        if (bool(ctx.error)) {
 3013|       |                           return;
 3014|       |                        }
 3015|       |                     }
 3016|       |                  }
 3017|  5.73k|                  ++it; // Increment after checking for missing keys so errors are within buffer bounds
 3018|  5.73k|                  if constexpr (not Opts.null_terminated) {
 3019|  5.73k|                     if (it == end) {
  ------------------
  |  Branch (3019:26): [True: 9, False: 5.72k]
  ------------------
 3020|      9|                        ctx.error = error_code::end_reached;
 3021|      9|                        return;
 3022|      9|                     }
 3023|  5.73k|                  }
 3024|  5.72k|                  return;
 3025|  5.73k|               }
 3026|  2.93M|               else if (first) {
  ------------------
  |  Branch (3026:25): [True: 71.3k, False: 2.86M]
  ------------------
 3027|  71.3k|                  first = false;
 3028|  71.3k|               }
 3029|  2.86M|               else {
 3030|  2.86M|                  if (match_invalid_end<',', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3030:23): [True: 1.58k, False: 2.86M]
  ------------------
 3031|  1.58k|                     return;
 3032|  1.58k|                  }
 3033|  2.86M|                  if constexpr (not Opts.null_terminated) {
 3034|  2.86M|                     if (it == end) [[unlikely]] {
  ------------------
  |  Branch (3034:26): [True: 0, False: 2.86M]
  ------------------
 3035|      0|                        ctx.error = error_code::unexpected_end;
 3036|      0|                        return;
 3037|      0|                     }
 3038|  2.86M|                  }
 3039|       |
 3040|       |                  if constexpr ((not Opts.minified) && (num_members > 1 || not Opts.error_on_unknown_keys) &&
 3041|       |                                (!Opts.comments)) {
 3042|       |                     if (ws_size && ws_size < size_t(end - it)) {
 3043|       |                        skip_matching_ws(ws_start, it, ws_size);
 3044|       |                     }
 3045|       |                  }
 3046|       |
 3047|  2.86M|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3047:23): [True: 12, False: 2.86M]
  ------------------
 3048|     12|                     return;
 3049|     12|                  }
 3050|  2.86M|               }
 3051|       |
 3052|  2.93M|               constexpr auto reflection_type = glaze_object_t<T> || reflectable<T>;
  ------------------
  |  Branch (3052:49): [Folded, False: 0]
  |  Branch (3052:70): [Folded, False: 0]
  ------------------
 3053|       |
 3054|       |               if constexpr (reflection_type && (num_members == 0)) {
 3055|       |                  if constexpr (Opts.error_on_unknown_keys) {
 3056|       |                     static_assert(false_v<T>, "This should be unreachable");
 3057|       |                  }
 3058|       |                  else {
 3059|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 3060|       |                        return;
 3061|       |                     }
 3062|       |
 3063|       |                     // parsing to an empty object, but at this point the JSON presents keys
 3064|       |
 3065|       |                     // Unknown key handler does not unescape keys. Unknown escaped keys are
 3066|       |                     // handled by the user.
 3067|       |
 3068|       |                     const auto start = it;
 3069|       |                     uint64_t ascii_acc{};
 3070|       |                     skip_string_view(ctx, it, end, ascii_acc);
 3071|       |                     if (bool(ctx.error)) [[unlikely]]
 3072|       |                        return;
 3073|       |                     if (validate_utf8_span<Opts>(ctx, start, it, ascii_acc)) [[unlikely]]
 3074|       |                        return;
 3075|       |                     const sv key{start, size_t(it - start)};
 3076|       |                     ++it;
 3077|       |                     if constexpr (not Opts.null_terminated) {
 3078|       |                        if (it == end) [[unlikely]] {
 3079|       |                           ctx.error = error_code::unexpected_end;
 3080|       |                           return;
 3081|       |                        }
 3082|       |                     }
 3083|       |
 3084|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3085|       |                        return;
 3086|       |                     }
 3087|       |
 3088|       |                     // Check if this key is the variant tag that should be skipped
 3089|       |                     if constexpr (not tag.sv().empty()) {
 3090|       |                        if (key == tag.sv()) {
 3091|       |                           // Skip the tag value
 3092|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3093|       |                           if (bool(ctx.error)) [[unlikely]]
 3094|       |                              return;
 3095|       |                           resync_window_end(ctx, end); // a streaming skip refills
 3096|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 3097|       |                              return;
 3098|       |                           }
 3099|       |                           continue;
 3100|       |                        }
 3101|       |                     }
 3102|       |
 3103|       |                     parse<JSON>::handle_unknown<Opts>(key, value, ctx, it, end);
 3104|       |                     if (bool(ctx.error)) [[unlikely]]
 3105|       |                        return;
 3106|       |                     if constexpr (not Opts.null_terminated) {
 3107|       |                        if (it == end) [[unlikely]] {
 3108|       |                           ctx.error = error_code::unexpected_end;
 3109|       |                           return;
 3110|       |                        }
 3111|       |                     }
 3112|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 3113|       |                        return;
 3114|       |                     }
 3115|       |                  }
 3116|       |               }
 3117|       |               else if constexpr (reflection_type) {
 3118|       |                  static_assert(bool(hash_info<T>.type));
 3119|       |
 3120|       |                  if (*it != '"') [[unlikely]] {
 3121|       |                     ctx.error = error_code::expected_quote;
 3122|       |                     return;
 3123|       |                  }
 3124|       |                  ++it;
 3125|       |                  if constexpr (not Opts.null_terminated) {
 3126|       |                     if (it == end) [[unlikely]] {
 3127|       |                        ctx.error = error_code::unexpected_end;
 3128|       |                        return;
 3129|       |                     }
 3130|       |                  }
 3131|       |
 3132|       |                  if constexpr (not tag.sv().empty() && not contains_tag<T, tag>()) {
 3133|       |                     // For tagged variants we first check to see if the key matches the tag
 3134|       |                     // We only need to do this if the tag is not part of the keys
 3135|       |
 3136|       |                     const auto start = it;
 3137|       |                     uint64_t ascii_acc{};
 3138|       |                     skip_string_view(ctx, it, end, ascii_acc);
 3139|       |                     if (bool(ctx.error)) [[unlikely]]
 3140|       |                        return;
 3141|       |                     if (validate_utf8_span<Opts>(ctx, start, it, ascii_acc)) [[unlikely]]
 3142|       |                        return;
 3143|       |                     const sv key{start, size_t(it - start)};
 3144|       |                     ++it;
 3145|       |                     if constexpr (not Opts.null_terminated) {
 3146|       |                        if (it == end) [[unlikely]] {
 3147|       |                           ctx.error = error_code::unexpected_end;
 3148|       |                           return;
 3149|       |                        }
 3150|       |                     }
 3151|       |
 3152|       |                     if (key == tag.sv()) {
 3153|       |                        if (parse_ws_colon<Opts>(ctx, it, end)) {
 3154|       |                           return;
 3155|       |                        }
 3156|       |
 3157|       |                        parse<JSON>::handle_unknown<Opts>(key, value, ctx, it, end);
 3158|       |                        if (bool(ctx.error)) [[unlikely]]
 3159|       |                           return;
 3160|       |
 3161|       |                        if (skip_ws<Opts>(ctx, it, end)) {
 3162|       |                           return;
 3163|       |                        }
 3164|       |                        continue;
 3165|       |                     }
 3166|       |                     else {
 3167|       |                        it = start; // reset the iterator
 3168|       |                     }
 3169|       |                  }
 3170|       |
 3171|       |                  if constexpr (Opts.error_on_missing_keys || Opts.partial_read) {
 3172|       |                     size_t index = num_members;
 3173|       |                     parse_and_invoke<Opts, T>(value, ctx, it, end, index);
 3174|       |                     if (bool(ctx.error)) [[unlikely]]
 3175|       |                        return;
 3176|       |                     if (index < num_members) {
 3177|       |                        fields[index] = true;
 3178|       |                     }
 3179|       |                  }
 3180|       |                  else {
 3181|       |                     parse_and_invoke<Opts, T>(value, ctx, it, end);
 3182|       |                     if (bool(ctx.error)) [[unlikely]]
 3183|       |                        return;
 3184|       |                  }
 3185|       |               }
 3186|  2.93M|               else {
 3187|       |                  // For types like std::map, std::unordered_map
 3188|       |
 3189|  2.93M|                  auto reading = [&](auto&& key) {
 3190|  2.93M|                     if constexpr (Opts.partial_read) {
 3191|  2.93M|                        if (auto element = value.find(key); element != value.end()) {
 3192|  2.93M|                           ++read_count;
 3193|  2.93M|                           parse<JSON>::op<ws_handled<Opts>()>(element->second, ctx, it, end);
 3194|  2.93M|                        }
 3195|  2.93M|                        else {
 3196|  2.93M|                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3197|  2.93M|                        }
 3198|  2.93M|                     }
 3199|  2.93M|                     else {
 3200|  2.93M|                        parse<JSON>::op<ws_handled<Opts>()>(value[key], ctx, it, end);
 3201|  2.93M|                     }
 3202|  2.93M|                  };
 3203|       |
 3204|       |                  // using Key = std::conditional_t<heterogeneous_map<T>, sv, typename T::key_type>;
 3205|  2.93M|                  using Key = typename T::key_type;
 3206|  2.93M|                  if constexpr (std::is_same_v<Key, std::string>) {
 3207|  2.93M|                     ctx.scratch.clear();
 3208|  2.93M|                     parse<JSON>::op<Opts>(ctx.scratch, ctx, it, end);
 3209|  2.93M|                     if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (3209:26): [True: 3.63k, False: 2.93M]
  ------------------
 3210|  3.63k|                        return;
 3211|       |
 3212|  2.93M|                     if (parse_ws_colon<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3212:26): [True: 2.80k, False: 2.92M]
  ------------------
 3213|  2.80k|                        return;
 3214|  2.80k|                     }
 3215|       |
 3216|  2.92M|                     reading(ctx.scratch);
 3217|       |                     if constexpr (Opts.partial_read) {
 3218|       |                        if (read_count == value.size()) {
 3219|       |                           return;
 3220|       |                        }
 3221|       |                     }
 3222|  2.92M|                     if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (3222:26): [True: 62.8k, False: 2.86M]
  ------------------
 3223|  62.8k|                        return;
 3224|       |                  }
 3225|       |                  else if constexpr (str_t<Key>) {
 3226|       |                     Key key;
 3227|       |                     parse<JSON>::op<Opts>(key, ctx, it, end);
 3228|       |                     if (bool(ctx.error)) [[unlikely]]
 3229|       |                        return;
 3230|       |
 3231|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3232|       |                        return;
 3233|       |                     }
 3234|       |
 3235|       |                     reading(key);
 3236|       |                     if constexpr (Opts.partial_read) {
 3237|       |                        if (read_count == value.size()) {
 3238|       |                           return;
 3239|       |                        }
 3240|       |                     }
 3241|       |                     if (bool(ctx.error)) [[unlikely]]
 3242|       |                        return;
 3243|       |                  }
 3244|       |                  else {
 3245|       |                     Key key_value{};
 3246|       |                     if constexpr (is_named_enum<Key> || mimics_str_t<Key>) {
 3247|       |                        parse<JSON>::op<Opts>(key_value, ctx, it, end);
 3248|       |                     }
 3249|       |                     else if constexpr (std::is_arithmetic_v<Key>) {
 3250|       |                        // prefer over quoted_t below to avoid double parsing of quoted_t
 3251|       |                        parse<JSON>::op<opt_true<Opts, quoted_num_opt_tag{}>>(key_value, ctx, it, end);
 3252|       |                     }
 3253|       |                     else {
 3254|       |                        parse<JSON>::op<opt_false<Opts, raw_string_opt_tag{}>>(quoted_t<Key>{key_value}, ctx, it, end);
 3255|       |                     }
 3256|       |                     if (bool(ctx.error)) [[unlikely]]
 3257|       |                        return;
 3258|       |
 3259|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 3260|       |                        return;
 3261|       |                     }
 3262|       |
 3263|       |                     reading(key_value);
 3264|       |                     if constexpr (Opts.partial_read) {
 3265|       |                        if (read_count == value.size()) {
 3266|       |                           return;
 3267|       |                        }
 3268|       |                     }
 3269|       |                     if (bool(ctx.error)) [[unlikely]]
 3270|       |                        return;
 3271|       |                  }
 3272|  2.93M|               }
 3273|       |
 3274|       |               // Streaming refill point: after parsing each key-value pair, refill if buffer is low
 3275|       |               if constexpr (has_streaming_state<decltype(ctx)>) {
 3276|       |                  if (ctx.stream.enabled()) {
 3277|       |                     const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 3278|       |                     // Refill when less than 25% of buffer remains to ensure enough space for next element
 3279|       |                     if (ctx.stream.size() - consumed <= ctx.stream.size() / 4 || it >= end) {
 3280|       |                        const char* new_it;
 3281|       |                        const char* new_end;
 3282|       |                        ctx.stream.consume_and_refill(consumed, new_it, new_end);
 3283|       |                        it = new_it;
 3284|       |                        end = new_end;
 3285|       |                        if (it >= end && ctx.stream.at_eof()) {
 3286|       |                           ctx.error = error_code::unexpected_end;
 3287|       |                           return;
 3288|       |                        }
 3289|       |                     }
 3290|       |                  }
 3291|       |               }
 3292|       |
 3293|  2.93M|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3293:20): [True: 354, False: 2.93M]
  ------------------
 3294|    354|                  return;
 3295|    354|               }
 3296|  2.93M|            }
 3297|  76.9k|         }
 3298|  76.9k|      }
_ZZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_ENKUlvE_clEv:
 2895|  76.9k|            decltype(auto) fields = [&]() -> decltype(auto) {
 2896|       |               if constexpr ((glaze_object_t<T> || reflectable<T>) &&
 2897|       |                             (Opts.error_on_missing_keys || Opts.partial_read)) {
 2898|       |                  return bit_array<num_members>{};
 2899|       |               }
 2900|  76.9k|               else {
 2901|  76.9k|                  return nullptr;
 2902|  76.9k|               }
 2903|  76.9k|            }();
_ZZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_ENKUlvE1_clEv:
 2931|  76.9k|               ctx, [&]() -> void* {
 2932|       |                  if constexpr (tracks_include_keys) {
 2933|       |                     return &fields;
 2934|       |                  }
 2935|  76.9k|                  else {
 2936|  76.9k|                     return nullptr;
 2937|  76.9k|                  }
 2938|  76.9k|               }()};
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEETkNS_10is_contextERNS_7contextERPKcSF_EEvOT0_OT1_OT2_T3_:
   49|  2.93M|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  2.93M|         else {
   60|  2.93M|            using V = std::remove_cvref_t<T>;
   61|  2.93M|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  2.93M|                                             end);
   63|  2.93M|         }
   64|  2.93M|      }
_ZN3glz4fromILj10ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERPKcSC_S7_TkNS_10is_contextERNS_7contextEEEvRT2_OT3_OT0_T1_:
  887|  2.93M|      {
  888|       |         if constexpr (check_string_as_number(Opts)) {
  889|       |            auto start = it;
  890|       |            skip_number<Opts>(ctx, it, end);
  891|       |            if (bool(ctx.error)) [[unlikely]] {
  892|       |               return;
  893|       |            }
  894|       |            if (start == it) [[unlikely]] {
  895|       |               ctx.error = error_code::parse_number_failure;
  896|       |               return;
  897|       |            }
  898|       |            value.append(start, size_t(it - start));
  899|       |         }
  900|  2.93M|         else {
  901|  2.93M|            if constexpr (!check_opening_handled(Opts)) {
  902|  2.93M|               if constexpr (!check_ws_handled(Opts)) {
  903|  2.93M|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (903:23): [True: 0, False: 2.93M]
  ------------------
  904|      0|                     return;
  905|      0|                  }
  906|  2.93M|               }
  907|       |
  908|  2.93M|               if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (908:20): [True: 984, False: 2.93M]
  ------------------
  909|    984|                  return;
  910|    984|               }
  911|  2.93M|            }
  912|       |
  913|  2.93M|            if constexpr (not check_raw_string(Opts)) {
  914|  2.93M|               static constexpr auto string_padding_bytes = 8;
  915|       |
  916|       |               // How much buffer has to remain for an eight byte load at the cursor to stay inside
  917|       |               // it. One on a padded input, where the last chunk is free to straddle the end of the
  918|       |               // document, so the byte tails below are unreachable; eight otherwise, which costs the
  919|       |               // final bytes of the buffer their chunked path and nothing else.
  920|  2.93M|               const std::ptrdiff_t scan_min = chunk_min<8>(ctx.padded_input);
  921|       |
  922|  2.93M|               if (size_t(end - it) >= 8) {
  ------------------
  |  Branch (922:20): [True: 2.92M, False: 10.0k]
  ------------------
  923|       |                  // The bound as a pointer, so the loops below spend a compare per chunk rather
  924|       |                  // than a subtract and a compare. Well defined here and nowhere else in this
  925|       |                  // reader: the branch has just established that at least eight bytes remain, and
  926|       |                  // `scan_min` is at most eight.
  927|  2.92M|                  const auto* const chunk_limit = end - scan_min;
  928|       |
  929|  2.92M|                  auto start = it;
  930|  2.92M|                  uint64_t ascii_acc{};
  931|  12.8M|                  while (it <= chunk_limit) {
  ------------------
  |  Branch (931:26): [True: 12.8M, False: 1.51k]
  ------------------
  932|  12.8M|                     uint64_t chunk;
  933|  12.8M|                     std::memcpy(&chunk, it, 8);
  934|       |                     if constexpr (std::endian::native == std::endian::big) {
  935|       |                        chunk = std::byteswap(chunk);
  936|       |                     }
  937|  12.8M|                     ascii_acc |= chunk;
  938|  12.8M|                     const uint64_t test_chars = has_quote(chunk);
  939|  12.8M|                     if (test_chars) {
  ------------------
  |  Branch (939:26): [True: 2.92M, False: 9.96M]
  ------------------
  940|  2.92M|                        it += (countr_zero(test_chars) >> 3);
  941|       |
  942|  2.92M|                        auto* prev = it - 1;
  943|  2.92M|                        while (*prev == '\\') {
  ------------------
  |  Branch (943:32): [True: 2.57k, False: 2.92M]
  ------------------
  944|  2.57k|                           --prev;
  945|  2.57k|                        }
  946|  2.92M|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (946:29): [True: 2.92M, False: 873]
  ------------------
  947|  2.92M|                           goto continue_decode;
  948|  2.92M|                        }
  949|    873|                        ++it; // skip the escaped quote
  950|    873|                     }
  951|  9.96M|                     else {
  952|  9.96M|                        it += 8;
  953|  9.96M|                     }
  954|  12.8M|                  }
  955|       |
  956|  2.87k|                  while (it[-1] == '\\') [[unlikely]] {
  ------------------
  |  Branch (956:26): [True: 1.36k, False: 1.51k]
  ------------------
  957|       |                     // if we ended on an escape character then we need to rewind
  958|       |                     // because we lost our context
  959|  1.36k|                     --it;
  960|  1.36k|                  }
  961|       |
  962|       |                  // The byte-wise tail keeps feeding the accumulator: it has to cover every byte of
  963|       |                  // the string, or a non-ASCII byte reached here would be waved through unvalidated.
  964|  5.66k|                  for (; it < end; ++it) {
  ------------------
  |  Branch (964:26): [True: 5.34k, False: 315]
  ------------------
  965|  5.34k|                     ascii_acc |= uint8_t(*it);
  966|  5.34k|                     if (*it == '"') {
  ------------------
  |  Branch (966:26): [True: 1.24k, False: 4.10k]
  ------------------
  967|  1.24k|                        auto* prev = it - 1;
  968|  2.25k|                        while (*prev == '\\') {
  ------------------
  |  Branch (968:32): [True: 1.01k, False: 1.24k]
  ------------------
  969|  1.01k|                           --prev;
  970|  1.01k|                        }
  971|  1.24k|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (971:29): [True: 1.19k, False: 43]
  ------------------
  972|  1.19k|                           goto continue_decode;
  973|  1.19k|                        }
  974|  1.24k|                     }
  975|  5.34k|                  }
  976|       |
  977|    315|                  ctx.error = error_code::unexpected_end;
  978|    315|                  return;
  979|       |
  980|  2.92M|               continue_decode:
  981|       |
  982|  2.92M|                  if (validate_utf8_span<Opts>(ctx, start, it, ascii_acc)) [[unlikely]] {
  ------------------
  |  Branch (982:23): [True: 335, False: 2.92M]
  ------------------
  983|    335|                     return;
  984|    335|                  }
  985|       |
  986|  2.92M|                  auto n = size_t(it - start);
  987|       |
  988|       |                  // The padding lets the chunked copy below run up to the closing quote. Skip it when it
  989|       |                  // would be the only reason to allocate, as for a string that fits the small string
  990|       |                  // buffer but not with eight bytes to spare.
  991|  2.92M|                  bool pad = true;
  992|  2.92M|                  if constexpr (requires { value.capacity(); }) {
  993|  2.92M|                     const auto capacity = size_t(value.capacity());
  994|  2.92M|                     pad = capacity >= n + string_padding_bytes || capacity < n;
  ------------------
  |  Branch (994:28): [True: 2.90M, False: 16.5k]
  |  Branch (994:68): [True: 4.86k, False: 11.6k]
  ------------------
  995|  2.92M|                  }
  996|  2.92M|                  resize_unfilled(value, pad ? n + string_padding_bytes : n);
  ------------------
  |  Branch (996:42): [True: 2.91M, False: 11.6k]
  ------------------
  997|       |
  998|  2.92M|                  auto* p = value.data();
  999|       |
 1000|       |                  // An error below returns with the tail of `value` still unwritten. Leave the size at
 1001|       |                  // what was actually written rather than at the padded length, which resize_unfilled
 1002|       |                  // did not fill.
 1003|  2.92M|                  auto* const written_begin = p;
 1004|       |
 1005|       |                  // Without the padding, copy a chunk only while eight bytes remain before the quote.
 1006|       |                  // Unescaping never puts the output ahead of the input, so no store lands past the end.
 1007|  2.92M|                  const auto* const copy_end = pad ? it : it - (std::min)(n, size_t(7));
  ------------------
  |  Branch (1007:48): [True: 2.91M, False: 11.6k]
  ------------------
 1008|       |
 1009|       |                  // Copy eight bytes at a time for as long as eight bytes are there to read, then
 1010|       |                  // finish the span below. The chunked form reads past the character it is looking
 1011|       |                  // at, so on an unpadded buffer it has to stop short of the end; splitting it this
 1012|       |                  // way keeps it for the body of every string rather than giving it up whenever the
 1013|       |                  // string happens to finish near the end of the buffer -- which, for a document
 1014|       |                  // that is itself one string, is every string.
 1015|  14.2M|                  while (start < copy_end && start <= chunk_limit) {
  ------------------
  |  Branch (1015:26): [True: 11.3M, False: 2.91M]
  |  Branch (1015:46): [True: 11.3M, False: 505]
  ------------------
 1016|  11.3M|                     std::memcpy(p, start, 8);
 1017|  11.3M|                     uint64_t swar;
 1018|  11.3M|                     std::memcpy(&swar, p, 8);
 1019|       |                     if constexpr (std::endian::native == std::endian::big) {
 1020|       |                        swar = std::byteswap(swar);
 1021|       |                     }
 1022|       |
 1023|  11.3M|                     constexpr uint64_t lo7_mask = repeat_byte8(0b01111111);
 1024|  11.3M|                     const uint64_t lo7 = swar & lo7_mask;
 1025|  11.3M|                     const uint64_t backslash = (lo7 ^ repeat_byte8('\\')) + lo7_mask;
 1026|  11.3M|                     const uint64_t less_32 = (swar & repeat_byte8(0b01100000)) + lo7_mask;
 1027|  11.3M|                     uint64_t next = ~((backslash & less_32) | swar);
 1028|       |
 1029|  11.3M|                     next &= repeat_byte8(0b10000000);
 1030|  11.3M|                     if (next == 0) {
  ------------------
  |  Branch (1030:26): [True: 11.2M, False: 62.6k]
  ------------------
 1031|  11.2M|                        start += 8;
 1032|  11.2M|                        p += 8;
 1033|  11.2M|                        continue;
 1034|  11.2M|                     }
 1035|       |
 1036|  62.6k|                     next = countr_zero(next) >> 3;
 1037|  62.6k|                     start += next;
 1038|  62.6k|                     if (start >= it) {
  ------------------
  |  Branch (1038:26): [True: 6.81k, False: 55.8k]
  ------------------
 1039|  6.81k|                        break;
 1040|  6.81k|                     }
 1041|       |
 1042|  55.8k|                     if ((*start & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1042:26): [True: 217, False: 55.6k]
  ------------------
 1043|    217|                        ctx.error = error_code::syntax_error;
 1044|    217|                        value.resize(size_t(p - written_begin));
 1045|    217|                        return;
 1046|    217|                     }
 1047|  55.6k|                     ++start; // skip the escape
 1048|  55.6k|                     if (*start == 'u') {
  ------------------
  |  Branch (1048:26): [True: 48.1k, False: 7.49k]
  ------------------
 1049|  48.1k|                        ++start;
 1050|  48.1k|                        p += next;
 1051|  48.1k|                        const auto mark = start;
 1052|  48.1k|                        const auto decoded = handle_unicode_code_point(start, p, end);
 1053|  48.1k|                        if (decoded.written == 0) [[unlikely]] {
  ------------------
  |  Branch (1053:29): [True: 279, False: 47.8k]
  ------------------
 1054|    279|                           ctx.error = decoded.truncated ? error_code::unexpected_end
  ------------------
  |  Branch (1054:40): [True: 0, False: 279]
  ------------------
 1055|    279|                                                         : error_code::unicode_escape_conversion_failure;
 1056|    279|                           value.resize(size_t(p - written_begin));
 1057|    279|                           return;
 1058|    279|                        }
 1059|  47.8k|                        n += decoded.written;
 1060|       |                        // escape + u + unicode code points
 1061|  47.8k|                        n -= 2 + uint32_t(start - mark);
 1062|  47.8k|                     }
 1063|  7.49k|                     else {
 1064|  7.49k|                        p += next;
 1065|  7.49k|                        *p = char_unescape_table[uint8_t(*start)];
 1066|  7.49k|                        if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1066:29): [True: 28, False: 7.46k]
  ------------------
 1067|     28|                           ctx.error = error_code::invalid_escape;
 1068|     28|                           value.resize(size_t(p - written_begin));
 1069|     28|                           return;
 1070|     28|                        }
 1071|  7.46k|                        ++p;
 1072|  7.46k|                        ++start;
 1073|  7.46k|                        --n;
 1074|  7.46k|                     }
 1075|  55.6k|                  }
 1076|       |
 1077|       |                  // Whatever the chunked copy could not reach. `p` and `start` stay in step across
 1078|       |                  // that loop, so this picks up exactly where it stopped.
 1079|  2.95M|                  while (start < it) {
  ------------------
  |  Branch (1079:26): [True: 35.7k, False: 2.92M]
  ------------------
 1080|  35.7k|                     if ((*start & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1080:26): [True: 10, False: 35.7k]
  ------------------
 1081|     10|                        ctx.error = error_code::syntax_error;
 1082|     10|                        value.resize(size_t(p - written_begin));
 1083|     10|                        return;
 1084|     10|                     }
 1085|  35.7k|                     if (*start == '\\') {
  ------------------
  |  Branch (1085:26): [True: 2.88k, False: 32.8k]
  ------------------
 1086|  2.88k|                        ++start; // skip the escape
 1087|  2.88k|                        if (*start == 'u') {
  ------------------
  |  Branch (1087:29): [True: 2.14k, False: 736]
  ------------------
 1088|  2.14k|                           ++start;
 1089|  2.14k|                           const auto mark = start;
 1090|  2.14k|                           const auto decoded = handle_unicode_code_point(start, p, end);
 1091|  2.14k|                           if (decoded.written == 0) [[unlikely]] {
  ------------------
  |  Branch (1091:32): [True: 142, False: 2.00k]
  ------------------
 1092|    142|                              ctx.error = decoded.truncated ? error_code::unexpected_end
  ------------------
  |  Branch (1092:43): [True: 0, False: 142]
  ------------------
 1093|    142|                                                            : error_code::unicode_escape_conversion_failure;
 1094|    142|                              value.resize(size_t(p - written_begin));
 1095|    142|                              return;
 1096|    142|                           }
 1097|  2.00k|                           n += decoded.written;
 1098|  2.00k|                           n -= 2 + uint32_t(start - mark);
 1099|  2.00k|                        }
 1100|    736|                        else {
 1101|    736|                           *p = char_unescape_table[uint8_t(*start)];
 1102|    736|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1102:32): [True: 28, False: 708]
  ------------------
 1103|     28|                              ctx.error = error_code::invalid_escape;
 1104|     28|                              value.resize(size_t(p - written_begin));
 1105|     28|                              return;
 1106|     28|                           }
 1107|    708|                           ++p;
 1108|    708|                           ++start;
 1109|    708|                           --n;
 1110|    708|                        }
 1111|  2.88k|                     }
 1112|  32.8k|                     else {
 1113|  32.8k|                        *p = *start;
 1114|  32.8k|                        ++p;
 1115|  32.8k|                        ++start;
 1116|  32.8k|                     }
 1117|  35.7k|                  }
 1118|       |
 1119|  2.92M|                  value.resize(n);
 1120|  2.92M|                  ++it;
 1121|  2.92M|               }
 1122|  10.0k|               else {
 1123|       |                  // For short strings
 1124|       |
 1125|  10.0k|                  std::array<char, 8> buffer{};
 1126|       |
 1127|  10.0k|                  auto* p = buffer.data();
 1128|  10.0k|                  const auto* const utf8_start = it;
 1129|       |
 1130|  18.4k|                  while (it < end) [[likely]] {
  ------------------
  |  Branch (1130:26): [True: 17.3k, False: 1.14k]
  ------------------
 1131|  17.3k|                     *p = *it;
 1132|  17.3k|                     if (*it == '"') {
  ------------------
  |  Branch (1132:26): [True: 8.08k, False: 9.25k]
  ------------------
 1133|  8.08k|                        if (validate_utf8_span<Opts>(ctx, utf8_start, it)) [[unlikely]] {
  ------------------
  |  Branch (1133:29): [True: 208, False: 7.87k]
  ------------------
 1134|    208|                           return;
 1135|    208|                        }
 1136|  7.87k|                        const size_t n = size_t(p - buffer.data());
 1137|  7.87k|#if __has_cpp_attribute(assume) >= 202207L
 1138|  7.87k|                        [[assume(n <= sizeof(buffer))]];
 1139|  7.87k|#endif
 1140|  7.87k|                        value.assign(buffer.data(), n);
 1141|  7.87k|                        ++it;
 1142|  7.87k|                        if constexpr (not Opts.null_terminated) {
 1143|  7.87k|                           if (it == end) {
  ------------------
  |  Branch (1143:32): [True: 154, False: 7.71k]
  ------------------
 1144|    154|                              ctx.error = error_code::end_reached;
 1145|    154|                              return;
 1146|    154|                           }
 1147|  7.87k|                        }
 1148|  7.71k|                        return;
 1149|  8.08k|                     }
 1150|  9.25k|                     else if (*it == '\\') {
  ------------------
  |  Branch (1150:31): [True: 361, False: 8.89k]
  ------------------
 1151|       |                        // Bounded whatever `null_terminated` says: a document cut off inside an
 1152|       |                        // escape has run out of input, and saying so beats blaming the terminator
 1153|       |                        // the cut exposed -- which is what reading on would find, and would report
 1154|       |                        // as a malformed escape.
 1155|    361|                        ++it; // skip the escape
 1156|    361|                        if (it == end) [[unlikely]] {
  ------------------
  |  Branch (1156:29): [True: 3, False: 358]
  ------------------
 1157|      3|                           ctx.error = error_code::unexpected_end;
 1158|      3|                           return;
 1159|      3|                        }
 1160|    358|                        if (*it == 'u') {
  ------------------
  |  Branch (1160:29): [True: 250, False: 108]
  ------------------
 1161|    250|                           ++it;
 1162|    250|                           if (it == end) [[unlikely]] {
  ------------------
  |  Branch (1162:32): [True: 1, False: 249]
  ------------------
 1163|      1|                              ctx.error = error_code::unexpected_end;
 1164|      1|                              return;
 1165|      1|                           }
 1166|    249|                           const auto decoded = handle_unicode_code_point(it, p, end);
 1167|    249|                           if (decoded.written == 0) [[unlikely]] {
  ------------------
  |  Branch (1167:32): [True: 123, False: 126]
  ------------------
 1168|    123|                              ctx.error = decoded.truncated ? error_code::unexpected_end
  ------------------
  |  Branch (1168:43): [True: 51, False: 72]
  ------------------
 1169|    123|                                                            : error_code::unicode_escape_conversion_failure;
 1170|    123|                              return;
 1171|    123|                           }
 1172|    249|                        }
 1173|    108|                        else {
 1174|    108|                           *p = char_unescape_table[uint8_t(*it)];
 1175|    108|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1175:32): [True: 19, False: 89]
  ------------------
 1176|     19|                              ctx.error = error_code::invalid_escape;
 1177|     19|                              return;
 1178|     19|                           }
 1179|     89|                           ++p;
 1180|     89|                           ++it;
 1181|     89|                        }
 1182|    358|                     }
 1183|  8.89k|                     else if ((*it & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1183:31): [True: 631, False: 8.25k]
  ------------------
 1184|    631|                        ctx.error = error_code::syntax_error;
 1185|    631|                        return;
 1186|    631|                     }
 1187|  8.25k|                     else {
 1188|  8.25k|                        ++it;
 1189|  8.25k|                        ++p;
 1190|  8.25k|                     }
 1191|  17.3k|                  }
 1192|       |
 1193|  1.14k|                  ctx.error = error_code::unexpected_end;
 1194|  1.14k|               }
 1195|       |            }
 1196|       |            else {
 1197|       |               // raw_string
 1198|       |               auto start = it;
 1199|       |               skip_string_view(ctx, it, end);
 1200|       |               if (bool(ctx.error)) [[unlikely]]
 1201|       |                  return;
 1202|       |
 1203|       |               if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]] {
 1204|       |                  return;
 1205|       |               }
 1206|       |
 1207|       |               value.assign(start, size_t(it - start));
 1208|       |               ++it;
 1209|       |            }
 1210|  2.93M|         }
 1211|  2.93M|      }
_ZN3glz14parse_ws_colonITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextENS_7contextERPKcS4_EEbRT0_OT1_T2_:
  159|  2.93M|   {
  160|  2.93M|      if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (160:11): [True: 145, False: 2.93M]
  ------------------
  161|    145|         return true;
  162|    145|      }
  163|  2.93M|      if (match_invalid_end<':', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (163:11): [True: 2.63k, False: 2.92M]
  ------------------
  164|  2.63k|         return true;
  165|  2.63k|      }
  166|  2.92M|      if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (166:11): [True: 24, False: 2.92M]
  ------------------
  167|     24|         return true;
  168|     24|      }
  169|  2.92M|      return false;
  170|  2.92M|   }
_ZZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_ENKUlOT_E_clIRNSt3__112basic_stringIcNSS_11char_traitsIcEENSS_9allocatorIcEEEEEEDaSP_:
 3189|  2.92M|                  auto reading = [&](auto&& key) {
 3190|       |                     if constexpr (Opts.partial_read) {
 3191|       |                        if (auto element = value.find(key); element != value.end()) {
 3192|       |                           ++read_count;
 3193|       |                           parse<JSON>::op<ws_handled<Opts>()>(element->second, ctx, it, end);
 3194|       |                        }
 3195|       |                        else {
 3196|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3197|       |                        }
 3198|       |                     }
 3199|  2.92M|                     else {
 3200|  2.92M|                        parse<JSON>::op<ws_handled<Opts>()>(value[key], ctx, it, end);
 3201|  2.92M|                     }
 3202|  2.92M|                  };
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERNS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
   49|  7.75M|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  7.75M|         else {
   60|  7.75M|            using V = std::remove_cvref_t<T>;
   61|  7.75M|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  7.75M|                                             end);
   63|  7.75M|         }
   64|  7.75M|      }
_ZN3glz4fromILj10ENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERS4_TkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
  150|  7.75M|      {
  151|  7.75M|         using V = std::decay_t<decltype(get_member(std::declval<Value>(), meta_wrapper_v<T>))>;
  152|  7.75M|         from<JSON, V>::template op<Opts>(get_member(std::forward<Value>(value), meta_wrapper_v<T>),
  153|  7.75M|                                          std::forward<Ctx>(ctx), std::forward<It0>(it), end);
  154|  7.75M|      }
_ZN3glz4fromILj10ENSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERSH_TkNS_10is_contextERNS_7contextERPKcSP_EEvOT0_OT1_OT2_T3_:
 3860|  7.75M|      {
 3861|       |         if constexpr (tagging == variant_tagging_kind::adjacent) {
 3862|       |            read_adjacent<Options>(value, ctx, it, end);
 3863|       |         }
 3864|  7.75M|         else {
 3865|  7.75M|            read_deduced<Options>(value, ctx, it, end);
 3866|  7.75M|         }
 3867|  7.75M|      }
_ZN3glz4fromILj10ENSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEEE12read_deducedITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERSH_TkNS_10is_contextERNS_7contextERPKcSP_EEvOT0_OT1_OT2_T3_:
 3871|  7.75M|      {
 3872|  7.75M|         constexpr auto Opts = ws_handled_off<Options>();
 3873|  7.75M|         if constexpr (variant_is_auto_deducible<T>()) {
 3874|       |            if constexpr (not check_ws_handled(Options)) {
 3875|       |               if (skip_ws<Opts>(ctx, it, end)) {
 3876|       |                  return;
 3877|       |               }
 3878|       |            }
 3879|       |
 3880|  7.75M|            switch (*it) {
 3881|  3.80k|            case '\0':
  ------------------
  |  Branch (3881:13): [True: 3.80k, False: 7.75M]
  ------------------
 3882|  3.80k|               ctx.error = error_code::unexpected_end;
 3883|  3.80k|               return;
 3884|  62.1k|            case '{': {
  ------------------
  |  Branch (3884:13): [True: 62.1k, False: 7.69M]
  ------------------
 3885|       |               // This branch consumes the brace itself and hands the object to a reader with
 3886|       |               // `opening_handled`, which therefore does not count the level -- but does release it at
 3887|       |               // the closing brace. So the level is taken here, in both buffer modes, and paid back by
 3888|       |               // the reader below.
 3889|  62.1k|               if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (3889:20): [True: 21, False: 62.0k]
  ------------------
 3890|     21|                  return;
 3891|     21|               }
 3892|       |
 3893|  62.0k|               ++it;
 3894|  62.0k|               if constexpr (not Opts.null_terminated) {
 3895|  62.0k|                  if (it == end) [[unlikely]] {
  ------------------
  |  Branch (3895:23): [True: 67, False: 62.0k]
  ------------------
 3896|     67|                     ctx.error = error_code::unexpected_end;
 3897|     67|                     return;
 3898|     67|                  }
 3899|  62.0k|               }
 3900|  62.0k|               using type_counts = variant_type_count<T>;
 3901|  62.0k|               constexpr auto n_object_candidates = variant_object_candidate_count_v<Opts, T>;
 3902|       |               if constexpr (n_object_candidates < 1) {
 3903|       |                  ctx.error = error_code::no_matching_variant_type;
 3904|       |                  return;
 3905|       |               }
 3906|  62.0k|               else if constexpr (n_object_candidates == 1 && tag_v<T>.empty()) {
 3907|  62.0k|                  constexpr auto first_idx = variant_first_object_candidate_v<Opts, T>;
 3908|  62.0k|                  using V = std::variant_alternative_t<first_idx, T>;
 3909|  62.0k|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (3909:23): [True: 60.0k, False: 2.09k]
  ------------------
 3910|  62.0k|                  parse<JSON>::op<opening_handled<Opts>()>(std::get<V>(value), ctx, it, end);
 3911|  62.0k|                  return;
 3912|       |               }
 3913|       |               else {
 3914|       |                  auto possible_types = bit_array<std::variant_size_v<T>>{}.flip();
 3915|       |                  static constexpr auto& deduction_bits = variant_deduction_bits<T>;
 3916|       |                  static constexpr size_t deduction_key_count = variant_deduction_key_count<T>;
 3917|       |                  static constexpr auto tag_literal = string_literal_from_view<tag_v<T>.size()>(tag_v<T>);
 3918|       |
 3919|       |                  // Track if we've encountered a tag and what value it had
 3920|       |                  std::optional<size_t> tag_specified_index{};
 3921|       |
 3922|       |                  if (skip_ws<Opts>(ctx, it, end)) {
 3923|       |                     return;
 3924|       |                  }
 3925|       |                  // Once the reader knows which alternative this object holds it may have to read
 3926|       |                  // it again from here. Anchor the position rather than keep the pointer: the scan
 3927|       |                  // below skips values, and a streaming skip refills, which moves the window out
 3928|       |                  // from under a raw pointer (see rewind_anchor).
 3929|       |                  auto start = make_rewind_anchor(ctx, it);
 3930|       |                  bool first_key = true;
 3931|       |                  // Parse bifurcation for tagged variants:
 3932|       |                  //
 3933|       |                  // Without this optimization, tagged variant parsing always uses two passes:
 3934|       |                  //   1. Scan all keys to find the tag (e.g. "type"), skipping values
 3935|       |                  //   2. Reset `it = start` and re-parse the entire object into the resolved type
 3936|       |                  //
 3937|       |                  // When the tag is the first key, the second pass redundantly re-reads every
 3938|       |                  // field that follows it. This lambda avoids that: if the tag was the first key,
 3939|       |                  // it advances past the trailing comma so the object parser picks up at the
 3940|       |                  // second field. If the tag was found later, it falls back to the full re-parse.
 3941|       |                  //
 3942|       |                  // One exception: if the tag name is also a field on the resolved struct
 3943|       |                  // (contains_tag), we must re-parse regardless so the value is stored in
 3944|       |                  // the struct field. This override is applied inside each std::visit lambda.
 3945|       |                  //
 3946|       |                  // Either way the rewind can fail under a streaming read: the window only holds so
 3947|       |                  // much, and an object wider than it has no start left to return to.
 3948|       |                  auto position_after_tag = [&] {
 3949|       |                     if (first_key) {
 3950|       |                        if (*it == ',') ++it; // skip comma; handles tag-only objects where *it == '}'
 3951|       |                        return true;
 3952|       |                     }
 3953|       |                     return start.rewind(ctx, it, end); // tag came later, re-parse from the beginning
 3954|       |                  };
 3955|       |                  // `first_key` also answers "were we reset to the object start", which is what
 3956|       |                  // position_after_tag does for every key but the first.
 3957|       |                  for (; *it != '}'; first_key = false) {
 3958|       |                     if (!first_key) {
 3959|       |                        if (match_invalid_end<',', Opts>(ctx, it, end)) {
 3960|       |                           return;
 3961|       |                        }
 3962|       |                     }
 3963|       |
 3964|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 3965|       |                        return;
 3966|       |                     }
 3967|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 3968|       |                        return;
 3969|       |                     }
 3970|       |
 3971|       |                     auto* key_start = it;
 3972|       |                     skip_string_view(ctx, it, end);
 3973|       |                     if (bool(ctx.error)) [[unlikely]]
 3974|       |                        return;
 3975|       |                     if (validate_utf8_span<Opts>(ctx, key_start, it)) [[unlikely]]
 3976|       |                        return;
 3977|       |                     const sv key = {key_start, size_t(it - key_start)};
 3978|       |
 3979|       |                     if (match_invalid_end<'"', Opts>(ctx, it, end)) {
 3980|       |                        return;
 3981|       |                     }
 3982|       |
 3983|       |                     if constexpr (deduction_key_count > 0) {
 3984|       |                        // We first check if a tag is defined and see if the key matches the tag
 3985|       |                        if constexpr (not tag_v<T>.empty()) {
 3986|       |                           if (key == tag_v<T>) {
 3987|       |                              if (parse_ws_colon<Opts>(ctx, it, end)) {
 3988|       |                                 return;
 3989|       |                              }
 3990|       |
 3991|       |                              using id_type = std::decay_t<decltype(ids_v<T>[0])>;
 3992|       |
 3993|       |                              std::conditional_t<std::integral<id_type>, id_type, sv> type_id{};
 3994|       |                              if constexpr (std::integral<id_type>) {
 3995|       |                                 from<JSON, id_type>::template op<ws_handled<Opts>()>(type_id, ctx, it, end);
 3996|       |                              }
 3997|       |                              else {
 3998|       |                                 // The id is turned into an index below and never leaves this
 3999|       |                                 // reader, so the view of the window it borrows cannot outlive it.
 4000|       |                                 parse_transient_string_view<ws_handled<Opts>()>(type_id, ctx, it, end);
 4001|       |                              }
 4002|       |                              if (bool(ctx.error)) [[unlikely]]
 4003|       |                                 return;
 4004|       |                              if (skip_ws<Opts>(ctx, it, end)) {
 4005|       |                                 return;
 4006|       |                              }
 4007|       |                              if (!(*it == ',' || *it == '}')) [[unlikely]] {
 4008|       |                                 ctx.error = error_code::syntax_error;
 4009|       |                                 return;
 4010|       |                              }
 4011|       |
 4012|       |                              size_t type_index;
 4013|       |                              if constexpr (std::integral<id_type>) {
 4014|       |                                 type_index = variant_id_to_index<T>::op(type_id);
 4015|       |                              }
 4016|       |                              else {
 4017|       |                                 type_index = variant_id_to_index<T>::op(
 4018|       |                                    type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4019|       |                              }
 4020|       |                              if (type_index < ids_v<T>.size()) [[likely]] {
 4021|       |                                 // Check if the deduced types include the tag-specified type
 4022|       |                                 // If not, the tag doesn't match the fields
 4023|       |                                 // We're already inside if constexpr (deduction_registry.size()), so we know deduction
 4024|       |                                 // is happening. At this point, possible_types has been narrowed by field deduction.
 4025|       |                                 // Check if the tag-specified type is still possible
 4026|       |                                 const bool type_is_possible = possible_types[type_index];
 4027|       |                                 if (!type_is_possible) {
 4028|       |                                    // Tag specifies a type that doesn't match the fields seen so far
 4029|       |                                    ctx.error = error_code::no_matching_variant_type;
 4030|       |                                    return;
 4031|       |                                 }
 4032|       |
 4033|       |                                 if (!position_after_tag()) return;
 4034|       |                                 tag_specified_index = type_index; // Store the tag-specified type
 4035|       |                                 if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4036|       |                                 std::visit(
 4037|       |                                    [&](auto&& v) {
 4038|       |                                       using V = std::decay_t<decltype(v)>;
 4039|       |                                       constexpr bool is_object =
 4040|       |                                          (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4041|       |                                       if constexpr (variant_unit_alternative<V>) {
 4042|       |                                          // A unit alternative carries no data; its object holds only the
 4043|       |                                          // discriminator. Consume that body through an empty reflected object so
 4044|       |                                          // unknown-key policy and terminator handling match every other alternative.
 4045|       |                                          detail::variant_unit_body unit_body{};
 4046|       |                                          from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4047|       |                                                                                             tag_literal>(unit_body,
 4048|       |                                                                                                          ctx, it, end);
 4049|       |                                       }
 4050|       |                                       else if constexpr (is_object) {
 4051|       |                                          if constexpr (contains_tag<V, tag_literal>()) {
 4052|       |                                             // tag is a struct field, must re-parse
 4053|       |                                             if (!start.rewind(ctx, it, end)) return;
 4054|       |                                          }
 4055|       |                                          from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it,
 4056|       |                                                                                                           end);
 4057|       |                                       }
 4058|       |                                       else if constexpr (is_memory_object<V>) {
 4059|       |                                          if (!v) {
 4060|       |                                             if constexpr (is_specialization_v<V, std::optional>) {
 4061|       |                                                if constexpr (requires { v.emplace(); }) {
 4062|       |                                                   v.emplace();
 4063|       |                                                }
 4064|       |                                                else {
 4065|       |                                                   v = typename V::value_type{};
 4066|       |                                                }
 4067|       |                                             }
 4068|       |                                             else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4069|       |                                                v = std::make_unique<typename V::element_type>();
 4070|       |                                             else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4071|       |                                                v = std::make_shared<typename V::element_type>();
 4072|       |                                             else if constexpr (constructible<V>) {
 4073|       |                                                v = meta_construct_v<V>();
 4074|       |                                             }
 4075|       |                                             else if constexpr (std::is_pointer_v<V> &&
 4076|       |                                                                can_allocate_raw_pointer<Opts,
 4077|       |                                                                                         std::decay_t<decltype(ctx)>>) {
 4078|       |                                                if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4079|       |                                                   return;
 4080|       |                                                }
 4081|       |                                             }
 4082|       |                                             else {
 4083|       |                                                ctx.error = error_code::invalid_nullable_read;
 4084|       |                                                return;
 4085|       |                                                // Cannot read into unset nullable that is not std::optional,
 4086|       |                                                // std::unique_ptr, or std::shared_ptr
 4087|       |                                             }
 4088|       |                                          }
 4089|       |                                          if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4090|       |                                             // tag is a struct field, must re-parse
 4091|       |                                             if (!start.rewind(ctx, it, end)) return;
 4092|       |                                          }
 4093|       |                                          from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4094|       |                                             *v, ctx, it, end);
 4095|       |                                       }
 4096|       |                                       else if constexpr (custom_read<V>) {
 4097|       |                                          // Custom handlers parse the remaining body themselves and do not
 4098|       |                                          // accept the tag template parameter; the tag was already consumed.
 4099|       |                                          // This only works when the tag was the first key. If it came later,
 4100|       |                                          // we were reset to the object start and the custom handler would
 4101|       |                                          // absorb the tag, so error rather than corrupt the value.
 4102|       |                                          if (!first_key) {
 4103|       |                                             ctx.error = error_code::feature_not_supported;
 4104|       |                                             ctx.custom_error_message =
 4105|       |                                                "the tag must be the first key for a custom variant alternative";
 4106|       |                                             return;
 4107|       |                                          }
 4108|       |                                          from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4109|       |                                       }
 4110|       |                                    },
 4111|       |                                    value);
 4112|       |
 4113|       |                                 return; // we've decoded our target type
 4114|       |                              }
 4115|       |                              else [[unlikely]] {
 4116|       |                                 // Check if we have a default type (ids array shorter than variant)
 4117|       |                                 constexpr auto ids_size = ids_v<T>.size();
 4118|       |                                 constexpr auto variant_size = std::variant_size_v<T>;
 4119|       |                                 if constexpr (ids_size < variant_size) {
 4120|       |                                    // Use the first unlabeled type as the default
 4121|       |                                    const auto default_type_index = ids_size;
 4122|       |
 4123|       |                                    if (!position_after_tag()) return;
 4124|       |                                    tag_specified_index = default_type_index; // Store the default type index
 4125|       |                                    if (value.index() != default_type_index)
 4126|       |                                       emplace_runtime_variant(value, default_type_index);
 4127|       |                                    std::visit(
 4128|       |                                       [&](auto&& v) {
 4129|       |                                          using V = std::decay_t<decltype(v)>;
 4130|       |                                          constexpr bool is_object =
 4131|       |                                             (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4132|       |                                          if constexpr (variant_unit_alternative<V>) {
 4133|       |                                             // A unit alternative carries no data; its object holds only the
 4134|       |                                             // discriminator. Consume that body through an empty reflected object so
 4135|       |                                             // unknown-key policy and terminator handling match every other
 4136|       |                                             // alternative.
 4137|       |                                             detail::variant_unit_body unit_body{};
 4138|       |                                             from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4139|       |                                                                                                tag_literal>(
 4140|       |                                                unit_body, ctx, it, end);
 4141|       |                                          }
 4142|       |                                          else if constexpr (is_object) {
 4143|       |                                             if constexpr (contains_tag<V, tag_literal>()) {
 4144|       |                                                // tag is a struct field, must re-parse
 4145|       |                                                if (!start.rewind(ctx, it, end)) return;
 4146|       |                                             }
 4147|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4148|       |                                          }
 4149|       |                                          else if constexpr (is_memory_object<V>) {
 4150|       |                                             if (!v) {
 4151|       |                                                if constexpr (is_specialization_v<V, std::optional>) {
 4152|       |                                                   if constexpr (requires { v.emplace(); }) {
 4153|       |                                                      v.emplace();
 4154|       |                                                   }
 4155|       |                                                   else {
 4156|       |                                                      v = typename V::value_type{};
 4157|       |                                                   }
 4158|       |                                                }
 4159|       |                                                else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4160|       |                                                   v = std::make_unique<typename V::element_type>();
 4161|       |                                                else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4162|       |                                                   v = std::make_shared<typename V::element_type>();
 4163|       |                                                else if constexpr (constructible<V>) {
 4164|       |                                                   v = meta_construct_v<V>();
 4165|       |                                                }
 4166|       |                                                else if constexpr (std::is_pointer_v<V> &&
 4167|       |                                                                   can_allocate_raw_pointer<
 4168|       |                                                                      Opts, std::decay_t<decltype(ctx)>>) {
 4169|       |                                                   if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4170|       |                                                      return;
 4171|       |                                                   }
 4172|       |                                                }
 4173|       |                                                else {
 4174|       |                                                   ctx.error = error_code::invalid_nullable_read;
 4175|       |                                                   return;
 4176|       |                                                }
 4177|       |                                             }
 4178|       |                                             if constexpr (contains_tag<memory_type<V>, tag_literal>()) {
 4179|       |                                                // tag is a struct field, must re-parse
 4180|       |                                                if (!start.rewind(ctx, it, end)) return;
 4181|       |                                             }
 4182|       |                                             from<JSON, memory_type<V>>::template op<opening_handled<Opts>()>(*v, ctx,
 4183|       |                                                                                                              it, end);
 4184|       |                                          }
 4185|       |                                          else if constexpr (custom_read<V>) {
 4186|       |                                             // Custom handlers parse the remaining body themselves; this only
 4187|       |                                             // works when the tag was the first key (see above). If it came
 4188|       |                                             // later we were reset to the object start, so error rather than
 4189|       |                                             // let the custom handler absorb the tag.
 4190|       |                                             if (!first_key) {
 4191|       |                                                ctx.error = error_code::feature_not_supported;
 4192|       |                                                ctx.custom_error_message =
 4193|       |                                                   "the tag must be the first key for a custom variant alternative";
 4194|       |                                                return;
 4195|       |                                             }
 4196|       |                                             from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4197|       |                                          }
 4198|       |                                       },
 4199|       |                                       value);
 4200|       |
 4201|       |                                    return;
 4202|       |                                 }
 4203|       |                                 else {
 4204|       |                                    ctx.error = error_code::no_matching_variant_type;
 4205|       |                                    ctx.custom_error_message = variant_ids_string_v<T>;
 4206|       |                                    return;
 4207|       |                                 }
 4208|       |                              }
 4209|       |                           }
 4210|       |                        }
 4211|       |
 4212|       |                        // Inline decode_hash lookup for variant deduction
 4213|       |                        using deduction_keys_t = keys_wrapper<variant_deduction_keys<T>>;
 4214|       |                        constexpr auto& DeductionHashInfo = hash_info<deduction_keys_t>;
 4215|       |                        const auto deduction_index =
 4216|       |                           decode_hash_with_size<JSON, deduction_keys_t, DeductionHashInfo, DeductionHashInfo.type>::op(
 4217|       |                              key.data(), key.data() + key.size(), key.size());
 4218|       |                        if (deduction_index < deduction_key_count && variant_deduction_keys<T>[deduction_index] == key)
 4219|       |                           [[likely]] {
 4220|       |                           possible_types &= deduction_bits[deduction_index];
 4221|       |                        }
 4222|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4223|       |                           ctx.error = error_code::unknown_key;
 4224|       |                           return;
 4225|       |                        }
 4226|       |                     }
 4227|       |                     else if constexpr (not tag_v<T>.empty()) {
 4228|       |                        // empty object case for variant, if there are no normal elements
 4229|       |                        if (key == tag_v<T>) {
 4230|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4231|       |                              return;
 4232|       |                           }
 4233|       |
 4234|       |                           // The id is turned into an index below and never leaves this reader,
 4235|       |                           // so the view of the window it borrows cannot outlive that window.
 4236|       |                           std::string_view type_id{};
 4237|       |                           parse_transient_string_view<ws_handled<Opts>()>(type_id, ctx, it, end);
 4238|       |                           if (bool(ctx.error)) [[unlikely]]
 4239|       |                              return;
 4240|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4241|       |                              return;
 4242|       |                           }
 4243|       |
 4244|       |                           const auto type_index = variant_id_to_index<T>::op(
 4245|       |                              type_id.data(), type_id.data() + type_id.size(), type_id.size());
 4246|       |                           if (type_index < ids_v<T>.size()) [[likely]] {
 4247|       |                              if (!position_after_tag()) return;
 4248|       |                              tag_specified_index = type_index; // Store the tag-specified type
 4249|       |                              if (value.index() != type_index) emplace_runtime_variant(value, type_index);
 4250|       |                           }
 4251|       |                           else {
 4252|       |                              // Check if we have a default type (ids array shorter than variant)
 4253|       |                              constexpr auto ids_size = ids_v<T>.size();
 4254|       |                              constexpr auto variant_size = std::variant_size_v<T>;
 4255|       |                              if constexpr (ids_size < variant_size) {
 4256|       |                                 // Use the first unlabeled type as the default
 4257|       |                                 if (!position_after_tag()) return;
 4258|       |                                 const auto default_index = ids_size;
 4259|       |                                 tag_specified_index = default_index; // Store the default type index
 4260|       |                                 if (value.index() != default_index) emplace_runtime_variant(value, default_index);
 4261|       |                              }
 4262|       |                              else {
 4263|       |                                 ctx.error = error_code::no_matching_variant_type;
 4264|       |                                 ctx.custom_error_message = variant_ids_string_v<T>;
 4265|       |                                 return;
 4266|       |                              }
 4267|       |                           }
 4268|       |                           // Parse the type (handles tag skipping and unknown keys)
 4269|       |                           std::visit(
 4270|       |                              [&](auto&& v) {
 4271|       |                                 using V = std::decay_t<decltype(v)>;
 4272|       |                                 if constexpr (custom_read<V>) {
 4273|       |                                    // Custom handlers parse the remaining object body themselves and do not
 4274|       |                                    // accept the tag template parameter that reflected objects use to skip an
 4275|       |                                    // interior tag key. That only works when the tag is the first key (it was
 4276|       |                                    // just consumed). If the tag came after other keys, position_after_tag()
 4277|       |                                    // reset us to the object start and the custom handler would absorb the tag
 4278|       |                                    // into its value, so error here rather than corrupt the result.
 4279|       |                                    if (!first_key) {
 4280|       |                                       ctx.error = error_code::feature_not_supported;
 4281|       |                                       ctx.custom_error_message =
 4282|       |                                          "the tag must be the first key for a custom variant alternative";
 4283|       |                                       return;
 4284|       |                                    }
 4285|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4286|       |                                 }
 4287|       |                                 else {
 4288|       |                                    if constexpr (contains_tag<V, tag_literal>()) {
 4289|       |                                       // tag is a struct field, must re-parse
 4290|       |                                       if (!start.rewind(ctx, it, end)) return;
 4291|       |                                    }
 4292|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4293|       |                                 }
 4294|       |                              },
 4295|       |                              value);
 4296|       |                           return;
 4297|       |                        }
 4298|       |                        else if constexpr (Opts.error_on_unknown_keys) {
 4299|       |                           ctx.error = error_code::unknown_key;
 4300|       |                           return;
 4301|       |                        }
 4302|       |                        else {
 4303|       |                           // Skip unknown key's value (non-tag key in empty variant)
 4304|       |                           if (parse_ws_colon<Opts>(ctx, it, end)) {
 4305|       |                              return;
 4306|       |                           }
 4307|       |                           skip_value<JSON>::op<Opts>(ctx, it, end);
 4308|       |                           if (bool(ctx.error)) [[unlikely]]
 4309|       |                              return;
 4310|       |                           resync_window_end(ctx, end); // a streaming skip refills
 4311|       |                           if (skip_ws<Opts>(ctx, it, end)) {
 4312|       |                              return;
 4313|       |                           }
 4314|       |                           continue; // Continue loop to find the tag
 4315|       |                        }
 4316|       |                     }
 4317|       |                     else if constexpr (Opts.error_on_unknown_keys) {
 4318|       |                        ctx.error = error_code::unknown_key;
 4319|       |                        return;
 4320|       |                     }
 4321|       |
 4322|       |                     auto matching_types = possible_types.popcount();
 4323|       |                     if (matching_types == 0) {
 4324|       |                        ctx.error = error_code::no_matching_variant_type;
 4325|       |                        return;
 4326|       |                     }
 4327|       |                     // Only short-circuit for variants without tags
 4328|       |                     else if constexpr (tag_v<T>.empty()) {
 4329|       |                        if (matching_types == 1) {
 4330|       |                           if (!start.rewind(ctx, it, end)) return;
 4331|       |                           const auto type_index = possible_types.countr_zero();
 4332|       |
 4333|       |                           if (value.index() != static_cast<size_t>(type_index))
 4334|       |                              emplace_runtime_variant(value, type_index);
 4335|       |                           std::visit(
 4336|       |                              [&](auto&& v) {
 4337|       |                                 using V = std::decay_t<decltype(v)>;
 4338|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4339|       |                                 if constexpr (variant_unit_alternative<V>) {
 4340|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4341|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4342|       |                                    // terminator handling match every other alternative.
 4343|       |                                    detail::variant_unit_body unit_body{};
 4344|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4345|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4346|       |                                                                                                    end);
 4347|       |                                 }
 4348|       |                                 else if constexpr (is_object) {
 4349|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4350|       |                                 }
 4351|       |                                 else if constexpr (is_memory_object<V>) {
 4352|       |                                    if (!v) {
 4353|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4354|       |                                          if constexpr (requires { v.emplace(); }) {
 4355|       |                                             v.emplace();
 4356|       |                                          }
 4357|       |                                          else {
 4358|       |                                             v = typename V::value_type{};
 4359|       |                                          }
 4360|       |                                       }
 4361|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4362|       |                                          v = std::make_unique<typename V::element_type>();
 4363|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4364|       |                                          v = std::make_shared<typename V::element_type>();
 4365|       |                                       else if constexpr (constructible<V>) {
 4366|       |                                          v = meta_construct_v<V>();
 4367|       |                                       }
 4368|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4369|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4370|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4371|       |                                             return;
 4372|       |                                          }
 4373|       |                                       }
 4374|       |                                       else {
 4375|       |                                          ctx.error = error_code::invalid_nullable_read;
 4376|       |                                          return;
 4377|       |                                          // Cannot read into unset nullable that is not std::optional,
 4378|       |                                          // std::unique_ptr, or std::shared_ptr
 4379|       |                                       }
 4380|       |                                    }
 4381|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4382|       |                                       *v, ctx, it, end);
 4383|       |                                 }
 4384|       |                                 else if constexpr (custom_read<V>) {
 4385|       |                                    // Custom handlers parse the remaining body themselves.
 4386|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4387|       |                                 }
 4388|       |                              },
 4389|       |                              value);
 4390|       |
 4391|       |                           return; // we've decoded our target type
 4392|       |                        }
 4393|       |                     }
 4394|       |                     // For tagged variants, continue processing to validate tags
 4395|       |                     if (parse_ws_colon<Opts>(ctx, it, end)) {
 4396|       |                        return;
 4397|       |                     }
 4398|       |
 4399|       |                     skip_value<JSON>::op<Opts>(ctx, it, end);
 4400|       |                     if (bool(ctx.error)) [[unlikely]]
 4401|       |                        return;
 4402|       |                     resync_window_end(ctx, end); // a streaming skip refills
 4403|       |                     if (skip_ws<Opts>(ctx, it, end)) {
 4404|       |                        return;
 4405|       |                     }
 4406|       |                  }
 4407|       |                  // Only apply ambiguous variant resolution if we have multiple object types
 4408|       |                  if constexpr ((type_counts::n_object + type_counts::n_nullable_object) > 1) {
 4409|       |                     // After parsing all keys, check if we have multiple matching types
 4410|       |                     // If so, choose the one with the fewest fields
 4411|       |                     auto final_matching = possible_types.popcount();
 4412|       |                     if (final_matching == 0) {
 4413|       |                        ctx.error = error_code::no_matching_variant_type;
 4414|       |                     }
 4415|       |                     else if (final_matching == 1) {
 4416|       |                        // Single type remains after field deduction
 4417|       |                        const auto type_index = possible_types.countr_zero();
 4418|       |
 4419|       |                        // Validate against tag if one was specified
 4420|       |                        if (tag_specified_index.has_value() &&
 4421|       |                            tag_specified_index.value() != static_cast<size_t>(type_index)) {
 4422|       |                           ctx.error = error_code::no_matching_variant_type;
 4423|       |                           return;
 4424|       |                        }
 4425|       |
 4426|       |                        if (!start.rewind(ctx, it, end)) return;
 4427|       |                        if (value.index() != static_cast<size_t>(type_index))
 4428|       |                           emplace_runtime_variant(value, type_index);
 4429|       |                        std::visit(
 4430|       |                           [&](auto&& v) {
 4431|       |                              using V = std::decay_t<decltype(v)>;
 4432|       |                              constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4433|       |                              if constexpr (variant_unit_alternative<V>) {
 4434|       |                                 // A unit alternative carries no data; its object holds only the discriminator.
 4435|       |                                 // Consume that body through an empty reflected object so unknown-key policy and
 4436|       |                                 // terminator handling match every other alternative.
 4437|       |                                 detail::variant_unit_body unit_body{};
 4438|       |                                 from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4439|       |                                                                                    tag_literal>(unit_body, ctx, it,
 4440|       |                                                                                                 end);
 4441|       |                              }
 4442|       |                              else if constexpr (is_object) {
 4443|       |                                 from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4444|       |                              }
 4445|       |                              else if constexpr (is_memory_object<V>) {
 4446|       |                                 if (!v) {
 4447|       |                                    if constexpr (is_specialization_v<V, std::optional>) {
 4448|       |                                       if constexpr (requires { v.emplace(); }) {
 4449|       |                                          v.emplace();
 4450|       |                                       }
 4451|       |                                       else {
 4452|       |                                          v = typename V::value_type{};
 4453|       |                                       }
 4454|       |                                    }
 4455|       |                                    else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4456|       |                                       v = std::make_unique<typename V::element_type>();
 4457|       |                                    else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4458|       |                                       v = std::make_shared<typename V::element_type>();
 4459|       |                                    else if constexpr (constructible<V>) {
 4460|       |                                       v = meta_construct_v<V>();
 4461|       |                                    }
 4462|       |                                    else if constexpr (std::is_pointer_v<V> &&
 4463|       |                                                       can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4464|       |                                       if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4465|       |                                          return;
 4466|       |                                       }
 4467|       |                                    }
 4468|       |                                    else {
 4469|       |                                       ctx.error = error_code::invalid_nullable_read;
 4470|       |                                       return;
 4471|       |                                    }
 4472|       |                                 }
 4473|       |                                 from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(*v, ctx,
 4474|       |                                                                                                               it, end);
 4475|       |                              }
 4476|       |                              else if constexpr (custom_read<V>) {
 4477|       |                                 // Custom handlers parse the remaining body themselves.
 4478|       |                                 from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4479|       |                              }
 4480|       |                           },
 4481|       |                           value);
 4482|       |                     }
 4483|       |                     else if (final_matching > 1) {
 4484|       |                        constexpr auto N = std::variant_size_v<T>;
 4485|       |
 4486|       |                        // Compile-time array of field counts for each variant type
 4487|       |                        constexpr auto field_counts = []<size_t... I>(std::index_sequence<I...>) {
 4488|       |                           return std::array<size_t, N> {
 4489|       |                              ([]<size_t J = I>() -> size_t {
 4490|       |                                 using V = std::decay_t<std::variant_alternative_t<J, T>>;
 4491|       |                                 if constexpr (glaze_object_t<V> || reflectable<V>) {
 4492|       |                                    return reflect<V>::size;
 4493|       |                                 }
 4494|       |                                 else if constexpr (is_memory_object<V>) {
 4495|       |                                    using X = memory_type<V>;
 4496|       |                                    if constexpr (glaze_object_t<X> || reflectable<X>) {
 4497|       |                                       return reflect<X>::size;
 4498|       |                                    }
 4499|       |                                    else {
 4500|       |                                       return (std::numeric_limits<size_t>::max)();
 4501|       |                                    }
 4502|       |                                 }
 4503|       |                                 else {
 4504|       |                                    return (std::numeric_limits<size_t>::max)();
 4505|       |                                 }
 4506|       |                              }.template operator()<I>())...
 4507|       |                           };
 4508|       |                        }(std::make_index_sequence<N>{});
 4509|       |
 4510|       |                        // Find the type with minimum field count among the possible types
 4511|       |                        size_t min_fields = (std::numeric_limits<size_t>::max)();
 4512|       |                        size_t chosen_index = N; // Invalid index initially
 4513|       |
 4514|       |                        for (size_t i = 0; i < N; ++i) {
 4515|       |                           if (possible_types[i] && field_counts[i] < min_fields) {
 4516|       |                              min_fields = field_counts[i];
 4517|       |                              chosen_index = i;
 4518|       |                           }
 4519|       |                        }
 4520|       |
 4521|       |                        if (chosen_index < N) {
 4522|       |                           // Validate against tag if one was specified
 4523|       |                           if (tag_specified_index.has_value() && tag_specified_index.value() != chosen_index) {
 4524|       |                              ctx.error = error_code::no_matching_variant_type;
 4525|       |                              return;
 4526|       |                           }
 4527|       |
 4528|       |                           if (!start.rewind(ctx, it, end)) return;
 4529|       |                           if (value.index() != chosen_index) emplace_runtime_variant(value, chosen_index);
 4530|       |                           std::visit(
 4531|       |                              [&](auto&& v) {
 4532|       |                                 using V = std::decay_t<decltype(v)>;
 4533|       |                                 constexpr bool is_object = (glaze_object_t<V> || reflectable<V>) && not custom_read<V>;
 4534|       |                                 if constexpr (variant_unit_alternative<V>) {
 4535|       |                                    // A unit alternative carries no data; its object holds only the discriminator.
 4536|       |                                    // Consume that body through an empty reflected object so unknown-key policy and
 4537|       |                                    // terminator handling match every other alternative.
 4538|       |                                    detail::variant_unit_body unit_body{};
 4539|       |                                    from<JSON, detail::variant_unit_body>::template op<opening_handled<Opts>(),
 4540|       |                                                                                       tag_literal>(unit_body, ctx, it,
 4541|       |                                                                                                    end);
 4542|       |                                 }
 4543|       |                                 else if constexpr (is_object) {
 4544|       |                                    from<JSON, V>::template op<opening_handled<Opts>(), tag_literal>(v, ctx, it, end);
 4545|       |                                 }
 4546|       |                                 else if constexpr (is_memory_object<V>) {
 4547|       |                                    if (!v) {
 4548|       |                                       if constexpr (is_specialization_v<V, std::optional>) {
 4549|       |                                          if constexpr (requires { v.emplace(); }) {
 4550|       |                                             v.emplace();
 4551|       |                                          }
 4552|       |                                          else {
 4553|       |                                             v = typename V::value_type{};
 4554|       |                                          }
 4555|       |                                       }
 4556|       |                                       else if constexpr (is_specialization_v<V, std::unique_ptr>)
 4557|       |                                          v = std::make_unique<typename V::element_type>();
 4558|       |                                       else if constexpr (is_specialization_v<V, std::shared_ptr>)
 4559|       |                                          v = std::make_shared<typename V::element_type>();
 4560|       |                                       else if constexpr (constructible<V>) {
 4561|       |                                          v = meta_construct_v<V>();
 4562|       |                                       }
 4563|       |                                       else if constexpr (std::is_pointer_v<V> &&
 4564|       |                                                          can_allocate_raw_pointer<Opts, std::decay_t<decltype(ctx)>>) {
 4565|       |                                          if (!try_allocate_raw_pointer<Opts>(v, ctx)) {
 4566|       |                                             return;
 4567|       |                                          }
 4568|       |                                       }
 4569|       |                                       else {
 4570|       |                                          ctx.error = error_code::invalid_nullable_read;
 4571|       |                                          return;
 4572|       |                                       }
 4573|       |                                    }
 4574|       |                                    from<JSON, memory_type<V>>::template op<opening_handled<Opts>(), tag_literal>(
 4575|       |                                       *v, ctx, it, end);
 4576|       |                                 }
 4577|       |                                 else if constexpr (custom_read<V>) {
 4578|       |                                    // Custom handlers parse the remaining body themselves.
 4579|       |                                    from<JSON, V>::template op<opening_handled<Opts>()>(v, ctx, it, end);
 4580|       |                                 }
 4581|       |                              },
 4582|       |                              value);
 4583|       |                        }
 4584|       |                        else {
 4585|       |                           ctx.error = error_code::no_matching_variant_type;
 4586|       |                        }
 4587|       |                     }
 4588|       |                  }
 4589|       |                  else {
 4590|       |                     // For variants with 0 or 1 object types, use the original error handling
 4591|       |                     ctx.error = error_code::no_matching_variant_type;
 4592|       |                  }
 4593|       |               }
 4594|      0|               break;
 4595|  62.1k|            }
 4596|  1.51M|            case '[':
  ------------------
  |  Branch (4596:13): [True: 1.51M, False: 6.24M]
  ------------------
 4597|       |               // As with '{' above: the array reader each alternative goes through counts the level.
 4598|  1.51M|               process_variant_alternatives<T, is_variant_array>::template op<Opts>(value, ctx, it, end);
 4599|  1.51M|               break;
 4600|  41.2k|            case '"': {
  ------------------
  |  Branch (4600:13): [True: 41.2k, False: 7.71M]
  ------------------
 4601|  41.2k|               process_variant_alternatives<T, is_variant_str>::template op<Opts>(value, ctx, it, end);
 4602|  41.2k|               break;
 4603|  62.1k|            }
 4604|  2.46k|            case 't':
  ------------------
  |  Branch (4604:13): [True: 2.46k, False: 7.75M]
  ------------------
 4605|  4.41k|            case 'f': {
  ------------------
  |  Branch (4605:13): [True: 1.95k, False: 7.75M]
  ------------------
 4606|  4.41k|               process_variant_alternatives<T, is_variant_bool>::template op<Opts>(value, ctx, it, end);
 4607|  4.41k|               break;
 4608|  2.46k|            }
 4609|  3.33k|            case 'n':
  ------------------
  |  Branch (4609:13): [True: 3.33k, False: 7.75M]
  ------------------
 4610|       |               if constexpr (variant_count_v<T, is_variant_null> == 0) {
 4611|       |                  ctx.error = error_code::no_matching_variant_type;
 4612|       |               }
 4613|  3.33k|               else {
 4614|  3.33k|                  constexpr auto first_idx = variant_first_index_v<T, is_variant_null>;
 4615|  3.33k|                  using V = std::variant_alternative_t<first_idx, T>;
 4616|  3.33k|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4616:23): [True: 1.28k, False: 2.04k]
  ------------------
 4617|  3.33k|                  match<"null", Opts>(ctx, it, end);
 4618|  3.33k|               }
 4619|  3.33k|               break;
 4620|  6.12M|            default: {
  ------------------
  |  Branch (4620:13): [True: 6.12M, False: 1.63M]
  ------------------
 4621|       |               // Not bool, string, object, or array so must be number or null
 4622|  6.12M|               process_variant_alternatives<T, is_variant_num>::template op<Opts>(value, ctx, it, end);
 4623|  6.12M|            }
 4624|  7.75M|            }
 4625|       |         }
 4626|       |         else {
 4627|       |            // For non-auto-deducible variants, try each type until one succeeds
 4628|       |            constexpr auto N = std::variant_size_v<T>;
 4629|       |            bool parsed = false;
 4630|       |            bool exhausted = false; // speculation budget spent; see charge_speculation
 4631|       |
 4632|       |            for_each<N>([&]<size_t I>() {
 4633|       |               if (parsed || exhausted || variant_alternative_exhausted(ctx)) return;
 4634|       |
 4635|       |               auto copy_it = it;
 4636|       |               // A rejected alternative may have bailed out inside a container, which leaves its
 4637|       |               // nesting level counted (see enter_depth), so the depth rewinds with the iterator.
 4638|       |               const auto copy_depth = ctx.depth;
 4639|       |
 4640|       |               // Try parsing as this type
 4641|       |               if (value.index() != I) {
 4642|       |                  emplace_runtime_variant(value, I);
 4643|       |               }
 4644|       |
 4645|       |               std::visit([&](auto&& v) { parse<JSON>::op<Options>(v, ctx, it, end); }, value);
 4646|       |               if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 4647|       |                  exhausted = true; // only rejected attempts are charged; see charge_speculation
 4648|       |               }
 4649|       |
 4650|       |               if (!bool(ctx.error)) {
 4651|       |                  parsed = true;
 4652|       |               }
 4653|       |               else if constexpr (not Options.null_terminated) {
 4654|       |                  // In non-null-terminated mode, if we hit end_reached after advancing the iterator,
 4655|       |                  // it means we successfully parsed the value but couldn't skip trailing whitespace
 4656|       |                  if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 4657|       |                     // We advanced the iterator, so we did parse something -- unless what advanced it
 4658|       |                     // was an abandoned attempt, which is what a spent speculation budget means.
 4659|       |                     parsed = true;
 4660|       |                     ctx.error = error_code::none;
 4661|       |                  }
 4662|       |                  else {
 4663|       |                     // Reset for next attempt (unless this is the last type)
 4664|       |                     it = copy_it;
 4665|       |                     rewind_depth<Options>(ctx, copy_depth);
 4666|       |                     if constexpr (I + 1 < N) {
 4667|       |                        if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4668|       |                           ctx.error = error_code::none; // Clear error for next attempt
 4669|       |                        }
 4670|       |                     }
 4671|       |                  }
 4672|       |               }
 4673|       |               else {
 4674|       |                  // Reset for next attempt (unless this is the last type)
 4675|       |                  it = copy_it;
 4676|       |                  rewind_depth<Options>(ctx, copy_depth);
 4677|       |                  if constexpr (I + 1 < N) {
 4678|       |                     if (not exhausted && not variant_alternative_exhausted(ctx)) {
 4679|       |                        ctx.error = error_code::none; // Clear error for next attempt
 4680|       |                     }
 4681|       |                  }
 4682|       |               }
 4683|       |            });
 4684|       |         }
 4685|  7.75M|      }
_ZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_:
 3520|  1.52M|      {
 3521|  1.52M|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3522|       |
 3523|       |         if constexpr (category_count == 0) {
 3524|       |            ctx.error = error_code::no_matching_variant_type;
 3525|       |         }
 3526|  1.52M|         else {
 3527|  1.52M|            constexpr auto N = std::variant_size_v<Variant>;
 3528|  1.52M|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3529|  1.52M|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3530|       |
 3531|  1.52M|            bool found_match{};
 3532|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3533|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3534|       |            // so the budget stops it and the failure already in hand is reported.
 3535|  1.52M|            bool exhausted{};
 3536|       |
 3537|       |            // First pass: const glaze types in this category
 3538|       |            if constexpr (const_count > 0) {
 3539|       |               for_each<N>([&]<size_t I>() {
 3540|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3541|       |                     return;
 3542|       |                  }
 3543|       |                  using V = std::variant_alternative_t<I, Variant>;
 3544|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3545|       |                     // run time substitute to compare to const value
 3546|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3547|       |                     auto copy_it{it};
 3548|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3549|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3550|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3551|       |                     const auto copy_depth{ctx.depth};
 3552|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3553|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3554|       |                     if (substitute == const_value) {
 3555|       |                        found_match = true;
 3556|       |                        if (!std::holds_alternative<V>(value)) {
 3557|       |                           value = V{};
 3558|       |                        }
 3559|       |                     }
 3560|       |                     else {
 3561|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3562|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3563|       |                           exhausted = true;
 3564|       |                        }
 3565|       |                        if constexpr (not Options.null_terminated) {
 3566|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3567|       |                              ctx.error = error_code::none;
 3568|       |                           }
 3569|       |                        }
 3570|       |                        it = copy_it;
 3571|       |                        rewind_depth<Options>(ctx, copy_depth);
 3572|       |                     }
 3573|       |                  }
 3574|       |               });
 3575|       |               if (found_match) {
 3576|       |                  return;
 3577|       |               }
 3578|       |            }
 3579|       |
 3580|       |            // Second pass: non-const types in this category
 3581|  1.52M|            if constexpr (non_const_count > 0) {
 3582|       |               // Track position within matching types for "is last" check.
 3583|       |               // We iterate over all variant indices but only process matching types,
 3584|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3585|       |               // the loop index directly corresponded to position in filtered set).
 3586|       |               // This has negligible cost: one increment per matching type.
 3587|  1.52M|               size_t non_const_idx = 0;
 3588|       |
 3589|  1.52M|               for_each<N>([&]<size_t I>() {
 3590|  1.52M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3591|  1.52M|                     return;
 3592|  1.52M|                  }
 3593|  1.52M|                  using V = std::variant_alternative_t<I, Variant>;
 3594|  1.52M|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|  1.52M|                     auto copy_it{it};
 3596|  1.52M|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|  1.52M|                     if (!std::holds_alternative<V>(value)) {
 3598|  1.52M|                        value = V{};
 3599|  1.52M|                     }
 3600|  1.52M|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|  1.52M|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|  1.52M|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|  1.52M|                     }
 3604|  1.52M|                     if (!bool(ctx.error)) {
 3605|  1.52M|                        found_match = true;
 3606|  1.52M|                     }
 3607|  1.52M|                     else if constexpr (not Options.null_terminated) {
 3608|  1.52M|                        constexpr bool is_complete_type =
 3609|  1.52M|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|  1.52M|                        if constexpr (is_complete_type) {
 3612|  1.52M|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|  1.52M|                              found_match = true;
 3614|  1.52M|                              ctx.error = error_code::none;
 3615|  1.52M|                           }
 3616|  1.52M|                           else {
 3617|  1.52M|                              it = copy_it;
 3618|  1.52M|                              rewind_depth<Options>(ctx, copy_depth);
 3619|  1.52M|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|  1.52M|                                  not variant_alternative_exhausted(ctx)) {
 3621|  1.52M|                                 ctx.error = error_code::none;
 3622|  1.52M|                              }
 3623|  1.52M|                           }
 3624|  1.52M|                        }
 3625|  1.52M|                        else {
 3626|  1.52M|                           it = copy_it;
 3627|  1.52M|                           rewind_depth<Options>(ctx, copy_depth);
 3628|  1.52M|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|  1.52M|                               not variant_alternative_exhausted(ctx)) {
 3630|  1.52M|                              ctx.error = error_code::none;
 3631|  1.52M|                           }
 3632|  1.52M|                        }
 3633|  1.52M|                     }
 3634|  1.52M|                     else {
 3635|  1.52M|                        it = copy_it;
 3636|  1.52M|                        rewind_depth<Options>(ctx, copy_depth);
 3637|  1.52M|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|  1.52M|                            not variant_alternative_exhausted(ctx)) {
 3639|  1.52M|                           ctx.error = error_code::none;
 3640|  1.52M|                        }
 3641|  1.52M|                     }
 3642|  1.52M|                     ++non_const_idx;
 3643|  1.52M|                  }
 3644|  1.52M|               });
 3645|  1.52M|               if (!found_match) {
  ------------------
  |  Branch (3645:20): [True: 44.6k, False: 1.47M]
  ------------------
 3646|  44.6k|                  if constexpr (non_const_count == 1) {
 3647|       |                     // Keep the specific error from the single type we tried
 3648|       |                  }
 3649|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3650|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3651|       |                     ctx.error = error_code::no_matching_variant_type;
 3652|       |                  }
 3653|  44.6k|               }
 3654|       |            }
 3655|       |            else {
 3656|       |               ctx.error = error_code::no_matching_variant_type;
 3657|       |            }
 3658|  1.52M|         }
 3659|  1.52M|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm0EEEDav:
 3589|  1.52M|               for_each<N>([&]<size_t I>() {
 3590|  1.52M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 1.52M]
  |  Branch (3590:38): [True: 0, False: 1.52M]
  |  Branch (3590:51): [True: 0, False: 1.52M]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  1.52M|                  using V = std::variant_alternative_t<I, Variant>;
 3594|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|       |                     auto copy_it{it};
 3596|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|       |                     if (!std::holds_alternative<V>(value)) {
 3598|       |                        value = V{};
 3599|       |                     }
 3600|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|       |                     }
 3604|       |                     if (!bool(ctx.error)) {
 3605|       |                        found_match = true;
 3606|       |                     }
 3607|       |                     else if constexpr (not Options.null_terminated) {
 3608|       |                        constexpr bool is_complete_type =
 3609|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|       |                        if constexpr (is_complete_type) {
 3612|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|       |                              found_match = true;
 3614|       |                              ctx.error = error_code::none;
 3615|       |                           }
 3616|       |                           else {
 3617|       |                              it = copy_it;
 3618|       |                              rewind_depth<Options>(ctx, copy_depth);
 3619|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|       |                                  not variant_alternative_exhausted(ctx)) {
 3621|       |                                 ctx.error = error_code::none;
 3622|       |                              }
 3623|       |                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|       |                     ++non_const_idx;
 3643|       |                  }
 3644|  1.52M|               });
_ZN3glz29variant_alternative_exhaustedITkNS_10is_contextENS_7contextEEEbRT_:
 3509|  20.1M|   {
 3510|  20.1M|      return ctx.error == error_code::exceeded_max_recursive_depth;
 3511|  20.1M|   }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm1EEEDav:
 3589|  1.52M|               for_each<N>([&]<size_t I>() {
 3590|  1.52M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 1.52M]
  |  Branch (3590:38): [True: 0, False: 1.52M]
  |  Branch (3590:51): [True: 0, False: 1.52M]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  1.52M|                  using V = std::variant_alternative_t<I, Variant>;
 3594|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|       |                     auto copy_it{it};
 3596|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|       |                     if (!std::holds_alternative<V>(value)) {
 3598|       |                        value = V{};
 3599|       |                     }
 3600|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|       |                     }
 3604|       |                     if (!bool(ctx.error)) {
 3605|       |                        found_match = true;
 3606|       |                     }
 3607|       |                     else if constexpr (not Options.null_terminated) {
 3608|       |                        constexpr bool is_complete_type =
 3609|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|       |                        if constexpr (is_complete_type) {
 3612|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|       |                              found_match = true;
 3614|       |                              ctx.error = error_code::none;
 3615|       |                           }
 3616|       |                           else {
 3617|       |                              it = copy_it;
 3618|       |                              rewind_depth<Options>(ctx, copy_depth);
 3619|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|       |                                  not variant_alternative_exhausted(ctx)) {
 3621|       |                                 ctx.error = error_code::none;
 3622|       |                              }
 3623|       |                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|       |                     ++non_const_idx;
 3643|       |                  }
 3644|  1.52M|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm2EEEDav:
 3589|  1.52M|               for_each<N>([&]<size_t I>() {
 3590|  1.52M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 1.52M]
  |  Branch (3590:38): [True: 0, False: 1.52M]
  |  Branch (3590:51): [True: 0, False: 1.52M]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  1.52M|                  using V = std::variant_alternative_t<I, Variant>;
 3594|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|       |                     auto copy_it{it};
 3596|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|       |                     if (!std::holds_alternative<V>(value)) {
 3598|       |                        value = V{};
 3599|       |                     }
 3600|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|       |                     }
 3604|       |                     if (!bool(ctx.error)) {
 3605|       |                        found_match = true;
 3606|       |                     }
 3607|       |                     else if constexpr (not Options.null_terminated) {
 3608|       |                        constexpr bool is_complete_type =
 3609|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|       |                        if constexpr (is_complete_type) {
 3612|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|       |                              found_match = true;
 3614|       |                              ctx.error = error_code::none;
 3615|       |                           }
 3616|       |                           else {
 3617|       |                              it = copy_it;
 3618|       |                              rewind_depth<Options>(ctx, copy_depth);
 3619|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|       |                                  not variant_alternative_exhausted(ctx)) {
 3621|       |                                 ctx.error = error_code::none;
 3622|       |                              }
 3623|       |                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|       |                     ++non_const_idx;
 3643|       |                  }
 3644|  1.52M|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm3EEEDav:
 3589|  1.52M|               for_each<N>([&]<size_t I>() {
 3590|  1.52M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 1.52M]
  |  Branch (3590:38): [True: 0, False: 1.52M]
  |  Branch (3590:51): [True: 0, False: 1.52M]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  1.52M|                  using V = std::variant_alternative_t<I, Variant>;
 3594|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|       |                     auto copy_it{it};
 3596|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|       |                     if (!std::holds_alternative<V>(value)) {
 3598|       |                        value = V{};
 3599|       |                     }
 3600|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|       |                     }
 3604|       |                     if (!bool(ctx.error)) {
 3605|       |                        found_match = true;
 3606|       |                     }
 3607|       |                     else if constexpr (not Options.null_terminated) {
 3608|       |                        constexpr bool is_complete_type =
 3609|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|       |                        if constexpr (is_complete_type) {
 3612|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|       |                              found_match = true;
 3614|       |                              ctx.error = error_code::none;
 3615|       |                           }
 3616|       |                           else {
 3617|       |                              it = copy_it;
 3618|       |                              rewind_depth<Options>(ctx, copy_depth);
 3619|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|       |                                  not variant_alternative_exhausted(ctx)) {
 3621|       |                                 ctx.error = error_code::none;
 3622|       |                              }
 3623|       |                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|       |                     ++non_const_idx;
 3643|       |                  }
 3644|  1.52M|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm4EEEDav:
 3589|  1.52M|               for_each<N>([&]<size_t I>() {
 3590|  1.52M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 1.52M]
  |  Branch (3590:38): [True: 0, False: 1.52M]
  |  Branch (3590:51): [True: 0, False: 1.52M]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  1.52M|                  using V = std::variant_alternative_t<I, Variant>;
 3594|  1.52M|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|  1.52M|                     auto copy_it{it};
 3596|  1.52M|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|  1.52M|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3597:26): [True: 1.24M, False: 276k]
  ------------------
 3598|  1.24M|                        value = V{};
 3599|  1.24M|                     }
 3600|  1.52M|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|  1.52M|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3601:26): [True: 44.6k, False: 1.47M]
  |  Branch (3601:45): [True: 0, False: 44.6k]
  ------------------
 3602|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|      0|                     }
 3604|  1.52M|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3604:26): [True: 1.47M, False: 44.6k]
  ------------------
 3605|  1.47M|                        found_match = true;
 3606|  1.47M|                     }
 3607|  44.6k|                     else if constexpr (not Options.null_terminated) {
 3608|  44.6k|                        constexpr bool is_complete_type =
 3609|  44.6k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
  ------------------
  |  Branch (3609:28): [Folded, False: 0]
  |  Branch (3609:40): [Folded, False: 0]
  |  Branch (3609:53): [Folded, False: 0]
  |  Branch (3609:68): [Folded, False: 0]
  |  Branch (3609:89): [Folded, False: 0]
  |  Branch (3609:103): [Folded, False: 0]
  ------------------
 3610|       |
 3611|       |                        if constexpr (is_complete_type) {
 3612|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|       |                              found_match = true;
 3614|       |                              ctx.error = error_code::none;
 3615|       |                           }
 3616|       |                           else {
 3617|       |                              it = copy_it;
 3618|       |                              rewind_depth<Options>(ctx, copy_depth);
 3619|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|       |                                  not variant_alternative_exhausted(ctx)) {
 3621|       |                                 ctx.error = error_code::none;
 3622|       |                              }
 3623|       |                           }
 3624|       |                        }
 3625|  44.6k|                        else {
 3626|  44.6k|                           it = copy_it;
 3627|  44.6k|                           rewind_depth<Options>(ctx, copy_depth);
 3628|  44.6k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3628:32): [True: 0, False: 44.6k]
  |  Branch (3628:71): [True: 0, False: 0]
  ------------------
 3629|      0|                               not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3629:32): [True: 0, False: 0]
  ------------------
 3630|      0|                              ctx.error = error_code::none;
 3631|      0|                           }
 3632|  44.6k|                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|  1.52M|                     ++non_const_idx;
 3643|  1.52M|                  }
 3644|  1.52M|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERNSt3__16vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS4_9allocatorIS9_EEEETkNS_10is_contextERNS_7contextERPKcSH_EEvOT0_OT1_OT2_T3_:
   49|  1.52M|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  1.52M|         else {
   60|  1.52M|            using V = std::remove_cvref_t<T>;
   61|  1.52M|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  1.52M|                                             end);
   63|  1.52M|         }
   64|  1.52M|      }
_ZN3glz4fromILj10ENSt3__16vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS1_9allocatorIS6_EEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERS9_TkNS_10is_contextERNS_7contextERPKcSH_EEvOT0_OT1_OT2_T3_:
 2050|  1.52M|      {
 2051|  1.52M|         constexpr auto Opts = ws_handled_off<Options>();
 2052|       |         if constexpr (!check_ws_handled(Options)) {
 2053|       |            if (skip_ws<Opts>(ctx, it, end)) {
 2054|       |               return;
 2055|       |            }
 2056|       |         }
 2057|       |
 2058|  1.52M|         if (match_invalid_end<'[', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2058:14): [True: 101, False: 1.52M]
  ------------------
 2059|    101|            return;
 2060|    101|         }
 2061|       |         // one nesting level (see enter_depth): counted in both modes so the limit binds,
 2062|       |         // released at each syntactic close below
 2063|  1.52M|         if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (2063:14): [True: 17, False: 1.52M]
  ------------------
 2064|     17|            return;
 2065|     17|         }
 2066|       |
 2067|  1.52M|         const auto ws_start = it;
 2068|  1.52M|         if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2068:14): [True: 27, False: 1.52M]
  ------------------
 2069|     27|            return;
 2070|     27|         }
 2071|       |
 2072|  1.52M|         if (*it == ']') {
  ------------------
  |  Branch (2072:14): [True: 32.2k, False: 1.49M]
  ------------------
 2073|  32.2k|            --ctx.depth;
 2074|  32.2k|            ++it;
 2075|  32.2k|            if constexpr ((resizable<T> || is_inplace_vector<T>) && not check_append_arrays(Opts)) {
 2076|  32.2k|               value.clear();
 2077|       |
 2078|       |               if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2079|       |                  value.shrink_to_fit();
 2080|       |               }
 2081|  32.2k|            }
 2082|  32.2k|            return;
 2083|  32.2k|         }
 2084|       |
 2085|  1.49M|         const size_t ws_size = size_t(it - ws_start);
 2086|       |
 2087|  1.49M|         static constexpr bool should_append = (resizable<T> || is_inplace_vector<T>) && check_append_arrays(Opts);
  ------------------
  |  Branch (2087:49): [True: 1.49M, Folded]
  |  Branch (2087:65): [Folded, False: 0]
  |  Branch (2087:90): [Folded, False: 0]
  ------------------
 2088|  1.49M|         if constexpr (not should_append) {
 2089|  1.49M|            const auto n = value.size();
 2090|       |
 2091|  1.49M|            auto value_it = value.begin();
 2092|       |
 2093|  1.50M|            for (size_t i = 0; i < n; ++i) {
  ------------------
  |  Branch (2093:32): [True: 285k, False: 1.22M]
  ------------------
 2094|   285k|               parse<JSON>::op<ws_handled<Opts>()>(*value_it++, ctx, it, end);
 2095|   285k|               if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (2095:20): [True: 1.27k, False: 283k]
  ------------------
 2096|  1.27k|                  return;
 2097|   283k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2097:20): [True: 27, False: 283k]
  ------------------
 2098|     27|                  return;
 2099|     27|               }
 2100|   283k|               if (*it == ',') {
  ------------------
  |  Branch (2100:20): [True: 17.1k, False: 266k]
  ------------------
 2101|  17.1k|                  ++it;
 2102|       |
 2103|  17.1k|                  if constexpr (!Opts.minified && !Opts.comments) {
 2104|  17.1k|                     if (ws_size && ws_size < size_t(end - it)) {
  ------------------
  |  Branch (2104:26): [True: 9.34k, False: 7.83k]
  |  Branch (2104:37): [True: 8.76k, False: 582]
  ------------------
 2105|  8.76k|                        skip_matching_ws(ws_start, it, ws_size);
 2106|  8.76k|                     }
 2107|  17.1k|                  }
 2108|       |
 2109|  17.1k|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2109:23): [True: 84, False: 17.0k]
  ------------------
 2110|     84|                     return;
 2111|     84|                  }
 2112|  17.1k|               }
 2113|   266k|               else if (*it == ']') {
  ------------------
  |  Branch (2113:25): [True: 266k, False: 134]
  ------------------
 2114|   266k|                  --ctx.depth;
 2115|   266k|                  ++it;
 2116|   266k|                  if constexpr (erasable<T>) {
 2117|   266k|                     value.erase(value_it,
 2118|   266k|                                 value.end()); // use erase rather than resize for non-default constructible elements
 2119|       |
 2120|       |                     if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2121|       |                        value.shrink_to_fit();
 2122|       |                     }
 2123|   266k|                  }
 2124|   266k|                  return;
 2125|   266k|               }
 2126|    134|               else [[unlikely]] {
 2127|    134|                  ctx.error = error_code::expected_bracket;
 2128|    134|                  return;
 2129|    134|               }
 2130|   283k|            }
 2131|  1.49M|         }
 2132|       |
 2133|       |         if constexpr (Opts.partial_read) {
 2134|       |            // partial_read stops early on a success path, so give the level back like the
 2135|       |            // syntactic-close paths do; otherwise it accumulates across reads sharing a context.
 2136|       |            --ctx.depth;
 2137|       |            return;
 2138|       |         }
 2139|  1.49M|         else {
 2140|       |            // growing
 2141|  1.49M|            if constexpr (emplace_backable<T> || has_try_emplace_back<T>) {
 2142|  4.81M|               while (it < end) {
  ------------------
  |  Branch (2142:23): [True: 4.54M, False: 268k]
  ------------------
 2143|       |                  // Streaming refill point: at start of each iteration, ensure buffer has data
 2144|       |                  if constexpr (has_streaming_state<decltype(ctx)>) {
 2145|       |                     if (ctx.stream.enabled()) {
 2146|       |                        const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 2147|       |                        const size_t remaining = ctx.stream.size() - consumed;
 2148|       |                        // Refill when less than half of buffer remains to ensure space for next element
 2149|       |                        if (remaining <= ctx.stream.size() / 2 || it >= end) {
 2150|       |                           const char* new_it;
 2151|       |                           const char* new_end;
 2152|       |                           ctx.stream.consume_and_refill(consumed, new_it, new_end);
 2153|       |                           it = new_it;
 2154|       |                           end = new_end;
 2155|       |                           if (it >= end && ctx.stream.at_eof()) {
 2156|       |                              break; // No more data, exit loop normally
 2157|       |                           }
 2158|       |                        }
 2159|       |                     }
 2160|       |                  }
 2161|       |
 2162|       |                  if constexpr (has_try_emplace_back<T>) {
 2163|       |                     if (value.try_emplace_back())
 2164|       |                        parse<JSON>::op<ws_handled<Opts>()>(value.back(), ctx, it, end);
 2165|       |                     else
 2166|       |                        ctx.error = error_code::exceeded_static_array_size;
 2167|       |                  }
 2168|  4.54M|                  else {
 2169|  4.54M|                     parse<JSON>::op<ws_handled<Opts>()>(value.emplace_back(), ctx, it, end);
 2170|  4.54M|                  }
 2171|       |
 2172|  4.54M|                  if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (2172:23): [True: 40.2k, False: 4.50M]
  ------------------
 2173|  40.2k|                     return;
 2174|       |
 2175|       |                  // Streaming refill point: after parsing each element, refill if buffer is low
 2176|       |                  if constexpr (has_streaming_state<decltype(ctx)>) {
 2177|       |                     if (ctx.stream.enabled()) {
 2178|       |                        const size_t consumed = static_cast<size_t>(it - ctx.stream.data());
 2179|       |                        // Refill when less than 25% of buffer remains to ensure enough space for next element
 2180|       |                        if (ctx.stream.size() - consumed <= ctx.stream.size() / 4 || it >= end) {
 2181|       |                           const char* new_it;
 2182|       |                           const char* new_end;
 2183|       |                           ctx.stream.consume_and_refill(consumed, new_it, new_end);
 2184|       |                           it = new_it;
 2185|       |                           end = new_end;
 2186|       |                           if (it >= end && ctx.stream.at_eof()) {
 2187|       |                              ctx.error = error_code::unexpected_end;
 2188|       |                              return;
 2189|       |                           }
 2190|       |                        }
 2191|       |                     }
 2192|       |                  }
 2193|       |
 2194|  4.50M|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2194:23): [True: 592, False: 4.50M]
  ------------------
 2195|    592|                     return;
 2196|    592|                  }
 2197|  4.50M|                  if (*it == ',') [[likely]] {
  ------------------
  |  Branch (2197:23): [True: 3.32M, False: 1.18M]
  ------------------
 2198|  3.32M|                     ++it;
 2199|       |
 2200|  3.32M|                     if constexpr (!Opts.minified && !Opts.comments) {
 2201|  3.32M|                        if (ws_size && ws_size < size_t(end - it)) {
  ------------------
  |  Branch (2201:29): [True: 47.2k, False: 3.27M]
  |  Branch (2201:40): [True: 46.4k, False: 763]
  ------------------
 2202|  46.4k|                           skip_matching_ws(ws_start, it, ws_size);
 2203|  46.4k|                        }
 2204|  3.32M|                     }
 2205|       |
 2206|  3.32M|                     if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2206:26): [True: 176, False: 3.32M]
  ------------------
 2207|    176|                        return;
 2208|    176|                     }
 2209|  3.32M|                  }
 2210|  1.18M|                  else if (*it == ']') {
  ------------------
  |  Branch (2210:28): [True: 1.17M, False: 1.95k]
  ------------------
 2211|  1.17M|                     --ctx.depth;
 2212|  1.17M|                     ++it;
 2213|       |                     if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2214|       |                        value.shrink_to_fit();
 2215|       |                     }
 2216|  1.17M|                     return;
 2217|  1.17M|                  }
 2218|  1.95k|                  else [[unlikely]] {
 2219|  1.95k|                     ctx.error = error_code::expected_bracket;
 2220|  1.95k|                     return;
 2221|  1.95k|                  }
 2222|  4.50M|               }
 2223|       |
 2224|       |               // A valid array always returns from inside the loop upon reaching ']'.
 2225|       |               // For a null-terminated buffer the loop can only exit here by falling
 2226|       |               // through when `it` reaches the terminator without a closing bracket,
 2227|       |               // which means the input was truncated (e.g. "[", "[1," or "[1,2,").
 2228|       |               // Non-null-terminated buffers surface this through skip_ws/depth
 2229|       |               // tracking (or the streaming refill break), so this guard is limited
 2230|       |               // to the null-terminated case.
 2231|       |               if constexpr (Opts.null_terminated) {
 2232|       |                  ctx.error = error_code::unexpected_end;
 2233|       |               }
 2234|       |            }
 2235|       |            else {
 2236|       |               ctx.error = error_code::exceeded_static_array_size;
 2237|       |            }
 2238|  1.49M|         }
 2239|  1.49M|      }
_ZN3glz12rewind_depthITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextENS_7contextEEEvRT0_j:
 3492|  51.9k|   {
 3493|  51.9k|      if (ctx.error == error_code::exceeded_max_recursive_depth) [[unlikely]] {
  ------------------
  |  Branch (3493:11): [True: 5.99k, False: 45.9k]
  ------------------
 3494|  5.99k|         return;
 3495|  5.99k|      }
 3496|       |      if constexpr (Opts.null_terminated) {
 3497|       |         ctx.depth = depth;
 3498|       |      }
 3499|  45.9k|      else {
 3500|  45.9k|         if (ctx.error != error_code::end_reached && ctx.error != error_code::unexpected_end) {
  ------------------
  |  Branch (3500:14): [True: 43.1k, False: 2.77k]
  |  Branch (3500:54): [True: 23.8k, False: 19.3k]
  ------------------
 3501|  23.8k|            ctx.depth = depth;
 3502|  23.8k|         }
 3503|  45.9k|      }
 3504|  45.9k|   }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm5EEEDav:
 3589|  1.52M|               for_each<N>([&]<size_t I>() {
 3590|  1.52M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 1.47M, False: 44.6k]
  |  Branch (3590:38): [True: 0, False: 44.6k]
  |  Branch (3590:51): [True: 5.99k, False: 38.6k]
  ------------------
 3591|  1.48M|                     return;
 3592|  1.48M|                  }
 3593|  38.6k|                  using V = std::variant_alternative_t<I, Variant>;
 3594|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|       |                     auto copy_it{it};
 3596|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|       |                     if (!std::holds_alternative<V>(value)) {
 3598|       |                        value = V{};
 3599|       |                     }
 3600|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|       |                     }
 3604|       |                     if (!bool(ctx.error)) {
 3605|       |                        found_match = true;
 3606|       |                     }
 3607|       |                     else if constexpr (not Options.null_terminated) {
 3608|       |                        constexpr bool is_complete_type =
 3609|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|       |                        if constexpr (is_complete_type) {
 3612|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|       |                              found_match = true;
 3614|       |                              ctx.error = error_code::none;
 3615|       |                           }
 3616|       |                           else {
 3617|       |                              it = copy_it;
 3618|       |                              rewind_depth<Options>(ctx, copy_depth);
 3619|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|       |                                  not variant_alternative_exhausted(ctx)) {
 3621|       |                                 ctx.error = error_code::none;
 3622|       |                              }
 3623|       |                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|       |                     ++non_const_idx;
 3643|       |                  }
 3644|  38.6k|               });
_ZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_:
 3520|  43.9k|      {
 3521|  43.9k|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3522|       |
 3523|       |         if constexpr (category_count == 0) {
 3524|       |            ctx.error = error_code::no_matching_variant_type;
 3525|       |         }
 3526|  43.9k|         else {
 3527|  43.9k|            constexpr auto N = std::variant_size_v<Variant>;
 3528|  43.9k|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3529|  43.9k|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3530|       |
 3531|  43.9k|            bool found_match{};
 3532|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3533|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3534|       |            // so the budget stops it and the failure already in hand is reported.
 3535|  43.9k|            bool exhausted{};
 3536|       |
 3537|       |            // First pass: const glaze types in this category
 3538|       |            if constexpr (const_count > 0) {
 3539|       |               for_each<N>([&]<size_t I>() {
 3540|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3541|       |                     return;
 3542|       |                  }
 3543|       |                  using V = std::variant_alternative_t<I, Variant>;
 3544|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3545|       |                     // run time substitute to compare to const value
 3546|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3547|       |                     auto copy_it{it};
 3548|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3549|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3550|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3551|       |                     const auto copy_depth{ctx.depth};
 3552|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3553|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3554|       |                     if (substitute == const_value) {
 3555|       |                        found_match = true;
 3556|       |                        if (!std::holds_alternative<V>(value)) {
 3557|       |                           value = V{};
 3558|       |                        }
 3559|       |                     }
 3560|       |                     else {
 3561|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3562|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3563|       |                           exhausted = true;
 3564|       |                        }
 3565|       |                        if constexpr (not Options.null_terminated) {
 3566|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3567|       |                              ctx.error = error_code::none;
 3568|       |                           }
 3569|       |                        }
 3570|       |                        it = copy_it;
 3571|       |                        rewind_depth<Options>(ctx, copy_depth);
 3572|       |                     }
 3573|       |                  }
 3574|       |               });
 3575|       |               if (found_match) {
 3576|       |                  return;
 3577|       |               }
 3578|       |            }
 3579|       |
 3580|       |            // Second pass: non-const types in this category
 3581|  43.9k|            if constexpr (non_const_count > 0) {
 3582|       |               // Track position within matching types for "is last" check.
 3583|       |               // We iterate over all variant indices but only process matching types,
 3584|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3585|       |               // the loop index directly corresponded to position in filtered set).
 3586|       |               // This has negligible cost: one increment per matching type.
 3587|  43.9k|               size_t non_const_idx = 0;
 3588|       |
 3589|  43.9k|               for_each<N>([&]<size_t I>() {
 3590|  43.9k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3591|  43.9k|                     return;
 3592|  43.9k|                  }
 3593|  43.9k|                  using V = std::variant_alternative_t<I, Variant>;
 3594|  43.9k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|  43.9k|                     auto copy_it{it};
 3596|  43.9k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|  43.9k|                     if (!std::holds_alternative<V>(value)) {
 3598|  43.9k|                        value = V{};
 3599|  43.9k|                     }
 3600|  43.9k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|  43.9k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|  43.9k|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|  43.9k|                     }
 3604|  43.9k|                     if (!bool(ctx.error)) {
 3605|  43.9k|                        found_match = true;
 3606|  43.9k|                     }
 3607|  43.9k|                     else if constexpr (not Options.null_terminated) {
 3608|  43.9k|                        constexpr bool is_complete_type =
 3609|  43.9k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|  43.9k|                        if constexpr (is_complete_type) {
 3612|  43.9k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|  43.9k|                              found_match = true;
 3614|  43.9k|                              ctx.error = error_code::none;
 3615|  43.9k|                           }
 3616|  43.9k|                           else {
 3617|  43.9k|                              it = copy_it;
 3618|  43.9k|                              rewind_depth<Options>(ctx, copy_depth);
 3619|  43.9k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|  43.9k|                                  not variant_alternative_exhausted(ctx)) {
 3621|  43.9k|                                 ctx.error = error_code::none;
 3622|  43.9k|                              }
 3623|  43.9k|                           }
 3624|  43.9k|                        }
 3625|  43.9k|                        else {
 3626|  43.9k|                           it = copy_it;
 3627|  43.9k|                           rewind_depth<Options>(ctx, copy_depth);
 3628|  43.9k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|  43.9k|                               not variant_alternative_exhausted(ctx)) {
 3630|  43.9k|                              ctx.error = error_code::none;
 3631|  43.9k|                           }
 3632|  43.9k|                        }
 3633|  43.9k|                     }
 3634|  43.9k|                     else {
 3635|  43.9k|                        it = copy_it;
 3636|  43.9k|                        rewind_depth<Options>(ctx, copy_depth);
 3637|  43.9k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|  43.9k|                            not variant_alternative_exhausted(ctx)) {
 3639|  43.9k|                           ctx.error = error_code::none;
 3640|  43.9k|                        }
 3641|  43.9k|                     }
 3642|  43.9k|                     ++non_const_idx;
 3643|  43.9k|                  }
 3644|  43.9k|               });
 3645|  43.9k|               if (!found_match) {
  ------------------
  |  Branch (3645:20): [True: 2.48k, False: 41.4k]
  ------------------
 3646|  2.48k|                  if constexpr (non_const_count == 1) {
 3647|       |                     // Keep the specific error from the single type we tried
 3648|       |                  }
 3649|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3650|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3651|       |                     ctx.error = error_code::no_matching_variant_type;
 3652|       |                  }
 3653|  2.48k|               }
 3654|       |            }
 3655|       |            else {
 3656|       |               ctx.error = error_code::no_matching_variant_type;
 3657|       |            }
 3658|  43.9k|         }
 3659|  43.9k|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm0EEEDav:
 3589|  43.9k|               for_each<N>([&]<size_t I>() {
 3590|  43.9k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 43.9k]
  |  Branch (3590:38): [True: 0, False: 43.9k]
  |  Branch (3590:51): [True: 0, False: 43.9k]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  43.9k|                  using V = std::variant_alternative_t<I, Variant>;
 3594|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|       |                     auto copy_it{it};
 3596|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|       |                     if (!std::holds_alternative<V>(value)) {
 3598|       |                        value = V{};
 3599|       |                     }
 3600|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|       |                     }
 3604|       |                     if (!bool(ctx.error)) {
 3605|       |                        found_match = true;
 3606|       |                     }
 3607|       |                     else if constexpr (not Options.null_terminated) {
 3608|       |                        constexpr bool is_complete_type =
 3609|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|       |                        if constexpr (is_complete_type) {
 3612|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|       |                              found_match = true;
 3614|       |                              ctx.error = error_code::none;
 3615|       |                           }
 3616|       |                           else {
 3617|       |                              it = copy_it;
 3618|       |                              rewind_depth<Options>(ctx, copy_depth);
 3619|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|       |                                  not variant_alternative_exhausted(ctx)) {
 3621|       |                                 ctx.error = error_code::none;
 3622|       |                              }
 3623|       |                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|       |                     ++non_const_idx;
 3643|       |                  }
 3644|  43.9k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm1EEEDav:
 3589|  43.9k|               for_each<N>([&]<size_t I>() {
 3590|  43.9k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 43.9k]
  |  Branch (3590:38): [True: 0, False: 43.9k]
  |  Branch (3590:51): [True: 0, False: 43.9k]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  43.9k|                  using V = std::variant_alternative_t<I, Variant>;
 3594|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|       |                     auto copy_it{it};
 3596|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|       |                     if (!std::holds_alternative<V>(value)) {
 3598|       |                        value = V{};
 3599|       |                     }
 3600|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|       |                     }
 3604|       |                     if (!bool(ctx.error)) {
 3605|       |                        found_match = true;
 3606|       |                     }
 3607|       |                     else if constexpr (not Options.null_terminated) {
 3608|       |                        constexpr bool is_complete_type =
 3609|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|       |                        if constexpr (is_complete_type) {
 3612|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|       |                              found_match = true;
 3614|       |                              ctx.error = error_code::none;
 3615|       |                           }
 3616|       |                           else {
 3617|       |                              it = copy_it;
 3618|       |                              rewind_depth<Options>(ctx, copy_depth);
 3619|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|       |                                  not variant_alternative_exhausted(ctx)) {
 3621|       |                                 ctx.error = error_code::none;
 3622|       |                              }
 3623|       |                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|       |                     ++non_const_idx;
 3643|       |                  }
 3644|  43.9k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm2EEEDav:
 3589|  43.9k|               for_each<N>([&]<size_t I>() {
 3590|  43.9k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 43.9k]
  |  Branch (3590:38): [True: 0, False: 43.9k]
  |  Branch (3590:51): [True: 0, False: 43.9k]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  43.9k|                  using V = std::variant_alternative_t<I, Variant>;
 3594|  43.9k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|  43.9k|                     auto copy_it{it};
 3596|  43.9k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|  43.9k|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3597:26): [True: 32.6k, False: 11.3k]
  ------------------
 3598|  32.6k|                        value = V{};
 3599|  32.6k|                     }
 3600|  43.9k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|  43.9k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3601:26): [True: 2.62k, False: 41.3k]
  |  Branch (3601:45): [True: 0, False: 2.62k]
  ------------------
 3602|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|      0|                     }
 3604|  43.9k|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3604:26): [True: 41.3k, False: 2.62k]
  ------------------
 3605|  41.3k|                        found_match = true;
 3606|  41.3k|                     }
 3607|  2.62k|                     else if constexpr (not Options.null_terminated) {
 3608|  2.62k|                        constexpr bool is_complete_type =
 3609|  2.62k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
  ------------------
  |  Branch (3609:28): [Folded, False: 0]
  |  Branch (3609:40): [Folded, False: 0]
  |  Branch (3609:53): [True: 0, Folded]
  |  Branch (3609:68): [Folded, False: 0]
  |  Branch (3609:89): [Folded, False: 0]
  |  Branch (3609:103): [Folded, False: 0]
  ------------------
 3610|       |
 3611|  2.62k|                        if constexpr (is_complete_type) {
 3612|  2.62k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
  ------------------
  |  Branch (3612:32): [True: 146, False: 2.48k]
  |  Branch (3612:72): [True: 146, False: 0]
  |  Branch (3612:88): [True: 146, False: 0]
  ------------------
 3613|    146|                              found_match = true;
 3614|    146|                              ctx.error = error_code::none;
 3615|    146|                           }
 3616|  2.48k|                           else {
 3617|  2.48k|                              it = copy_it;
 3618|  2.48k|                              rewind_depth<Options>(ctx, copy_depth);
 3619|  2.48k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3619:35): [True: 0, False: 2.48k]
  |  Branch (3619:74): [True: 0, False: 0]
  ------------------
 3620|      0|                                  not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3620:35): [True: 0, False: 0]
  ------------------
 3621|      0|                                 ctx.error = error_code::none;
 3622|      0|                              }
 3623|  2.48k|                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|  43.9k|                     ++non_const_idx;
 3643|  43.9k|                  }
 3644|  43.9k|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEETkNS_10is_contextERNS_7contextERPKcSF_EEvOT0_OT1_OT2_T3_:
   49|  43.9k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  43.9k|         else {
   60|  43.9k|            using V = std::remove_cvref_t<T>;
   61|  43.9k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  43.9k|                                             end);
   63|  43.9k|         }
   64|  43.9k|      }
_ZN3glz4fromILj10ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERPKcSC_S7_TkNS_10is_contextERNS_7contextEEEvRT2_OT3_OT0_T1_:
  887|  43.9k|      {
  888|       |         if constexpr (check_string_as_number(Opts)) {
  889|       |            auto start = it;
  890|       |            skip_number<Opts>(ctx, it, end);
  891|       |            if (bool(ctx.error)) [[unlikely]] {
  892|       |               return;
  893|       |            }
  894|       |            if (start == it) [[unlikely]] {
  895|       |               ctx.error = error_code::parse_number_failure;
  896|       |               return;
  897|       |            }
  898|       |            value.append(start, size_t(it - start));
  899|       |         }
  900|  43.9k|         else {
  901|  43.9k|            if constexpr (!check_opening_handled(Opts)) {
  902|       |               if constexpr (!check_ws_handled(Opts)) {
  903|       |                  if (skip_ws<Opts>(ctx, it, end)) {
  904|       |                     return;
  905|       |                  }
  906|       |               }
  907|       |
  908|  43.9k|               if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (908:20): [True: 90, False: 43.8k]
  ------------------
  909|     90|                  return;
  910|     90|               }
  911|  43.9k|            }
  912|       |
  913|  43.9k|            if constexpr (not check_raw_string(Opts)) {
  914|  43.9k|               static constexpr auto string_padding_bytes = 8;
  915|       |
  916|       |               // How much buffer has to remain for an eight byte load at the cursor to stay inside
  917|       |               // it. One on a padded input, where the last chunk is free to straddle the end of the
  918|       |               // document, so the byte tails below are unreachable; eight otherwise, which costs the
  919|       |               // final bytes of the buffer their chunked path and nothing else.
  920|  43.9k|               const std::ptrdiff_t scan_min = chunk_min<8>(ctx.padded_input);
  921|       |
  922|  43.9k|               if (size_t(end - it) >= 8) {
  ------------------
  |  Branch (922:20): [True: 42.4k, False: 1.54k]
  ------------------
  923|       |                  // The bound as a pointer, so the loops below spend a compare per chunk rather
  924|       |                  // than a subtract and a compare. Well defined here and nowhere else in this
  925|       |                  // reader: the branch has just established that at least eight bytes remain, and
  926|       |                  // `scan_min` is at most eight.
  927|  42.4k|                  const auto* const chunk_limit = end - scan_min;
  928|       |
  929|  42.4k|                  auto start = it;
  930|  42.4k|                  uint64_t ascii_acc{};
  931|  6.77M|                  while (it <= chunk_limit) {
  ------------------
  |  Branch (931:26): [True: 6.77M, False: 1.13k]
  ------------------
  932|  6.77M|                     uint64_t chunk;
  933|  6.77M|                     std::memcpy(&chunk, it, 8);
  934|       |                     if constexpr (std::endian::native == std::endian::big) {
  935|       |                        chunk = std::byteswap(chunk);
  936|       |                     }
  937|  6.77M|                     ascii_acc |= chunk;
  938|  6.77M|                     const uint64_t test_chars = has_quote(chunk);
  939|  6.77M|                     if (test_chars) {
  ------------------
  |  Branch (939:26): [True: 42.2k, False: 6.73M]
  ------------------
  940|  42.2k|                        it += (countr_zero(test_chars) >> 3);
  941|       |
  942|  42.2k|                        auto* prev = it - 1;
  943|  45.7k|                        while (*prev == '\\') {
  ------------------
  |  Branch (943:32): [True: 3.45k, False: 42.2k]
  ------------------
  944|  3.45k|                           --prev;
  945|  3.45k|                        }
  946|  42.2k|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (946:29): [True: 41.2k, False: 984]
  ------------------
  947|  41.2k|                           goto continue_decode;
  948|  41.2k|                        }
  949|    984|                        ++it; // skip the escaped quote
  950|    984|                     }
  951|  6.73M|                     else {
  952|  6.73M|                        it += 8;
  953|  6.73M|                     }
  954|  6.77M|                  }
  955|       |
  956|  2.37k|                  while (it[-1] == '\\') [[unlikely]] {
  ------------------
  |  Branch (956:26): [True: 1.24k, False: 1.13k]
  ------------------
  957|       |                     // if we ended on an escape character then we need to rewind
  958|       |                     // because we lost our context
  959|  1.24k|                     --it;
  960|  1.24k|                  }
  961|       |
  962|       |                  // The byte-wise tail keeps feeding the accumulator: it has to cover every byte of
  963|       |                  // the string, or a non-ASCII byte reached here would be waved through unvalidated.
  964|  4.96k|                  for (; it < end; ++it) {
  ------------------
  |  Branch (964:26): [True: 4.76k, False: 206]
  ------------------
  965|  4.76k|                     ascii_acc |= uint8_t(*it);
  966|  4.76k|                     if (*it == '"') {
  ------------------
  |  Branch (966:26): [True: 978, False: 3.78k]
  ------------------
  967|    978|                        auto* prev = it - 1;
  968|  1.42k|                        while (*prev == '\\') {
  ------------------
  |  Branch (968:32): [True: 450, False: 978]
  ------------------
  969|    450|                           --prev;
  970|    450|                        }
  971|    978|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (971:29): [True: 930, False: 48]
  ------------------
  972|    930|                           goto continue_decode;
  973|    930|                        }
  974|    978|                     }
  975|  4.76k|                  }
  976|       |
  977|    206|                  ctx.error = error_code::unexpected_end;
  978|    206|                  return;
  979|       |
  980|  42.2k|               continue_decode:
  981|       |
  982|  42.2k|                  if (validate_utf8_span<Opts>(ctx, start, it, ascii_acc)) [[unlikely]] {
  ------------------
  |  Branch (982:23): [True: 325, False: 41.8k]
  ------------------
  983|    325|                     return;
  984|    325|                  }
  985|       |
  986|  41.8k|                  auto n = size_t(it - start);
  987|       |
  988|       |                  // The padding lets the chunked copy below run up to the closing quote. Skip it when it
  989|       |                  // would be the only reason to allocate, as for a string that fits the small string
  990|       |                  // buffer but not with eight bytes to spare.
  991|  41.8k|                  bool pad = true;
  992|  41.8k|                  if constexpr (requires { value.capacity(); }) {
  993|  41.8k|                     const auto capacity = size_t(value.capacity());
  994|  41.8k|                     pad = capacity >= n + string_padding_bytes || capacity < n;
  ------------------
  |  Branch (994:28): [True: 30.0k, False: 11.8k]
  |  Branch (994:68): [True: 6.36k, False: 5.49k]
  ------------------
  995|  41.8k|                  }
  996|  41.8k|                  resize_unfilled(value, pad ? n + string_padding_bytes : n);
  ------------------
  |  Branch (996:42): [True: 36.3k, False: 5.49k]
  ------------------
  997|       |
  998|  41.8k|                  auto* p = value.data();
  999|       |
 1000|       |                  // An error below returns with the tail of `value` still unwritten. Leave the size at
 1001|       |                  // what was actually written rather than at the padded length, which resize_unfilled
 1002|       |                  // did not fill.
 1003|  41.8k|                  auto* const written_begin = p;
 1004|       |
 1005|       |                  // Without the padding, copy a chunk only while eight bytes remain before the quote.
 1006|       |                  // Unescaping never puts the output ahead of the input, so no store lands past the end.
 1007|  41.8k|                  const auto* const copy_end = pad ? it : it - (std::min)(n, size_t(7));
  ------------------
  |  Branch (1007:48): [True: 36.3k, False: 5.49k]
  ------------------
 1008|       |
 1009|       |                  // Copy eight bytes at a time for as long as eight bytes are there to read, then
 1010|       |                  // finish the span below. The chunked form reads past the character it is looking
 1011|       |                  // at, so on an unpadded buffer it has to stop short of the end; splitting it this
 1012|       |                  // way keeps it for the body of every string rather than giving it up whenever the
 1013|       |                  // string happens to finish near the end of the buffer -- which, for a document
 1014|       |                  // that is itself one string, is every string.
 1015|   575k|                  while (start < copy_end && start <= chunk_limit) {
  ------------------
  |  Branch (1015:26): [True: 535k, False: 39.9k]
  |  Branch (1015:46): [True: 535k, False: 315]
  ------------------
 1016|   535k|                     std::memcpy(p, start, 8);
 1017|   535k|                     uint64_t swar;
 1018|   535k|                     std::memcpy(&swar, p, 8);
 1019|       |                     if constexpr (std::endian::native == std::endian::big) {
 1020|       |                        swar = std::byteswap(swar);
 1021|       |                     }
 1022|       |
 1023|   535k|                     constexpr uint64_t lo7_mask = repeat_byte8(0b01111111);
 1024|   535k|                     const uint64_t lo7 = swar & lo7_mask;
 1025|   535k|                     const uint64_t backslash = (lo7 ^ repeat_byte8('\\')) + lo7_mask;
 1026|   535k|                     const uint64_t less_32 = (swar & repeat_byte8(0b01100000)) + lo7_mask;
 1027|   535k|                     uint64_t next = ~((backslash & less_32) | swar);
 1028|       |
 1029|   535k|                     next &= repeat_byte8(0b10000000);
 1030|   535k|                     if (next == 0) {
  ------------------
  |  Branch (1030:26): [True: 523k, False: 11.1k]
  ------------------
 1031|   523k|                        start += 8;
 1032|   523k|                        p += 8;
 1033|   523k|                        continue;
 1034|   523k|                     }
 1035|       |
 1036|  11.1k|                     next = countr_zero(next) >> 3;
 1037|  11.1k|                     start += next;
 1038|  11.1k|                     if (start >= it) {
  ------------------
  |  Branch (1038:26): [True: 905, False: 10.2k]
  ------------------
 1039|    905|                        break;
 1040|    905|                     }
 1041|       |
 1042|  10.2k|                     if ((*start & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1042:26): [True: 266, False: 10.0k]
  ------------------
 1043|    266|                        ctx.error = error_code::syntax_error;
 1044|    266|                        value.resize(size_t(p - written_begin));
 1045|    266|                        return;
 1046|    266|                     }
 1047|  10.0k|                     ++start; // skip the escape
 1048|  10.0k|                     if (*start == 'u') {
  ------------------
  |  Branch (1048:26): [True: 7.44k, False: 2.55k]
  ------------------
 1049|  7.44k|                        ++start;
 1050|  7.44k|                        p += next;
 1051|  7.44k|                        const auto mark = start;
 1052|  7.44k|                        const auto decoded = handle_unicode_code_point(start, p, end);
 1053|  7.44k|                        if (decoded.written == 0) [[unlikely]] {
  ------------------
  |  Branch (1053:29): [True: 368, False: 7.07k]
  ------------------
 1054|    368|                           ctx.error = decoded.truncated ? error_code::unexpected_end
  ------------------
  |  Branch (1054:40): [True: 0, False: 368]
  ------------------
 1055|    368|                                                         : error_code::unicode_escape_conversion_failure;
 1056|    368|                           value.resize(size_t(p - written_begin));
 1057|    368|                           return;
 1058|    368|                        }
 1059|  7.07k|                        n += decoded.written;
 1060|       |                        // escape + u + unicode code points
 1061|  7.07k|                        n -= 2 + uint32_t(start - mark);
 1062|  7.07k|                     }
 1063|  2.55k|                     else {
 1064|  2.55k|                        p += next;
 1065|  2.55k|                        *p = char_unescape_table[uint8_t(*start)];
 1066|  2.55k|                        if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1066:29): [True: 65, False: 2.49k]
  ------------------
 1067|     65|                           ctx.error = error_code::invalid_escape;
 1068|     65|                           value.resize(size_t(p - written_begin));
 1069|     65|                           return;
 1070|     65|                        }
 1071|  2.49k|                        ++p;
 1072|  2.49k|                        ++start;
 1073|  2.49k|                        --n;
 1074|  2.49k|                     }
 1075|  10.0k|                  }
 1076|       |
 1077|       |                  // Whatever the chunked copy could not reach. `p` and `start` stay in step across
 1078|       |                  // that loop, so this picks up exactly where it stopped.
 1079|  58.9k|                  while (start < it) {
  ------------------
  |  Branch (1079:26): [True: 18.0k, False: 40.9k]
  ------------------
 1080|  18.0k|                     if ((*start & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1080:26): [True: 35, False: 17.9k]
  ------------------
 1081|     35|                        ctx.error = error_code::syntax_error;
 1082|     35|                        value.resize(size_t(p - written_begin));
 1083|     35|                        return;
 1084|     35|                     }
 1085|  17.9k|                     if (*start == '\\') {
  ------------------
  |  Branch (1085:26): [True: 2.33k, False: 15.6k]
  ------------------
 1086|  2.33k|                        ++start; // skip the escape
 1087|  2.33k|                        if (*start == 'u') {
  ------------------
  |  Branch (1087:29): [True: 1.87k, False: 467]
  ------------------
 1088|  1.87k|                           ++start;
 1089|  1.87k|                           const auto mark = start;
 1090|  1.87k|                           const auto decoded = handle_unicode_code_point(start, p, end);
 1091|  1.87k|                           if (decoded.written == 0) [[unlikely]] {
  ------------------
  |  Branch (1091:32): [True: 171, False: 1.70k]
  ------------------
 1092|    171|                              ctx.error = decoded.truncated ? error_code::unexpected_end
  ------------------
  |  Branch (1092:43): [True: 0, False: 171]
  ------------------
 1093|    171|                                                            : error_code::unicode_escape_conversion_failure;
 1094|    171|                              value.resize(size_t(p - written_begin));
 1095|    171|                              return;
 1096|    171|                           }
 1097|  1.70k|                           n += decoded.written;
 1098|  1.70k|                           n -= 2 + uint32_t(start - mark);
 1099|  1.70k|                        }
 1100|    467|                        else {
 1101|    467|                           *p = char_unescape_table[uint8_t(*start)];
 1102|    467|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1102:32): [True: 25, False: 442]
  ------------------
 1103|     25|                              ctx.error = error_code::invalid_escape;
 1104|     25|                              value.resize(size_t(p - written_begin));
 1105|     25|                              return;
 1106|     25|                           }
 1107|    442|                           ++p;
 1108|    442|                           ++start;
 1109|    442|                           --n;
 1110|    442|                        }
 1111|  2.33k|                     }
 1112|  15.6k|                     else {
 1113|  15.6k|                        *p = *start;
 1114|  15.6k|                        ++p;
 1115|  15.6k|                        ++start;
 1116|  15.6k|                     }
 1117|  17.9k|                  }
 1118|       |
 1119|  40.9k|                  value.resize(n);
 1120|  40.9k|                  ++it;
 1121|  40.9k|               }
 1122|  1.54k|               else {
 1123|       |                  // For short strings
 1124|       |
 1125|  1.54k|                  std::array<char, 8> buffer{};
 1126|       |
 1127|  1.54k|                  auto* p = buffer.data();
 1128|  1.54k|                  const auto* const utf8_start = it;
 1129|       |
 1130|  3.59k|                  while (it < end) [[likely]] {
  ------------------
  |  Branch (1130:26): [True: 3.42k, False: 166]
  ------------------
 1131|  3.42k|                     *p = *it;
 1132|  3.42k|                     if (*it == '"') {
  ------------------
  |  Branch (1132:26): [True: 745, False: 2.68k]
  ------------------
 1133|    745|                        if (validate_utf8_span<Opts>(ctx, utf8_start, it)) [[unlikely]] {
  ------------------
  |  Branch (1133:29): [True: 222, False: 523]
  ------------------
 1134|    222|                           return;
 1135|    222|                        }
 1136|    523|                        const size_t n = size_t(p - buffer.data());
 1137|    523|#if __has_cpp_attribute(assume) >= 202207L
 1138|    523|                        [[assume(n <= sizeof(buffer))]];
 1139|    523|#endif
 1140|    523|                        value.assign(buffer.data(), n);
 1141|    523|                        ++it;
 1142|    523|                        if constexpr (not Opts.null_terminated) {
 1143|    523|                           if (it == end) {
  ------------------
  |  Branch (1143:32): [True: 146, False: 377]
  ------------------
 1144|    146|                              ctx.error = error_code::end_reached;
 1145|    146|                              return;
 1146|    146|                           }
 1147|    523|                        }
 1148|    377|                        return;
 1149|    745|                     }
 1150|  2.68k|                     else if (*it == '\\') {
  ------------------
  |  Branch (1150:31): [True: 396, False: 2.28k]
  ------------------
 1151|       |                        // Bounded whatever `null_terminated` says: a document cut off inside an
 1152|       |                        // escape has run out of input, and saying so beats blaming the terminator
 1153|       |                        // the cut exposed -- which is what reading on would find, and would report
 1154|       |                        // as a malformed escape.
 1155|    396|                        ++it; // skip the escape
 1156|    396|                        if (it == end) [[unlikely]] {
  ------------------
  |  Branch (1156:29): [True: 2, False: 394]
  ------------------
 1157|      2|                           ctx.error = error_code::unexpected_end;
 1158|      2|                           return;
 1159|      2|                        }
 1160|    394|                        if (*it == 'u') {
  ------------------
  |  Branch (1160:29): [True: 264, False: 130]
  ------------------
 1161|    264|                           ++it;
 1162|    264|                           if (it == end) [[unlikely]] {
  ------------------
  |  Branch (1162:32): [True: 2, False: 262]
  ------------------
 1163|      2|                              ctx.error = error_code::unexpected_end;
 1164|      2|                              return;
 1165|      2|                           }
 1166|    262|                           const auto decoded = handle_unicode_code_point(it, p, end);
 1167|    262|                           if (decoded.written == 0) [[unlikely]] {
  ------------------
  |  Branch (1167:32): [True: 121, False: 141]
  ------------------
 1168|    121|                              ctx.error = decoded.truncated ? error_code::unexpected_end
  ------------------
  |  Branch (1168:43): [True: 56, False: 65]
  ------------------
 1169|    121|                                                            : error_code::unicode_escape_conversion_failure;
 1170|    121|                              return;
 1171|    121|                           }
 1172|    262|                        }
 1173|    130|                        else {
 1174|    130|                           *p = char_unescape_table[uint8_t(*it)];
 1175|    130|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1175:32): [True: 39, False: 91]
  ------------------
 1176|     39|                              ctx.error = error_code::invalid_escape;
 1177|     39|                              return;
 1178|     39|                           }
 1179|     91|                           ++p;
 1180|     91|                           ++it;
 1181|     91|                        }
 1182|    394|                     }
 1183|  2.28k|                     else if ((*it & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1183:31): [True: 468, False: 1.81k]
  ------------------
 1184|    468|                        ctx.error = error_code::syntax_error;
 1185|    468|                        return;
 1186|    468|                     }
 1187|  1.81k|                     else {
 1188|  1.81k|                        ++it;
 1189|  1.81k|                        ++p;
 1190|  1.81k|                     }
 1191|  3.42k|                  }
 1192|       |
 1193|    166|                  ctx.error = error_code::unexpected_end;
 1194|    166|               }
 1195|       |            }
 1196|       |            else {
 1197|       |               // raw_string
 1198|       |               auto start = it;
 1199|       |               skip_string_view(ctx, it, end);
 1200|       |               if (bool(ctx.error)) [[unlikely]]
 1201|       |                  return;
 1202|       |
 1203|       |               if (validate_utf8_span<Opts>(ctx, start, it)) [[unlikely]] {
 1204|       |                  return;
 1205|       |               }
 1206|       |
 1207|       |               value.assign(start, size_t(it - start));
 1208|       |               ++it;
 1209|       |            }
 1210|  43.9k|         }
 1211|  43.9k|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm3EEEDav:
 3589|  43.9k|               for_each<N>([&]<size_t I>() {
 3590|  43.9k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 41.4k, False: 2.48k]
  |  Branch (3590:38): [True: 0, False: 2.48k]
  |  Branch (3590:51): [True: 0, False: 2.48k]
  ------------------
 3591|  41.4k|                     return;
 3592|  41.4k|                  }
 3593|  2.48k|                  using V = std::variant_alternative_t<I, Variant>;
 3594|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|       |                     auto copy_it{it};
 3596|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|       |                     if (!std::holds_alternative<V>(value)) {
 3598|       |                        value = V{};
 3599|       |                     }
 3600|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|       |                     }
 3604|       |                     if (!bool(ctx.error)) {
 3605|       |                        found_match = true;
 3606|       |                     }
 3607|       |                     else if constexpr (not Options.null_terminated) {
 3608|       |                        constexpr bool is_complete_type =
 3609|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|       |                        if constexpr (is_complete_type) {
 3612|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|       |                              found_match = true;
 3614|       |                              ctx.error = error_code::none;
 3615|       |                           }
 3616|       |                           else {
 3617|       |                              it = copy_it;
 3618|       |                              rewind_depth<Options>(ctx, copy_depth);
 3619|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|       |                                  not variant_alternative_exhausted(ctx)) {
 3621|       |                                 ctx.error = error_code::none;
 3622|       |                              }
 3623|       |                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|       |                     ++non_const_idx;
 3643|       |                  }
 3644|  2.48k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm4EEEDav:
 3589|  43.9k|               for_each<N>([&]<size_t I>() {
 3590|  43.9k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 41.4k, False: 2.48k]
  |  Branch (3590:38): [True: 0, False: 2.48k]
  |  Branch (3590:51): [True: 0, False: 2.48k]
  ------------------
 3591|  41.4k|                     return;
 3592|  41.4k|                  }
 3593|  2.48k|                  using V = std::variant_alternative_t<I, Variant>;
 3594|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|       |                     auto copy_it{it};
 3596|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|       |                     if (!std::holds_alternative<V>(value)) {
 3598|       |                        value = V{};
 3599|       |                     }
 3600|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|       |                     }
 3604|       |                     if (!bool(ctx.error)) {
 3605|       |                        found_match = true;
 3606|       |                     }
 3607|       |                     else if constexpr (not Options.null_terminated) {
 3608|       |                        constexpr bool is_complete_type =
 3609|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|       |                        if constexpr (is_complete_type) {
 3612|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|       |                              found_match = true;
 3614|       |                              ctx.error = error_code::none;
 3615|       |                           }
 3616|       |                           else {
 3617|       |                              it = copy_it;
 3618|       |                              rewind_depth<Options>(ctx, copy_depth);
 3619|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|       |                                  not variant_alternative_exhausted(ctx)) {
 3621|       |                                 ctx.error = error_code::none;
 3622|       |                              }
 3623|       |                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|       |                     ++non_const_idx;
 3643|       |                  }
 3644|  2.48k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm5EEEDav:
 3589|  43.9k|               for_each<N>([&]<size_t I>() {
 3590|  43.9k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 41.4k, False: 2.48k]
  |  Branch (3590:38): [True: 0, False: 2.48k]
  |  Branch (3590:51): [True: 0, False: 2.48k]
  ------------------
 3591|  41.4k|                     return;
 3592|  41.4k|                  }
 3593|  2.48k|                  using V = std::variant_alternative_t<I, Variant>;
 3594|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|       |                     auto copy_it{it};
 3596|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|       |                     if (!std::holds_alternative<V>(value)) {
 3598|       |                        value = V{};
 3599|       |                     }
 3600|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|       |                     }
 3604|       |                     if (!bool(ctx.error)) {
 3605|       |                        found_match = true;
 3606|       |                     }
 3607|       |                     else if constexpr (not Options.null_terminated) {
 3608|       |                        constexpr bool is_complete_type =
 3609|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|       |                        if constexpr (is_complete_type) {
 3612|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|       |                              found_match = true;
 3614|       |                              ctx.error = error_code::none;
 3615|       |                           }
 3616|       |                           else {
 3617|       |                              it = copy_it;
 3618|       |                              rewind_depth<Options>(ctx, copy_depth);
 3619|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|       |                                  not variant_alternative_exhausted(ctx)) {
 3621|       |                                 ctx.error = error_code::none;
 3622|       |                              }
 3623|       |                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|       |                     ++non_const_idx;
 3643|       |                  }
 3644|  2.48k|               });
_ZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_:
 3520|  4.72k|      {
 3521|  4.72k|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3522|       |
 3523|       |         if constexpr (category_count == 0) {
 3524|       |            ctx.error = error_code::no_matching_variant_type;
 3525|       |         }
 3526|  4.72k|         else {
 3527|  4.72k|            constexpr auto N = std::variant_size_v<Variant>;
 3528|  4.72k|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3529|  4.72k|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3530|       |
 3531|  4.72k|            bool found_match{};
 3532|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3533|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3534|       |            // so the budget stops it and the failure already in hand is reported.
 3535|  4.72k|            bool exhausted{};
 3536|       |
 3537|       |            // First pass: const glaze types in this category
 3538|       |            if constexpr (const_count > 0) {
 3539|       |               for_each<N>([&]<size_t I>() {
 3540|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3541|       |                     return;
 3542|       |                  }
 3543|       |                  using V = std::variant_alternative_t<I, Variant>;
 3544|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3545|       |                     // run time substitute to compare to const value
 3546|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3547|       |                     auto copy_it{it};
 3548|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3549|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3550|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3551|       |                     const auto copy_depth{ctx.depth};
 3552|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3553|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3554|       |                     if (substitute == const_value) {
 3555|       |                        found_match = true;
 3556|       |                        if (!std::holds_alternative<V>(value)) {
 3557|       |                           value = V{};
 3558|       |                        }
 3559|       |                     }
 3560|       |                     else {
 3561|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3562|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3563|       |                           exhausted = true;
 3564|       |                        }
 3565|       |                        if constexpr (not Options.null_terminated) {
 3566|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3567|       |                              ctx.error = error_code::none;
 3568|       |                           }
 3569|       |                        }
 3570|       |                        it = copy_it;
 3571|       |                        rewind_depth<Options>(ctx, copy_depth);
 3572|       |                     }
 3573|       |                  }
 3574|       |               });
 3575|       |               if (found_match) {
 3576|       |                  return;
 3577|       |               }
 3578|       |            }
 3579|       |
 3580|       |            // Second pass: non-const types in this category
 3581|  4.72k|            if constexpr (non_const_count > 0) {
 3582|       |               // Track position within matching types for "is last" check.
 3583|       |               // We iterate over all variant indices but only process matching types,
 3584|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3585|       |               // the loop index directly corresponded to position in filtered set).
 3586|       |               // This has negligible cost: one increment per matching type.
 3587|  4.72k|               size_t non_const_idx = 0;
 3588|       |
 3589|  4.72k|               for_each<N>([&]<size_t I>() {
 3590|  4.72k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3591|  4.72k|                     return;
 3592|  4.72k|                  }
 3593|  4.72k|                  using V = std::variant_alternative_t<I, Variant>;
 3594|  4.72k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|  4.72k|                     auto copy_it{it};
 3596|  4.72k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|  4.72k|                     if (!std::holds_alternative<V>(value)) {
 3598|  4.72k|                        value = V{};
 3599|  4.72k|                     }
 3600|  4.72k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|  4.72k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|  4.72k|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|  4.72k|                     }
 3604|  4.72k|                     if (!bool(ctx.error)) {
 3605|  4.72k|                        found_match = true;
 3606|  4.72k|                     }
 3607|  4.72k|                     else if constexpr (not Options.null_terminated) {
 3608|  4.72k|                        constexpr bool is_complete_type =
 3609|  4.72k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|  4.72k|                        if constexpr (is_complete_type) {
 3612|  4.72k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|  4.72k|                              found_match = true;
 3614|  4.72k|                              ctx.error = error_code::none;
 3615|  4.72k|                           }
 3616|  4.72k|                           else {
 3617|  4.72k|                              it = copy_it;
 3618|  4.72k|                              rewind_depth<Options>(ctx, copy_depth);
 3619|  4.72k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|  4.72k|                                  not variant_alternative_exhausted(ctx)) {
 3621|  4.72k|                                 ctx.error = error_code::none;
 3622|  4.72k|                              }
 3623|  4.72k|                           }
 3624|  4.72k|                        }
 3625|  4.72k|                        else {
 3626|  4.72k|                           it = copy_it;
 3627|  4.72k|                           rewind_depth<Options>(ctx, copy_depth);
 3628|  4.72k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|  4.72k|                               not variant_alternative_exhausted(ctx)) {
 3630|  4.72k|                              ctx.error = error_code::none;
 3631|  4.72k|                           }
 3632|  4.72k|                        }
 3633|  4.72k|                     }
 3634|  4.72k|                     else {
 3635|  4.72k|                        it = copy_it;
 3636|  4.72k|                        rewind_depth<Options>(ctx, copy_depth);
 3637|  4.72k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|  4.72k|                            not variant_alternative_exhausted(ctx)) {
 3639|  4.72k|                           ctx.error = error_code::none;
 3640|  4.72k|                        }
 3641|  4.72k|                     }
 3642|  4.72k|                     ++non_const_idx;
 3643|  4.72k|                  }
 3644|  4.72k|               });
 3645|  4.72k|               if (!found_match) {
  ------------------
  |  Branch (3645:20): [True: 423, False: 4.30k]
  ------------------
 3646|    423|                  if constexpr (non_const_count == 1) {
 3647|       |                     // Keep the specific error from the single type we tried
 3648|       |                  }
 3649|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3650|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3651|       |                     ctx.error = error_code::no_matching_variant_type;
 3652|       |                  }
 3653|    423|               }
 3654|       |            }
 3655|       |            else {
 3656|       |               ctx.error = error_code::no_matching_variant_type;
 3657|       |            }
 3658|  4.72k|         }
 3659|  4.72k|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm0EEEDav:
 3589|  4.72k|               for_each<N>([&]<size_t I>() {
 3590|  4.72k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 4.72k]
  |  Branch (3590:38): [True: 0, False: 4.72k]
  |  Branch (3590:51): [True: 0, False: 4.72k]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  4.72k|                  using V = std::variant_alternative_t<I, Variant>;
 3594|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|       |                     auto copy_it{it};
 3596|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|       |                     if (!std::holds_alternative<V>(value)) {
 3598|       |                        value = V{};
 3599|       |                     }
 3600|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|       |                     }
 3604|       |                     if (!bool(ctx.error)) {
 3605|       |                        found_match = true;
 3606|       |                     }
 3607|       |                     else if constexpr (not Options.null_terminated) {
 3608|       |                        constexpr bool is_complete_type =
 3609|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|       |                        if constexpr (is_complete_type) {
 3612|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|       |                              found_match = true;
 3614|       |                              ctx.error = error_code::none;
 3615|       |                           }
 3616|       |                           else {
 3617|       |                              it = copy_it;
 3618|       |                              rewind_depth<Options>(ctx, copy_depth);
 3619|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|       |                                  not variant_alternative_exhausted(ctx)) {
 3621|       |                                 ctx.error = error_code::none;
 3622|       |                              }
 3623|       |                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|       |                     ++non_const_idx;
 3643|       |                  }
 3644|  4.72k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm1EEEDav:
 3589|  4.72k|               for_each<N>([&]<size_t I>() {
 3590|  4.72k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 4.72k]
  |  Branch (3590:38): [True: 0, False: 4.72k]
  |  Branch (3590:51): [True: 0, False: 4.72k]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  4.72k|                  using V = std::variant_alternative_t<I, Variant>;
 3594|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|       |                     auto copy_it{it};
 3596|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|       |                     if (!std::holds_alternative<V>(value)) {
 3598|       |                        value = V{};
 3599|       |                     }
 3600|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|       |                     }
 3604|       |                     if (!bool(ctx.error)) {
 3605|       |                        found_match = true;
 3606|       |                     }
 3607|       |                     else if constexpr (not Options.null_terminated) {
 3608|       |                        constexpr bool is_complete_type =
 3609|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|       |                        if constexpr (is_complete_type) {
 3612|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|       |                              found_match = true;
 3614|       |                              ctx.error = error_code::none;
 3615|       |                           }
 3616|       |                           else {
 3617|       |                              it = copy_it;
 3618|       |                              rewind_depth<Options>(ctx, copy_depth);
 3619|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|       |                                  not variant_alternative_exhausted(ctx)) {
 3621|       |                                 ctx.error = error_code::none;
 3622|       |                              }
 3623|       |                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|       |                     ++non_const_idx;
 3643|       |                  }
 3644|  4.72k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm2EEEDav:
 3589|  4.72k|               for_each<N>([&]<size_t I>() {
 3590|  4.72k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 4.72k]
  |  Branch (3590:38): [True: 0, False: 4.72k]
  |  Branch (3590:51): [True: 0, False: 4.72k]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  4.72k|                  using V = std::variant_alternative_t<I, Variant>;
 3594|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|       |                     auto copy_it{it};
 3596|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|       |                     if (!std::holds_alternative<V>(value)) {
 3598|       |                        value = V{};
 3599|       |                     }
 3600|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|       |                     }
 3604|       |                     if (!bool(ctx.error)) {
 3605|       |                        found_match = true;
 3606|       |                     }
 3607|       |                     else if constexpr (not Options.null_terminated) {
 3608|       |                        constexpr bool is_complete_type =
 3609|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|       |                        if constexpr (is_complete_type) {
 3612|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|       |                              found_match = true;
 3614|       |                              ctx.error = error_code::none;
 3615|       |                           }
 3616|       |                           else {
 3617|       |                              it = copy_it;
 3618|       |                              rewind_depth<Options>(ctx, copy_depth);
 3619|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|       |                                  not variant_alternative_exhausted(ctx)) {
 3621|       |                                 ctx.error = error_code::none;
 3622|       |                              }
 3623|       |                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|       |                     ++non_const_idx;
 3643|       |                  }
 3644|  4.72k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm3EEEDav:
 3589|  4.72k|               for_each<N>([&]<size_t I>() {
 3590|  4.72k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 4.72k]
  |  Branch (3590:38): [True: 0, False: 4.72k]
  |  Branch (3590:51): [True: 0, False: 4.72k]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  4.72k|                  using V = std::variant_alternative_t<I, Variant>;
 3594|  4.72k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|  4.72k|                     auto copy_it{it};
 3596|  4.72k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|  4.72k|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3597:26): [True: 4.26k, False: 456]
  ------------------
 3598|  4.26k|                        value = V{};
 3599|  4.26k|                     }
 3600|  4.72k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|  4.72k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3601:26): [True: 445, False: 4.28k]
  |  Branch (3601:45): [True: 0, False: 445]
  ------------------
 3602|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|      0|                     }
 3604|  4.72k|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3604:26): [True: 4.28k, False: 445]
  ------------------
 3605|  4.28k|                        found_match = true;
 3606|  4.28k|                     }
 3607|    445|                     else if constexpr (not Options.null_terminated) {
 3608|    445|                        constexpr bool is_complete_type =
 3609|    445|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
  ------------------
  |  Branch (3609:28): [Folded, False: 0]
  |  Branch (3609:40): [True: 0, Folded]
  |  Branch (3609:53): [Folded, False: 0]
  |  Branch (3609:68): [Folded, False: 0]
  |  Branch (3609:89): [Folded, False: 0]
  |  Branch (3609:103): [Folded, False: 0]
  ------------------
 3610|       |
 3611|    445|                        if constexpr (is_complete_type) {
 3612|    445|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
  ------------------
  |  Branch (3612:32): [True: 22, False: 423]
  |  Branch (3612:72): [True: 22, False: 0]
  |  Branch (3612:88): [True: 22, False: 0]
  ------------------
 3613|     22|                              found_match = true;
 3614|     22|                              ctx.error = error_code::none;
 3615|     22|                           }
 3616|    423|                           else {
 3617|    423|                              it = copy_it;
 3618|    423|                              rewind_depth<Options>(ctx, copy_depth);
 3619|    423|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3619:35): [True: 0, False: 423]
  |  Branch (3619:74): [True: 0, False: 0]
  ------------------
 3620|      0|                                  not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3620:35): [True: 0, False: 0]
  ------------------
 3621|      0|                                 ctx.error = error_code::none;
 3622|      0|                              }
 3623|    423|                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|  4.72k|                     ++non_const_idx;
 3643|  4.72k|                  }
 3644|  4.72k|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERbTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
   49|  4.72k|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  4.72k|         else {
   60|  4.72k|            using V = std::remove_cvref_t<T>;
   61|  4.72k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  4.72k|                                             end);
   63|  4.72k|         }
   64|  4.72k|      }
_ZN3glz4fromILj10EbE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEETkNS_6bool_tERbTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
  667|  4.72k|      {
  668|       |         if constexpr (check_quoted_num(Opts)) {
  669|       |            if (skip_ws<Opts>(ctx, it, end)) {
  670|       |               return;
  671|       |            }
  672|       |            if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  673|       |               return;
  674|       |            }
  675|       |         }
  676|       |
  677|       |         if constexpr (!check_ws_handled(Opts)) {
  678|       |            if (skip_ws<Opts>(ctx, it, end)) {
  679|       |               return;
  680|       |            }
  681|       |         }
  682|       |
  683|       |         if constexpr (check_bools_as_numbers(Opts)) {
  684|       |            if (*it == '1') {
  685|       |               value = true;
  686|       |               ++it;
  687|       |            }
  688|       |            else if (*it == '0') {
  689|       |               value = false;
  690|       |               ++it;
  691|       |            }
  692|       |            else {
  693|       |               ctx.error = error_code::syntax_error;
  694|       |               return;
  695|       |            }
  696|       |         }
  697|  4.72k|         else {
  698|  4.72k|            if (end - it < 4) [[unlikely]] {
  ------------------
  |  Branch (698:17): [True: 114, False: 4.61k]
  ------------------
  699|    114|               ctx.error = error_code::expected_true_or_false;
  700|    114|               return;
  701|    114|            }
  702|       |
  703|  4.61k|            uint32_t c;
  704|  4.61k|            static constexpr uint32_t u_true = 0b01100101'01110101'01110010'01110100;
  705|  4.61k|            static constexpr uint32_t u_fals = 0b01110011'01101100'01100001'01100110;
  706|  4.61k|            std::memcpy(&c, it, 4);
  707|       |            if constexpr (std::endian::native == std::endian::big) {
  708|       |               c = std::byteswap(c);
  709|       |            }
  710|  4.61k|            it += 4;
  711|  4.61k|            if (c == u_true) {
  ------------------
  |  Branch (711:17): [True: 2.38k, False: 2.22k]
  ------------------
  712|  2.38k|               value = true;
  713|  2.38k|            }
  714|  2.22k|            else if (it == end) [[unlikely]] {
  ------------------
  |  Branch (714:22): [True: 108, False: 2.11k]
  ------------------
  715|    108|               ctx.error = error_code::unexpected_end;
  716|    108|               return;
  717|    108|            }
  718|  2.11k|            else {
  719|  2.11k|               if (c == u_fals && (*it == 'e')) [[likely]] {
  ------------------
  |  Branch (719:20): [True: 1.94k, False: 169]
  |  Branch (719:35): [True: 1.91k, False: 32]
  ------------------
  720|  1.91k|                  value = false;
  721|  1.91k|                  ++it;
  722|  1.91k|               }
  723|    201|               else [[unlikely]] {
  724|    201|                  ctx.error = error_code::expected_true_or_false;
  725|    201|                  return;
  726|    201|               }
  727|  2.11k|            }
  728|  4.61k|         }
  729|       |
  730|       |         if constexpr (check_quoted_num(Opts)) {
  731|       |            if constexpr (not Opts.null_terminated) {
  732|       |               if (it == end) [[unlikely]] {
  733|       |                  ctx.error = error_code::unexpected_end;
  734|       |                  return;
  735|       |               }
  736|       |            }
  737|       |            if (match<'"'>(ctx, it)) {
  738|       |               return;
  739|       |            }
  740|       |            if constexpr (not Opts.null_terminated) {
  741|       |               if (it == end) {
  742|       |                  ctx.error = error_code::end_reached;
  743|       |                  return;
  744|       |               }
  745|       |            }
  746|       |         }
  747|  4.72k|         else {
  748|  4.72k|            if constexpr (not Opts.null_terminated) {
  749|  4.72k|               if (it == end) {
  ------------------
  |  Branch (749:20): [True: 22, False: 4.70k]
  ------------------
  750|     22|                  ctx.error = error_code::end_reached;
  751|     22|                  return;
  752|     22|               }
  753|  4.72k|            }
  754|  4.72k|         }
  755|  4.72k|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm4EEEDav:
 3589|  4.72k|               for_each<N>([&]<size_t I>() {
 3590|  4.72k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 4.30k, False: 423]
  |  Branch (3590:38): [True: 0, False: 423]
  |  Branch (3590:51): [True: 0, False: 423]
  ------------------
 3591|  4.30k|                     return;
 3592|  4.30k|                  }
 3593|    423|                  using V = std::variant_alternative_t<I, Variant>;
 3594|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|       |                     auto copy_it{it};
 3596|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|       |                     if (!std::holds_alternative<V>(value)) {
 3598|       |                        value = V{};
 3599|       |                     }
 3600|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|       |                     }
 3604|       |                     if (!bool(ctx.error)) {
 3605|       |                        found_match = true;
 3606|       |                     }
 3607|       |                     else if constexpr (not Options.null_terminated) {
 3608|       |                        constexpr bool is_complete_type =
 3609|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|       |                        if constexpr (is_complete_type) {
 3612|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|       |                              found_match = true;
 3614|       |                              ctx.error = error_code::none;
 3615|       |                           }
 3616|       |                           else {
 3617|       |                              it = copy_it;
 3618|       |                              rewind_depth<Options>(ctx, copy_depth);
 3619|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|       |                                  not variant_alternative_exhausted(ctx)) {
 3621|       |                                 ctx.error = error_code::none;
 3622|       |                              }
 3623|       |                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|       |                     ++non_const_idx;
 3643|       |                  }
 3644|    423|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm5EEEDav:
 3589|  4.72k|               for_each<N>([&]<size_t I>() {
 3590|  4.72k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 4.30k, False: 423]
  |  Branch (3590:38): [True: 0, False: 423]
  |  Branch (3590:51): [True: 0, False: 423]
  ------------------
 3591|  4.30k|                     return;
 3592|  4.30k|                  }
 3593|    423|                  using V = std::variant_alternative_t<I, Variant>;
 3594|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|       |                     auto copy_it{it};
 3596|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|       |                     if (!std::holds_alternative<V>(value)) {
 3598|       |                        value = V{};
 3599|       |                     }
 3600|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|       |                     }
 3604|       |                     if (!bool(ctx.error)) {
 3605|       |                        found_match = true;
 3606|       |                     }
 3607|       |                     else if constexpr (not Options.null_terminated) {
 3608|       |                        constexpr bool is_complete_type =
 3609|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|       |                        if constexpr (is_complete_type) {
 3612|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|       |                              found_match = true;
 3614|       |                              ctx.error = error_code::none;
 3615|       |                           }
 3616|       |                           else {
 3617|       |                              it = copy_it;
 3618|       |                              rewind_depth<Options>(ctx, copy_depth);
 3619|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|       |                                  not variant_alternative_exhausted(ctx)) {
 3621|       |                                 ctx.error = error_code::none;
 3622|       |                              }
 3623|       |                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|       |                     ++non_const_idx;
 3643|       |                  }
 3644|    423|               });
_ZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_:
 3520|  6.13M|      {
 3521|  6.13M|         constexpr auto category_count = variant_count_v<Variant, Trait>;
 3522|       |
 3523|       |         if constexpr (category_count == 0) {
 3524|       |            ctx.error = error_code::no_matching_variant_type;
 3525|       |         }
 3526|  6.13M|         else {
 3527|  6.13M|            constexpr auto N = std::variant_size_v<Variant>;
 3528|  6.13M|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3529|  6.13M|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3530|       |
 3531|  6.13M|            bool found_match{};
 3532|       |            // Set when the speculative parsing budget runs out; see charge_speculation. An ambiguous
 3533|       |            // nest re-parses the same subtree per alternative at every level, which is exponential,
 3534|       |            // so the budget stops it and the failure already in hand is reported.
 3535|  6.13M|            bool exhausted{};
 3536|       |
 3537|       |            // First pass: const glaze types in this category
 3538|       |            if constexpr (const_count > 0) {
 3539|       |               for_each<N>([&]<size_t I>() {
 3540|       |                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3541|       |                     return;
 3542|       |                  }
 3543|       |                  using V = std::variant_alternative_t<I, Variant>;
 3544|       |                  if constexpr (Trait<V>::value && glaze_const_value_t<V>) {
 3545|       |                     // run time substitute to compare to const value
 3546|       |                     std::remove_const_t<std::remove_pointer_t<std::remove_const_t<meta_wrapper_t<V>>>> substitute{};
 3547|       |                     auto copy_it{it};
 3548|       |                     // A rejected alternative may have bailed out inside a container, which leaves its
 3549|       |                     // nesting level counted (see enter_depth). Rewind the depth with the iterator so
 3550|       |                     // trying N alternatives cannot spend N levels of the recursion budget.
 3551|       |                     const auto copy_depth{ctx.depth};
 3552|       |                     parse<JSON>::op<ws_handled<Options>()>(substitute, ctx, it, end);
 3553|       |                     static constexpr auto const_value{*meta_wrapper_v<V>};
 3554|       |                     if (substitute == const_value) {
 3555|       |                        found_match = true;
 3556|       |                        if (!std::holds_alternative<V>(value)) {
 3557|       |                           value = V{};
 3558|       |                        }
 3559|       |                     }
 3560|       |                     else {
 3561|       |                        // Rejected: charge the bytes it parsed before we rewind. See charge_speculation.
 3562|       |                        if (!charge_speculation(ctx, size_t(it - copy_it))) {
 3563|       |                           exhausted = true;
 3564|       |                        }
 3565|       |                        if constexpr (not Options.null_terminated) {
 3566|       |                           if (ctx.error == error_code::end_reached && not exhausted) {
 3567|       |                              ctx.error = error_code::none;
 3568|       |                           }
 3569|       |                        }
 3570|       |                        it = copy_it;
 3571|       |                        rewind_depth<Options>(ctx, copy_depth);
 3572|       |                     }
 3573|       |                  }
 3574|       |               });
 3575|       |               if (found_match) {
 3576|       |                  return;
 3577|       |               }
 3578|       |            }
 3579|       |
 3580|       |            // Second pass: non-const types in this category
 3581|  6.13M|            if constexpr (non_const_count > 0) {
 3582|       |               // Track position within matching types for "is last" check.
 3583|       |               // We iterate over all variant indices but only process matching types,
 3584|       |               // so we need runtime tracking (vs the old tuple-based approach where
 3585|       |               // the loop index directly corresponded to position in filtered set).
 3586|       |               // This has negligible cost: one increment per matching type.
 3587|  6.13M|               size_t non_const_idx = 0;
 3588|       |
 3589|  6.13M|               for_each<N>([&]<size_t I>() {
 3590|  6.13M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3591|  6.13M|                     return;
 3592|  6.13M|                  }
 3593|  6.13M|                  using V = std::variant_alternative_t<I, Variant>;
 3594|  6.13M|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|  6.13M|                     auto copy_it{it};
 3596|  6.13M|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|  6.13M|                     if (!std::holds_alternative<V>(value)) {
 3598|  6.13M|                        value = V{};
 3599|  6.13M|                     }
 3600|  6.13M|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|  6.13M|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|  6.13M|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|  6.13M|                     }
 3604|  6.13M|                     if (!bool(ctx.error)) {
 3605|  6.13M|                        found_match = true;
 3606|  6.13M|                     }
 3607|  6.13M|                     else if constexpr (not Options.null_terminated) {
 3608|  6.13M|                        constexpr bool is_complete_type =
 3609|  6.13M|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|  6.13M|                        if constexpr (is_complete_type) {
 3612|  6.13M|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|  6.13M|                              found_match = true;
 3614|  6.13M|                              ctx.error = error_code::none;
 3615|  6.13M|                           }
 3616|  6.13M|                           else {
 3617|  6.13M|                              it = copy_it;
 3618|  6.13M|                              rewind_depth<Options>(ctx, copy_depth);
 3619|  6.13M|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|  6.13M|                                  not variant_alternative_exhausted(ctx)) {
 3621|  6.13M|                                 ctx.error = error_code::none;
 3622|  6.13M|                              }
 3623|  6.13M|                           }
 3624|  6.13M|                        }
 3625|  6.13M|                        else {
 3626|  6.13M|                           it = copy_it;
 3627|  6.13M|                           rewind_depth<Options>(ctx, copy_depth);
 3628|  6.13M|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|  6.13M|                               not variant_alternative_exhausted(ctx)) {
 3630|  6.13M|                              ctx.error = error_code::none;
 3631|  6.13M|                           }
 3632|  6.13M|                        }
 3633|  6.13M|                     }
 3634|  6.13M|                     else {
 3635|  6.13M|                        it = copy_it;
 3636|  6.13M|                        rewind_depth<Options>(ctx, copy_depth);
 3637|  6.13M|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|  6.13M|                            not variant_alternative_exhausted(ctx)) {
 3639|  6.13M|                           ctx.error = error_code::none;
 3640|  6.13M|                        }
 3641|  6.13M|                     }
 3642|  6.13M|                     ++non_const_idx;
 3643|  6.13M|                  }
 3644|  6.13M|               });
 3645|  6.13M|               if (!found_match) {
  ------------------
  |  Branch (3645:20): [True: 4.40k, False: 6.13M]
  ------------------
 3646|  4.40k|                  if constexpr (non_const_count == 1) {
 3647|       |                     // Keep the specific error from the single type we tried
 3648|       |                  }
 3649|       |                  else if (not exhausted && not variant_alternative_exhausted(ctx)) {
 3650|       |                     // Over-nested input is not a failure of the alternative set; keep saying so.
 3651|       |                     ctx.error = error_code::no_matching_variant_type;
 3652|       |                  }
 3653|  4.40k|               }
 3654|       |            }
 3655|       |            else {
 3656|       |               ctx.error = error_code::no_matching_variant_type;
 3657|       |            }
 3658|  6.13M|         }
 3659|  6.13M|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm0EEEDav:
 3589|  6.13M|               for_each<N>([&]<size_t I>() {
 3590|  6.13M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 6.13M]
  |  Branch (3590:38): [True: 0, False: 6.13M]
  |  Branch (3590:51): [True: 0, False: 6.13M]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  6.13M|                  using V = std::variant_alternative_t<I, Variant>;
 3594|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|       |                     auto copy_it{it};
 3596|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|       |                     if (!std::holds_alternative<V>(value)) {
 3598|       |                        value = V{};
 3599|       |                     }
 3600|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|       |                     }
 3604|       |                     if (!bool(ctx.error)) {
 3605|       |                        found_match = true;
 3606|       |                     }
 3607|       |                     else if constexpr (not Options.null_terminated) {
 3608|       |                        constexpr bool is_complete_type =
 3609|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|       |                        if constexpr (is_complete_type) {
 3612|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|       |                              found_match = true;
 3614|       |                              ctx.error = error_code::none;
 3615|       |                           }
 3616|       |                           else {
 3617|       |                              it = copy_it;
 3618|       |                              rewind_depth<Options>(ctx, copy_depth);
 3619|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|       |                                  not variant_alternative_exhausted(ctx)) {
 3621|       |                                 ctx.error = error_code::none;
 3622|       |                              }
 3623|       |                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|       |                     ++non_const_idx;
 3643|       |                  }
 3644|  6.13M|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm1EEEDav:
 3589|  6.13M|               for_each<N>([&]<size_t I>() {
 3590|  6.13M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 6.13M]
  |  Branch (3590:38): [True: 0, False: 6.13M]
  |  Branch (3590:51): [True: 0, False: 6.13M]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  6.13M|                  using V = std::variant_alternative_t<I, Variant>;
 3594|  6.13M|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|  6.13M|                     auto copy_it{it};
 3596|  6.13M|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|  6.13M|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3597:26): [True: 5.63M, False: 501k]
  ------------------
 3598|  5.63M|                        value = V{};
 3599|  5.63M|                     }
 3600|  6.13M|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|  6.13M|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3601:26): [True: 7.41k, False: 6.12M]
  |  Branch (3601:45): [True: 0, False: 7.41k]
  ------------------
 3602|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|      0|                     }
 3604|  6.13M|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3604:26): [True: 6.12M, False: 7.41k]
  ------------------
 3605|  6.12M|                        found_match = true;
 3606|  6.12M|                     }
 3607|  7.41k|                     else if constexpr (not Options.null_terminated) {
 3608|  7.41k|                        constexpr bool is_complete_type =
 3609|  7.41k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
  ------------------
  |  Branch (3609:28): [True: 7.41k, Folded]
  |  Branch (3609:40): [Folded, False: 0]
  |  Branch (3609:53): [Folded, False: 0]
  |  Branch (3609:68): [Folded, False: 0]
  |  Branch (3609:89): [Folded, False: 0]
  |  Branch (3609:103): [Folded, False: 0]
  ------------------
 3610|       |
 3611|  7.41k|                        if constexpr (is_complete_type) {
 3612|  7.41k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
  ------------------
  |  Branch (3612:32): [True: 3.01k, False: 4.40k]
  |  Branch (3612:72): [True: 3.01k, False: 0]
  |  Branch (3612:88): [True: 3.01k, False: 0]
  ------------------
 3613|  3.01k|                              found_match = true;
 3614|  3.01k|                              ctx.error = error_code::none;
 3615|  3.01k|                           }
 3616|  4.40k|                           else {
 3617|  4.40k|                              it = copy_it;
 3618|  4.40k|                              rewind_depth<Options>(ctx, copy_depth);
 3619|  4.40k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3619:35): [True: 0, False: 4.40k]
  |  Branch (3619:74): [True: 0, False: 0]
  ------------------
 3620|      0|                                  not variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3620:35): [True: 0, False: 0]
  ------------------
 3621|      0|                                 ctx.error = error_code::none;
 3622|      0|                              }
 3623|  4.40k|                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|  6.13M|                     ++non_const_idx;
 3643|  6.13M|                  }
 3644|  6.13M|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERdTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
   49|  6.13M|      {
   50|       |         if constexpr (const_value_v<T>) {
   51|       |            if constexpr (check_error_on_const_read(Opts)) {
   52|       |               ctx.error = error_code::attempt_const_read;
   53|       |            }
   54|       |            else {
   55|       |               // do not read anything into the const value
   56|       |               skip_value<JSON>::op<Opts>(std::forward<Ctx>(ctx), std::forward<It0>(it), end);
   57|       |            }
   58|       |         }
   59|  6.13M|         else {
   60|  6.13M|            using V = std::remove_cvref_t<T>;
   61|  6.13M|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  6.13M|                                             end);
   63|  6.13M|         }
   64|  6.13M|      }
_ZN3glz4fromILj10EdE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERPKcRdTkNS_10is_contextERNS_7contextES5_EEvOT1_OT2_OT0_T3_:
  763|  6.13M|      {
  764|       |         if constexpr (check_quoted_num(Opts)) {
  765|       |            if (skip_ws<Opts>(ctx, it, end)) {
  766|       |               return;
  767|       |            }
  768|       |            if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  769|       |               return;
  770|       |            }
  771|       |         }
  772|       |
  773|       |         if constexpr (!check_ws_handled(Opts)) {
  774|       |            if (skip_ws<Opts>(ctx, it, end)) {
  775|       |               return;
  776|       |            }
  777|       |         }
  778|       |
  779|  6.13M|         using V = std::decay_t<decltype(value)>;
  780|       |         if constexpr (int_t<V>) {
  781|       |            static_assert(sizeof(*it) == sizeof(char));
  782|       |
  783|       |            if constexpr (Opts.null_terminated) {
  784|       |               if (not glz::atoi(value, it)) [[unlikely]] {
  785|       |                  ctx.error = error_code::parse_number_failure;
  786|       |                  return;
  787|       |               }
  788|       |            }
  789|       |            else {
  790|       |               if (not glz::atoi(value, it, end)) [[unlikely]] {
  791|       |                  ctx.error = error_code::parse_number_failure;
  792|       |                  return;
  793|       |               }
  794|       |            }
  795|       |         }
  796|  6.13M|         else {
  797|       |// float128_t requires std::from_chars for floating-point, unavailable on older Apple platforms (iOS < 16.3)
  798|  6.13M|#if !defined(_LIBCPP_VERSION) || defined(_LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT)
  799|       |            if constexpr (is_float128<V>) {
  800|       |               auto [ptr, ec] = std::from_chars(it, end, value);
  801|       |               if (ec != std::errc()) {
  802|       |                  ctx.error = error_code::parse_number_failure;
  803|       |                  return;
  804|       |               }
  805|       |               it = ptr;
  806|       |            }
  807|       |            else
  808|       |#endif
  809|  6.13M|            {
  810|       |               if constexpr (std::is_volatile_v<std::remove_reference_t<decltype(value)>>) {
  811|       |                  // Hardware may interact with value changes, so we parse into a temporary and assign in one
  812|       |                  // place
  813|       |                  V temp;
  814|       |                  if constexpr (is_size_optimized(Opts)) {
  815|       |                     auto [ptr, ec] = simple_float::from_chars<Opts.null_terminated>(it, end, temp);
  816|       |                     if (ec != std::errc{}) [[unlikely]] {
  817|       |                        ctx.error = error_code::parse_number_failure;
  818|       |                        return;
  819|       |                     }
  820|       |                     it = ptr;
  821|       |                  }
  822|       |                  else {
  823|       |                     auto [ptr, ec] = glz::from_chars<Opts.null_terminated>(it, end, temp);
  824|       |                     if (ec != std::errc()) [[unlikely]] {
  825|       |                        ctx.error = error_code::parse_number_failure;
  826|       |                        return;
  827|       |                     }
  828|       |                     it = ptr;
  829|       |                  }
  830|       |                  value = temp;
  831|       |               }
  832|  6.13M|               else {
  833|       |                  if constexpr (is_size_optimized(Opts)) {
  834|       |                     auto [ptr, ec] = simple_float::from_chars<Opts.null_terminated>(it, end, value);
  835|       |                     if (ec != std::errc{}) [[unlikely]] {
  836|       |                        ctx.error = error_code::parse_number_failure;
  837|       |                        return;
  838|       |                     }
  839|       |                     it = ptr;
  840|       |                  }
  841|  6.13M|                  else {
  842|  6.13M|                     auto [ptr, ec] = glz::from_chars<Opts.null_terminated>(it, end, value);
  843|  6.13M|                     if (ec != std::errc()) [[unlikely]] {
  ------------------
  |  Branch (843:26): [True: 4.40k, False: 6.13M]
  ------------------
  844|  4.40k|                        ctx.error = error_code::parse_number_failure;
  845|  4.40k|                        return;
  846|  4.40k|                     }
  847|  6.13M|                     it = ptr;
  848|  6.13M|                  }
  849|  6.13M|               }
  850|  6.13M|            }
  851|  6.13M|         }
  852|       |
  853|       |         if constexpr (check_quoted_num(Opts)) {
  854|       |            if constexpr (not Opts.null_terminated) {
  855|       |               if (it == end) [[unlikely]] {
  856|       |                  ctx.error = error_code::unexpected_end;
  857|       |                  return;
  858|       |               }
  859|       |            }
  860|       |            if (match<'"'>(ctx, it)) {
  861|       |               return;
  862|       |            }
  863|       |            if constexpr (not Opts.null_terminated) {
  864|       |               if (it == end) {
  865|       |                  ctx.error = error_code::end_reached;
  866|       |                  return;
  867|       |               }
  868|       |            }
  869|       |         }
  870|  6.13M|         else {
  871|  6.13M|            if constexpr (not Opts.null_terminated) {
  872|  6.13M|               if (it == end) {
  ------------------
  |  Branch (872:20): [True: 3.01k, False: 6.13M]
  ------------------
  873|  3.01k|                  ctx.error = error_code::end_reached;
  874|  3.01k|                  return;
  875|  3.01k|               }
  876|  6.13M|            }
  877|  6.13M|         }
  878|  6.13M|      }
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm2EEEDav:
 3589|  6.13M|               for_each<N>([&]<size_t I>() {
 3590|  6.13M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 6.13M, False: 4.40k]
  |  Branch (3590:38): [True: 0, False: 4.40k]
  |  Branch (3590:51): [True: 0, False: 4.40k]
  ------------------
 3591|  6.13M|                     return;
 3592|  6.13M|                  }
 3593|  4.40k|                  using V = std::variant_alternative_t<I, Variant>;
 3594|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|       |                     auto copy_it{it};
 3596|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|       |                     if (!std::holds_alternative<V>(value)) {
 3598|       |                        value = V{};
 3599|       |                     }
 3600|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|       |                     }
 3604|       |                     if (!bool(ctx.error)) {
 3605|       |                        found_match = true;
 3606|       |                     }
 3607|       |                     else if constexpr (not Options.null_terminated) {
 3608|       |                        constexpr bool is_complete_type =
 3609|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|       |                        if constexpr (is_complete_type) {
 3612|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|       |                              found_match = true;
 3614|       |                              ctx.error = error_code::none;
 3615|       |                           }
 3616|       |                           else {
 3617|       |                              it = copy_it;
 3618|       |                              rewind_depth<Options>(ctx, copy_depth);
 3619|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|       |                                  not variant_alternative_exhausted(ctx)) {
 3621|       |                                 ctx.error = error_code::none;
 3622|       |                              }
 3623|       |                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|       |                     ++non_const_idx;
 3643|       |                  }
 3644|  4.40k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm3EEEDav:
 3589|  6.13M|               for_each<N>([&]<size_t I>() {
 3590|  6.13M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 6.13M, False: 4.40k]
  |  Branch (3590:38): [True: 0, False: 4.40k]
  |  Branch (3590:51): [True: 0, False: 4.40k]
  ------------------
 3591|  6.13M|                     return;
 3592|  6.13M|                  }
 3593|  4.40k|                  using V = std::variant_alternative_t<I, Variant>;
 3594|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|       |                     auto copy_it{it};
 3596|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|       |                     if (!std::holds_alternative<V>(value)) {
 3598|       |                        value = V{};
 3599|       |                     }
 3600|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|       |                     }
 3604|       |                     if (!bool(ctx.error)) {
 3605|       |                        found_match = true;
 3606|       |                     }
 3607|       |                     else if constexpr (not Options.null_terminated) {
 3608|       |                        constexpr bool is_complete_type =
 3609|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|       |                        if constexpr (is_complete_type) {
 3612|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|       |                              found_match = true;
 3614|       |                              ctx.error = error_code::none;
 3615|       |                           }
 3616|       |                           else {
 3617|       |                              it = copy_it;
 3618|       |                              rewind_depth<Options>(ctx, copy_depth);
 3619|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|       |                                  not variant_alternative_exhausted(ctx)) {
 3621|       |                                 ctx.error = error_code::none;
 3622|       |                              }
 3623|       |                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|       |                     ++non_const_idx;
 3643|       |                  }
 3644|  4.40k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm4EEEDav:
 3589|  6.13M|               for_each<N>([&]<size_t I>() {
 3590|  6.13M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 6.13M, False: 4.40k]
  |  Branch (3590:38): [True: 0, False: 4.40k]
  |  Branch (3590:51): [True: 0, False: 4.40k]
  ------------------
 3591|  6.13M|                     return;
 3592|  6.13M|                  }
 3593|  4.40k|                  using V = std::variant_alternative_t<I, Variant>;
 3594|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|       |                     auto copy_it{it};
 3596|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|       |                     if (!std::holds_alternative<V>(value)) {
 3598|       |                        value = V{};
 3599|       |                     }
 3600|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|       |                     }
 3604|       |                     if (!bool(ctx.error)) {
 3605|       |                        found_match = true;
 3606|       |                     }
 3607|       |                     else if constexpr (not Options.null_terminated) {
 3608|       |                        constexpr bool is_complete_type =
 3609|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|       |                        if constexpr (is_complete_type) {
 3612|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|       |                              found_match = true;
 3614|       |                              ctx.error = error_code::none;
 3615|       |                           }
 3616|       |                           else {
 3617|       |                              it = copy_it;
 3618|       |                              rewind_depth<Options>(ctx, copy_depth);
 3619|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|       |                                  not variant_alternative_exhausted(ctx)) {
 3621|       |                                 ctx.error = error_code::none;
 3622|       |                              }
 3623|       |                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|       |                     ++non_const_idx;
 3643|       |                  }
 3644|  4.40k|               });
_ZZN3glz28process_variant_alternativesINSt3__17variantIJDndNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEbNS1_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS6_ISD_EEEENSC_ISD_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSH_TkNS_10is_contextERNS_7contextERPKcSQ_EEvOT0_OT1_OT2_T3_ENKUlTnmvE_clILm5EEEDav:
 3589|  6.13M|               for_each<N>([&]<size_t I>() {
 3590|  6.13M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 6.13M, False: 4.40k]
  |  Branch (3590:38): [True: 0, False: 4.40k]
  |  Branch (3590:51): [True: 0, False: 4.40k]
  ------------------
 3591|  6.13M|                     return;
 3592|  6.13M|                  }
 3593|  4.40k|                  using V = std::variant_alternative_t<I, Variant>;
 3594|       |                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|       |                     auto copy_it{it};
 3596|       |                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|       |                     if (!std::holds_alternative<V>(value)) {
 3598|       |                        value = V{};
 3599|       |                     }
 3600|       |                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|       |                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|       |                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|       |                     }
 3604|       |                     if (!bool(ctx.error)) {
 3605|       |                        found_match = true;
 3606|       |                     }
 3607|       |                     else if constexpr (not Options.null_terminated) {
 3608|       |                        constexpr bool is_complete_type =
 3609|       |                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|       |                        if constexpr (is_complete_type) {
 3612|       |                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|       |                              found_match = true;
 3614|       |                              ctx.error = error_code::none;
 3615|       |                           }
 3616|       |                           else {
 3617|       |                              it = copy_it;
 3618|       |                              rewind_depth<Options>(ctx, copy_depth);
 3619|       |                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|       |                                  not variant_alternative_exhausted(ctx)) {
 3621|       |                                 ctx.error = error_code::none;
 3622|       |                              }
 3623|       |                           }
 3624|       |                        }
 3625|       |                        else {
 3626|       |                           it = copy_it;
 3627|       |                           rewind_depth<Options>(ctx, copy_depth);
 3628|       |                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|       |                               not variant_alternative_exhausted(ctx)) {
 3630|       |                              ctx.error = error_code::none;
 3631|       |                           }
 3632|       |                        }
 3633|       |                     }
 3634|       |                     else {
 3635|       |                        it = copy_it;
 3636|       |                        rewind_depth<Options>(ctx, copy_depth);
 3637|       |                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|       |                            not variant_alternative_exhausted(ctx)) {
 3639|       |                           ctx.error = error_code::none;
 3640|       |                        }
 3641|       |                     }
 3642|       |                     ++non_const_idx;
 3643|       |                  }
 3644|  4.40k|               });
_ZN3glz9read_jsonITkNS_14read_supportedIL_ZNS_4JSONEEEENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_9is_bufferERKNSt3__16vectorIcNS6_9allocatorIcEEEEQnt18is_input_streamingIu20__remove_reference_tIT0_EEEENS_9error_ctxERT_OSD_:
 5056|  10.3k|   {
 5057|  10.3k|      context ctx{};
 5058|  10.3k|      return read<opts{}>(value, std::forward<Buffer>(buffer), ctx);
 5059|  10.3k|   }
_ZN3glz9read_jsonITkNS_14read_supportedIL_ZNS_4JSONEEEENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_9is_bufferERNSt3__16vectorIcNS6_9allocatorIcEEEEQnt18is_input_streamingIu20__remove_reference_tIT0_EEEENS_9error_ctxERT_OSC_:
 5056|  10.3k|   {
 5057|  10.3k|      context ctx{};
 5058|  10.3k|      return read<opts{}>(value, std::forward<Buffer>(buffer), ctx);
 5059|  10.3k|   }

_ZN3glz9has_quoteEm:
   86|  19.6M|   {
   87|  19.6M|      return has_zero(chunk ^ repeat_byte8('"'));
   88|  19.6M|   }
_ZN3glz8has_zeroEm:
   81|  19.6M|   {
   82|  19.6M|      return (((chunk - 0x0101010101010101ull) & ~chunk) & 0x8080808080808080ull);
   83|  19.6M|   }
_ZN3glz11countr_zeroEm:
   29|  3.04M|   {
   30|       |#ifdef _MSC_VER
   31|       |      return std::countr_zero(x);
   32|       |#else
   33|  3.04M|#if __has_builtin(__builtin_ctzll)
   34|  3.04M|      return __builtin_ctzll(x);
   35|       |#else
   36|       |      return std::countr_zero(x);
   37|       |#endif
   38|  3.04M|#endif
   39|  3.04M|   }

_ZN3glz10comparitorIL_ZZNS_5matchITnNS_14string_literalEXtlNS2_ILm5EEEtlA5_cLc110ELc117ELc108ELc108EEEETnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS9_EEvOT1_OT2_T3_E1SELm4EcEEbPKSB_:
  245|  3.38k|   {
  246|       |      // pack() builds values in little-endian order (byte 0 in LSB position).
  247|       |      // On big-endian systems, memcpy produces native (big-endian) values,
  248|       |      // so we need to byteswap to match the packed representation.
  249|       |      if constexpr (N == 8) {
  250|       |         static constexpr auto packed = pack<Str, 8>();
  251|       |         uint64_t in;
  252|       |         std::memcpy(&in, other, 8);
  253|       |         if constexpr (std::endian::native == std::endian::big) {
  254|       |            in = std::byteswap(in);
  255|       |         }
  256|       |         return (in == packed);
  257|       |      }
  258|       |      else if constexpr (N == 7) {
  259|       |         static constexpr auto packed = pack_buffered<Str, 8>();
  260|       |         uint64_t in{};
  261|       |         std::memcpy(&in, other, 7);
  262|       |         if constexpr (std::endian::native == std::endian::big) {
  263|       |            in = std::byteswap(in);
  264|       |         }
  265|       |         return (in == packed);
  266|       |      }
  267|       |      else if constexpr (N == 6) {
  268|       |         static constexpr auto packed = pack_buffered<Str, 8>();
  269|       |         uint64_t in{};
  270|       |         std::memcpy(&in, other, 6);
  271|       |         if constexpr (std::endian::native == std::endian::big) {
  272|       |            in = std::byteswap(in);
  273|       |         }
  274|       |         return (in == packed);
  275|       |      }
  276|       |      else if constexpr (N == 5) {
  277|       |         static constexpr auto packed = pack<Str, 4>();
  278|       |         uint32_t in;
  279|       |         std::memcpy(&in, other, 4);
  280|       |         if constexpr (std::endian::native == std::endian::big) {
  281|       |            in = std::byteswap(in);
  282|       |         }
  283|       |         return (in == packed) & (Str[4] == other[4]);
  284|       |      }
  285|  3.38k|      else if constexpr (N == 4) {
  286|  3.38k|         static constexpr auto packed = pack<Str, 4>();
  287|  3.38k|         uint32_t in;
  288|  3.38k|         std::memcpy(&in, other, 4);
  289|       |         if constexpr (std::endian::native == std::endian::big) {
  290|       |            in = std::byteswap(in);
  291|       |         }
  292|  3.38k|         return (in == packed);
  293|       |      }
  294|       |      else if constexpr (N == 3) {
  295|       |         static constexpr auto packed = pack<Str, 2>();
  296|       |         uint16_t in;
  297|       |         std::memcpy(&in, other, 2);
  298|       |         if constexpr (std::endian::native == std::endian::big) {
  299|       |            in = std::byteswap(in);
  300|       |         }
  301|       |         return (in == packed) & (Str[2] == other[2]);
  302|       |      }
  303|       |      else if constexpr (N == 2) {
  304|       |         static constexpr auto packed = pack<Str, 2>();
  305|       |         uint16_t in;
  306|       |         std::memcpy(&in, other, 2);
  307|       |         if constexpr (std::endian::native == std::endian::big) {
  308|       |            in = std::byteswap(in);
  309|       |         }
  310|       |         return (in == packed);
  311|       |      }
  312|       |      else if constexpr (N == 1) {
  313|       |         return Str[0] == other[0];
  314|       |      }
  315|       |      else if constexpr (N == 0) {
  316|       |         return true;
  317|       |      }
  318|       |      else {
  319|       |         // Clang and GCC optimize this extremely well for constexpr std::string_view
  320|       |         // Packing data can create more binary on GCC
  321|       |         // The other cases probably aren't needed as compiler explorer shows them optimized equally well as memcmp
  322|       |         return 0 == std::memcmp(Str.data(), other, N);
  323|       |      }
  324|  3.38k|   }

_ZN3glz10fast_float4spanIKcEC2Ev:
  438|  12.2M|  constexpr span() : ptr(nullptr), length(0) {}
_ZN3glz10fast_float10is_integerIcEEbT_:
 1481|  8.95k|fastfloat_really_inline constexpr bool is_integer(UC c) noexcept {
 1482|  8.95k|  return !(c > UC('9') || c < UC('0'));
  ------------------
  |  Branch (1482:12): [True: 3, False: 8.94k]
  |  Branch (1482:27): [True: 60, False: 8.88k]
  ------------------
 1483|  8.95k|}
_ZN3glz10fast_float11digit_valueIcEEmT_:
 1489|  31.9M|fastfloat_really_inline constexpr uint64_t digit_value(UC c) noexcept {
 1490|  31.9M|  return uint64_t(uint8_t(c) - uint8_t('0'));
 1491|  31.9M|}
_ZN3glz10fast_float4spanIKcEC2EPS2_m:
  436|  6.18M|  constexpr span(T const *_ptr, size_t _length) : ptr(_ptr), length(_length) {}
_ZN3glz10fast_float26loop_parse_if_eight_digitsERPKcS2_Rm:
 1679|  47.1k|                           uint64_t &i) {
 1680|       |  // optimizes better than parse_if_eight_digits_unrolled() for UC = char.
 1681|  5.07M|  while ((std::distance(p, pend) >= 8) &&
  ------------------
  |  Branch (1681:10): [True: 5.07M, False: 3.17k]
  ------------------
 1682|  5.07M|         is_made_of_eight_digits_fast(read8_to_u64(p))) {
  ------------------
  |  Branch (1682:10): [True: 5.02M, False: 44.0k]
  ------------------
 1683|  5.02M|    i = i * 100000000 +
 1684|  5.02M|        parse_eight_digits_unrolled(read8_to_u64(
 1685|  5.02M|            p)); // in rare cases, this will overflow, but that's ok
 1686|  5.02M|    p += 8;
 1687|  5.02M|  }
 1688|  47.1k|}
_ZN3glz10fast_float28is_made_of_eight_digits_fastEm:
 1597|  5.07M|is_made_of_eight_digits_fast(uint64_t val) noexcept {
 1598|  5.07M|  return !((((val + 0x4646464646464646) | (val - 0x3030303030303030)) &
 1599|  5.07M|            0x8080808080808080));
 1600|  5.07M|}
_ZN3glz10fast_float12read8_to_u64IcEEmPKT_:
 1503|  11.9M|read8_to_u64(UC const *chars) {
 1504|  11.9M|  if (cpp20_and_in_constexpr() || !std::is_same<UC, char>::value) {
  ------------------
  |  Branch (1504:7): [Folded, False: 0]
  |  Branch (1504:35): [Folded, False: 0]
  ------------------
 1505|      0|    uint64_t val = 0;
 1506|      0|    for (int i = 0; i < 8; ++i) {
  ------------------
  |  Branch (1506:21): [True: 0, False: 0]
  ------------------
 1507|      0|      val |= uint64_t(uint8_t(*chars)) << (i * 8);
 1508|      0|      ++chars;
 1509|      0|    }
 1510|      0|    return val;
 1511|      0|  }
 1512|  11.9M|  uint64_t val;
 1513|  11.9M|  ::memcpy(&val, chars, sizeof(uint64_t));
 1514|       |#if GLZ_FASTFLOAT_IS_BIG_ENDIAN == 1
 1515|       |  // Need to read as-if the number was in little-endian order.
 1516|       |  val = byteswap(val);
 1517|       |#endif
 1518|  11.9M|  return val;
 1519|  11.9M|}
_ZN3glz10fast_float27parse_eight_digits_unrolledEm:
 1575|  6.91M|parse_eight_digits_unrolled(uint64_t val) {
 1576|  6.91M|  uint64_t const mask = 0x000000FF000000FF;
 1577|  6.91M|  uint64_t const mul1 = 0x000F424000000064; // 100 + (1000000ULL << 32)
 1578|  6.91M|  uint64_t const mul2 = 0x0000271000000001; // 1 + (10000ULL << 32)
 1579|  6.91M|  val -= 0x3030303030303030;
 1580|  6.91M|  val = (val * 10) + (val >> 8); // val = (val * 2561) >> 8;
 1581|  6.91M|  val = (((val & mask) * mul1) + (((val >> 16) & mask) * mul2)) >> 32;
 1582|  6.91M|  return uint32_t(val);
 1583|  6.91M|}
_ZNK3glz10fast_float4spanIKcE3lenEv:
  440|   182k|  constexpr size_t len() const noexcept { return length; }
_ZN3glz10fast_float19from_chars_advancedIdcEENS0_19from_chars_result_tIT0_EERNS0_22parsed_number_string_tIS3_EERT_:
 4249|  6.13M|from_chars_advanced(parsed_number_string_t<UC> &pns, T &value) noexcept {
 4250|       |
 4251|  6.13M|  static_assert(is_supported_float_type<T>::value,
 4252|  6.13M|                "only some floating-point types are supported");
 4253|  6.13M|  static_assert(is_supported_char_type<UC>::value,
 4254|  6.13M|                "only char, wchar_t, char16_t and char32_t are supported");
 4255|       |
 4256|  6.13M|  from_chars_result_t<UC> answer;
 4257|       |
 4258|  6.13M|  answer.ec = std::errc(); // be optimistic
 4259|  6.13M|  answer.ptr = pns.lastmatch;
 4260|       |  // The implementation of the Clinger's fast path is convoluted because
 4261|       |  // we want round-to-nearest in all cases, irrespective of the rounding mode
 4262|       |  // selected on the thread.
 4263|       |  // We proceed optimistically, assuming that detail::rounds_to_nearest()
 4264|       |  // returns true.
 4265|  6.13M|  if (binary_format<T>::min_exponent_fast_path() <= pns.exponent &&
  ------------------
  |  Branch (4265:7): [True: 6.11M, False: 12.1k]
  ------------------
 4266|  6.11M|      pns.exponent <= binary_format<T>::max_exponent_fast_path() &&
  ------------------
  |  Branch (4266:7): [True: 6.08M, False: 32.4k]
  ------------------
 4267|  6.08M|      !pns.too_many_digits) {
  ------------------
  |  Branch (4267:7): [True: 6.04M, False: 36.2k]
  ------------------
 4268|       |    // Unfortunately, the conventional Clinger's fast path is only possible
 4269|       |    // when the system rounds to the nearest float.
 4270|       |    //
 4271|       |    // We expect the next branch to almost always be selected.
 4272|       |    // We could check it first (before the previous branch), but
 4273|       |    // there might be performance advantages at having the check
 4274|       |    // be last.
 4275|  6.04M|    if (!cpp20_and_in_constexpr() && detail::rounds_to_nearest()) {
  ------------------
  |  Branch (4275:9): [True: 6.04M, Folded]
  |  Branch (4275:38): [True: 6.04M, False: 0]
  ------------------
 4276|       |      // We have that fegetround() == FE_TONEAREST.
 4277|       |      // Next is Clinger's fast path.
 4278|  6.04M|      if (pns.mantissa <= binary_format<T>::max_mantissa_fast_path()) {
  ------------------
  |  Branch (4278:11): [True: 6.04M, False: 3.25k]
  ------------------
 4279|  6.04M|        value = T(pns.mantissa);
 4280|  6.04M|        if (pns.exponent < 0) {
  ------------------
  |  Branch (4280:13): [True: 6.09k, False: 6.04M]
  ------------------
 4281|  6.09k|          value = value / binary_format<T>::exact_power_of_ten(-pns.exponent);
 4282|  6.04M|        } else {
 4283|  6.04M|          value = value * binary_format<T>::exact_power_of_ten(pns.exponent);
 4284|  6.04M|        }
 4285|  6.04M|        if (pns.negative) {
  ------------------
  |  Branch (4285:13): [True: 5.36k, False: 6.04M]
  ------------------
 4286|  5.36k|          value = -value;
 4287|  5.36k|        }
 4288|  6.04M|        return answer;
 4289|  6.04M|      }
 4290|  6.04M|    } else {
 4291|       |      // We do not have that fegetround() == FE_TONEAREST.
 4292|       |      // Next is a modified Clinger's fast path, inspired by Jakub Jelínek's
 4293|       |      // proposal
 4294|      0|      if (pns.exponent >= 0 &&
  ------------------
  |  Branch (4294:11): [True: 0, False: 0]
  ------------------
 4295|      0|          pns.mantissa <=
  ------------------
  |  Branch (4295:11): [True: 0, False: 0]
  ------------------
 4296|      0|              binary_format<T>::max_mantissa_fast_path(pns.exponent)) {
 4297|      0|#if defined(__clang__) || defined(GLZ_FASTFLOAT_32BIT)
 4298|       |        // Clang may map 0 to -0.0 when fegetround() == FE_DOWNWARD
 4299|      0|        if (pns.mantissa == 0) {
  ------------------
  |  Branch (4299:13): [True: 0, False: 0]
  ------------------
 4300|      0|          value = pns.negative ? T(-0.) : T(0.);
  ------------------
  |  Branch (4300:19): [True: 0, False: 0]
  ------------------
 4301|      0|          return answer;
 4302|      0|        }
 4303|      0|#endif
 4304|      0|        value = T(pns.mantissa) *
 4305|      0|                binary_format<T>::exact_power_of_ten(pns.exponent);
 4306|      0|        if (pns.negative) {
  ------------------
  |  Branch (4306:13): [True: 0, False: 0]
  ------------------
 4307|      0|          value = -value;
 4308|      0|        }
 4309|      0|        return answer;
 4310|      0|      }
 4311|      0|    }
 4312|  6.04M|  }
 4313|  84.1k|  adjusted_mantissa am =
 4314|  84.1k|      compute_float<binary_format<T>>(pns.exponent, pns.mantissa);
 4315|  84.1k|  if (pns.too_many_digits && am.power2 >= 0) {
  ------------------
  |  Branch (4315:7): [True: 67.6k, False: 16.5k]
  |  Branch (4315:30): [True: 67.6k, False: 0]
  ------------------
 4316|  67.6k|    if (am != compute_float<binary_format<T>>(pns.exponent, pns.mantissa + 1)) {
  ------------------
  |  Branch (4316:9): [True: 57.3k, False: 10.2k]
  ------------------
 4317|  57.3k|      am = compute_error<binary_format<T>>(pns.exponent, pns.mantissa);
 4318|  57.3k|    }
 4319|  67.6k|  }
 4320|       |  // If we called compute_float<binary_format<T>>(pns.exponent, pns.mantissa)
 4321|       |  // and we have an invalid power (am.power2 < 0), then we need to go the long
 4322|       |  // way around again. This is very uncommon.
 4323|  84.1k|  if (am.power2 < 0) {
  ------------------
  |  Branch (4323:7): [True: 57.3k, False: 26.8k]
  ------------------
 4324|  57.3k|    am = digit_comp<T>(pns, am);
 4325|  57.3k|  }
 4326|  84.1k|  to_float(pns.negative, am, value);
 4327|       |  // Test for over/underflow.
 4328|  84.1k|  if ((pns.mantissa != 0 && am.mantissa == 0 && am.power2 == 0) ||
  ------------------
  |  Branch (4328:8): [True: 83.0k, False: 1.17k]
  |  Branch (4328:29): [True: 6.71k, False: 76.3k]
  |  Branch (4328:49): [True: 306, False: 6.40k]
  ------------------
 4329|  83.8k|      am.power2 == binary_format<T>::infinite_power()) {
  ------------------
  |  Branch (4329:7): [True: 387, False: 83.5k]
  ------------------
 4330|    693|    answer.ec = std::errc::result_out_of_range;
 4331|    693|  }
 4332|  84.1k|  return answer;
 4333|  6.13M|}
_ZN3glz10fast_float13binary_formatIdE22min_exponent_fast_pathEv:
  695|  6.13M|inline constexpr int binary_format<double>::min_exponent_fast_path() {
  696|       |#if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0)
  697|       |  return 0;
  698|       |#else
  699|  6.13M|  return -22;
  700|  6.13M|#endif
  701|  6.13M|}
_ZN3glz10fast_float13binary_formatIdE22max_exponent_fast_pathEv:
  767|  6.11M|inline constexpr int binary_format<double>::max_exponent_fast_path() {
  768|  6.11M|  return 22;
  769|  6.11M|}
_ZN3glz10fast_float6detail17rounds_to_nearestEv:
 4129|  6.04M|fastfloat_really_inline bool rounds_to_nearest() noexcept {
 4130|       |  // https://lemire.me/blog/2020/06/26/gcc-not-nearest/
 4131|       |#if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0)
 4132|       |  return false;
 4133|       |#endif
 4134|       |  // See
 4135|       |  // A fast function to check your floating-point rounding mode
 4136|       |  // https://lemire.me/blog/2022/11/16/a-fast-function-to-check-your-floating-point-rounding-mode/
 4137|       |  //
 4138|       |  // This function is meant to be equivalent to :
 4139|       |  // prior: #include <cfenv>
 4140|       |  //  return fegetround() == FE_TONEAREST;
 4141|       |  // However, it is expected to be much faster than the fegetround()
 4142|       |  // function call.
 4143|       |  //
 4144|       |  // The volatile keyword prevents the compiler from computing the function
 4145|       |  // at compile-time.
 4146|       |  // There might be other ways to prevent compile-time optimizations (e.g.,
 4147|       |  // asm). The value does not need to be std::numeric_limits<float>::min(), any
 4148|       |  // small value so that 1 + x should round to 1 would do (after accounting for
 4149|       |  // excess precision, as in 387 instructions).
 4150|  6.04M|  static float volatile fmin = (std::numeric_limits<float>::min)();
 4151|  6.04M|  float fmini = fmin; // we copy it so that it gets loaded at most once.
 4152|       |//
 4153|       |// Explanation:
 4154|       |// Only when fegetround() == FE_TONEAREST do we have that
 4155|       |// fmin + 1.0f == 1.0f - fmin.
 4156|       |//
 4157|       |// FE_UPWARD:
 4158|       |//  fmin + 1.0f > 1
 4159|       |//  1.0f - fmin == 1
 4160|       |//
 4161|       |// FE_DOWNWARD or  FE_TOWARDZERO:
 4162|       |//  fmin + 1.0f == 1
 4163|       |//  1.0f - fmin < 1
 4164|       |//
 4165|       |// Note: This may fail to be accurate if fast-math has been
 4166|       |// enabled, as rounding conventions may not apply.
 4167|       |#ifdef GLZ_FASTFLOAT_VISUAL_STUDIO
 4168|       |#pragma warning(push)
 4169|       |//  todo: is there a VS warning?
 4170|       |//  see
 4171|       |//  https://stackoverflow.com/questions/46079446/is-there-a-warning-for-floating-point-equality-checking-in-visual-studio-2013
 4172|       |#elif defined(__clang__)
 4173|       |#pragma clang diagnostic push
 4174|  6.04M|#pragma clang diagnostic ignored "-Wfloat-equal"
 4175|       |#elif defined(__GNUC__)
 4176|       |#pragma GCC diagnostic push
 4177|       |#pragma GCC diagnostic ignored "-Wfloat-equal"
 4178|       |#endif
 4179|  6.04M|  return (fmini + 1.0f == 1.0f - fmini);
 4180|       |#ifdef GLZ_FASTFLOAT_VISUAL_STUDIO
 4181|       |#pragma warning(pop)
 4182|       |#elif defined(__clang__)
 4183|       |#pragma clang diagnostic pop
 4184|       |#elif defined(__GNUC__)
 4185|       |#pragma GCC diagnostic pop
 4186|       |#endif
 4187|  6.04M|}
_ZN3glz10fast_float13binary_formatIdE22max_mantissa_fast_pathEv:
  777|  6.04M|inline constexpr uint64_t binary_format<double>::max_mantissa_fast_path() {
  778|  6.04M|  return uint64_t(2) << mantissa_explicit_bits();
  779|  6.04M|}
_ZN3glz10fast_float13binary_formatIdE22mantissa_explicit_bitsEv:
  713|  7.05M|inline constexpr int binary_format<double>::mantissa_explicit_bits() {
  714|  7.05M|  return 52;
  715|  7.05M|}
_ZN3glz10fast_float13binary_formatIdE18exact_power_of_tenEl:
 1057|  6.04M|binary_format<double>::exact_power_of_ten(int64_t power) {
 1058|       |  // Work around clang bug https://godbolt.org/z/zedh7rrhc
 1059|  6.04M|  return (void)powers_of_ten[0], powers_of_ten[power];
 1060|  6.04M|}
_ZN3glz10fast_float13compute_floatINS0_13binary_formatIdEEEENS0_17adjusted_mantissaElm:
 2852|   151k|compute_float(int64_t q, uint64_t w) noexcept {
 2853|   151k|  adjusted_mantissa answer;
 2854|   151k|  if ((w == 0) || (q < binary::smallest_power_of_ten())) {
  ------------------
  |  Branch (2854:7): [True: 1.17k, False: 150k]
  |  Branch (2854:19): [True: 348, False: 150k]
  ------------------
 2855|  1.51k|    answer.power2 = 0;
 2856|  1.51k|    answer.mantissa = 0;
 2857|       |    // result should be zero
 2858|  1.51k|    return answer;
 2859|  1.51k|  }
 2860|   150k|  if (q > binary::largest_power_of_ten()) {
  ------------------
  |  Branch (2860:7): [True: 450, False: 149k]
  ------------------
 2861|       |    // we want to get infinity:
 2862|    450|    answer.power2 = binary::infinite_power();
 2863|    450|    answer.mantissa = 0;
 2864|    450|    return answer;
 2865|    450|  }
 2866|       |  // At this point in time q is in [powers::smallest_power_of_five,
 2867|       |  // powers::largest_power_of_five].
 2868|       |
 2869|       |  // We want the most significant bit of i to be 1. Shift if needed.
 2870|   149k|  int lz = leading_zeroes(w);
 2871|   149k|  w <<= lz;
 2872|       |
 2873|       |  // The required precision is binary::mantissa_explicit_bits() + 3 because
 2874|       |  // 1. We need the implicit bit
 2875|       |  // 2. We need an extra bit for rounding purposes
 2876|       |  // 3. We might lose a bit due to the "upperbit" routine (result too small,
 2877|       |  // requiring a shift)
 2878|       |
 2879|   149k|  value128 product =
 2880|   149k|      compute_product_approximation<binary::mantissa_explicit_bits() + 3>(q, w);
 2881|       |  // The computed 'product' is always sufficient.
 2882|       |  // Mathematical proof:
 2883|       |  // Noble Mushtak and Daniel Lemire, Fast Number Parsing Without Fallback (to
 2884|       |  // appear) See script/mushtak_lemire.py
 2885|       |
 2886|       |  // The "compute_product_approximation" function can be slightly slower than a
 2887|       |  // branchless approach: value128 product = compute_product(q, w); but in
 2888|       |  // practice, we can win big with the compute_product_approximation if its
 2889|       |  // additional branch is easily predicted. Which is best is data specific.
 2890|   149k|  int upperbit = int(product.high >> 63);
 2891|   149k|  int shift = upperbit + 64 - binary::mantissa_explicit_bits() - 3;
 2892|       |
 2893|   149k|  answer.mantissa = product.high >> shift;
 2894|       |
 2895|   149k|  answer.power2 = int32_t(detail::power(int32_t(q)) + upperbit - lz -
 2896|   149k|                          binary::minimum_exponent());
 2897|   149k|  if (answer.power2 <= 0) { // we have a subnormal?
  ------------------
  |  Branch (2897:7): [True: 11.0k, False: 138k]
  ------------------
 2898|       |    // Here have that answer.power2 <= 0 so -answer.power2 >= 0
 2899|  11.0k|    if (-answer.power2 + 1 >=
  ------------------
  |  Branch (2899:9): [True: 9, False: 10.9k]
  ------------------
 2900|  11.0k|        64) { // if we have more than 64 bits below the minimum exponent, you
 2901|       |              // have a zero for sure.
 2902|      9|      answer.power2 = 0;
 2903|      9|      answer.mantissa = 0;
 2904|       |      // result should be zero
 2905|      9|      return answer;
 2906|      9|    }
 2907|       |    // next line is safe because -answer.power2 + 1 < 64
 2908|  10.9k|    answer.mantissa >>= -answer.power2 + 1;
 2909|       |    // Thankfully, we can't have both "round-to-even" and subnormals because
 2910|       |    // "round-to-even" only occurs for powers close to 0 in the 32-bit and
 2911|       |    // and 64-bit case (with no more than 19 digits).
 2912|  10.9k|    answer.mantissa += (answer.mantissa & 1); // round up
 2913|  10.9k|    answer.mantissa >>= 1;
 2914|       |    // There is a weird scenario where we don't have a subnormal but just.
 2915|       |    // Suppose we start with 2.2250738585072013e-308, we end up
 2916|       |    // with 0x3fffffffffffff x 2^-1023-53 which is technically subnormal
 2917|       |    // whereas 0x40000000000000 x 2^-1023-53  is normal. Now, we need to round
 2918|       |    // up 0x3fffffffffffff x 2^-1023-53  and once we do, we are no longer
 2919|       |    // subnormal, but we can only know this after rounding.
 2920|       |    // So we only declare a subnormal if we are smaller than the threshold.
 2921|  10.9k|    answer.power2 =
 2922|  10.9k|        (answer.mantissa < (uint64_t(1) << binary::mantissa_explicit_bits()))
  ------------------
  |  Branch (2922:9): [True: 10.9k, False: 12]
  ------------------
 2923|  10.9k|            ? 0
 2924|  10.9k|            : 1;
 2925|  10.9k|    return answer;
 2926|  11.0k|  }
 2927|       |
 2928|       |  // usually, we round *up*, but if we fall right in between and and we have an
 2929|       |  // even basis, we need to round down
 2930|       |  // We are only concerned with the cases where 5**q fits in single 64-bit word.
 2931|   138k|  if ((product.low <= 1) && (q >= binary::min_exponent_round_to_even()) &&
  ------------------
  |  Branch (2931:7): [True: 32.5k, False: 106k]
  |  Branch (2931:29): [True: 29.7k, False: 2.79k]
  ------------------
 2932|  29.7k|      (q <= binary::max_exponent_round_to_even()) &&
  ------------------
  |  Branch (2932:7): [True: 27.4k, False: 2.37k]
  ------------------
 2933|  27.4k|      ((answer.mantissa & 3) == 1)) { // we may fall between two floats!
  ------------------
  |  Branch (2933:7): [True: 13.7k, False: 13.7k]
  ------------------
 2934|       |    // To be in-between two floats we need that in doing
 2935|       |    //   answer.mantissa = product.high >> (upperbit + 64 -
 2936|       |    //   binary::mantissa_explicit_bits() - 3);
 2937|       |    // ... we dropped out only zeroes. But if this happened, then we can go
 2938|       |    // back!!!
 2939|  13.7k|    if ((answer.mantissa << shift) == product.high) {
  ------------------
  |  Branch (2939:9): [True: 9.81k, False: 3.90k]
  ------------------
 2940|  9.81k|      answer.mantissa &= ~uint64_t(1); // flip it so that we do not round up
 2941|  9.81k|    }
 2942|  13.7k|  }
 2943|       |
 2944|   138k|  answer.mantissa += (answer.mantissa & 1); // round up
 2945|   138k|  answer.mantissa >>= 1;
 2946|   138k|  if (answer.mantissa >= (uint64_t(2) << binary::mantissa_explicit_bits())) {
  ------------------
  |  Branch (2946:7): [True: 5.87k, False: 132k]
  ------------------
 2947|  5.87k|    answer.mantissa = (uint64_t(1) << binary::mantissa_explicit_bits());
 2948|  5.87k|    answer.power2++; // undo previous addition
 2949|  5.87k|  }
 2950|       |
 2951|   138k|  answer.mantissa &= ~(uint64_t(1) << binary::mantissa_explicit_bits());
 2952|   138k|  if (answer.power2 >= binary::infinite_power()) { // infinity
  ------------------
  |  Branch (2952:7): [True: 27, False: 138k]
  ------------------
 2953|     27|    answer.power2 = binary::infinite_power();
 2954|     27|    answer.mantissa = 0;
 2955|     27|  }
 2956|   138k|  return answer;
 2957|   149k|}
_ZN3glz10fast_float17adjusted_mantissaC2Ev:
  568|   266k|  adjusted_mantissa() = default;
_ZN3glz10fast_float13binary_formatIdE21smallest_power_of_tenEv:
 1077|   150k|inline constexpr int binary_format<double>::smallest_power_of_ten() {
 1078|   150k|  return -342;
 1079|   150k|}
_ZN3glz10fast_float13binary_formatIdE20largest_power_of_tenEv:
 1068|   150k|template <> inline constexpr int binary_format<double>::largest_power_of_ten() {
 1069|   150k|  return 308;
 1070|   150k|}
_ZN3glz10fast_float14leading_zeroesEm:
  488|   241k|leading_zeroes(uint64_t input_num) {
  489|   241k|  assert(input_num > 0);
  ------------------
  |  Branch (489:3): [True: 241k, False: 0]
  ------------------
  490|   241k|  if (cpp20_and_in_constexpr()) {
  ------------------
  |  Branch (490:7): [Folded, False: 241k]
  ------------------
  491|      0|    return leading_zeroes_generic(input_num);
  492|      0|  }
  493|       |#ifdef GLZ_FASTFLOAT_VISUAL_STUDIO
  494|       |#if defined(_M_X64) || defined(_M_ARM64)
  495|       |  unsigned long leading_zero = 0;
  496|       |  // Search the mask data from most significant bit (MSB)
  497|       |  // to least significant bit (LSB) for a set bit (1).
  498|       |  _BitScanReverse64(&leading_zero, input_num);
  499|       |  return (int)(63 - leading_zero);
  500|       |#else
  501|       |  return leading_zeroes_generic(input_num);
  502|       |#endif
  503|       |#else
  504|   241k|  return __builtin_clzll(input_num);
  505|   241k|#endif
  506|   241k|}
_ZN3glz10fast_float29compute_product_approximationILi55EEENS0_8value128Elm:
 2771|   207k|compute_product_approximation(int64_t q, uint64_t w) {
 2772|   207k|  int const index = 2 * int(q - powers::smallest_power_of_five);
 2773|       |  // For small values of q, e.g., q in [0,27], the answer is always exact
 2774|       |  // because The line value128 firstproduct = full_multiplication(w,
 2775|       |  // power_of_five_128[index]); gives the exact answer.
 2776|   207k|  value128 firstproduct =
 2777|   207k|      full_multiplication(w, powers::power_of_five_128[index]);
 2778|   207k|  static_assert((bit_precision >= 0) && (bit_precision <= 64),
 2779|   207k|                " precision should  be in (0,64]");
 2780|   207k|  constexpr uint64_t precision_mask =
 2781|   207k|      (bit_precision < 64) ? (uint64_t(0xFFFFFFFFFFFFFFFF) >> bit_precision)
  ------------------
  |  Branch (2781:7): [True: 0, Folded]
  ------------------
 2782|   207k|                           : uint64_t(0xFFFFFFFFFFFFFFFF);
 2783|   207k|  if ((firstproduct.high & precision_mask) ==
  ------------------
  |  Branch (2783:7): [True: 46.6k, False: 160k]
  ------------------
 2784|   207k|      precision_mask) { // could further guard with  (lower + w < lower)
 2785|       |    // regarding the second product, we only need secondproduct.high, but our
 2786|       |    // expectation is that the compiler will optimize this extra work away if
 2787|       |    // needed.
 2788|  46.6k|    value128 secondproduct =
 2789|  46.6k|        full_multiplication(w, powers::power_of_five_128[index + 1]);
 2790|  46.6k|    firstproduct.low += secondproduct.high;
 2791|  46.6k|    if (secondproduct.high > firstproduct.low) {
  ------------------
  |  Branch (2791:9): [True: 11.2k, False: 35.3k]
  ------------------
 2792|  11.2k|      firstproduct.high++;
 2793|  11.2k|    }
 2794|  46.6k|  }
 2795|   207k|  return firstproduct;
 2796|   207k|}
_ZN3glz10fast_float19full_multiplicationEmm:
  540|   253k|full_multiplication(uint64_t a, uint64_t b) {
  541|   253k|  if (cpp20_and_in_constexpr()) {
  ------------------
  |  Branch (541:7): [Folded, False: 253k]
  ------------------
  542|      0|    value128 answer;
  543|      0|    answer.low = umul128_generic(a, b, &answer.high);
  544|      0|    return answer;
  545|      0|  }
  546|   253k|  value128 answer;
  547|       |#if defined(_M_ARM64) && !defined(__MINGW32__)
  548|       |  // ARM64 has native support for 64-bit multiplications, no need to emulate
  549|       |  // But MinGW on ARM64 doesn't have native support for 64-bit multiplications
  550|       |  answer.high = __umulh(a, b);
  551|       |  answer.low = a * b;
  552|       |#elif defined(GLZ_FASTFLOAT_32BIT) ||                                              \
  553|       |    (defined(_WIN64) && !defined(__clang__) && !defined(_M_ARM64))
  554|       |  answer.low = _umul128(a, b, &answer.high); // _umul128 not available on ARM64
  555|       |#elif defined(GLZ_FASTFLOAT_64BIT) && defined(__SIZEOF_INT128__)
  556|       |  __uint128_t r = ((__uint128_t)a) * b;
  557|   253k|  answer.low = uint64_t(r);
  558|   253k|  answer.high = uint64_t(r >> 64);
  559|       |#else
  560|       |  answer.low = umul128_generic(a, b, &answer.high);
  561|       |#endif
  562|   253k|  return answer;
  563|   253k|}
_ZN3glz10fast_float8value128C2Ev:
  454|   253k|  constexpr value128() : low(0), high(0) {}
_ZN3glz10fast_float6detail5powerEi:
 2814|   207k|constexpr fastfloat_really_inline int32_t power(int32_t q) noexcept {
 2815|   207k|  return (((152170 + 65536) * q) >> 16) + 63;
 2816|   207k|}
_ZN3glz10fast_float13binary_formatIdE16minimum_exponentEv:
  742|   264k|template <> inline constexpr int binary_format<double>::minimum_exponent() {
  743|   264k|  return -1023;
  744|   264k|}
_ZN3glz10fast_float13binary_formatIdE26min_exponent_round_to_evenEv:
  733|  32.5k|inline constexpr int binary_format<double>::min_exponent_round_to_even() {
  734|  32.5k|  return -4;
  735|  32.5k|}
_ZN3glz10fast_float13binary_formatIdE26max_exponent_round_to_evenEv:
  723|  29.7k|inline constexpr int binary_format<double>::max_exponent_round_to_even() {
  724|  29.7k|  return 23;
  725|  29.7k|}
_ZNK3glz10fast_float17adjusted_mantissaneERKS1_:
  574|  67.6k|  constexpr bool operator!=(adjusted_mantissa const &o) const {
  575|  67.6k|    return mantissa != o.mantissa || power2 != o.power2;
  ------------------
  |  Branch (575:12): [True: 57.3k, False: 10.2k]
  |  Branch (575:38): [True: 0, False: 10.2k]
  ------------------
  576|  67.6k|  }
_ZN3glz10fast_float13compute_errorINS0_13binary_formatIdEEEENS0_17adjusted_mantissaElm:
 2837|  57.3k|compute_error(int64_t q, uint64_t w) noexcept {
 2838|  57.3k|  int lz = leading_zeroes(w);
 2839|  57.3k|  w <<= lz;
 2840|  57.3k|  value128 product =
 2841|  57.3k|      compute_product_approximation<binary::mantissa_explicit_bits() + 3>(q, w);
 2842|  57.3k|  return compute_error_scaled<binary>(q, product.high, lz);
 2843|  57.3k|}
_ZN3glz10fast_float20compute_error_scaledINS0_13binary_formatIdEEEENS0_17adjusted_mantissaElmi:
 2823|  57.3k|compute_error_scaled(int64_t q, uint64_t w, int lz) noexcept {
 2824|  57.3k|  int hilz = int(w >> 63) ^ 1;
 2825|  57.3k|  adjusted_mantissa answer;
 2826|  57.3k|  answer.mantissa = w << hilz;
 2827|  57.3k|  int bias = binary::mantissa_explicit_bits() - binary::minimum_exponent();
 2828|  57.3k|  answer.power2 = int32_t(detail::power(int32_t(q)) + bias - hilz - lz - 62 +
 2829|  57.3k|                          invalid_am_bias);
 2830|  57.3k|  return answer;
 2831|  57.3k|}
_ZN3glz10fast_float10digit_compIdcEENS0_17adjusted_mantissaERNS0_22parsed_number_string_tIT0_EES2_:
 4034|  57.3k|digit_comp(parsed_number_string_t<UC> &num, adjusted_mantissa am) noexcept {
 4035|       |  // remove the invalid exponent bias
 4036|  57.3k|  am.power2 -= invalid_am_bias;
 4037|       |
 4038|  57.3k|  int32_t sci_exp = scientific_exponent(num);
 4039|  57.3k|  size_t max_digits = binary_format<T>::max_digits();
 4040|  57.3k|  size_t digits = 0;
 4041|  57.3k|  bigint bigmant;
 4042|  57.3k|  parse_mantissa(bigmant, num, max_digits, digits);
 4043|       |  // can't underflow, since digits is at most max_digits.
 4044|  57.3k|  int32_t exponent = sci_exp + 1 - int32_t(digits);
 4045|  57.3k|  if (exponent >= 0) {
  ------------------
  |  Branch (4045:7): [True: 17.1k, False: 40.1k]
  ------------------
 4046|  17.1k|    return positive_digit_comp<T>(bigmant, exponent);
 4047|  40.1k|  } else {
 4048|  40.1k|    return negative_digit_comp<T>(bigmant, am, exponent);
 4049|  40.1k|  }
 4050|  57.3k|}
_ZN3glz10fast_float19scientific_exponentIcEEiRNS0_22parsed_number_string_tIT_EE:
 3640|  57.3k|scientific_exponent(parsed_number_string_t<UC> &num) noexcept {
 3641|  57.3k|  uint64_t mantissa = num.mantissa;
 3642|  57.3k|  int32_t exponent = int32_t(num.exponent);
 3643|   286k|  while (mantissa >= 10000) {
  ------------------
  |  Branch (3643:10): [True: 229k, False: 57.3k]
  ------------------
 3644|   229k|    mantissa /= 10000;
 3645|   229k|    exponent += 4;
 3646|   229k|  }
 3647|   114k|  while (mantissa >= 100) {
  ------------------
  |  Branch (3647:10): [True: 57.3k, False: 57.3k]
  ------------------
 3648|  57.3k|    mantissa /= 100;
 3649|  57.3k|    exponent += 2;
 3650|  57.3k|  }
 3651|  57.3k|  while (mantissa >= 10) {
  ------------------
  |  Branch (3651:10): [True: 0, False: 57.3k]
  ------------------
 3652|      0|    mantissa /= 10;
 3653|      0|    exponent += 1;
 3654|      0|  }
 3655|  57.3k|  return exponent;
 3656|  57.3k|}
_ZN3glz10fast_float13binary_formatIdE10max_digitsEv:
 1085|  57.3k|template <> inline constexpr size_t binary_format<double>::max_digits() {
 1086|  57.3k|  return 769;
 1087|  57.3k|}
_ZN3glz10fast_float6bigintC2Ev:
 3399|  57.3k|  GLZ_FASTFLOAT_CONSTEXPR20 bigint() : vec() {}
_ZN3glz10fast_float8stackvecILt62EEC2Ev:
 3006|   580k|  stackvec() = default;
_ZN3glz10fast_float14parse_mantissaIcEEvRNS0_6bigintERNS0_22parsed_number_string_tIT_EEmRm:
 3859|  57.3k|               size_t max_digits, size_t &digits) noexcept {
 3860|       |  // try to minimize the number of big integer and scalar multiplication.
 3861|       |  // therefore, try to parse 8 digits at a time, and multiply by the largest
 3862|       |  // scalar value (9 or 19 digits) for each step.
 3863|  57.3k|  size_t counter = 0;
 3864|  57.3k|  digits = 0;
 3865|  57.3k|  limb value = 0;
 3866|  57.3k|#ifdef GLZ_FASTFLOAT_64BIT_LIMB
 3867|  57.3k|  size_t step = 19;
 3868|       |#else
 3869|       |  size_t step = 9;
 3870|       |#endif
 3871|       |
 3872|       |  // process all integer digits.
 3873|  57.3k|  UC const *p = num.integer.ptr;
 3874|  57.3k|  UC const *pend = p + num.integer.len();
 3875|  57.3k|  skip_zeros(p, pend);
 3876|       |  // process all digits, in increments of step per loop
 3877|   604k|  while (p != pend) {
  ------------------
  |  Branch (3877:10): [True: 559k, False: 45.4k]
  ------------------
 3878|  1.60M|    while ((std::distance(p, pend) >= 8) && (step - counter >= 8) &&
  ------------------
  |  Branch (3878:12): [True: 1.53M, False: 64.0k]
  |  Branch (3878:45): [True: 1.05M, False: 486k]
  ------------------
 3879|  1.05M|           (max_digits - digits >= 8)) {
  ------------------
  |  Branch (3879:12): [True: 1.04M, False: 8.03k]
  ------------------
 3880|  1.04M|      parse_eight_digits(p, value, counter, digits);
 3881|  1.04M|    }
 3882|  2.15M|    while (counter < step && p != pend && digits < max_digits) {
  ------------------
  |  Branch (3882:12): [True: 1.64M, False: 505k]
  |  Branch (3882:30): [True: 1.60M, False: 44.6k]
  |  Branch (3882:43): [True: 1.59M, False: 8.43k]
  ------------------
 3883|  1.59M|      parse_one_digit(p, value, counter, digits);
 3884|  1.59M|    }
 3885|   559k|    if (digits == max_digits) {
  ------------------
  |  Branch (3885:9): [True: 11.9k, False: 547k]
  ------------------
 3886|       |      // add the temporary value, then check if we've truncated any digits
 3887|  11.9k|      add_native(result, limb(powers_of_ten_uint64[counter]), value);
 3888|  11.9k|      bool truncated = is_truncated(p, pend);
 3889|  11.9k|      if (num.fraction.ptr != nullptr) {
  ------------------
  |  Branch (3889:11): [True: 9.24k, False: 2.67k]
  ------------------
 3890|  9.24k|        truncated |= is_truncated(num.fraction);
 3891|  9.24k|      }
 3892|  11.9k|      if (truncated) {
  ------------------
  |  Branch (3892:11): [True: 6.70k, False: 5.20k]
  ------------------
 3893|  6.70k|        round_up_bigint(result, digits);
 3894|  6.70k|      }
 3895|  11.9k|      return;
 3896|   547k|    } else {
 3897|   547k|      add_native(result, limb(powers_of_ten_uint64[counter]), value);
 3898|   547k|      counter = 0;
 3899|   547k|      value = 0;
 3900|   547k|    }
 3901|   559k|  }
 3902|       |
 3903|       |  // add our fraction digits, if they're available.
 3904|  45.4k|  if (num.fraction.ptr != nullptr) {
  ------------------
  |  Branch (3904:7): [True: 25.9k, False: 19.5k]
  ------------------
 3905|  25.9k|    p = num.fraction.ptr;
 3906|  25.9k|    pend = p + num.fraction.len();
 3907|  25.9k|    if (digits == 0) {
  ------------------
  |  Branch (3907:9): [True: 4.25k, False: 21.6k]
  ------------------
 3908|  4.25k|      skip_zeros(p, pend);
 3909|  4.25k|    }
 3910|       |    // process all digits, in increments of step per loop
 3911|   455k|    while (p != pend) {
  ------------------
  |  Branch (3911:12): [True: 439k, False: 15.8k]
  ------------------
 3912|  1.28M|      while ((std::distance(p, pend) >= 8) && (step - counter >= 8) &&
  ------------------
  |  Branch (3912:14): [True: 1.25M, False: 24.5k]
  |  Branch (3912:47): [True: 847k, False: 410k]
  ------------------
 3913|   847k|             (max_digits - digits >= 8)) {
  ------------------
  |  Branch (3913:14): [True: 843k, False: 4.26k]
  ------------------
 3914|   843k|        parse_eight_digits(p, value, counter, digits);
 3915|   843k|      }
 3916|  1.74M|      while (counter < step && p != pend && digits < max_digits) {
  ------------------
  |  Branch (3916:14): [True: 1.33M, False: 417k]
  |  Branch (3916:32): [True: 1.31M, False: 15.0k]
  |  Branch (3916:45): [True: 1.30M, False: 6.69k]
  ------------------
 3917|  1.30M|        parse_one_digit(p, value, counter, digits);
 3918|  1.30M|      }
 3919|   439k|      if (digits == max_digits) {
  ------------------
  |  Branch (3919:11): [True: 10.1k, False: 429k]
  ------------------
 3920|       |        // add the temporary value, then check if we've truncated any digits
 3921|  10.1k|        add_native(result, limb(powers_of_ten_uint64[counter]), value);
 3922|  10.1k|        bool truncated = is_truncated(p, pend);
 3923|  10.1k|        if (truncated) {
  ------------------
  |  Branch (3923:13): [True: 6.36k, False: 3.78k]
  ------------------
 3924|  6.36k|          round_up_bigint(result, digits);
 3925|  6.36k|        }
 3926|  10.1k|        return;
 3927|   429k|      } else {
 3928|   429k|        add_native(result, limb(powers_of_ten_uint64[counter]), value);
 3929|   429k|        counter = 0;
 3930|   429k|        value = 0;
 3931|   429k|      }
 3932|   439k|    }
 3933|  25.9k|  }
 3934|       |
 3935|  35.3k|  if (counter != 0) {
  ------------------
  |  Branch (3935:7): [True: 0, False: 35.3k]
  ------------------
 3936|      0|    add_native(result, limb(powers_of_ten_uint64[counter]), value);
 3937|      0|  }
 3938|  35.3k|}
_ZN3glz10fast_float10skip_zerosIcEEvRPKT_S4_:
 3773|  61.6k|skip_zeros(UC const *&first, UC const *last) noexcept {
 3774|  61.6k|  uint64_t val;
 3775|  63.1k|  while (!cpp20_and_in_constexpr() &&
  ------------------
  |  Branch (3775:10): [True: 63.1k, Folded]
  ------------------
 3776|  63.1k|         std::distance(first, last) >= int_cmp_len<UC>()) {
  ------------------
  |  Branch (3776:10): [True: 52.0k, False: 11.0k]
  ------------------
 3777|  52.0k|    ::memcpy(&val, first, sizeof(uint64_t));
 3778|  52.0k|    if (val != int_cmp_zeros<UC>()) {
  ------------------
  |  Branch (3778:9): [True: 50.5k, False: 1.49k]
  ------------------
 3779|  50.5k|      break;
 3780|  50.5k|    }
 3781|  1.49k|    first += int_cmp_len<UC>();
 3782|  1.49k|  }
 3783|  71.7k|  while (first != last) {
  ------------------
  |  Branch (3783:10): [True: 67.4k, False: 4.25k]
  ------------------
 3784|  67.4k|    if (*first != UC('0')) {
  ------------------
  |  Branch (3784:9): [True: 57.3k, False: 10.1k]
  ------------------
 3785|  57.3k|      break;
 3786|  57.3k|    }
 3787|  10.1k|    first++;
 3788|  10.1k|  }
 3789|  61.6k|}
_ZN3glz10fast_float11int_cmp_lenIcEEiv:
 1180|   348k|template <typename UC> constexpr int int_cmp_len() {
 1181|   348k|  return sizeof(uint64_t) / sizeof(UC);
 1182|   348k|}
_ZN3glz10fast_float13int_cmp_zerosIcEEmv:
 1170|   183k|template <typename UC> constexpr uint64_t int_cmp_zeros() {
 1171|   183k|  static_assert((sizeof(UC) == 1) || (sizeof(UC) == 2) || (sizeof(UC) == 4),
 1172|   183k|                "Unsupported character size");
 1173|   183k|  return (sizeof(UC) == 1) ? 0x3030303030303030
  ------------------
  |  Branch (1173:10): [True: 183k, Folded]
  ------------------
 1174|   183k|         : (sizeof(UC) == 2)
  ------------------
  |  Branch (1174:12): [Folded, False: 0]
  ------------------
 1175|      0|             ? (uint64_t(UC('0')) << 48 | uint64_t(UC('0')) << 32 |
 1176|      0|                uint64_t(UC('0')) << 16 | UC('0'))
 1177|      0|             : (uint64_t(UC('0')) << 32 | UC('0'));
 1178|   183k|}
_ZN3glz10fast_float18parse_eight_digitsIcEEvRPKT_RmS6_S6_:
 3824|  1.88M|                   size_t &count) noexcept {
 3825|  1.88M|  value = value * 100000000 + parse_eight_digits_unrolled(p);
 3826|  1.88M|  p += 8;
 3827|  1.88M|  counter += 8;
 3828|  1.88M|  count += 8;
 3829|  1.88M|}
_ZN3glz10fast_float27parse_eight_digits_unrolledIcEEjPKT_:
 1588|  1.88M|parse_eight_digits_unrolled(UC const *chars) noexcept {
 1589|  1.88M|  if (cpp20_and_in_constexpr() || !has_simd_opt<UC>()) {
  ------------------
  |  Branch (1589:7): [Folded, False: 0]
  |  Branch (1589:35): [True: 0, Folded]
  ------------------
 1590|  1.88M|    return parse_eight_digits_unrolled(read8_to_u64(chars)); // truncation okay
 1591|  1.88M|  }
 1592|      0|  return parse_eight_digits_unrolled(simd_read8_to_u64(chars));
 1593|  1.88M|}
_ZN3glz10fast_float15parse_one_digitIcEEvRPKT_RmS6_S6_:
 3834|  2.90M|                size_t &count) noexcept {
 3835|  2.90M|  value = value * 10 + limb(*p - UC('0'));
 3836|  2.90M|  p++;
 3837|  2.90M|  counter++;
 3838|  2.90M|  count++;
 3839|  2.90M|}
_ZN3glz10fast_float10add_nativeERNS0_6bigintEmm:
 3842|  1.01M|add_native(bigint &big, limb power, limb value) noexcept {
 3843|  1.01M|  big.mul(power);
 3844|  1.01M|  big.add(value);
 3845|  1.01M|}
_ZN3glz10fast_float6bigint3mulEm:
 3552|  1.01M|  GLZ_FASTFLOAT_CONSTEXPR20 bool mul(limb y) noexcept { return small_mul(vec, y); }
_ZN3glz10fast_float9small_mulILt62EEEbRNS0_8stackvecIXT_EEEm:
 3249|  1.73M|                                            limb y) noexcept {
 3250|  1.73M|  limb carry = 0;
 3251|  28.4M|  for (size_t index = 0; index < vec.len(); index++) {
  ------------------
  |  Branch (3251:26): [True: 26.7M, False: 1.73M]
  ------------------
 3252|  26.7M|    vec[index] = scalar_mul(vec[index], y, carry);
 3253|  26.7M|  }
 3254|  1.73M|  if (carry != 0) {
  ------------------
  |  Branch (3254:7): [True: 1.55M, False: 170k]
  ------------------
 3255|  1.55M|    GLZ_FASTFLOAT_TRY(vec.try_push(carry));
  ------------------
  |  |  354|  1.55M|  {                                                                            \
  |  |  355|  1.55M|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 1.55M]
  |  |  ------------------
  |  |  356|  1.55M|      return false;                                                            \
  |  |  357|  1.55M|  }
  ------------------
 3256|  1.55M|  }
 3257|  1.73M|  return true;
 3258|  1.73M|}
_ZNK3glz10fast_float8stackvecILt62EE3lenEv:
 3039|  36.1M|  constexpr size_t len() const noexcept { return length; }
_ZN3glz10fast_float10scalar_mulEmmRm:
 3196|  26.7M|scalar_mul(limb x, limb y, limb &carry) noexcept {
 3197|  26.7M|#ifdef GLZ_FASTFLOAT_64BIT_LIMB
 3198|  26.7M|#if defined(__SIZEOF_INT128__)
 3199|       |  // GCC and clang both define it as an extension.
 3200|  26.7M|  __uint128_t z = __uint128_t(x) * __uint128_t(y) + __uint128_t(carry);
 3201|  26.7M|  carry = limb(z >> limb_bits);
 3202|  26.7M|  return limb(z);
 3203|       |#else
 3204|       |  // fallback, no native 128-bit integer multiplication with carry.
 3205|       |  // on msvc, this optimizes identically, somehow.
 3206|       |  value128 z = full_multiplication(x, y);
 3207|       |  bool overflow;
 3208|       |  z.low = scalar_add(z.low, carry, overflow);
 3209|       |  z.high += uint64_t(overflow); // cannot overflow
 3210|       |  carry = z.high;
 3211|       |  return z.low;
 3212|       |#endif
 3213|       |#else
 3214|       |  uint64_t z = uint64_t(x) * uint64_t(y) + uint64_t(carry);
 3215|       |  carry = limb(z >> limb_bits);
 3216|       |  return limb(z);
 3217|       |#endif
 3218|  26.7M|}
_ZN3glz10fast_float8stackvecILt62EEixEm:
 3017|  65.9M|  GLZ_FASTFLOAT_CONSTEXPR14 limb &operator[](size_t index) noexcept {
 3018|  65.9M|    GLZ_FASTFLOAT_DEBUG_ASSERT(index < length);
  ------------------
  |  |  349|  65.9M|  { ((void)(x)); }
  ------------------
 3019|  65.9M|    return data[index];
 3020|  65.9M|  }
_ZN3glz10fast_float8stackvecILt62EE8try_pushEm:
 3052|  1.63M|  GLZ_FASTFLOAT_CONSTEXPR14 bool try_push(limb value) noexcept {
 3053|  1.63M|    if (len() < capacity()) {
  ------------------
  |  Branch (3053:9): [True: 1.63M, False: 0]
  ------------------
 3054|  1.63M|      push_unchecked(value);
 3055|  1.63M|      return true;
 3056|  1.63M|    } else {
 3057|      0|      return false;
 3058|      0|    }
 3059|  1.63M|  }
_ZNK3glz10fast_float8stackvecILt62EE8capacityEv:
 3043|  2.75M|  constexpr size_t capacity() const noexcept { return size; }
_ZN3glz10fast_float8stackvecILt62EE14push_uncheckedEm:
 3046|  1.67M|  GLZ_FASTFLOAT_CONSTEXPR14 void push_unchecked(limb value) noexcept {
 3047|  1.67M|    data[length] = value;
 3048|  1.67M|    length++;
 3049|  1.67M|  }
_ZN3glz10fast_float6bigint3addEm:
 3554|  1.01M|  GLZ_FASTFLOAT_CONSTEXPR20 bool add(limb y) noexcept { return small_add(vec, y); }
_ZN3glz10fast_float9small_addILt62EEEbRNS0_8stackvecIXT_EEEm:
 3242|  1.01M|small_add(stackvec<size> &vec, limb y) noexcept {
 3243|  1.01M|  return small_add_from(vec, y, 0);
 3244|  1.01M|}
_ZN3glz10fast_float14small_add_fromILt62EEEbRNS0_8stackvecIXT_EEEmm:
 3224|  1.01M|                                                 size_t start) noexcept {
 3225|  1.01M|  size_t index = start;
 3226|  1.01M|  limb carry = y;
 3227|  1.01M|  bool overflow;
 3228|  1.33M|  while (carry != 0 && index < vec.len()) {
  ------------------
  |  Branch (3228:10): [True: 383k, False: 949k]
  |  Branch (3228:24): [True: 321k, False: 62.6k]
  ------------------
 3229|   321k|    vec[index] = scalar_add(vec[index], carry, overflow);
 3230|   321k|    carry = limb(overflow);
 3231|   321k|    index += 1;
 3232|   321k|  }
 3233|  1.01M|  if (carry != 0) {
  ------------------
  |  Branch (3233:7): [True: 62.6k, False: 949k]
  ------------------
 3234|  62.6k|    GLZ_FASTFLOAT_TRY(vec.try_push(carry));
  ------------------
  |  |  354|  62.6k|  {                                                                            \
  |  |  355|  62.6k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 62.6k]
  |  |  ------------------
  |  |  356|  62.6k|      return false;                                                            \
  |  |  357|  62.6k|  }
  ------------------
 3235|  62.6k|  }
 3236|  1.01M|  return true;
 3237|  1.01M|}
_ZN3glz10fast_float10scalar_addEmmRb:
 3176|  7.67M|scalar_add(limb x, limb y, bool &overflow) noexcept {
 3177|  7.67M|  limb z;
 3178|       |// gcc and clang
 3179|  7.67M|#if defined(__has_builtin)
 3180|  7.67M|#if __has_builtin(__builtin_add_overflow)
 3181|  7.67M|  if (!cpp20_and_in_constexpr()) {
  ------------------
  |  Branch (3181:7): [True: 7.67M, Folded]
  ------------------
 3182|  7.67M|    overflow = __builtin_add_overflow(x, y, &z);
 3183|  7.67M|    return z;
 3184|  7.67M|  }
 3185|      0|#endif
 3186|      0|#endif
 3187|       |
 3188|       |  // generic, this still optimizes correctly on MSVC.
 3189|      0|  z = x + y;
 3190|      0|  overflow = z < x;
 3191|      0|  return z;
 3192|  7.67M|}
_ZN3glz10fast_float12is_truncatedIcEEbPKT_S4_:
 3795|  31.2k|is_truncated(UC const *first, UC const *last) noexcept {
 3796|       |  // do 8-bit optimizations, can just compare to 8 literal 0s.
 3797|  31.2k|  uint64_t val;
 3798|   157k|  while (!cpp20_and_in_constexpr() &&
  ------------------
  |  Branch (3798:10): [True: 157k, Folded]
  ------------------
 3799|   157k|         std::distance(first, last) >= int_cmp_len<UC>()) {
  ------------------
  |  Branch (3799:10): [True: 131k, False: 25.8k]
  ------------------
 3800|   131k|    ::memcpy(&val, first, sizeof(uint64_t));
 3801|   131k|    if (val != int_cmp_zeros<UC>()) {
  ------------------
  |  Branch (3801:9): [True: 5.40k, False: 126k]
  ------------------
 3802|  5.40k|      return true;
 3803|  5.40k|    }
 3804|   126k|    first += int_cmp_len<UC>();
 3805|   126k|  }
 3806|  64.1k|  while (first != last) {
  ------------------
  |  Branch (3806:10): [True: 49.3k, False: 14.7k]
  ------------------
 3807|  49.3k|    if (*first != UC('0')) {
  ------------------
  |  Branch (3807:9): [True: 11.1k, False: 38.2k]
  ------------------
 3808|  11.1k|      return true;
 3809|  11.1k|    }
 3810|  38.2k|    ++first;
 3811|  38.2k|  }
 3812|  14.7k|  return false;
 3813|  25.8k|}
_ZN3glz10fast_float12is_truncatedIcEEbNS0_4spanIKT_EE:
 3817|  9.24k|is_truncated(span<UC const> s) noexcept {
 3818|  9.24k|  return is_truncated(s.ptr, s.ptr + s.len());
 3819|  9.24k|}
_ZN3glz10fast_float15round_up_bigintERNS0_6bigintERm:
 3848|  13.0k|round_up_bigint(bigint &big, size_t &count) noexcept {
 3849|       |  // need to round-up the digits, but need to avoid rounding
 3850|       |  // ....9999 to ...10000, which could cause a false halfway point.
 3851|  13.0k|  add_native(big, 10, 1);
 3852|  13.0k|  count++;
 3853|  13.0k|}
_ZN3glz10fast_float19positive_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintEi:
 3942|  17.1k|positive_digit_comp(bigint &bigmant, int32_t exponent) noexcept {
 3943|  17.1k|  GLZ_FASTFLOAT_ASSERT(bigmant.pow10(uint32_t(exponent)));
  ------------------
  |  |  344|  17.1k|  { ((void)(x)); }
  ------------------
 3944|  17.1k|  adjusted_mantissa answer;
 3945|  17.1k|  bool truncated;
 3946|  17.1k|  answer.mantissa = bigmant.hi64(truncated);
 3947|  17.1k|  int bias = binary_format<T>::mantissa_explicit_bits() -
 3948|  17.1k|             binary_format<T>::minimum_exponent();
 3949|  17.1k|  answer.power2 = bigmant.bit_length() - 64 + bias;
 3950|       |
 3951|  17.1k|  round<T>(answer, [truncated](adjusted_mantissa &a, int32_t shift) {
 3952|  17.1k|    round_nearest_tie_even(
 3953|  17.1k|        a, shift,
 3954|  17.1k|        [truncated](bool is_odd, bool is_halfway, bool is_above) -> bool {
 3955|  17.1k|          return is_above || (is_halfway && truncated) ||
 3956|  17.1k|                 (is_odd && is_halfway);
 3957|  17.1k|        });
 3958|  17.1k|  });
 3959|       |
 3960|  17.1k|  return answer;
 3961|  17.1k|}
_ZN3glz10fast_float6bigint5pow10Ej:
 3591|  17.1k|  GLZ_FASTFLOAT_CONSTEXPR20 bool pow10(uint32_t exp) noexcept {
 3592|  17.1k|    GLZ_FASTFLOAT_TRY(pow5(exp));
  ------------------
  |  |  354|  17.1k|  {                                                                            \
  |  |  355|  17.1k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 17.1k]
  |  |  ------------------
  |  |  356|  17.1k|      return false;                                                            \
  |  |  357|  17.1k|  }
  ------------------
 3593|  17.1k|    return pow2(exp);
 3594|  17.1k|  }
_ZN3glz10fast_float6bigint4pow5Ej:
 3560|  57.3k|  GLZ_FASTFLOAT_CONSTEXPR20 bool pow5(uint32_t exp) noexcept {
 3561|       |    // multiply by a power of 5
 3562|  57.3k|    size_t large_length = sizeof(large_power_of_5) / sizeof(limb);
 3563|  57.3k|    limb_span large = limb_span(large_power_of_5, large_length);
 3564|   178k|    while (exp >= large_step) {
  ------------------
  |  Branch (3564:12): [True: 120k, False: 57.3k]
  ------------------
 3565|   120k|      GLZ_FASTFLOAT_TRY(large_mul(vec, large));
  ------------------
  |  |  354|   120k|  {                                                                            \
  |  |  355|   120k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 120k]
  |  |  ------------------
  |  |  356|   120k|      return false;                                                            \
  |  |  357|   120k|  }
  ------------------
 3566|   120k|      exp -= large_step;
 3567|   120k|    }
 3568|  57.3k|#ifdef GLZ_FASTFLOAT_64BIT_LIMB
 3569|  57.3k|    uint32_t small_step = 27;
 3570|  57.3k|    limb max_native = 7450580596923828125UL;
 3571|       |#else
 3572|       |    uint32_t small_step = 13;
 3573|       |    limb max_native = 1220703125U;
 3574|       |#endif
 3575|   122k|    while (exp >= small_step) {
  ------------------
  |  Branch (3575:12): [True: 64.9k, False: 57.3k]
  ------------------
 3576|  64.9k|      GLZ_FASTFLOAT_TRY(small_mul(vec, max_native));
  ------------------
  |  |  354|  64.9k|  {                                                                            \
  |  |  355|  64.9k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 64.9k]
  |  |  ------------------
  |  |  356|  64.9k|      return false;                                                            \
  |  |  357|  64.9k|  }
  ------------------
 3577|  64.9k|      exp -= small_step;
 3578|  64.9k|    }
 3579|  57.3k|    if (exp != 0) {
  ------------------
  |  Branch (3579:9): [True: 49.4k, False: 7.92k]
  ------------------
 3580|       |      // Work around clang bug https://godbolt.org/z/zedh7rrhc
 3581|       |      // This is similar to https://github.com/llvm/llvm-project/issues/47746,
 3582|       |      // except the workaround described there don't work here
 3583|  49.4k|      GLZ_FASTFLOAT_TRY(small_mul(
  ------------------
  |  |  354|  49.4k|  {                                                                            \
  |  |  355|  49.4k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 49.4k]
  |  |  ------------------
  |  |  356|  49.4k|      return false;                                                            \
  |  |  357|  49.4k|  }
  ------------------
 3584|  49.4k|          vec, limb(((void)small_power_of_5[0], small_power_of_5[exp]))));
 3585|  49.4k|    }
 3586|       |
 3587|  57.3k|    return true;
 3588|  57.3k|  }
_ZN3glz10fast_float4spanImEC2EPKmm:
  436|   782k|  constexpr span(T const *_ptr, size_t _length) : ptr(_ptr), length(_length) {}
_ZN3glz10fast_float9large_mulILt62EEEbRNS0_8stackvecIXT_EEENS0_4spanImEE:
 3329|   120k|GLZ_FASTFLOAT_CONSTEXPR20 bool large_mul(stackvec<size> &x, limb_span y) noexcept {
 3330|   120k|  if (y.len() == 1) {
  ------------------
  |  Branch (3330:7): [True: 0, False: 120k]
  ------------------
 3331|      0|    GLZ_FASTFLOAT_TRY(small_mul(x, y[0]));
  ------------------
  |  |  354|      0|  {                                                                            \
  |  |  355|      0|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  356|      0|      return false;                                                            \
  |  |  357|      0|  }
  ------------------
 3332|   120k|  } else {
 3333|   120k|    GLZ_FASTFLOAT_TRY(long_mul(x, y));
  ------------------
  |  |  354|   120k|  {                                                                            \
  |  |  355|   120k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 120k]
  |  |  ------------------
  |  |  356|   120k|      return false;                                                            \
  |  |  357|   120k|  }
  ------------------
 3334|   120k|  }
 3335|   120k|  return true;
 3336|   120k|}
_ZNK3glz10fast_float4spanImE3lenEv:
  440|  9.32M|  constexpr size_t len() const noexcept { return length; }
_ZNK3glz10fast_float4spanImEixEm:
  442|  5.82M|  GLZ_FASTFLOAT_CONSTEXPR14 const T &operator[](size_t index) const noexcept {
  443|  5.82M|    GLZ_FASTFLOAT_DEBUG_ASSERT(index < length);
  ------------------
  |  |  349|  5.82M|  { ((void)(x)); }
  ------------------
  444|  5.82M|    return ptr[index];
  445|  5.82M|  }
_ZN3glz10fast_float8long_mulILt62EEEbRNS0_8stackvecIXT_EEENS0_4spanImEE:
 3301|   120k|GLZ_FASTFLOAT_CONSTEXPR20 bool long_mul(stackvec<size> &x, limb_span y) noexcept {
 3302|   120k|  limb_span xs = limb_span(x.data, x.len());
 3303|   120k|  stackvec<size> z(xs);
 3304|   120k|  limb_span zs = limb_span(z.data, z.len());
 3305|       |
 3306|   120k|  if (y.len() != 0) {
  ------------------
  |  Branch (3306:7): [True: 120k, False: 0]
  ------------------
 3307|   120k|    limb y0 = y[0];
 3308|   120k|    GLZ_FASTFLOAT_TRY(small_mul(x, y0));
  ------------------
  |  |  354|   120k|  {                                                                            \
  |  |  355|   120k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 120k]
  |  |  ------------------
  |  |  356|   120k|      return false;                                                            \
  |  |  357|   120k|  }
  ------------------
 3309|   603k|    for (size_t index = 1; index < y.len(); index++) {
  ------------------
  |  Branch (3309:28): [True: 483k, False: 120k]
  ------------------
 3310|   483k|      limb yi = y[index];
 3311|   483k|      stackvec<size> zi;
 3312|   483k|      if (yi != 0) {
  ------------------
  |  Branch (3312:11): [True: 483k, False: 0]
  ------------------
 3313|       |        // re-use the same buffer throughout
 3314|   483k|        zi.set_len(0);
 3315|   483k|        GLZ_FASTFLOAT_TRY(zi.try_extend(zs));
  ------------------
  |  |  354|   483k|  {                                                                            \
  |  |  355|   483k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 483k]
  |  |  ------------------
  |  |  356|   483k|      return false;                                                            \
  |  |  357|   483k|  }
  ------------------
 3316|   483k|        GLZ_FASTFLOAT_TRY(small_mul(zi, yi));
  ------------------
  |  |  354|   483k|  {                                                                            \
  |  |  355|   483k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 483k]
  |  |  ------------------
  |  |  356|   483k|      return false;                                                            \
  |  |  357|   483k|  }
  ------------------
 3317|   483k|        limb_span zis = limb_span(zi.data, zi.len());
 3318|   483k|        GLZ_FASTFLOAT_TRY(large_add_from(x, zis, index));
  ------------------
  |  |  354|   483k|  {                                                                            \
  |  |  355|   483k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 483k]
  |  |  ------------------
  |  |  356|   483k|      return false;                                                            \
  |  |  357|   483k|  }
  ------------------
 3319|   483k|      }
 3320|   483k|    }
 3321|   120k|  }
 3322|       |
 3323|   120k|  x.normalize();
 3324|   120k|  return true;
 3325|   120k|}
_ZN3glz10fast_float8stackvecILt62EEC2ENS0_4spanImEE:
 3013|   120k|  GLZ_FASTFLOAT_CONSTEXPR20 stackvec(limb_span s) {
 3014|   120k|    GLZ_FASTFLOAT_ASSERT(try_extend(s));
  ------------------
  |  |  344|   120k|  { ((void)(x)); }
  ------------------
 3015|   120k|  }
_ZN3glz10fast_float8stackvecILt62EE7set_lenEm:
 3035|  1.60M|  GLZ_FASTFLOAT_CONSTEXPR14 void set_len(size_t len) noexcept {
 3036|  1.60M|    length = uint16_t(len);
 3037|  1.60M|  }
_ZN3glz10fast_float8stackvecILt62EE10try_extendENS0_4spanImEE:
 3069|   603k|  GLZ_FASTFLOAT_CONSTEXPR20 bool try_extend(limb_span s) noexcept {
 3070|   603k|    if (len() + s.len() <= capacity()) {
  ------------------
  |  Branch (3070:9): [True: 603k, False: 0]
  ------------------
 3071|   603k|      extend_unchecked(s);
 3072|   603k|      return true;
 3073|   603k|    } else {
 3074|      0|      return false;
 3075|      0|    }
 3076|   603k|  }
_ZN3glz10fast_float8stackvecILt62EE16extend_uncheckedENS0_4spanImEE:
 3062|   603k|  GLZ_FASTFLOAT_CONSTEXPR20 void extend_unchecked(limb_span s) noexcept {
 3063|   603k|    limb *ptr = data + length;
 3064|   603k|    std::copy_n(s.ptr, s.len(), ptr);
 3065|   603k|    set_len(len() + s.len());
 3066|   603k|  }
_ZN3glz10fast_float14large_add_fromILt62EEEbRNS0_8stackvecIXT_EEENS0_4spanImEEm:
 3264|   483k|                                          size_t start) noexcept {
 3265|       |  // the effective x buffer is from `xstart..x.len()`, so exit early
 3266|       |  // if we can't get that current range.
 3267|   483k|  if (x.len() < start || y.len() > x.len() - start) {
  ------------------
  |  Branch (3267:7): [True: 0, False: 483k]
  |  Branch (3267:26): [True: 478k, False: 4.38k]
  ------------------
 3268|   478k|    GLZ_FASTFLOAT_TRY(x.try_resize(y.len() + start, 0));
  ------------------
  |  |  354|   478k|  {                                                                            \
  |  |  355|   478k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 478k]
  |  |  ------------------
  |  |  356|   478k|      return false;                                                            \
  |  |  357|   478k|  }
  ------------------
 3269|   478k|  }
 3270|       |
 3271|   483k|  bool carry = false;
 3272|  5.70M|  for (size_t index = 0; index < y.len(); index++) {
  ------------------
  |  Branch (3272:26): [True: 5.22M, False: 483k]
  ------------------
 3273|  5.22M|    limb xi = x[index + start];
 3274|  5.22M|    limb yi = y[index];
 3275|  5.22M|    bool c1 = false;
 3276|  5.22M|    bool c2 = false;
 3277|  5.22M|    xi = scalar_add(xi, yi, c1);
 3278|  5.22M|    if (carry) {
  ------------------
  |  Branch (3278:9): [True: 2.13M, False: 3.09M]
  ------------------
 3279|  2.13M|      xi = scalar_add(xi, 1, c2);
 3280|  2.13M|    }
 3281|  5.22M|    x[index + start] = xi;
 3282|  5.22M|    carry = c1 | c2;
 3283|  5.22M|  }
 3284|       |
 3285|       |  // handle overflow
 3286|   483k|  if (carry) {
  ------------------
  |  Branch (3286:7): [True: 0, False: 483k]
  ------------------
 3287|      0|    GLZ_FASTFLOAT_TRY(small_add_from(x, 1, y.len() + start));
  ------------------
  |  |  354|      0|  {                                                                            \
  |  |  355|      0|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  356|      0|      return false;                                                            \
  |  |  357|      0|  }
  ------------------
 3288|      0|  }
 3289|   483k|  return true;
 3290|   483k|}
_ZN3glz10fast_float8stackvecILt62EE10try_resizeEmm:
 3095|   478k|  GLZ_FASTFLOAT_CONSTEXPR20 bool try_resize(size_t new_len, limb value) noexcept {
 3096|   478k|    if (new_len > capacity()) {
  ------------------
  |  Branch (3096:9): [True: 0, False: 478k]
  ------------------
 3097|      0|      return false;
 3098|   478k|    } else {
 3099|   478k|      resize_unchecked(new_len, value);
 3100|   478k|      return true;
 3101|   478k|    }
 3102|   478k|  }
_ZN3glz10fast_float8stackvecILt62EE16resize_uncheckedEmm:
 3082|   478k|  void resize_unchecked(size_t new_len, limb value) noexcept {
 3083|   478k|    if (new_len > len()) {
  ------------------
  |  Branch (3083:9): [True: 478k, False: 0]
  ------------------
 3084|   478k|      size_t count = new_len - len();
 3085|   478k|      limb *first = data + len();
 3086|   478k|      limb *last = first + count;
 3087|   478k|      ::std::fill(first, last, value);
 3088|   478k|      set_len(new_len);
 3089|   478k|    } else {
 3090|      0|      set_len(new_len);
 3091|      0|    }
 3092|   478k|  }
_ZN3glz10fast_float8stackvecILt62EE9normalizeEv:
 3118|   160k|  GLZ_FASTFLOAT_CONSTEXPR14 void normalize() noexcept {
 3119|   160k|    while (len() > 0 && rindex(0) == 0) {
  ------------------
  |  Branch (3119:12): [True: 160k, False: 0]
  |  Branch (3119:25): [True: 0, False: 160k]
  ------------------
 3120|      0|      length--;
 3121|      0|    }
 3122|   160k|  }
_ZNK3glz10fast_float8stackvecILt62EE6rindexEm:
 3028|   218k|  GLZ_FASTFLOAT_CONSTEXPR14 const limb &rindex(size_t index) const noexcept {
 3029|   218k|    GLZ_FASTFLOAT_DEBUG_ASSERT(index < length);
  ------------------
  |  |  349|   218k|  { ((void)(x)); }
  ------------------
 3030|   218k|    size_t rindex = length - index - 1;
 3031|   218k|    return data[rindex];
 3032|   218k|  }
_ZN3glz10fast_float6bigint4pow2Ej:
 3557|  56.4k|  GLZ_FASTFLOAT_CONSTEXPR20 bool pow2(uint32_t exp) noexcept { return shl(exp); }
_ZN3glz10fast_float6bigint3shlEm:
 3519|  56.4k|  GLZ_FASTFLOAT_CONSTEXPR20 bool shl(size_t n) noexcept {
 3520|  56.4k|    size_t rem = n % limb_bits;
 3521|  56.4k|    size_t div = n / limb_bits;
 3522|  56.4k|    if (rem != 0) {
  ------------------
  |  Branch (3522:9): [True: 45.8k, False: 10.5k]
  ------------------
 3523|  45.8k|      GLZ_FASTFLOAT_TRY(shl_bits(rem));
  ------------------
  |  |  354|  45.8k|  {                                                                            \
  |  |  355|  45.8k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 45.8k]
  |  |  ------------------
  |  |  356|  45.8k|      return false;                                                            \
  |  |  357|  45.8k|  }
  ------------------
 3524|  45.8k|    }
 3525|  56.4k|    if (div != 0) {
  ------------------
  |  Branch (3525:9): [True: 34.7k, False: 21.6k]
  ------------------
 3526|  34.7k|      GLZ_FASTFLOAT_TRY(shl_limbs(div));
  ------------------
  |  |  354|  34.7k|  {                                                                            \
  |  |  355|  34.7k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 34.7k]
  |  |  ------------------
  |  |  356|  34.7k|      return false;                                                            \
  |  |  357|  34.7k|  }
  ------------------
 3527|  34.7k|    }
 3528|  56.4k|    return true;
 3529|  56.4k|  }
_ZN3glz10fast_float6bigint8shl_bitsEm:
 3472|  45.8k|  GLZ_FASTFLOAT_CONSTEXPR20 bool shl_bits(size_t n) noexcept {
 3473|       |    // Internally, for each item, we shift left by n, and add the previous
 3474|       |    // right shifted limb-bits.
 3475|       |    // For example, we transform (for u8) shifted left 2, to:
 3476|       |    //      b10100100 b01000010
 3477|       |    //      b10 b10010001 b00001000
 3478|  45.8k|    GLZ_FASTFLOAT_DEBUG_ASSERT(n != 0);
  ------------------
  |  |  349|  45.8k|  { ((void)(x)); }
  ------------------
 3479|  45.8k|    GLZ_FASTFLOAT_DEBUG_ASSERT(n < sizeof(limb) * 8);
  ------------------
  |  |  349|  45.8k|  { ((void)(x)); }
  ------------------
 3480|       |
 3481|  45.8k|    size_t shl = n;
 3482|  45.8k|    size_t shr = limb_bits - shl;
 3483|  45.8k|    limb prev = 0;
 3484|   722k|    for (size_t index = 0; index < vec.len(); index++) {
  ------------------
  |  Branch (3484:28): [True: 676k, False: 45.8k]
  ------------------
 3485|   676k|      limb xi = vec[index];
 3486|   676k|      vec[index] = (xi << shl) | (prev >> shr);
 3487|   676k|      prev = xi;
 3488|   676k|    }
 3489|       |
 3490|  45.8k|    limb carry = prev >> shr;
 3491|  45.8k|    if (carry != 0) {
  ------------------
  |  Branch (3491:9): [True: 11.6k, False: 34.1k]
  ------------------
 3492|  11.6k|      return vec.try_push(carry);
 3493|  11.6k|    }
 3494|  34.1k|    return true;
 3495|  45.8k|  }
_ZN3glz10fast_float6bigint9shl_limbsEm:
 3498|  34.7k|  GLZ_FASTFLOAT_CONSTEXPR20 bool shl_limbs(size_t n) noexcept {
 3499|  34.7k|    GLZ_FASTFLOAT_DEBUG_ASSERT(n != 0);
  ------------------
  |  |  349|  34.7k|  { ((void)(x)); }
  ------------------
 3500|  34.7k|    if (n + vec.len() > vec.capacity()) {
  ------------------
  |  Branch (3500:9): [True: 0, False: 34.7k]
  ------------------
 3501|      0|      return false;
 3502|  34.7k|    } else if (!vec.is_empty()) {
  ------------------
  |  Branch (3502:16): [True: 34.7k, False: 0]
  ------------------
 3503|       |      // move limbs
 3504|  34.7k|      limb *dst = vec.data + n;
 3505|  34.7k|      limb const *src = vec.data;
 3506|  34.7k|      std::copy_backward(src, src + vec.len(), dst + vec.len());
 3507|       |      // fill in empty limbs
 3508|  34.7k|      limb *first = vec.data;
 3509|  34.7k|      limb *last = first + n;
 3510|  34.7k|      ::std::fill(first, last, 0);
 3511|  34.7k|      vec.set_len(n + vec.len());
 3512|  34.7k|      return true;
 3513|  34.7k|    } else {
 3514|      0|      return true;
 3515|      0|    }
 3516|  34.7k|  }
_ZNK3glz10fast_float8stackvecILt62EE8is_emptyEv:
 3041|  51.9k|  constexpr bool is_empty() const noexcept { return length == 0; }
_ZNK3glz10fast_float6bigint4hi64ERb:
 3418|  17.1k|  GLZ_FASTFLOAT_CONSTEXPR20 uint64_t hi64(bool &truncated) const noexcept {
 3419|  17.1k|#ifdef GLZ_FASTFLOAT_64BIT_LIMB
 3420|  17.1k|    if (vec.len() == 0) {
  ------------------
  |  Branch (3420:9): [True: 0, False: 17.1k]
  ------------------
 3421|      0|      return empty_hi64(truncated);
 3422|  17.1k|    } else if (vec.len() == 1) {
  ------------------
  |  Branch (3422:16): [True: 4.26k, False: 12.9k]
  ------------------
 3423|  4.26k|      return uint64_hi64(vec.rindex(0), truncated);
 3424|  12.9k|    } else {
 3425|  12.9k|      uint64_t result = uint64_hi64(vec.rindex(0), vec.rindex(1), truncated);
 3426|  12.9k|      truncated |= vec.nonzero(2);
 3427|  12.9k|      return result;
 3428|  12.9k|    }
 3429|       |#else
 3430|       |    if (vec.len() == 0) {
 3431|       |      return empty_hi64(truncated);
 3432|       |    } else if (vec.len() == 1) {
 3433|       |      return uint32_hi64(vec.rindex(0), truncated);
 3434|       |    } else if (vec.len() == 2) {
 3435|       |      return uint32_hi64(vec.rindex(0), vec.rindex(1), truncated);
 3436|       |    } else {
 3437|       |      uint64_t result =
 3438|       |          uint32_hi64(vec.rindex(0), vec.rindex(1), vec.rindex(2), truncated);
 3439|       |      truncated |= vec.nonzero(3);
 3440|       |      return result;
 3441|       |    }
 3442|       |#endif
 3443|  17.1k|  }
_ZN3glz10fast_float11uint64_hi64EmRb:
 3132|  4.26k|uint64_hi64(uint64_t r0, bool &truncated) noexcept {
 3133|  4.26k|  truncated = false;
 3134|  4.26k|  int shl = leading_zeroes(r0);
 3135|  4.26k|  return r0 << shl;
 3136|  4.26k|}
_ZN3glz10fast_float11uint64_hi64EmmRb:
 3139|  12.9k|uint64_hi64(uint64_t r0, uint64_t r1, bool &truncated) noexcept {
 3140|  12.9k|  int shl = leading_zeroes(r0);
 3141|  12.9k|  if (shl == 0) {
  ------------------
  |  Branch (3141:7): [True: 1.37k, False: 11.5k]
  ------------------
 3142|  1.37k|    truncated = r1 != 0;
 3143|  1.37k|    return r0;
 3144|  11.5k|  } else {
 3145|  11.5k|    int shr = 64 - shl;
 3146|  11.5k|    truncated = (r1 << shl) != 0;
 3147|  11.5k|    return (r0 << shl) | (r1 >> shr);
 3148|  11.5k|  }
 3149|  12.9k|}
_ZNK3glz10fast_float8stackvecILt62EE7nonzeroEm:
 3107|  12.9k|  GLZ_FASTFLOAT_CONSTEXPR14 bool nonzero(size_t index) const noexcept {
 3108|  17.6k|    while (index < len()) {
  ------------------
  |  Branch (3108:12): [True: 10.6k, False: 6.92k]
  ------------------
 3109|  10.6k|      if (rindex(index) != 0) {
  ------------------
  |  Branch (3109:11): [True: 6.00k, False: 4.68k]
  ------------------
 3110|  6.00k|        return true;
 3111|  6.00k|      }
 3112|  4.68k|      index++;
 3113|  4.68k|    }
 3114|  6.92k|    return false;
 3115|  12.9k|  }
_ZNK3glz10fast_float6bigint10bit_lengthEv:
 3547|  17.1k|  GLZ_FASTFLOAT_CONSTEXPR20 int bit_length() const noexcept {
 3548|  17.1k|    int lz = ctlz();
 3549|  17.1k|    return int(limb_bits * vec.len()) - lz;
 3550|  17.1k|  }
_ZNK3glz10fast_float6bigint4ctlzEv:
 3532|  17.1k|  GLZ_FASTFLOAT_CONSTEXPR20 int ctlz() const noexcept {
 3533|  17.1k|    if (vec.is_empty()) {
  ------------------
  |  Branch (3533:9): [True: 0, False: 17.1k]
  ------------------
 3534|      0|      return 0;
 3535|  17.1k|    } else {
 3536|  17.1k|#ifdef GLZ_FASTFLOAT_64BIT_LIMB
 3537|  17.1k|      return leading_zeroes(vec.rindex(0));
 3538|       |#else
 3539|       |      // no use defining a specialized leading_zeroes for a 32-bit type.
 3540|       |      uint64_t r0 = vec.rindex(0);
 3541|       |      return leading_zeroes(r0 << 32);
 3542|       |#endif
 3543|  17.1k|    }
 3544|  17.1k|  }
_ZN3glz10fast_float5roundIdZNS0_19positive_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintEiEUlRS3_iE_EEvS6_T0_:
 3707|  17.1k|                                                         callback cb) noexcept {
 3708|  17.1k|  int32_t mantissa_shift = 64 - binary_format<T>::mantissa_explicit_bits() - 1;
 3709|  17.1k|  if (-am.power2 >= mantissa_shift) {
  ------------------
  |  Branch (3709:7): [True: 0, False: 17.1k]
  ------------------
 3710|       |    // have a denormal float
 3711|      0|    int32_t shift = -am.power2 + 1;
 3712|      0|    cb(am, (std::min<int32_t>)(shift, 64));
 3713|       |    // check for round-up: if rounding-nearest carried us to the hidden bit.
 3714|      0|    am.power2 = (am.mantissa <
  ------------------
  |  Branch (3714:17): [True: 0, False: 0]
  ------------------
 3715|      0|                 (uint64_t(1) << binary_format<T>::mantissa_explicit_bits()))
 3716|      0|                    ? 0
 3717|      0|                    : 1;
 3718|      0|    return;
 3719|      0|  }
 3720|       |
 3721|       |  // have a normal float, use the default shift.
 3722|  17.1k|  cb(am, mantissa_shift);
 3723|       |
 3724|       |  // check for carry
 3725|  17.1k|  if (am.mantissa >=
  ------------------
  |  Branch (3725:7): [True: 2.41k, False: 14.7k]
  ------------------
 3726|  17.1k|      (uint64_t(2) << binary_format<T>::mantissa_explicit_bits())) {
 3727|  2.41k|    am.mantissa = (uint64_t(1) << binary_format<T>::mantissa_explicit_bits());
 3728|  2.41k|    am.power2++;
 3729|  2.41k|  }
 3730|       |
 3731|       |  // check for infinite: we could have carried to an infinite power
 3732|  17.1k|  am.mantissa &= ~(uint64_t(1) << binary_format<T>::mantissa_explicit_bits());
 3733|  17.1k|  if (am.power2 >= binary_format<T>::infinite_power()) {
  ------------------
  |  Branch (3733:7): [True: 0, False: 17.1k]
  ------------------
 3734|      0|    am.power2 = binary_format<T>::infinite_power();
 3735|      0|    am.mantissa = 0;
 3736|      0|  }
 3737|  17.1k|}
_ZZN3glz10fast_float19positive_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintEiENKUlRS2_iE_clES5_i:
 3951|  17.1k|  round<T>(answer, [truncated](adjusted_mantissa &a, int32_t shift) {
 3952|  17.1k|    round_nearest_tie_even(
 3953|  17.1k|        a, shift,
 3954|  17.1k|        [truncated](bool is_odd, bool is_halfway, bool is_above) -> bool {
 3955|  17.1k|          return is_above || (is_halfway && truncated) ||
 3956|  17.1k|                 (is_odd && is_halfway);
 3957|  17.1k|        });
 3958|  17.1k|  });
_ZN3glz10fast_float22round_nearest_tie_evenIZZNS0_19positive_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintEiENKUlRS3_iE_clES6_iEUlbbbE_EEvS6_iT_:
 3742|  17.1k|                       callback cb) noexcept {
 3743|  17.1k|  uint64_t const mask = (shift == 64) ? UINT64_MAX : (uint64_t(1) << shift) - 1;
  ------------------
  |  Branch (3743:25): [True: 0, False: 17.1k]
  ------------------
 3744|  17.1k|  uint64_t const halfway = (shift == 0) ? 0 : uint64_t(1) << (shift - 1);
  ------------------
  |  Branch (3744:28): [True: 0, False: 17.1k]
  ------------------
 3745|  17.1k|  uint64_t truncated_bits = am.mantissa & mask;
 3746|  17.1k|  bool is_above = truncated_bits > halfway;
 3747|  17.1k|  bool is_halfway = truncated_bits == halfway;
 3748|       |
 3749|       |  // shift digits into position
 3750|  17.1k|  if (shift == 64) {
  ------------------
  |  Branch (3750:7): [True: 0, False: 17.1k]
  ------------------
 3751|      0|    am.mantissa = 0;
 3752|  17.1k|  } else {
 3753|  17.1k|    am.mantissa >>= shift;
 3754|  17.1k|  }
 3755|  17.1k|  am.power2 += shift;
 3756|       |
 3757|  17.1k|  bool is_odd = (am.mantissa & 1) == 1;
 3758|  17.1k|  am.mantissa += uint64_t(cb(is_odd, is_halfway, is_above));
 3759|  17.1k|}
_ZZZN3glz10fast_float19positive_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintEiENKUlRS2_iE_clES5_iENKUlbbbE_clEbbb:
 3954|  17.1k|        [truncated](bool is_odd, bool is_halfway, bool is_above) -> bool {
 3955|  17.1k|          return is_above || (is_halfway && truncated) ||
  ------------------
  |  Branch (3955:18): [True: 3.80k, False: 13.3k]
  |  Branch (3955:31): [True: 9.67k, False: 3.70k]
  |  Branch (3955:45): [True: 4.67k, False: 4.99k]
  ------------------
 3956|  8.70k|                 (is_odd && is_halfway);
  ------------------
  |  Branch (3956:19): [True: 2.68k, False: 6.02k]
  |  Branch (3956:29): [True: 18, False: 2.66k]
  ------------------
 3957|  17.1k|        });
_ZN3glz10fast_float19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES2_i:
 3970|  40.1k|    bigint &bigmant, adjusted_mantissa am, int32_t exponent) noexcept {
 3971|  40.1k|  bigint &real_digits = bigmant;
 3972|  40.1k|  int32_t real_exp = exponent;
 3973|       |
 3974|       |  // get the value of `b`, rounded down, and get a bigint representation of b+h
 3975|  40.1k|  adjusted_mantissa am_b = am;
 3976|       |  // gcc7 buf: use a lambda to remove the noexcept qualifier bug with
 3977|       |  // -Wnoexcept-type.
 3978|  40.1k|  round<T>(am_b,
 3979|  40.1k|           [](adjusted_mantissa &a, int32_t shift) { round_down(a, shift); });
 3980|  40.1k|  T b;
 3981|  40.1k|  to_float(false, am_b, b);
 3982|  40.1k|  adjusted_mantissa theor = to_extended_halfway(b);
 3983|  40.1k|  bigint theor_digits(theor.mantissa);
 3984|  40.1k|  int32_t theor_exp = theor.power2;
 3985|       |
 3986|       |  // scale real digits and theor digits to be same power.
 3987|  40.1k|  int32_t pow2_exp = theor_exp - real_exp;
 3988|  40.1k|  uint32_t pow5_exp = uint32_t(-real_exp);
 3989|  40.1k|  if (pow5_exp != 0) {
  ------------------
  |  Branch (3989:7): [True: 40.1k, False: 0]
  ------------------
 3990|  40.1k|    GLZ_FASTFLOAT_ASSERT(theor_digits.pow5(pow5_exp));
  ------------------
  |  |  344|  40.1k|  { ((void)(x)); }
  ------------------
 3991|  40.1k|  }
 3992|  40.1k|  if (pow2_exp > 0) {
  ------------------
  |  Branch (3992:7): [True: 27.8k, False: 12.3k]
  ------------------
 3993|  27.8k|    GLZ_FASTFLOAT_ASSERT(theor_digits.pow2(uint32_t(pow2_exp)));
  ------------------
  |  |  344|  27.8k|  { ((void)(x)); }
  ------------------
 3994|  27.8k|  } else if (pow2_exp < 0) {
  ------------------
  |  Branch (3994:14): [True: 11.3k, False: 969]
  ------------------
 3995|  11.3k|    GLZ_FASTFLOAT_ASSERT(real_digits.pow2(uint32_t(-pow2_exp)));
  ------------------
  |  |  344|  11.3k|  { ((void)(x)); }
  ------------------
 3996|  11.3k|  }
 3997|       |
 3998|       |  // compare digits, and use it to director rounding
 3999|  40.1k|  int ord = real_digits.compare(theor_digits);
 4000|  40.1k|  adjusted_mantissa answer = am;
 4001|  40.1k|  round<T>(answer, [ord](adjusted_mantissa &a, int32_t shift) {
 4002|  40.1k|    round_nearest_tie_even(
 4003|  40.1k|        a, shift, [ord](bool is_odd, bool _, bool __) -> bool {
 4004|  40.1k|          (void)_;  // not needed, since we've done our comparison
 4005|  40.1k|          (void)__; // not needed, since we've done our comparison
 4006|  40.1k|          if (ord > 0) {
 4007|  40.1k|            return true;
 4008|  40.1k|          } else if (ord < 0) {
 4009|  40.1k|            return false;
 4010|  40.1k|          } else {
 4011|  40.1k|            return is_odd;
 4012|  40.1k|          }
 4013|  40.1k|        });
 4014|  40.1k|  });
 4015|       |
 4016|  40.1k|  return answer;
 4017|  40.1k|}
_ZN3glz10fast_float5roundIdZNS0_19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES3_iEUlRS3_iE_EEvS6_T0_:
 3707|  40.1k|                                                         callback cb) noexcept {
 3708|  40.1k|  int32_t mantissa_shift = 64 - binary_format<T>::mantissa_explicit_bits() - 1;
 3709|  40.1k|  if (-am.power2 >= mantissa_shift) {
  ------------------
  |  Branch (3709:7): [True: 4.62k, False: 35.5k]
  ------------------
 3710|       |    // have a denormal float
 3711|  4.62k|    int32_t shift = -am.power2 + 1;
 3712|  4.62k|    cb(am, (std::min<int32_t>)(shift, 64));
 3713|       |    // check for round-up: if rounding-nearest carried us to the hidden bit.
 3714|  4.62k|    am.power2 = (am.mantissa <
  ------------------
  |  Branch (3714:17): [True: 4.62k, False: 0]
  ------------------
 3715|  4.62k|                 (uint64_t(1) << binary_format<T>::mantissa_explicit_bits()))
 3716|  4.62k|                    ? 0
 3717|  4.62k|                    : 1;
 3718|  4.62k|    return;
 3719|  4.62k|  }
 3720|       |
 3721|       |  // have a normal float, use the default shift.
 3722|  35.5k|  cb(am, mantissa_shift);
 3723|       |
 3724|       |  // check for carry
 3725|  35.5k|  if (am.mantissa >=
  ------------------
  |  Branch (3725:7): [True: 0, False: 35.5k]
  ------------------
 3726|  35.5k|      (uint64_t(2) << binary_format<T>::mantissa_explicit_bits())) {
 3727|      0|    am.mantissa = (uint64_t(1) << binary_format<T>::mantissa_explicit_bits());
 3728|      0|    am.power2++;
 3729|      0|  }
 3730|       |
 3731|       |  // check for infinite: we could have carried to an infinite power
 3732|  35.5k|  am.mantissa &= ~(uint64_t(1) << binary_format<T>::mantissa_explicit_bits());
 3733|  35.5k|  if (am.power2 >= binary_format<T>::infinite_power()) {
  ------------------
  |  Branch (3733:7): [True: 0, False: 35.5k]
  ------------------
 3734|      0|    am.power2 = binary_format<T>::infinite_power();
 3735|      0|    am.mantissa = 0;
 3736|      0|  }
 3737|  35.5k|}
_ZZN3glz10fast_float19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES2_iENKUlRS2_iE_clES5_i:
 3979|  40.1k|           [](adjusted_mantissa &a, int32_t shift) { round_down(a, shift); });
_ZN3glz10fast_float10round_downERNS0_17adjusted_mantissaEi:
 3762|  40.1k|round_down(adjusted_mantissa &am, int32_t shift) noexcept {
 3763|  40.1k|  if (shift == 64) {
  ------------------
  |  Branch (3763:7): [True: 1.03k, False: 39.1k]
  ------------------
 3764|  1.03k|    am.mantissa = 0;
 3765|  39.1k|  } else {
 3766|  39.1k|    am.mantissa >>= shift;
 3767|  39.1k|  }
 3768|  40.1k|  am.power2 += shift;
 3769|  40.1k|}
_ZN3glz10fast_float19to_extended_halfwayIdEENS0_17adjusted_mantissaET_:
 3696|  40.1k|to_extended_halfway(T value) noexcept {
 3697|  40.1k|  adjusted_mantissa am = to_extended(value);
 3698|  40.1k|  am.mantissa <<= 1;
 3699|  40.1k|  am.mantissa += 1;
 3700|  40.1k|  am.power2 -= 1;
 3701|  40.1k|  return am;
 3702|  40.1k|}
_ZN3glz10fast_float11to_extendedIdEENS0_17adjusted_mantissaET_:
 3661|  40.1k|to_extended(T value) noexcept {
 3662|  40.1k|  using equiv_uint = equiv_uint_t<T>;
 3663|  40.1k|  constexpr equiv_uint exponent_mask = binary_format<T>::exponent_mask();
 3664|  40.1k|  constexpr equiv_uint mantissa_mask = binary_format<T>::mantissa_mask();
 3665|  40.1k|  constexpr equiv_uint hidden_bit_mask = binary_format<T>::hidden_bit_mask();
 3666|       |
 3667|  40.1k|  adjusted_mantissa am;
 3668|  40.1k|  int32_t bias = binary_format<T>::mantissa_explicit_bits() -
 3669|  40.1k|                 binary_format<T>::minimum_exponent();
 3670|  40.1k|  equiv_uint bits;
 3671|  40.1k|#if GLZ_FASTFLOAT_HAS_BIT_CAST
 3672|  40.1k|  bits = std::bit_cast<equiv_uint>(value);
 3673|       |#else
 3674|       |  ::memcpy(&bits, &value, sizeof(T));
 3675|       |#endif
 3676|  40.1k|  if ((bits & exponent_mask) == 0) {
  ------------------
  |  Branch (3676:7): [True: 4.62k, False: 35.5k]
  ------------------
 3677|       |    // denormal
 3678|  4.62k|    am.power2 = 1 - bias;
 3679|  4.62k|    am.mantissa = bits & mantissa_mask;
 3680|  35.5k|  } else {
 3681|       |    // normal
 3682|  35.5k|    am.power2 = int32_t((bits & exponent_mask) >>
 3683|  35.5k|                        binary_format<T>::mantissa_explicit_bits());
 3684|  35.5k|    am.power2 -= bias;
 3685|  35.5k|    am.mantissa = (bits & mantissa_mask) | hidden_bit_mask;
 3686|  35.5k|  }
 3687|       |
 3688|  40.1k|  return am;
 3689|  40.1k|}
_ZN3glz10fast_float6bigintC2Em:
 3406|  40.1k|  GLZ_FASTFLOAT_CONSTEXPR20 bigint(uint64_t value) : vec() {
 3407|  40.1k|#ifdef GLZ_FASTFLOAT_64BIT_LIMB
 3408|  40.1k|    vec.push_unchecked(value);
 3409|       |#else
 3410|       |    vec.push_unchecked(uint32_t(value));
 3411|       |    vec.push_unchecked(uint32_t(value >> 32));
 3412|       |#endif
 3413|  40.1k|    vec.normalize();
 3414|  40.1k|  }
_ZNK3glz10fast_float6bigint7compareERKS1_:
 3451|  40.1k|  GLZ_FASTFLOAT_CONSTEXPR20 int compare(bigint const &other) const noexcept {
 3452|  40.1k|    if (vec.len() > other.vec.len()) {
  ------------------
  |  Branch (3452:9): [True: 0, False: 40.1k]
  ------------------
 3453|      0|      return 1;
 3454|  40.1k|    } else if (vec.len() < other.vec.len()) {
  ------------------
  |  Branch (3454:16): [True: 0, False: 40.1k]
  ------------------
 3455|      0|      return -1;
 3456|  40.1k|    } else {
 3457|  82.9k|      for (size_t index = vec.len(); index > 0; index--) {
  ------------------
  |  Branch (3457:38): [True: 80.3k, False: 2.62k]
  ------------------
 3458|  80.3k|        limb xi = vec[index - 1];
 3459|  80.3k|        limb yi = other.vec[index - 1];
 3460|  80.3k|        if (xi > yi) {
  ------------------
  |  Branch (3460:13): [True: 13.9k, False: 66.4k]
  ------------------
 3461|  13.9k|          return 1;
 3462|  66.4k|        } else if (xi < yi) {
  ------------------
  |  Branch (3462:20): [True: 23.6k, False: 42.7k]
  ------------------
 3463|  23.6k|          return -1;
 3464|  23.6k|        }
 3465|  80.3k|      }
 3466|  2.62k|      return 0;
 3467|  40.1k|    }
 3468|  40.1k|  }
_ZNK3glz10fast_float8stackvecILt62EEixEm:
 3022|   160k|  GLZ_FASTFLOAT_CONSTEXPR14 const limb &operator[](size_t index) const noexcept {
 3023|   160k|    GLZ_FASTFLOAT_DEBUG_ASSERT(index < length);
  ------------------
  |  |  349|   160k|  { ((void)(x)); }
  ------------------
 3024|   160k|    return data[index];
 3025|   160k|  }
_ZN3glz10fast_float5roundIdZNS0_19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES3_iEUlRS3_iE0_EEvS6_T0_:
 3707|  40.1k|                                                         callback cb) noexcept {
 3708|  40.1k|  int32_t mantissa_shift = 64 - binary_format<T>::mantissa_explicit_bits() - 1;
 3709|  40.1k|  if (-am.power2 >= mantissa_shift) {
  ------------------
  |  Branch (3709:7): [True: 4.62k, False: 35.5k]
  ------------------
 3710|       |    // have a denormal float
 3711|  4.62k|    int32_t shift = -am.power2 + 1;
 3712|  4.62k|    cb(am, (std::min<int32_t>)(shift, 64));
 3713|       |    // check for round-up: if rounding-nearest carried us to the hidden bit.
 3714|  4.62k|    am.power2 = (am.mantissa <
  ------------------
  |  Branch (3714:17): [True: 4.61k, False: 6]
  ------------------
 3715|  4.62k|                 (uint64_t(1) << binary_format<T>::mantissa_explicit_bits()))
 3716|  4.62k|                    ? 0
 3717|  4.62k|                    : 1;
 3718|  4.62k|    return;
 3719|  4.62k|  }
 3720|       |
 3721|       |  // have a normal float, use the default shift.
 3722|  35.5k|  cb(am, mantissa_shift);
 3723|       |
 3724|       |  // check for carry
 3725|  35.5k|  if (am.mantissa >=
  ------------------
  |  Branch (3725:7): [True: 1.61k, False: 33.9k]
  ------------------
 3726|  35.5k|      (uint64_t(2) << binary_format<T>::mantissa_explicit_bits())) {
 3727|  1.61k|    am.mantissa = (uint64_t(1) << binary_format<T>::mantissa_explicit_bits());
 3728|  1.61k|    am.power2++;
 3729|  1.61k|  }
 3730|       |
 3731|       |  // check for infinite: we could have carried to an infinite power
 3732|  35.5k|  am.mantissa &= ~(uint64_t(1) << binary_format<T>::mantissa_explicit_bits());
 3733|  35.5k|  if (am.power2 >= binary_format<T>::infinite_power()) {
  ------------------
  |  Branch (3733:7): [True: 0, False: 35.5k]
  ------------------
 3734|      0|    am.power2 = binary_format<T>::infinite_power();
 3735|      0|    am.mantissa = 0;
 3736|      0|  }
 3737|  35.5k|}
_ZZN3glz10fast_float19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES2_iENKUlRS2_iE0_clES5_i:
 4001|  40.1k|  round<T>(answer, [ord](adjusted_mantissa &a, int32_t shift) {
 4002|  40.1k|    round_nearest_tie_even(
 4003|  40.1k|        a, shift, [ord](bool is_odd, bool _, bool __) -> bool {
 4004|  40.1k|          (void)_;  // not needed, since we've done our comparison
 4005|  40.1k|          (void)__; // not needed, since we've done our comparison
 4006|  40.1k|          if (ord > 0) {
 4007|  40.1k|            return true;
 4008|  40.1k|          } else if (ord < 0) {
 4009|  40.1k|            return false;
 4010|  40.1k|          } else {
 4011|  40.1k|            return is_odd;
 4012|  40.1k|          }
 4013|  40.1k|        });
 4014|  40.1k|  });
_ZN3glz10fast_float22round_nearest_tie_evenIZZNS0_19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES3_iENKUlRS3_iE0_clES6_iEUlbbbE_EEvS6_iT_:
 3742|  40.1k|                       callback cb) noexcept {
 3743|  40.1k|  uint64_t const mask = (shift == 64) ? UINT64_MAX : (uint64_t(1) << shift) - 1;
  ------------------
  |  Branch (3743:25): [True: 1.03k, False: 39.1k]
  ------------------
 3744|  40.1k|  uint64_t const halfway = (shift == 0) ? 0 : uint64_t(1) << (shift - 1);
  ------------------
  |  Branch (3744:28): [True: 0, False: 40.1k]
  ------------------
 3745|  40.1k|  uint64_t truncated_bits = am.mantissa & mask;
 3746|  40.1k|  bool is_above = truncated_bits > halfway;
 3747|  40.1k|  bool is_halfway = truncated_bits == halfway;
 3748|       |
 3749|       |  // shift digits into position
 3750|  40.1k|  if (shift == 64) {
  ------------------
  |  Branch (3750:7): [True: 1.03k, False: 39.1k]
  ------------------
 3751|  1.03k|    am.mantissa = 0;
 3752|  39.1k|  } else {
 3753|  39.1k|    am.mantissa >>= shift;
 3754|  39.1k|  }
 3755|  40.1k|  am.power2 += shift;
 3756|       |
 3757|  40.1k|  bool is_odd = (am.mantissa & 1) == 1;
 3758|  40.1k|  am.mantissa += uint64_t(cb(is_odd, is_halfway, is_above));
 3759|  40.1k|}
_ZZZN3glz10fast_float19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES2_iENKUlRS2_iE0_clES5_iENKUlbbbE_clEbbb:
 4003|  40.1k|        a, shift, [ord](bool is_odd, bool _, bool __) -> bool {
 4004|  40.1k|          (void)_;  // not needed, since we've done our comparison
 4005|  40.1k|          (void)__; // not needed, since we've done our comparison
 4006|  40.1k|          if (ord > 0) {
  ------------------
  |  Branch (4006:15): [True: 13.9k, False: 26.2k]
  ------------------
 4007|  13.9k|            return true;
 4008|  26.2k|          } else if (ord < 0) {
  ------------------
  |  Branch (4008:22): [True: 23.6k, False: 2.62k]
  ------------------
 4009|  23.6k|            return false;
 4010|  23.6k|          } else {
 4011|  2.62k|            return is_odd;
 4012|  2.62k|          }
 4013|  40.1k|        });
_ZN3glz10fast_float8to_floatIdEEvbNS0_17adjusted_mantissaERT_:
 1131|   124k|to_float(bool negative, adjusted_mantissa am, T &value) {
 1132|   124k|  using equiv_uint = equiv_uint_t<T>;
 1133|   124k|  equiv_uint word = equiv_uint(am.mantissa);
 1134|   124k|  word = equiv_uint(word | equiv_uint(am.power2)
 1135|   124k|                               << binary_format<T>::mantissa_explicit_bits());
 1136|   124k|  word =
 1137|   124k|      equiv_uint(word | equiv_uint(negative) << binary_format<T>::sign_index());
 1138|   124k|#if GLZ_FASTFLOAT_HAS_BIT_CAST
 1139|   124k|  value = std::bit_cast<T>(word);
 1140|       |#else
 1141|       |  ::memcpy(&value, &word, sizeof(T));
 1142|       |#endif
 1143|   124k|}
_ZN3glz10fast_float13binary_formatIdE10sign_indexEv:
  758|   124k|template <> inline constexpr int binary_format<double>::sign_index() {
  759|   124k|  return 63;
  760|   124k|}
_ZN3glz10fast_float13binary_formatIdE14infinite_powerEv:
  750|   311k|template <> inline constexpr int binary_format<double>::infinite_power() {
  751|   311k|  return 0x7FF;
  752|   311k|}

_ZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_:
   27|  1.52M|   {
   28|  1.52M|      if constexpr (N > 0) {
   29|       |         // Explicit sizes for small N to help the compiler and make debugging easier
   30|       |         // These generate less assembly with O0, but make no difference for higher optimization
   31|       |         if constexpr (N == 1) {
   32|       |            lambda.template operator()<0>();
   33|       |         }
   34|       |         else if constexpr (N == 2) {
   35|       |            lambda.template operator()<0>();
   36|       |            lambda.template operator()<1>();
   37|       |         }
   38|       |         else if constexpr (N == 3) {
   39|       |            lambda.template operator()<0>();
   40|       |            lambda.template operator()<1>();
   41|       |            lambda.template operator()<2>();
   42|       |         }
   43|       |         else if constexpr (N == 4) {
   44|       |            lambda.template operator()<0>();
   45|       |            lambda.template operator()<1>();
   46|       |            lambda.template operator()<2>();
   47|       |            lambda.template operator()<3>();
   48|       |         }
   49|  1.52M|         else {
   50|  1.52M|            [&]<size_t... I>(std::index_sequence<I...>) {
   51|  1.52M|               (void)(lambda.template operator()<I>(), ...);
   52|  1.52M|            }(std::make_index_sequence<N>{});
   53|  1.52M|         }
   54|  1.52M|      }
   55|  1.52M|   }
_ZZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_16is_variant_arrayEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_ENKUlTpTnmNS2_16integer_sequenceImJXspT_EEEEE_clIJLm0ELm1ELm2ELm3ELm4ELm5EEEEDaS12_:
   50|  1.52M|            [&]<size_t... I>(std::index_sequence<I...>) {
   51|  1.52M|               (void)(lambda.template operator()<I>(), ...);
   52|  1.52M|            }(std::make_index_sequence<N>{});
_ZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_:
   27|  43.9k|   {
   28|  43.9k|      if constexpr (N > 0) {
   29|       |         // Explicit sizes for small N to help the compiler and make debugging easier
   30|       |         // These generate less assembly with O0, but make no difference for higher optimization
   31|       |         if constexpr (N == 1) {
   32|       |            lambda.template operator()<0>();
   33|       |         }
   34|       |         else if constexpr (N == 2) {
   35|       |            lambda.template operator()<0>();
   36|       |            lambda.template operator()<1>();
   37|       |         }
   38|       |         else if constexpr (N == 3) {
   39|       |            lambda.template operator()<0>();
   40|       |            lambda.template operator()<1>();
   41|       |            lambda.template operator()<2>();
   42|       |         }
   43|       |         else if constexpr (N == 4) {
   44|       |            lambda.template operator()<0>();
   45|       |            lambda.template operator()<1>();
   46|       |            lambda.template operator()<2>();
   47|       |            lambda.template operator()<3>();
   48|       |         }
   49|  43.9k|         else {
   50|  43.9k|            [&]<size_t... I>(std::index_sequence<I...>) {
   51|  43.9k|               (void)(lambda.template operator()<I>(), ...);
   52|  43.9k|            }(std::make_index_sequence<N>{});
   53|  43.9k|         }
   54|  43.9k|      }
   55|  43.9k|   }
_ZZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_14is_variant_strEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_ENKUlTpTnmNS2_16integer_sequenceImJXspT_EEEEE_clIJLm0ELm1ELm2ELm3ELm4ELm5EEEEDaS12_:
   50|  43.9k|            [&]<size_t... I>(std::index_sequence<I...>) {
   51|  43.9k|               (void)(lambda.template operator()<I>(), ...);
   52|  43.9k|            }(std::make_index_sequence<N>{});
_ZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_:
   27|  4.72k|   {
   28|  4.72k|      if constexpr (N > 0) {
   29|       |         // Explicit sizes for small N to help the compiler and make debugging easier
   30|       |         // These generate less assembly with O0, but make no difference for higher optimization
   31|       |         if constexpr (N == 1) {
   32|       |            lambda.template operator()<0>();
   33|       |         }
   34|       |         else if constexpr (N == 2) {
   35|       |            lambda.template operator()<0>();
   36|       |            lambda.template operator()<1>();
   37|       |         }
   38|       |         else if constexpr (N == 3) {
   39|       |            lambda.template operator()<0>();
   40|       |            lambda.template operator()<1>();
   41|       |            lambda.template operator()<2>();
   42|       |         }
   43|       |         else if constexpr (N == 4) {
   44|       |            lambda.template operator()<0>();
   45|       |            lambda.template operator()<1>();
   46|       |            lambda.template operator()<2>();
   47|       |            lambda.template operator()<3>();
   48|       |         }
   49|  4.72k|         else {
   50|  4.72k|            [&]<size_t... I>(std::index_sequence<I...>) {
   51|  4.72k|               (void)(lambda.template operator()<I>(), ...);
   52|  4.72k|            }(std::make_index_sequence<N>{});
   53|  4.72k|         }
   54|  4.72k|      }
   55|  4.72k|   }
_ZZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_15is_variant_boolEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_ENKUlTpTnmNS2_16integer_sequenceImJXspT_EEEEE_clIJLm0ELm1ELm2ELm3ELm4ELm5EEEEDaS12_:
   50|  4.72k|            [&]<size_t... I>(std::index_sequence<I...>) {
   51|  4.72k|               (void)(lambda.template operator()<I>(), ...);
   52|  4.72k|            }(std::make_index_sequence<N>{});
_ZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_:
   27|  6.13M|   {
   28|  6.13M|      if constexpr (N > 0) {
   29|       |         // Explicit sizes for small N to help the compiler and make debugging easier
   30|       |         // These generate less assembly with O0, but make no difference for higher optimization
   31|       |         if constexpr (N == 1) {
   32|       |            lambda.template operator()<0>();
   33|       |         }
   34|       |         else if constexpr (N == 2) {
   35|       |            lambda.template operator()<0>();
   36|       |            lambda.template operator()<1>();
   37|       |         }
   38|       |         else if constexpr (N == 3) {
   39|       |            lambda.template operator()<0>();
   40|       |            lambda.template operator()<1>();
   41|       |            lambda.template operator()<2>();
   42|       |         }
   43|       |         else if constexpr (N == 4) {
   44|       |            lambda.template operator()<0>();
   45|       |            lambda.template operator()<1>();
   46|       |            lambda.template operator()<2>();
   47|       |            lambda.template operator()<3>();
   48|       |         }
   49|  6.13M|         else {
   50|  6.13M|            [&]<size_t... I>(std::index_sequence<I...>) {
   51|  6.13M|               (void)(lambda.template operator()<I>(), ...);
   52|  6.13M|            }(std::make_index_sequence<N>{});
   53|  6.13M|         }
   54|  6.13M|      }
   55|  6.13M|   }
_ZZN3glz8for_eachILm6EZNS_28process_variant_alternativesINSt3__17variantIJDndNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEbNS2_6vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS7_ISE_EEEENSD_ISE_EEEEENS_14is_variant_numEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERSI_TkNS_10is_contextERNS_7contextERPKcSR_EEvOT0_OT1_OT2_T3_EUlTnmvE_EEvSU_ENKUlTpTnmNS2_16integer_sequenceImJXspT_EEEEE_clIJLm0ELm1ELm2ELm3ELm4ELm5EEEEDaS12_:
   50|  6.13M|            [&]<size_t... I>(std::index_sequence<I...>) {
   51|  6.13M|               (void)(lambda.template operator()<I>(), ...);
   52|  6.13M|            }(std::make_index_sequence<N>{});

_ZN3glz10from_charsILb0EdcEENS_10fast_float19from_chars_result_tIT1_EEPKS3_S6_RT0_:
  235|  6.13M|   {
  236|  6.13M|      using namespace glz::fast_float;
  237|  6.13M|      static_assert(is_supported_float_type<T>(), "only some floating-point types are supported");
  238|  6.13M|      static_assert(is_supported_char_type<UC>(), "only char, wchar_t, char16_t and char32_t are supported");
  239|       |
  240|  6.13M|      parsed_number_string_t<UC> pns = glz::parse_number_string<null_terminated, UC>(first, last);
  241|  6.13M|      if (!pns.valid) [[unlikely]] {
  ------------------
  |  Branch (241:11): [True: 3.70k, False: 6.13M]
  ------------------
  242|  3.70k|         return {.ptr = first, .ec = std::errc::invalid_argument};
  243|  3.70k|      }
  244|       |
  245|  6.13M|      return from_chars_advanced(pns, value);
  246|  6.13M|   }
_ZN3glz19parse_number_stringILb0EcEENS_10fast_float22parsed_number_string_tIT0_EEPKS3_S6_:
   18|  6.13M|   {
   19|  6.13M|      using namespace glz::fast_float;
   20|  6.13M|      static constexpr UC decimal_point = '.';
   21|       |
   22|  6.13M|      parsed_number_string_t<UC> answer;
   23|  6.13M|      answer.valid = false;
   24|  6.13M|      answer.too_many_digits = false;
   25|  6.13M|      answer.negative = (*p == UC('-'));
   26|  6.13M|      if (*p == UC('-')) { // C++17 20.19.3.(7.1) explicitly forbids '+' sign here
  ------------------
  |  Branch (26:11): [True: 8.96k, False: 6.12M]
  ------------------
   27|  8.96k|         ++p;
   28|       |
   29|  8.96k|         if constexpr (not null_terminated) {
   30|  8.96k|            if (p == pend) [[unlikely]] {
  ------------------
  |  Branch (30:17): [True: 9, False: 8.95k]
  ------------------
   31|      9|               return answer;
   32|      9|            }
   33|  8.96k|         }
   34|       |
   35|  8.96k|         if (!glz::fast_float::is_integer(*p)) [[unlikely]] { // a sign must be followed by an integer
  ------------------
  |  Branch (35:14): [True: 63, False: 8.89k]
  ------------------
   36|     63|            return answer;
   37|     63|         }
   38|  8.96k|      }
   39|  6.13M|      UC const* const start_digits = p;
   40|       |
   41|  6.13M|      uint64_t i = 0; // an unsigned int avoids signed overflows (which are bad)
   42|       |
   43|  6.13M|      uint64_t digit;
   44|       |      if constexpr (null_terminated) {
   45|       |         while ((digit = glz::fast_float::digit_value(*p)) <= 9) {
   46|       |            // a multiplication by 10 is cheaper than an arbitrary integer
   47|       |            // multiplication
   48|       |            i = 10 * i + digit; // might overflow, we will handle the overflow later
   49|       |            ++p;
   50|       |         }
   51|       |      }
   52|  6.13M|      else {
   53|  31.6M|         while ((p != pend) && (digit = glz::fast_float::digit_value(*p)) <= 9) {
  ------------------
  |  Branch (53:17): [True: 31.6M, False: 998]
  |  Branch (53:32): [True: 25.5M, False: 6.13M]
  ------------------
   54|       |            // a multiplication by 10 is cheaper than an arbitrary integer
   55|       |            // multiplication
   56|  25.5M|            i = 10 * i + digit; // might overflow, we will handle the overflow later
   57|  25.5M|            ++p;
   58|  25.5M|         }
   59|  6.13M|      }
   60|       |
   61|  6.13M|      UC const* const end_of_integer_part = p;
   62|  6.13M|      int64_t digit_count = int64_t(end_of_integer_part - start_digits);
   63|  6.13M|      answer.integer = glz::fast_float::span<const UC>(start_digits, size_t(digit_count));
   64|       |
   65|       |      // at least 1 digit in integer part, without leading zeros
   66|  6.13M|      if (digit_count == 0 || (start_digits[0] == UC('0') && digit_count > 1)) {
  ------------------
  |  Branch (66:11): [True: 3.30k, False: 6.13M]
  |  Branch (66:32): [True: 2.70M, False: 3.42M]
  |  Branch (66:62): [True: 165, False: 2.70M]
  ------------------
   67|  3.45k|         return answer;
   68|  3.45k|      }
   69|       |
   70|  6.13M|      int64_t exponent = 0;
   71|  6.13M|      const bool has_decimal_point = [&] {
   72|  6.13M|         if constexpr (null_terminated) {
   73|  6.13M|            return (*p == decimal_point);
   74|  6.13M|         }
   75|  6.13M|         else {
   76|  6.13M|            return (p != pend) && (*p == decimal_point);
   77|  6.13M|         }
   78|  6.13M|      }();
   79|  6.13M|      if (has_decimal_point) {
  ------------------
  |  Branch (79:11): [True: 47.1k, False: 6.08M]
  ------------------
   80|  47.1k|         ++p;
   81|  47.1k|         UC const* before = p;
   82|       |         // can occur at most twice without overflowing, but let it occur more, since
   83|       |         // for integers with many digits, digit parsing is the primary bottleneck.
   84|  47.1k|         loop_parse_if_eight_digits(p, pend, i);
   85|       |
   86|       |         if constexpr (null_terminated) {
   87|       |            while ((digit = glz::fast_float::digit_value(*p)) <= 9) {
   88|       |               ++p;
   89|       |               i = i * 10 + digit; // in rare cases, this will overflow, but that's ok
   90|       |            }
   91|       |         }
   92|  47.1k|         else {
   93|   183k|            while ((p != pend) && (digit = glz::fast_float::digit_value(*p)) <= 9) {
  ------------------
  |  Branch (93:20): [True: 182k, False: 1.03k]
  |  Branch (93:35): [True: 136k, False: 46.1k]
  ------------------
   94|   136k|               ++p;
   95|   136k|               i = i * 10 + digit; // in rare cases, this will overflow, but that's ok
   96|   136k|            }
   97|  47.1k|         }
   98|  47.1k|         exponent = before - p;
   99|  47.1k|         answer.fraction = glz::fast_float::span<const UC>(before, size_t(p - before));
  100|  47.1k|         digit_count -= exponent;
  101|  47.1k|      }
  102|       |      // at least 1 digit in fractional part
  103|  6.13M|      if (has_decimal_point && exponent == 0) {
  ------------------
  |  Branch (103:11): [True: 47.1k, False: 6.08M]
  |  Branch (103:32): [True: 60, False: 47.1k]
  ------------------
  104|     60|         return answer;
  105|     60|      }
  106|       |
  107|  6.13M|      int64_t exp_number = 0; // explicit exponential part
  108|       |
  109|       |      // An exponent marker must be followed by at least one digit, after an optional sign. Unlike
  110|       |      // std::from_chars, which ends the number before a digitless marker, "1e", "1e+" and "1.0E-" are
  111|       |      // rejected: ending early would read "1.0e" as 1 wherever trailing content goes unchecked.
  112|       |      if constexpr (null_terminated) {
  113|       |         if ((UC('e') == *p) || (UC('E') == *p)) {
  114|       |            ++p;
  115|       |            bool neg_exp = false;
  116|       |            if (UC('-') == *p) {
  117|       |               neg_exp = true;
  118|       |               ++p;
  119|       |            }
  120|       |            else if (UC('+') == *p) { // '+' on exponent is allowed by C++17 20.19.3.(7.1)
  121|       |               ++p;
  122|       |            }
  123|       |            if ((digit = glz::fast_float::digit_value(*p)) > 9) [[unlikely]] {
  124|       |               return answer;
  125|       |            }
  126|       |            else {
  127|       |               do {
  128|       |                  if (exp_number < 0x10000000) {
  129|       |                     exp_number = 10 * exp_number + digit;
  130|       |                  }
  131|       |                  ++p;
  132|       |               } while ((digit = glz::fast_float::digit_value(*p)) <= 9);
  133|       |               if (neg_exp) {
  134|       |                  exp_number = -exp_number;
  135|       |               }
  136|       |               exponent += exp_number;
  137|       |            }
  138|       |         }
  139|       |      }
  140|  6.13M|      else {
  141|  6.13M|         if ((p != pend) && ((UC('e') == *p) || (UC('E') == *p))) {
  ------------------
  |  Branch (141:14): [True: 6.12M, False: 2.00k]
  |  Branch (141:30): [True: 21.6k, False: 6.10M]
  |  Branch (141:49): [True: 22.6k, False: 6.08M]
  ------------------
  142|  44.2k|            ++p;
  143|  44.2k|            bool neg_exp = false;
  144|  44.2k|            if ((p != pend) && (UC('-') == *p)) {
  ------------------
  |  Branch (144:17): [True: 44.2k, False: 10]
  |  Branch (144:32): [True: 22.5k, False: 21.7k]
  ------------------
  145|  22.5k|               neg_exp = true;
  146|  22.5k|               ++p;
  147|  22.5k|            }
  148|  21.7k|            else if ((p != pend) && (UC('+') == *p)) { // '+' on exponent is allowed by C++17 20.19.3.(7.1)
  ------------------
  |  Branch (148:22): [True: 21.7k, False: 10]
  |  Branch (148:37): [True: 1.31k, False: 20.4k]
  ------------------
  149|  1.31k|               ++p;
  150|  1.31k|            }
  151|  44.2k|            if ((p == pend) || (digit = glz::fast_float::digit_value(*p)) > 9) [[unlikely]] {
  ------------------
  |  Branch (151:17): [True: 21, False: 44.2k]
  |  Branch (151:32): [True: 96, False: 44.1k]
  ------------------
  152|    117|               return answer;
  153|    117|            }
  154|  44.1k|            else {
  155|   117k|               do {
  156|   117k|                  if (exp_number < 0x10000000) {
  ------------------
  |  Branch (156:23): [True: 115k, False: 1.84k]
  ------------------
  157|   115k|                     exp_number = 10 * exp_number + digit;
  158|   115k|                  }
  159|   117k|                  ++p;
  160|   117k|               } while ((p != pend) && (digit = glz::fast_float::digit_value(*p)) <= 9);
  ------------------
  |  Branch (160:25): [True: 116k, False: 1.23k]
  |  Branch (160:40): [True: 73.2k, False: 42.9k]
  ------------------
  161|  44.1k|               if (neg_exp) {
  ------------------
  |  Branch (161:20): [True: 22.5k, False: 21.6k]
  ------------------
  162|  22.5k|                  exp_number = -exp_number;
  163|  22.5k|               }
  164|  44.1k|               exponent += exp_number;
  165|  44.1k|            }
  166|  44.2k|         }
  167|  6.13M|      }
  168|       |
  169|  6.13M|      answer.lastmatch = p;
  170|  6.13M|      answer.valid = true;
  171|       |
  172|       |      // If we frequently had to deal with long strings of digits,
  173|       |      // we could extend our code by using a 128-bit integer instead
  174|       |      // of a 64-bit integer. However, this is uncommon.
  175|       |      //
  176|       |      // We can deal with up to 19 digits.
  177|  6.13M|      if (digit_count > 19) { // this is uncommon
  ------------------
  |  Branch (177:11): [True: 68.8k, False: 6.06M]
  ------------------
  178|       |         // It is possible that the integer had an overflow.
  179|       |         // We have to handle the case where we have 0.0000somenumber.
  180|       |         // We need to be mindful of the case where we only have zeroes...
  181|       |         // E.g., 0.000000000...000.
  182|  68.8k|         UC const* start = start_digits;
  183|       |         if constexpr (null_terminated) {
  184|       |            while ((*start == UC('0') || *start == decimal_point)) {
  185|       |               if (*start == UC('0')) {
  186|       |                  --digit_count;
  187|       |               }
  188|       |               ++start;
  189|       |            }
  190|       |         }
  191|  68.8k|         else {
  192|  3.67M|            while ((start != pend) && (*start == UC('0') || *start == decimal_point)) {
  ------------------
  |  Branch (192:20): [True: 3.67M, False: 28]
  |  Branch (192:40): [True: 3.57M, False: 90.9k]
  |  Branch (192:61): [True: 22.1k, False: 68.8k]
  ------------------
  193|  3.60M|               if (*start == UC('0')) {
  ------------------
  |  Branch (193:20): [True: 3.57M, False: 22.1k]
  ------------------
  194|  3.57M|                  --digit_count;
  195|  3.57M|               }
  196|  3.60M|               ++start;
  197|  3.60M|            }
  198|  68.8k|         }
  199|       |
  200|  68.8k|         if (digit_count > 19) {
  ------------------
  |  Branch (200:14): [True: 67.6k, False: 1.22k]
  ------------------
  201|  67.6k|            answer.too_many_digits = true;
  202|       |            // Let us start again, this time, avoiding overflows.
  203|       |            // We don't need to check if is_integer, since we use the
  204|       |            // pre-tokenized spans from above.
  205|  67.6k|            i = 0;
  206|  67.6k|            p = answer.integer.ptr;
  207|  67.6k|            UC const* int_end = p + answer.integer.len();
  208|  67.6k|            const uint64_t minimal_nineteen_digit_integer{1000000000000000000};
  209|  1.07M|            while ((i < minimal_nineteen_digit_integer) && (p != int_end)) {
  ------------------
  |  Branch (209:20): [True: 1.03M, False: 44.8k]
  |  Branch (209:60): [True: 1.00M, False: 22.7k]
  ------------------
  210|  1.00M|               i = i * 10 + uint64_t(*p - UC('0'));
  211|  1.00M|               ++p;
  212|  1.00M|            }
  213|  67.6k|            if (i >= minimal_nineteen_digit_integer) { // We have a big integers
  ------------------
  |  Branch (213:17): [True: 44.8k, False: 22.7k]
  ------------------
  214|  44.8k|               exponent = end_of_integer_part - p + exp_number;
  215|  44.8k|            }
  216|  22.7k|            else { // We have a value with a fractional component.
  217|  22.7k|               p = answer.fraction.ptr;
  218|  22.7k|               UC const* frac_end = p + answer.fraction.len();
  219|   326k|               while ((i < minimal_nineteen_digit_integer) && (p != frac_end)) {
  ------------------
  |  Branch (219:23): [True: 303k, False: 22.7k]
  |  Branch (219:63): [True: 303k, False: 0]
  ------------------
  220|   303k|                  i = i * 10 + uint64_t(*p - UC('0'));
  221|   303k|                  ++p;
  222|   303k|               }
  223|  22.7k|               exponent = answer.fraction.ptr - p + exp_number;
  224|  22.7k|            }
  225|       |            // We have now corrected both exponent and i, to a truncated value
  226|  67.6k|         }
  227|  68.8k|      }
  228|  6.13M|      answer.exponent = exponent;
  229|  6.13M|      answer.mantissa = i;
  230|  6.13M|      return answer;
  231|  6.13M|   }
_ZZN3glz19parse_number_stringILb0EcEENS_10fast_float22parsed_number_string_tIT0_EEPKS3_S6_ENKUlvE_clEv:
   71|  6.13M|      const bool has_decimal_point = [&] {
   72|       |         if constexpr (null_terminated) {
   73|       |            return (*p == decimal_point);
   74|       |         }
   75|  6.13M|         else {
   76|  6.13M|            return (p != pend) && (*p == decimal_point);
  ------------------
  |  Branch (76:20): [True: 6.13M, False: 968]
  |  Branch (76:35): [True: 47.1k, False: 6.08M]
  ------------------
   77|  6.13M|         }
   78|  6.13M|      }();

_ZN3glz7skip_wsIXtlNS_7ws_optsEEETkNS_10is_contextERNS_7contextERPKcS5_EEbOT0_OT1_T2_:
  663|  24.2M|   {
  664|  24.2M|      using namespace glz::detail;
  665|       |
  666|  24.2M|      if constexpr (not Opts.minified) {
  667|       |         if constexpr (Opts.null_terminated) {
  668|       |            if constexpr (Opts.comments) {
  669|       |               while (whitespace_comment_table[uint8_t(*it)]) {
  670|       |                  if (*it == '/') [[unlikely]] {
  671|       |                     skip_comment(ctx, it, end);
  672|       |                     if (bool(ctx.error)) [[unlikely]] {
  673|       |                        return true;
  674|       |                     }
  675|       |                  }
  676|       |                  else [[likely]] {
  677|       |                     ++it;
  678|       |                  }
  679|       |               }
  680|       |            }
  681|       |            else {
  682|       |               while (whitespace_table[uint8_t(*it)]) {
  683|       |                  ++it;
  684|       |               }
  685|       |            }
  686|       |         }
  687|  24.2M|         else {
  688|       |            if constexpr (Opts.comments) {
  689|       |               while (it < end && whitespace_comment_table[uint8_t(*it)]) {
  690|       |                  if (*it == '/') [[unlikely]] {
  691|       |                     skip_comment(ctx, it, end);
  692|       |                     if (bool(ctx.error)) [[unlikely]] {
  693|       |                        return true;
  694|       |                     }
  695|       |                  }
  696|       |                  else [[likely]] {
  697|       |                     ++it;
  698|       |                  }
  699|       |               }
  700|       |               if (it == end) [[unlikely]] {
  701|       |                  ctx.error = error_code::end_reached;
  702|       |                  return true;
  703|       |               }
  704|       |            }
  705|  24.2M|            else {
  706|  45.9M|               while (it < end && whitespace_table[uint8_t(*it)]) {
  ------------------
  |  Branch (706:23): [True: 45.9M, False: 1.48k]
  |  Branch (706:35): [True: 21.6M, False: 24.2M]
  ------------------
  707|  21.6M|                  ++it;
  708|  21.6M|               }
  709|  24.2M|               if (it == end) [[unlikely]] {
  ------------------
  |  Branch (709:20): [True: 1.48k, False: 24.2M]
  ------------------
  710|  1.48k|                  ctx.error = error_code::end_reached;
  711|  1.48k|                  return true;
  712|  1.48k|               }
  713|  24.2M|            }
  714|  24.2M|         }
  715|       |      }
  716|       |      else if constexpr (not Opts.null_terminated) {
  717|       |         // Minified input has no whitespace to skip, but a non-null-terminated buffer can still
  718|       |         // be exhausted at this point. The non-minified branch above performs the same check; a
  719|       |         // null-terminated buffer relies on the trailing sentinel and keeps this a pure no-op.
  720|       |         if (it == end) [[unlikely]] {
  721|       |            ctx.error = error_code::end_reached;
  722|       |            return true;
  723|       |         }
  724|       |      }
  725|       |
  726|  24.2M|      return false;
  727|  24.2M|   }
_ZN3glz17match_invalid_endILc44EXtlNS_22match_invalid_end_optsEEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  470|  2.86M|   {
  471|  2.86M|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (471:11): [True: 1.45k, False: 2.86M]
  ------------------
  472|       |         if constexpr (C == '"') {
  473|       |            ctx.error = error_code::expected_quote;
  474|       |         }
  475|  1.45k|         else if constexpr (C == ',') {
  476|  1.45k|            ctx.error = error_code::expected_comma;
  477|       |         }
  478|       |         else if constexpr (C == ':') {
  479|       |            ctx.error = error_code::expected_colon;
  480|       |         }
  481|       |         else if constexpr (C == '[' || C == ']') {
  482|       |            ctx.error = error_code::expected_bracket;
  483|       |         }
  484|       |         else if constexpr (C == '{' || C == '}') {
  485|       |            ctx.error = error_code::expected_brace;
  486|       |         }
  487|       |         else {
  488|       |            ctx.error = error_code::syntax_error;
  489|       |         }
  490|  1.45k|         return true;
  491|  1.45k|      }
  492|  2.86M|      else [[likely]] {
  493|  2.86M|         ++it;
  494|  2.86M|      }
  495|  2.86M|      if constexpr (not Opts.null_terminated) {
  496|  2.86M|         if (it == end) [[unlikely]] {
  ------------------
  |  Branch (496:14): [True: 130, False: 2.86M]
  ------------------
  497|    130|            ctx.error = error_code::unexpected_end;
  498|    130|            return true;
  499|    130|         }
  500|  2.86M|      }
  501|  2.86M|      return false;
  502|  2.86M|   }
_ZN3glz17match_invalid_endILc34EXtlNS_22match_invalid_end_optsEEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  470|  2.97M|   {
  471|  2.97M|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (471:11): [True: 880, False: 2.97M]
  ------------------
  472|    880|         if constexpr (C == '"') {
  473|    880|            ctx.error = error_code::expected_quote;
  474|       |         }
  475|       |         else if constexpr (C == ',') {
  476|       |            ctx.error = error_code::expected_comma;
  477|       |         }
  478|       |         else if constexpr (C == ':') {
  479|       |            ctx.error = error_code::expected_colon;
  480|       |         }
  481|       |         else if constexpr (C == '[' || C == ']') {
  482|       |            ctx.error = error_code::expected_bracket;
  483|       |         }
  484|       |         else if constexpr (C == '{' || C == '}') {
  485|       |            ctx.error = error_code::expected_brace;
  486|       |         }
  487|       |         else {
  488|       |            ctx.error = error_code::syntax_error;
  489|       |         }
  490|    880|         return true;
  491|    880|      }
  492|  2.97M|      else [[likely]] {
  493|  2.97M|         ++it;
  494|  2.97M|      }
  495|  2.97M|      if constexpr (not Opts.null_terminated) {
  496|  2.97M|         if (it == end) [[unlikely]] {
  ------------------
  |  Branch (496:14): [True: 194, False: 2.97M]
  ------------------
  497|    194|            ctx.error = error_code::unexpected_end;
  498|    194|            return true;
  499|    194|         }
  500|  2.97M|      }
  501|  2.97M|      return false;
  502|  2.97M|   }
_ZN3glz9chunk_minILm8EEElb:
   47|  2.97M|   {
   48|  2.97M|      static_assert(Width <= padding_bytes);
   49|  2.97M|      return padded ? 1 : std::ptrdiff_t(Width);
  ------------------
  |  Branch (49:14): [True: 0, False: 2.97M]
  ------------------
   50|  2.97M|   }
_ZN3glz18validate_utf8_spanITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextEccEEbOT0_PKT1_PKT2_m:
  873|  2.93M|   {
  874|       |      if constexpr (not check_validate_utf8(Opts)) {
  875|       |         // Everything the caller computed for us is dead, which lets its scan loop drop the
  876|       |         // accumulator entirely.
  877|       |         (void)ctx, (void)start, (void)fin, (void)ascii_acc;
  878|       |         return false;
  879|       |      }
  880|  2.93M|      else {
  881|  2.93M|         if ((ascii_acc & repeat_byte8(0b10000000)) == 0) {
  ------------------
  |  Branch (881:14): [True: 2.80M, False: 132k]
  ------------------
  882|  2.80M|            return false; // pure ASCII is trivially well formed UTF-8
  883|  2.80M|         }
  884|   132k|         if (!validate_utf8(start, size_t(fin - start))) [[unlikely]] {
  ------------------
  |  Branch (884:14): [True: 543, False: 131k]
  ------------------
  885|    543|            ctx.error = error_code::invalid_utf8;
  886|    543|            return true;
  887|    543|         }
  888|   131k|         return false;
  889|   132k|      }
  890|  2.93M|   }
_ZN3glz13validate_utf8IcEEbPKT_m:
  842|   147k|   {
  843|   147k|      const uint8_t* it = reinterpret_cast<const uint8_t*>(str);
  844|   147k|      const uint8_t* const end = it + size;
  845|       |#if defined(GLZ_UTF8_SIMD)
  846|       |      // 16 is a measured compromise, not a register-size coincidence. The scalar path skips ASCII 8
  847|       |      // bytes at a time, so on ASCII it stays ahead of the vector path's fixed setup cost until the
  848|       |      // input is long enough for the 64 byte ASCII step to engage; on non-ASCII the vector path
  849|       |      // wins from roughly 8 bytes. Raising the threshold buys a few percent on short ASCII and
  850|       |      // costs up to 2.3x on mid length non-ASCII strings, so it stays low.
  851|       |      if (size >= 16) {
  852|       |         return detail::utf8_simd::validate(it, end);
  853|       |      }
  854|       |#endif
  855|   147k|      return validate_utf8_scalar(it, end);
  856|   147k|   }
_ZN3glz20validate_utf8_scalarEPKhS1_:
  793|   147k|   {
  794|  5.06M|      while (it < end) {
  ------------------
  |  Branch (794:14): [True: 4.91M, False: 146k]
  ------------------
  795|       |         // Optimistic SWAR check for ASCII
  796|  4.91M|         if (it + 8 <= end) {
  ------------------
  |  Branch (796:14): [True: 4.58M, False: 332k]
  ------------------
  797|  4.58M|            uint64_t chunk;
  798|  4.58M|            std::memcpy(&chunk, it, 8);
  799|  4.58M|            if ((chunk & glz::repeat_byte8(0x80)) == 0) {
  ------------------
  |  Branch (799:17): [True: 4.46M, False: 116k]
  ------------------
  800|  4.46M|               it += 8;
  801|  4.46M|               continue;
  802|  4.46M|            }
  803|  4.58M|         }
  804|       |
  805|       |         // Byte-by-byte validation (standard conformant)
  806|   449k|         uint8_t byte = *it;
  807|       |
  808|   449k|         if (byte < 0x80) {
  ------------------
  |  Branch (808:14): [True: 327k, False: 122k]
  ------------------
  809|   327k|            it++;
  810|   327k|         }
  811|   122k|         else if ((byte & 0xE0) == 0xC0) {
  ------------------
  |  Branch (811:19): [True: 104k, False: 17.3k]
  ------------------
  812|       |            // 2-byte sequence
  813|   104k|            if (it + 2 > end || (it[1] & 0xC0) != 0x80) return false;
  ------------------
  |  Branch (813:17): [True: 45, False: 104k]
  |  Branch (813:33): [True: 116, False: 104k]
  ------------------
  814|   104k|            if (byte < 0xC2) return false; // Overlong
  ------------------
  |  Branch (814:17): [True: 38, False: 104k]
  ------------------
  815|   104k|            it += 2;
  816|   104k|         }
  817|  17.3k|         else if ((byte & 0xF0) == 0xE0) {
  ------------------
  |  Branch (817:19): [True: 10.4k, False: 6.89k]
  ------------------
  818|       |            // 3-byte sequence
  819|  10.4k|            if (it + 3 > end || (it[1] & 0xC0) != 0x80 || (it[2] & 0xC0) != 0x80) return false;
  ------------------
  |  Branch (819:17): [True: 35, False: 10.4k]
  |  Branch (819:33): [True: 82, False: 10.3k]
  |  Branch (819:59): [True: 70, False: 10.3k]
  ------------------
  820|  10.3k|            if (byte == 0xE0 && it[1] < 0xA0) return false; // Overlong
  ------------------
  |  Branch (820:17): [True: 3.90k, False: 6.40k]
  |  Branch (820:33): [True: 72, False: 3.82k]
  ------------------
  821|  10.2k|            if (byte == 0xED && it[1] >= 0xA0) return false; // Surrogate
  ------------------
  |  Branch (821:17): [True: 2.39k, False: 7.83k]
  |  Branch (821:33): [True: 41, False: 2.35k]
  ------------------
  822|  10.1k|            it += 3;
  823|  10.1k|         }
  824|  6.89k|         else if ((byte & 0xF8) == 0xF0) {
  ------------------
  |  Branch (824:19): [True: 6.63k, False: 266]
  ------------------
  825|       |            // 4-byte sequence
  826|  6.63k|            if (it + 4 > end || (it[1] & 0xC0) != 0x80 || (it[2] & 0xC0) != 0x80 || (it[3] & 0xC0) != 0x80)
  ------------------
  |  Branch (826:17): [True: 48, False: 6.58k]
  |  Branch (826:33): [True: 48, False: 6.53k]
  |  Branch (826:59): [True: 48, False: 6.48k]
  |  Branch (826:85): [True: 53, False: 6.43k]
  ------------------
  827|    197|               return false;
  828|  6.43k|            if (byte == 0xF0 && it[1] < 0x90) return false; // Overlong
  ------------------
  |  Branch (828:17): [True: 2.14k, False: 4.28k]
  |  Branch (828:33): [True: 68, False: 2.07k]
  ------------------
  829|  6.36k|            if (byte == 0xF4 && it[1] >= 0x90) return false; // > U+10FFFF
  ------------------
  |  Branch (829:17): [True: 1.64k, False: 4.72k]
  |  Branch (829:33): [True: 33, False: 1.61k]
  ------------------
  830|  6.33k|            if (byte > 0xF4) return false; // > U+10FFFF
  ------------------
  |  Branch (830:17): [True: 27, False: 6.30k]
  ------------------
  831|  6.30k|            it += 4;
  832|  6.30k|         }
  833|    266|         else {
  834|    266|            return false;
  835|    266|         }
  836|   449k|      }
  837|       |
  838|   146k|      return true;
  839|   147k|   }
_ZN3glz25handle_unicode_code_pointIccEENS_14unicode_resultERPKT_RPT0_S4_:
  347|  60.1k|   {
  348|  60.1k|      using namespace unicode;
  349|       |
  350|  60.1k|      if (end - it <= 4) [[unlikely]] {
  ------------------
  |  Branch (350:11): [True: 278, False: 59.8k]
  ------------------
  351|    278|         return {0, escape_prefix_intact<false>(it, end)};
  352|    278|      }
  353|  59.8k|      const uint32_t high = hex_to_u32(it);
  354|  59.8k|      if (high == 0xFFFFFFFFu) [[unlikely]] {
  ------------------
  |  Branch (354:11): [True: 222, False: 59.6k]
  ------------------
  355|    222|         return {};
  356|    222|      }
  357|  59.6k|      it += 4; // skip the code point characters
  358|       |
  359|  59.6k|      uint32_t code_point;
  360|       |
  361|  59.6k|      if ((high & generic_surrogate_mask) == generic_surrogate_value) {
  ------------------
  |  Branch (361:11): [True: 3.10k, False: 56.5k]
  ------------------
  362|       |         // surrogate pair code points
  363|  3.10k|         if ((high & surrogate_mask) != high_surrogate_value) {
  ------------------
  |  Branch (363:14): [True: 73, False: 3.03k]
  ------------------
  364|     73|            return {};
  365|     73|         }
  366|       |
  367|  3.03k|         if (end - it <= 6) [[unlikely]] {
  ------------------
  |  Branch (367:14): [True: 274, False: 2.76k]
  ------------------
  368|    274|            return {0, escape_prefix_intact<true>(it, end)};
  369|    274|         }
  370|       |         // The next two characters must be `\u`
  371|  2.76k|         uint16_t u;
  372|  2.76k|         std::memcpy(&u, it, 2);
  373|  2.76k|         if (u != to_uint16_t(R"(\u)")) [[unlikely]] {
  ------------------
  |  Branch (373:14): [True: 258, False: 2.50k]
  ------------------
  374|    258|            return {};
  375|    258|         }
  376|  2.50k|         it += 2;
  377|       |         // verify that second unicode escape sequence is present
  378|  2.50k|         const uint32_t low = hex_to_u32(it);
  379|  2.50k|         if (low == 0xFFFFFFFFu) [[unlikely]] {
  ------------------
  |  Branch (379:14): [True: 27, False: 2.47k]
  ------------------
  380|     27|            return {};
  381|     27|         }
  382|  2.47k|         it += 4;
  383|       |
  384|  2.47k|         if ((low & surrogate_mask) != low_surrogate_value) [[unlikely]] {
  ------------------
  |  Branch (384:14): [True: 72, False: 2.40k]
  ------------------
  385|     72|            return {};
  386|     72|         }
  387|       |
  388|  2.40k|         code_point = (high & surrogate_codepoint_mask) << surrogate_codepoint_bits;
  389|  2.40k|         code_point |= (low & surrogate_codepoint_mask);
  390|  2.40k|         code_point += surrogate_codepoint_offset;
  391|  2.40k|      }
  392|  56.5k|      else {
  393|  56.5k|         code_point = high;
  394|  56.5k|      }
  395|  58.9k|      const uint32_t offset = code_point_to_utf8(code_point, dst);
  396|  58.9k|      dst += offset;
  397|  58.9k|      return {offset, false};
  398|  59.6k|   }
_ZN3glz20escape_prefix_intactILb0EccEEbPKT0_PKT1_:
  329|    278|   {
  330|    278|      auto n = size_t(end - it);
  331|       |      if constexpr (ExpectOpener) {
  332|       |         if (n > 0 && it[0] != '\\') return false;
  333|       |         if (n > 1 && it[1] != 'u') return false;
  334|       |         if (n < 2) return true;
  335|       |         it += 2;
  336|       |         n -= 2;
  337|       |      }
  338|    834|      for (size_t i = 0; i < n; ++i) {
  ------------------
  |  Branch (338:26): [True: 729, False: 105]
  ------------------
  339|    729|         if (digit_hex_table[uint8_t(it[i])] == 255) return false;
  ------------------
  |  Branch (339:14): [True: 173, False: 556]
  ------------------
  340|    729|      }
  341|    105|      return true;
  342|    278|   }
_ZN3glz10hex_to_u32EPKc:
  224|  62.3k|   {
  225|  62.3k|      constexpr auto& t = digit_hex_table;
  226|  62.3k|      const uint8_t arr[4]{t[uint8_t(c[3])], t[uint8_t(c[2])], t[uint8_t(c[1])], t[uint8_t(c[0])]};
  227|  62.3k|      auto chunk = std::bit_cast<uint32_t>(arr);
  228|       |      // On big-endian, bit_cast produces bytes in opposite order than expected
  229|       |      // byteswap to get consistent little-endian representation
  230|       |      if constexpr (std::endian::native == std::endian::big) {
  231|       |         chunk = std::byteswap(chunk);
  232|       |      }
  233|       |      // check that all hex characters are valid
  234|  62.3k|      if (chunk & repeat_byte4(0b11110000u)) [[unlikely]] {
  ------------------
  |  Branch (234:11): [True: 249, False: 62.0k]
  ------------------
  235|    249|         return 0xFFFFFFFFu;
  236|    249|      }
  237|       |
  238|       |      // now pack into first four bytes of uint32_t
  239|  62.0k|      uint32_t packed{};
  240|  62.0k|      packed |= (chunk & 0x0000000F);
  241|  62.0k|      packed |= (chunk & 0x00000F00) >> 4;
  242|  62.0k|      packed |= (chunk & 0x000F0000) >> 8;
  243|  62.0k|      packed |= (chunk & 0x0F000000) >> 12;
  244|  62.0k|      return packed;
  245|  62.3k|   }
_ZN3glz20escape_prefix_intactILb1EccEEbPKT0_PKT1_:
  329|    274|   {
  330|    274|      auto n = size_t(end - it);
  331|    274|      if constexpr (ExpectOpener) {
  332|    274|         if (n > 0 && it[0] != '\\') return false;
  ------------------
  |  Branch (332:14): [True: 274, False: 0]
  |  Branch (332:23): [True: 158, False: 116]
  ------------------
  333|    116|         if (n > 1 && it[1] != 'u') return false;
  ------------------
  |  Branch (333:14): [True: 114, False: 2]
  |  Branch (333:23): [True: 66, False: 48]
  ------------------
  334|     50|         if (n < 2) return true;
  ------------------
  |  Branch (334:14): [True: 2, False: 48]
  ------------------
  335|     48|         it += 2;
  336|     48|         n -= 2;
  337|     48|      }
  338|    320|      for (size_t i = 0; i < n; ++i) {
  ------------------
  |  Branch (338:26): [True: 94, False: 226]
  ------------------
  339|     94|         if (digit_hex_table[uint8_t(it[i])] == 255) return false;
  ------------------
  |  Branch (339:14): [True: 48, False: 46]
  ------------------
  340|     94|      }
  341|    226|      return true;
  342|    274|   }
_ZN3glz18code_point_to_utf8IcEEjjPT_:
  249|  58.9k|   {
  250|  58.9k|      if (code_point <= 0x7F) {
  ------------------
  |  Branch (250:11): [True: 44.0k, False: 14.8k]
  ------------------
  251|  44.0k|         c[0] = Char(code_point);
  252|  44.0k|         return 1;
  253|  44.0k|      }
  254|  14.8k|      if (code_point <= 0x7FF) {
  ------------------
  |  Branch (254:11): [True: 7.15k, False: 7.68k]
  ------------------
  255|  7.15k|         c[0] = Char(0xC0 | ((code_point >> 6) & 0x1F));
  256|  7.15k|         c[1] = Char(0x80 | (code_point & 0x3F));
  257|  7.15k|         return 2;
  258|  7.15k|      }
  259|  7.68k|      if (code_point <= 0xFFFF) {
  ------------------
  |  Branch (259:11): [True: 5.28k, False: 2.40k]
  ------------------
  260|  5.28k|         c[0] = Char(0xE0 | ((code_point >> 12) & 0x0F));
  261|  5.28k|         c[1] = Char(0x80 | ((code_point >> 6) & 0x3F));
  262|  5.28k|         c[2] = Char(0x80 | (code_point & 0x3F));
  263|  5.28k|         return 3;
  264|  5.28k|      }
  265|  2.40k|      if (code_point <= 0x10FFFF) {
  ------------------
  |  Branch (265:11): [True: 2.40k, False: 0]
  ------------------
  266|  2.40k|         c[0] = Char(0xF0 | ((code_point >> 18) & 0x07));
  267|  2.40k|         c[1] = Char(0x80 | ((code_point >> 12) & 0x3F));
  268|  2.40k|         c[2] = Char(0x80 | ((code_point >> 6) & 0x3F));
  269|  2.40k|         c[3] = Char(0x80 | (code_point & 0x3F));
  270|  2.40k|         return 4;
  271|  2.40k|      }
  272|      0|      return 0;
  273|  2.40k|   }
_ZN3glz17match_invalid_endILc58EXtlNS_22match_invalid_end_optsEEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  470|  2.93M|   {
  471|  2.93M|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (471:11): [True: 1.22k, False: 2.92M]
  ------------------
  472|       |         if constexpr (C == '"') {
  473|       |            ctx.error = error_code::expected_quote;
  474|       |         }
  475|       |         else if constexpr (C == ',') {
  476|       |            ctx.error = error_code::expected_comma;
  477|       |         }
  478|  1.22k|         else if constexpr (C == ':') {
  479|  1.22k|            ctx.error = error_code::expected_colon;
  480|       |         }
  481|       |         else if constexpr (C == '[' || C == ']') {
  482|       |            ctx.error = error_code::expected_bracket;
  483|       |         }
  484|       |         else if constexpr (C == '{' || C == '}') {
  485|       |            ctx.error = error_code::expected_brace;
  486|       |         }
  487|       |         else {
  488|       |            ctx.error = error_code::syntax_error;
  489|       |         }
  490|  1.22k|         return true;
  491|  1.22k|      }
  492|  2.92M|      else [[likely]] {
  493|  2.92M|         ++it;
  494|  2.92M|      }
  495|  2.92M|      if constexpr (not Opts.null_terminated) {
  496|  2.92M|         if (it == end) [[unlikely]] {
  ------------------
  |  Branch (496:14): [True: 1.41k, False: 2.92M]
  ------------------
  497|  1.41k|            ctx.error = error_code::unexpected_end;
  498|  1.41k|            return true;
  499|  1.41k|         }
  500|  2.92M|      }
  501|  2.92M|      return false;
  502|  2.93M|   }
_ZN3glz17match_invalid_endILc91EXtlNS_22match_invalid_end_optsEEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  470|  1.52M|   {
  471|  1.52M|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (471:11): [True: 0, False: 1.52M]
  ------------------
  472|       |         if constexpr (C == '"') {
  473|       |            ctx.error = error_code::expected_quote;
  474|       |         }
  475|       |         else if constexpr (C == ',') {
  476|       |            ctx.error = error_code::expected_comma;
  477|       |         }
  478|       |         else if constexpr (C == ':') {
  479|       |            ctx.error = error_code::expected_colon;
  480|       |         }
  481|      0|         else if constexpr (C == '[' || C == ']') {
  482|      0|            ctx.error = error_code::expected_bracket;
  483|       |         }
  484|       |         else if constexpr (C == '{' || C == '}') {
  485|       |            ctx.error = error_code::expected_brace;
  486|       |         }
  487|       |         else {
  488|       |            ctx.error = error_code::syntax_error;
  489|       |         }
  490|      0|         return true;
  491|      0|      }
  492|  1.52M|      else [[likely]] {
  493|  1.52M|         ++it;
  494|  1.52M|      }
  495|  1.52M|      if constexpr (not Opts.null_terminated) {
  496|  1.52M|         if (it == end) [[unlikely]] {
  ------------------
  |  Branch (496:14): [True: 101, False: 1.52M]
  ------------------
  497|    101|            ctx.error = error_code::unexpected_end;
  498|    101|            return true;
  499|    101|         }
  500|  1.52M|      }
  501|  1.52M|      return false;
  502|  1.52M|   }
_ZN3glz16skip_matching_wsIcRPKcEEvPKT_OT0_m:
  730|  55.2k|   {
  731|  55.2k|      if (length > 7) {
  ------------------
  |  Branch (731:11): [True: 11.4k, False: 43.8k]
  ------------------
  732|  11.4k|         uint64_t v[2];
  733|  15.6k|         while (length > 8) {
  ------------------
  |  Branch (733:17): [True: 8.83k, False: 6.76k]
  ------------------
  734|  8.83k|            std::memcpy(v, ws, 8);
  735|  8.83k|            std::memcpy(v + 1, it, 8);
  736|  8.83k|            if (v[0] != v[1]) {
  ------------------
  |  Branch (736:17): [True: 4.65k, False: 4.17k]
  ------------------
  737|  4.65k|               return;
  738|  4.65k|            }
  739|  4.17k|            length -= 8;
  740|  4.17k|            ws += 8;
  741|  4.17k|            it += 8;
  742|  4.17k|         }
  743|       |
  744|  6.76k|         const auto shift = 8 - length;
  745|  6.76k|         ws -= shift;
  746|  6.76k|         it -= shift;
  747|       |
  748|  6.76k|         std::memcpy(v, ws, 8);
  749|  6.76k|         std::memcpy(v + 1, it, 8);
  750|  6.76k|         if (v[0] != v[1]) {
  ------------------
  |  Branch (750:14): [True: 4.36k, False: 2.40k]
  ------------------
  751|  4.36k|            return;
  752|  4.36k|         }
  753|  2.40k|         it += 8;
  754|  2.40k|         return;
  755|  6.76k|      }
  756|  43.8k|      {
  757|  43.8k|         constexpr uint64_t n{sizeof(uint32_t)};
  758|  43.8k|         if (length >= n) {
  ------------------
  |  Branch (758:14): [True: 19.8k, False: 24.0k]
  ------------------
  759|  19.8k|            uint32_t v[2];
  760|  19.8k|            std::memcpy(v, ws, n);
  761|  19.8k|            std::memcpy(v + 1, it, n);
  762|  19.8k|            if (v[0] != v[1]) {
  ------------------
  |  Branch (762:17): [True: 11.8k, False: 7.90k]
  ------------------
  763|  11.8k|               return;
  764|  11.8k|            }
  765|  7.90k|            length -= n;
  766|  7.90k|            ws += n;
  767|  7.90k|            it += n;
  768|  7.90k|         }
  769|  43.8k|      }
  770|  31.9k|      {
  771|  31.9k|         constexpr uint64_t n{sizeof(uint16_t)};
  772|  31.9k|         if (length >= n) {
  ------------------
  |  Branch (772:14): [True: 6.18k, False: 25.7k]
  ------------------
  773|  6.18k|            uint16_t v[2];
  774|  6.18k|            std::memcpy(v, ws, n);
  775|  6.18k|            std::memcpy(v + 1, it, n);
  776|  6.18k|            if (v[0] != v[1]) {
  ------------------
  |  Branch (776:17): [True: 3.34k, False: 2.84k]
  ------------------
  777|  3.34k|               return;
  778|  3.34k|            }
  779|       |            // length -= n;
  780|       |            // ws += n;
  781|  2.84k|            it += n;
  782|  2.84k|         }
  783|  31.9k|      }
  784|       |      // We have to call a whitespace check after this function
  785|       |      // in case the whitespace is mismatching.
  786|       |      // So, we forgo this check as to not duplicate.
  787|       |      /*if (length && *ws == *it) {
  788|       |         ++it;
  789|       |      }*/
  790|  31.9k|   }
_ZN3glz18validate_utf8_spanITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEETkNS_10is_contextERNS_7contextEccEEbOT0_PKT1_PKT2_m:
  873|  42.9k|   {
  874|       |      if constexpr (not check_validate_utf8(Opts)) {
  875|       |         // Everything the caller computed for us is dead, which lets its scan loop drop the
  876|       |         // accumulator entirely.
  877|       |         (void)ctx, (void)start, (void)fin, (void)ascii_acc;
  878|       |         return false;
  879|       |      }
  880|  42.9k|      else {
  881|  42.9k|         if ((ascii_acc & repeat_byte8(0b10000000)) == 0) {
  ------------------
  |  Branch (881:14): [True: 27.2k, False: 15.6k]
  ------------------
  882|  27.2k|            return false; // pure ASCII is trivially well formed UTF-8
  883|  27.2k|         }
  884|  15.6k|         if (!validate_utf8(start, size_t(fin - start))) [[unlikely]] {
  ------------------
  |  Branch (884:14): [True: 547, False: 15.1k]
  ------------------
  885|    547|            ctx.error = error_code::invalid_utf8;
  886|    547|            return true;
  887|    547|         }
  888|  15.1k|         return false;
  889|  15.6k|      }
  890|  42.9k|   }
_ZN3glz5matchITnNS_14string_literalEXtlNS1_ILm5EEEtlA5_cLc110ELc117ELc108ELc108EEEETnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS8_EEvOT1_OT2_T3_:
  539|  3.47k|   {
  540|  3.47k|      static constexpr auto S = str.sv();
  541|  3.47k|      if ((end - it < std::ptrdiff_t(str.size())) || not comparitor<S>(it)) [[unlikely]] {
  ------------------
  |  Branch (541:11): [True: 89, False: 3.38k]
  |  Branch (541:54): [True: 283, False: 3.09k]
  ------------------
  542|    372|         ctx.error = error_code::syntax_error;
  543|    372|      }
  544|  3.09k|      else [[likely]] {
  545|  3.09k|         it += str.size();
  546|  3.09k|      }
  547|  3.47k|   }

_ZNK3glz14string_literalILm5EE4sizeEv:
   25|  6.57k|      [[nodiscard]] constexpr size_t size() const noexcept { return length; }

