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.63k, False: 7.75k]
  ------------------
   16|  2.63k|         [[maybe_unused]] auto s = json.size();
   17|  2.63k|      }
   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.63k, False: 7.75k]
  ------------------
   31|  2.63k|         [[maybe_unused]] auto s = json.size();
   32|  2.63k|      }
   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.63k, False: 7.75k]
  ------------------
   40|  2.63k|         [[maybe_unused]] auto s = json.size();
   41|  2.63k|      }
   42|  10.3k|   }
   43|       |
   44|  10.3k|   return 0;
   45|  10.3k|}

_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEED2Ev:
  569|   162k|      {
  570|   162k|         free_data();
  571|   162k|         free_index();
  572|   162k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE9free_dataEv:
  266|   162k|      {
  267|   162k|         destroy_all();
  268|   162k|         ::operator delete(data_);
  269|   162k|         data_ = nullptr;
  270|   162k|         size_ = 0;
  271|   162k|         capacity_ = 0;
  272|   162k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE11destroy_allEv:
  259|   432k|      {
  260|  7.19M|         for (uint32_t i = 0; i < size_; ++i) {
  ------------------
  |  Branch (260:31): [True: 6.76M, False: 432k]
  ------------------
  261|  6.76M|            std::destroy_at(data_ + i);
  262|  6.76M|         }
  263|   432k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE10free_indexEv:
  308|   162k|      {
  309|   162k|         std::free(index_);
  310|   162k|         index_ = nullptr;
  311|   162k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEEC2Ev:
  566|  76.9k|      ordered_small_map() = default;
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEEC2EOS4_:
  610|  85.1k|         : data_(other.data_), size_(other.size_), capacity_(other.capacity_), index_(other.index_)
  611|  85.1k|      {
  612|  85.1k|         other.data_ = nullptr;
  613|  85.1k|         other.size_ = 0;
  614|  85.1k|         other.capacity_ = 0;
  615|  85.1k|         other.index_ = nullptr;
  616|  85.1k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEEixERKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE:
  932|  3.24M|      {
  933|  3.24M|         return subscript_or_insert(key, [&] { emplace_back_impl(key, mapped_type{}); });
  934|  3.24M|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE19subscript_or_insertINSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEZNS4_ixERKSC_EUlvE_EERS3_RKT_OT0_:
  491|  3.24M|      {
  492|  3.24M|         if (size_ <= linear_search_threshold) {
  ------------------
  |  Branch (492:14): [True: 539k, False: 2.70M]
  ------------------
  493|   539k|            auto it = linear_find(key);
  494|   539k|            if (it != end()) return it->second;
  ------------------
  |  Branch (494:17): [True: 26.1k, False: 513k]
  ------------------
  495|   513k|            append_fn();
  496|   513k|            return data_[size_ - 1].second;
  497|   539k|         }
  498|       |
  499|  2.70M|         const uint32_t h = hash_key(key);
  500|  2.70M|         if (try_bloom_insert(h, append_fn)) {
  ------------------
  |  Branch (500:14): [True: 1.94M, False: 763k]
  ------------------
  501|  1.94M|            return data_[size_ - 1].second;
  502|  1.94M|         }
  503|       |
  504|   763k|         auto [it, pos, _] = index_find_or_pos(key, h);
  505|   763k|         if (it != end()) return it->second;
  ------------------
  |  Branch (505:14): [True: 577k, False: 186k]
  ------------------
  506|       |
  507|   186k|         append_fn();
  508|   186k|         bloom_set(h);
  509|   186k|         if (index_size() > 0) {
  ------------------
  |  Branch (509:14): [True: 186k, False: 0]
  ------------------
  510|   186k|            const uint32_t n = index_->size;
  511|   186k|            ensure_index_capacity(static_cast<size_type>(n) + 1);
  512|   186k|            auto* entries = index_entries();
  513|   186k|            if (pos < n) {
  ------------------
  |  Branch (513:17): [True: 181k, False: 4.41k]
  ------------------
  514|   181k|               std::memmove(entries + pos + 1, entries + pos, (n - pos) * sizeof(hash_index_entry));
  515|   181k|            }
  516|   186k|            entries[pos] = {h, size_ - 1};
  517|   186k|            index_->size = size_;
  518|   186k|         }
  519|   186k|         return data_[size_ - 1].second;
  520|   763k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE11linear_findINSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEEEPNS6_4pairISC_S3_EERKT_:
  421|   539k|      {
  422|  2.53M|         for (uint32_t i = 0; i < size_; ++i) {
  ------------------
  |  Branch (422:31): [True: 2.02M, False: 513k]
  ------------------
  423|  2.02M|            if (data_[i].first == key) return data_ + i;
  ------------------
  |  Branch (423:17): [True: 26.1k, False: 1.99M]
  ------------------
  424|  2.02M|         }
  425|   513k|         return data_ + size_;
  426|   539k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE3endEv:
  649|  1.30M|      iterator end() noexcept { return data_ + size_; }
_ZZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEEixERKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEENKUlvE_clEv:
  933|  2.64M|         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.64M|      {
  244|  2.64M|         grow_if_needed();
  245|  2.64M|         std::construct_at(data_ + size_, std::forward<Args>(args)...);
  246|  2.64M|         ++size_;
  247|  2.64M|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE14grow_if_neededEv:
  217|  2.64M|      {
  218|  2.64M|         if (size_ == capacity_) {
  ------------------
  |  Branch (218:14): [True: 270k, False: 2.37M]
  ------------------
  219|   270k|            if (size_ == max_u32) {
  ------------------
  |  Branch (219:17): [True: 0, False: 270k]
  ------------------
  220|      0|               throw_capacity_overflow();
  221|      0|            }
  222|   270k|            const uint32_t new_cap = next_data_capacity(capacity_);
  223|   270k|            reallocate_data(new_cap);
  224|   270k|         }
  225|  2.64M|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE18next_data_capacityEj:
  120|   270k|      {
  121|   270k|         if (current == 0) return 4;
  ------------------
  |  Branch (121:14): [True: 69.7k, False: 200k]
  ------------------
  122|   200k|         if (current > (max_u32 / 2)) return max_u32;
  ------------------
  |  Branch (122:14): [True: 0, False: 200k]
  ------------------
  123|   200k|         return current * 2;
  124|   200k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE15reallocate_dataEj:
  205|   270k|      {
  206|   270k|         if (new_cap < size_) {
  ------------------
  |  Branch (206:14): [True: 0, False: 270k]
  ------------------
  207|      0|            throw_capacity_overflow();
  208|      0|         }
  209|   270k|         auto* new_data = allocate_and_relocate(new_cap);
  210|   270k|         destroy_all();
  211|   270k|         ::operator delete(data_);
  212|   270k|         data_ = new_data;
  213|   270k|         capacity_ = new_cap;
  214|   270k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE21allocate_and_relocateEj:
  159|   270k|      {
  160|   270k|         auto* new_data = static_cast<value_type*>(::operator new(checked_data_allocation_bytes(new_cap)));
  161|   270k|#if __cpp_exceptions
  162|   270k|         uint32_t constructed = 0;
  163|   270k|         try {
  164|  4.39M|            for (; constructed < size_; ++constructed) {
  ------------------
  |  Branch (164:20): [True: 4.12M, False: 270k]
  ------------------
  165|  4.12M|               std::construct_at(new_data + constructed, std::move_if_noexcept(data_[constructed]));
  166|  4.12M|            }
  167|   270k|         }
  168|   270k|         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|   270k|         return new_data;
  179|   270k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE29checked_data_allocation_bytesEj:
  134|   270k|      {
  135|   270k|         if (count > ((std::numeric_limits<size_t>::max)() / sizeof(value_type))) {
  ------------------
  |  Branch (135:14): [True: 0, False: 270k]
  ------------------
  136|      0|            GLZ_THROW_OR_ABORT(std::bad_alloc{});
  ------------------
  |  |    8|      0|#define GLZ_THROW_OR_ABORT(EXC) (throw(EXC))
  ------------------
  137|      0|         }
  138|   270k|         return static_cast<size_t>(count) * sizeof(value_type);
  139|   270k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE8hash_keyENSt3__117basic_string_viewIcNS5_11char_traitsIcEEEE:
   97|  10.0M|      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.70M|      {
  530|  2.70M|         if (index_ && size_ <= bloom_threshold && !bloom_maybe_contains(h)) {
  ------------------
  |  Branch (530:14): [True: 2.65M, False: 53.8k]
  |  Branch (530:24): [True: 2.51M, False: 140k]
  |  Branch (530:52): [True: 1.94M, False: 568k]
  ------------------
  531|       |            // Definitely not present — skip the search
  532|  1.94M|            append_fn();
  533|  1.94M|            bloom_set(h);
  534|       |            // Index is now stale (index_->size < size_), will rebuild on next lookup or false positive
  535|  1.94M|            return true;
  536|  1.94M|         }
  537|   763k|         return false;
  538|  2.70M|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE20bloom_maybe_containsEj:
  285|  2.51M|      {
  286|  2.51M|         const uint32_t a = h & bloom_mask;
  287|  2.51M|         const uint32_t b = (h >> 10) & bloom_mask;
  288|  2.51M|         return (index_->bloom[a >> 3] & (uint8_t(1) << (a & 7))) && (index_->bloom[b >> 3] & (uint8_t(1) << (b & 7)));
  ------------------
  |  Branch (288:17): [True: 742k, False: 1.76M]
  |  Branch (288:70): [True: 568k, False: 174k]
  ------------------
  289|  2.51M|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE17index_find_or_posINSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEEEENS4_17index_find_resultERKT_j:
  400|   763k|      {
  401|   763k|         ensure_index();
  402|       |
  403|   763k|         const auto* base = index_entries();
  404|   763k|         const auto* idx_end = base + index_->size;
  405|   763k|         const auto* p = branchless_lower_bound(base, index_->size, h);
  406|   763k|         const size_t pos = static_cast<size_t>(p - base);
  407|       |
  408|       |         // Scan adjacent entries with matching hash
  409|   783k|         for (auto* scan = p; scan != idx_end && scan->key_hash == h; ++scan) {
  ------------------
  |  Branch (409:31): [True: 779k, False: 4.42k]
  |  Branch (409:50): [True: 597k, False: 181k]
  ------------------
  410|   597k|            if (data_[scan->index].first == key) {
  ------------------
  |  Branch (410:17): [True: 577k, False: 20.4k]
  ------------------
  411|   577k|               return {data_ + scan->index, pos, h};
  412|   577k|            }
  413|   597k|         }
  414|       |
  415|   186k|         return {data_ + size_, pos, h};
  416|   763k|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE12ensure_indexEv:
  360|   763k|      {
  361|   763k|         if (size_ <= linear_search_threshold) return;
  ------------------
  |  Branch (361:14): [True: 0, False: 763k]
  ------------------
  362|   763k|         const auto current = index_size();
  363|   763k|         if (current == size_) return; // fully current
  ------------------
  |  Branch (363:14): [True: 461k, False: 301k]
  ------------------
  364|       |
  365|   301k|         if (current == 0 || (size_ - current) > linear_search_threshold) {
  ------------------
  |  Branch (365:14): [True: 53.8k, False: 247k]
  |  Branch (365:30): [True: 110k, False: 137k]
  ------------------
  366|   164k|            rebuild_index(); // full rebuild
  367|   164k|            return;
  368|   164k|         }
  369|       |
  370|       |         // Incrementally insert-sort the few new entries
  371|   436k|         for (uint32_t i = current; i < size_; ++i) {
  ------------------
  |  Branch (371:37): [True: 298k, False: 137k]
  ------------------
  372|   298k|            const hash_index_entry entry{hash_key(data_[i].first), i};
  373|   298k|            const auto* base = index_entries();
  374|   298k|            const auto* p = branchless_lower_bound(base, index_->size, entry.key_hash);
  375|   298k|            auto pos = static_cast<size_t>(p - base);
  376|       |
  377|   298k|            const uint32_t m = index_->size;
  378|   298k|            ensure_index_capacity(static_cast<size_type>(m) + 1);
  379|   298k|            auto* entries = index_entries();
  380|   298k|            if (pos < m) {
  ------------------
  |  Branch (380:17): [True: 288k, False: 9.66k]
  ------------------
  381|   288k|               std::memmove(entries + pos + 1, entries + pos, (m - pos) * sizeof(hash_index_entry));
  382|   288k|            }
  383|   298k|            entries[pos] = entry;
  384|   298k|            index_->size = i + 1;
  385|   298k|         }
  386|   137k|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE13rebuild_indexEv:
  343|   164k|      {
  344|   164k|         ensure_index_capacity(static_cast<size_type>(size_));
  345|   164k|         bloom_clear();
  346|   164k|         auto* entries = index_entries();
  347|  7.18M|         for (uint32_t i = 0; i < size_; ++i) {
  ------------------
  |  Branch (347:31): [True: 7.02M, False: 164k]
  ------------------
  348|  7.02M|            const uint32_t h = hash_key(data_[i].first);
  349|  7.02M|            entries[i] = {h, i};
  350|  7.02M|            bloom_set(h);
  351|  7.02M|         }
  352|   164k|         std::sort(entries, entries + size_, [](const auto& a, const auto& b) { return a.key_hash < b.key_hash; });
  353|   164k|         index_->size = size_;
  354|   164k|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE11bloom_clearEv:
  291|   164k|      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|  49.1M|         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|  1.06M|      {
  441|  7.82M|         while (len > 1) {
  ------------------
  |  Branch (441:17): [True: 6.76M, False: 1.06M]
  ------------------
  442|  6.76M|            size_t half = len / 2;
  443|  6.76M|            p += (p[half - 1].key_hash < target) * half;
  444|  6.76M|            len -= half;
  445|  6.76M|         }
  446|       |         // Final element check: advance past it if it's less than target
  447|  1.06M|         p += (len == 1 && p->key_hash < target);
  ------------------
  |  Branch (447:16): [True: 1.06M, False: 0]
  |  Branch (447:28): [True: 14.0k, False: 1.04M]
  ------------------
  448|  1.06M|         return p;
  449|  1.06M|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE9bloom_setEj:
  277|  9.14M|      {
  278|  9.14M|         const uint32_t a = h & bloom_mask;
  279|  9.14M|         const uint32_t b = (h >> 10) & bloom_mask;
  280|  9.14M|         index_->bloom[a >> 3] |= uint8_t(1) << (a & 7);
  281|  9.14M|         index_->bloom[b >> 3] |= uint8_t(1) << (b & 7);
  282|  9.14M|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE10index_sizeEv:
  300|   949k|      uint32_t index_size() const noexcept { return index_ ? index_->size : 0; }
  ------------------
  |  Branch (300:53): [True: 895k, False: 53.8k]
  ------------------
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE21ensure_index_capacityEm:
  314|   648k|      {
  315|   648k|         if (needed == 0) return;
  ------------------
  |  Branch (315:14): [True: 0, False: 648k]
  ------------------
  316|   648k|         if (needed > static_cast<size_type>(max_u32)) {
  ------------------
  |  Branch (316:14): [True: 0, False: 648k]
  ------------------
  317|      0|            throw_index_overflow();
  318|      0|         }
  319|   648k|         const auto needed_u32 = static_cast<uint32_t>(needed);
  320|   648k|         if (index_ && index_->capacity >= needed_u32) return;
  ------------------
  |  Branch (320:14): [True: 595k, False: 53.8k]
  |  Branch (320:24): [True: 510k, False: 84.3k]
  ------------------
  321|   138k|         uint32_t cap = index_ ? index_->capacity : 0;
  ------------------
  |  Branch (321:25): [True: 84.3k, False: 53.8k]
  ------------------
  322|   280k|         while (cap < needed_u32) {
  ------------------
  |  Branch (322:17): [True: 142k, False: 138k]
  ------------------
  323|   142k|            const uint32_t next = next_index_capacity(cap);
  324|   142k|            if (next <= cap) {
  ------------------
  |  Branch (324:17): [True: 0, False: 142k]
  ------------------
  325|      0|               throw_index_overflow();
  326|      0|            }
  327|   142k|            cap = next;
  328|   142k|         }
  329|   138k|         auto* block = static_cast<index_header*>(std::realloc(index_, checked_index_allocation_bytes(cap)));
  330|   138k|         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: 138k]
  ------------------
  331|   138k|         if (!index_) {
  ------------------
  |  Branch (331:14): [True: 53.8k, False: 84.3k]
  ------------------
  332|  53.8k|            block->size = 0;
  333|  53.8k|            std::memset(block->bloom, 0, bloom_bytes);
  334|  53.8k|         }
  335|   138k|         block->capacity = cap;
  336|   138k|         index_ = block;
  337|   138k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE19next_index_capacityEj:
  127|   142k|      {
  128|   142k|         if (current == 0) return 16;
  ------------------
  |  Branch (128:14): [True: 53.8k, False: 88.7k]
  ------------------
  129|  88.7k|         if (current > (max_u32 / 2)) return max_u32;
  ------------------
  |  Branch (129:14): [True: 0, False: 88.7k]
  ------------------
  130|  88.7k|         return current * 2;
  131|  88.7k|      }
_ZN3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE30checked_index_allocation_bytesEj:
  142|   138k|      {
  143|   138k|         constexpr size_t header = sizeof(index_header);
  144|   138k|         constexpr size_t entry = sizeof(hash_index_entry);
  145|   138k|         if (count > (((std::numeric_limits<size_t>::max)() - header) / entry)) {
  ------------------
  |  Branch (145:14): [True: 0, False: 138k]
  ------------------
  146|      0|            GLZ_THROW_OR_ABORT(std::bad_alloc{});
  ------------------
  |  |    8|      0|#define GLZ_THROW_OR_ABORT(EXC) (throw(EXC))
  ------------------
  147|      0|         }
  148|   138k|         return header + static_cast<size_t>(count) * entry;
  149|   138k|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE13index_entriesEv:
  296|  1.71M|      {
  297|  1.71M|         return static_cast<hash_index_entry*>(static_cast<void*>(index_ + 1));
  298|  1.71M|      }
_ZNK3glz17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES0_EEE4sizeEv:
  663|     15|      size_type size() const noexcept { return size_; }

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

_ZN3glz20inert_key_bits_scopeC2IRNS_7contextEEEOT_Pv:
  192|  77.4k|      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|  8.29M|   {
  678|  8.29M|      using V = std::decay_t<decltype(element)>;
  679|  8.29M|      if constexpr (std::is_member_object_pointer_v<V>) {
  680|  8.29M|         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|  8.29M|   }

_ZNK3glz9error_ctxcvbEv:
  148|  31.1k|      operator bool() const noexcept { return ec != error_code::none; }
_ZN3glz10call_scopeINS_7contextEEC2ERS1_:
  272|  31.1k|      explicit call_scope(Ctx& c) noexcept : ctx(c), depth(c.depth)
  273|  31.1k|      {
  274|  31.1k|         ctx.error = error_code::none;
  275|  31.1k|         ctx.custom_error_message = {};
  276|  31.1k|      }
_ZN3glz11enter_depthITkNS_10is_contextENS_7contextEEEbRT_:
  344|  1.81M|   {
  345|  1.81M|      if (ctx.depth >= max_recursive_depth_limit) [[unlikely]] {
  ------------------
  |  Branch (345:11): [True: 32, False: 1.81M]
  ------------------
  346|     32|         ctx.error = error_code::exceeded_max_recursive_depth;
  347|     32|         return true;
  348|     32|      }
  349|  1.81M|      ++ctx.depth;
  350|  1.81M|      return false;
  351|  1.81M|   }
_ZN3glz18charge_speculationITkNS_10is_contextENS_7contextEEEbRT_m:
  311|  55.7k|   {
  312|  55.7k|      if constexpr (requires { ctx.speculation_budget; }) {
  313|  55.7k|         if (ctx.speculation_budget == 0) {
  ------------------
  |  Branch (313:14): [True: 0, False: 55.7k]
  ------------------
  314|      0|            return true;
  315|      0|         }
  316|  55.7k|         ctx.speculation_budget = consumed >= ctx.speculation_budget ? 1 : ctx.speculation_budget - consumed;
  ------------------
  |  Branch (316:35): [True: 0, False: 55.7k]
  ------------------
  317|  55.7k|         return ctx.speculation_budget > 1;
  318|       |      }
  319|       |      else {
  320|       |         return true;
  321|       |      }
  322|  55.7k|   }
_ZN3glz21speculation_exhaustedITkNS_10is_contextENS_7contextEEEbRT_:
  328|  3.28k|   {
  329|  3.28k|      if constexpr (requires { ctx.speculation_budget; }) {
  330|  3.28k|         return ctx.speculation_budget == 1; // the latched floor; 0 means unbudgeted
  331|       |      }
  332|       |      else {
  333|       |         return false;
  334|       |      }
  335|  3.28k|   }
_ZN3glz10call_scopeINS_7contextEED2Ev:
  277|  31.1k|      ~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: 231, 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.75k, False: 2.62k]
  ------------------
  203|  7.75k|         goto finish;
  204|  7.75k|      }
  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.7k|   {
   41|  20.7k|      static_assert(sizeof(decltype(*buffer.data())) == 1);
   42|       |
   43|  20.7k|      auto it = reinterpret_cast<const char*>(buffer.data());
   44|  20.7k|      auto end = it + buffer.size();
   45|       |
   46|  20.7k|      return std::pair{it, end};
   47|  20.7k|   }
_ZN3glz23finalize_top_level_readITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextEEEvOT0_PKcS7_S7_:
  131|  31.1k|   {
  132|  31.1k|      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.1k|         if (ctx.error == error_code::end_reached && ctx.depth == 0 && it == end && start < it) {
  ------------------
  |  Branch (137:14): [True: 1.72k, False: 29.4k]
  |  Branch (137:54): [True: 18, False: 1.70k]
  |  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.1k|      }
  146|  31.1k|      finalize_read_context(ctx);
  147|  31.1k|   }
_ZN3glz21finalize_read_contextITkNS_10is_contextERNS_7contextEEEvOT_:
  109|  31.1k|   {
  110|  31.1k|      settle_partial_read_complete(ctx);
  111|  31.1k|      settle_end_reached(ctx);
  112|  31.1k|   }
_ZN3glz28settle_partial_read_completeITkNS_10is_contextERNS_7contextEEEvOT_:
  102|  31.1k|   {
  103|  31.1k|      if (ctx.error == error_code::partial_read_complete) {
  ------------------
  |  Branch (103:11): [True: 0, False: 31.1k]
  ------------------
  104|      0|         ctx.error = error_code::none;
  105|      0|      }
  106|  31.1k|   }
_ZN3glz18settle_end_reachedITkNS_10is_contextERNS_7contextEEEvOT_:
   88|  31.1k|   {
   89|  31.1k|      if (ctx.error == error_code::end_reached) {
  ------------------
  |  Branch (89:11): [True: 1.70k, False: 29.4k]
  ------------------
   90|  1.70k|         ctx.error = (ctx.depth == 0) ? error_code::none : error_code::unexpected_end;
  ------------------
  |  Branch (90:22): [True: 1, False: 1.70k]
  ------------------
   91|  1.70k|      }
   92|  31.1k|   }
_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: 234, 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.75k, False: 2.63k]
  ------------------
  203|  7.75k|         goto finish;
  204|  7.75k|      }
  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.63k|   }
_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: 234, 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.75k, False: 2.63k]
  ------------------
  203|  7.75k|         goto finish;
  204|  7.75k|      }
  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.63k|   }
_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|  10.0M|   {
  271|  10.0M|      return sweet32(static_cast<const void*>(s.data()), s.size(), seed);
  272|  10.0M|   }
_ZN3glz9sweethash7sweet32EPKvmj:
  154|  10.0M|   {
  155|  10.0M|      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|  10.0M|      if (len <= 8) {
  ------------------
  |  Branch (158:11): [True: 7.68M, False: 2.33M]
  ------------------
  159|  7.68M|         uint64_t v = 0;
  160|  7.68M|         switch (len) {
  161|   532k|         case 8:
  ------------------
  |  Branch (161:10): [True: 532k, False: 7.15M]
  ------------------
  162|   532k|            std::memcpy(&v, p, 8);
  163|   532k|            break;
  164|   559k|         case 7:
  ------------------
  |  Branch (164:10): [True: 559k, False: 7.12M]
  ------------------
  165|   559k|            std::memcpy(&v, p, 7);
  166|   559k|            break;
  167|   599k|         case 6:
  ------------------
  |  Branch (167:10): [True: 599k, False: 7.08M]
  ------------------
  168|   599k|            std::memcpy(&v, p, 6);
  169|   599k|            break;
  170|   424k|         case 5:
  ------------------
  |  Branch (170:10): [True: 424k, False: 7.26M]
  ------------------
  171|   424k|            std::memcpy(&v, p, 5);
  172|   424k|            break;
  173|   954k|         case 4:
  ------------------
  |  Branch (173:10): [True: 954k, False: 6.73M]
  ------------------
  174|   954k|            std::memcpy(&v, p, 4);
  175|   954k|            break;
  176|   449k|         case 3:
  ------------------
  |  Branch (176:10): [True: 449k, False: 7.23M]
  ------------------
  177|   449k|            std::memcpy(&v, p, 3);
  178|   449k|            break;
  179|  2.20M|         case 2:
  ------------------
  |  Branch (179:10): [True: 2.20M, False: 5.48M]
  ------------------
  180|  2.20M|            std::memcpy(&v, p, 2);
  181|  2.20M|            break;
  182|  1.79M|         case 1:
  ------------------
  |  Branch (182:10): [True: 1.79M, False: 5.88M]
  ------------------
  183|  1.79M|            v = p[0];
  184|  1.79M|            break;
  185|   165k|         default:
  ------------------
  |  Branch (185:10): [True: 165k, False: 7.52M]
  ------------------
  186|   165k|            break;
  187|  7.68M|         }
  188|  7.68M|         v = v ^ seed ^ (len + 1);
  189|  7.68M|         return static_cast<uint32_t>(v) ^ static_cast<uint32_t>(v >> 32);
  190|  7.68M|      }
  191|       |
  192|       |      // Full hash for inputs > 8 bytes
  193|  2.33M|      uint64_t seed64 = (static_cast<uint64_t>(seed) << 32) | static_cast<uint64_t>(seed);
  194|  2.33M|      uint64_t h = (seed64 ^ prime4) + (len * prime1);
  195|  2.33M|      const uint8_t* const end = p + len;
  196|       |
  197|  2.33M|      if (len >= 32) {
  ------------------
  |  Branch (197:11): [True: 226k, False: 2.11M]
  ------------------
  198|   226k|         uint64_t h1 = h;
  199|   226k|         uint64_t h2 = (seed64 * prime2) ^ prime3;
  200|   226k|         uint64_t h3 = (seed64 * prime3) ^ prime4;
  201|   226k|         uint64_t h4 = (seed64 * prime4) ^ prime5;
  202|       |
  203|  1.72M|         do {
  204|  1.72M|            uint64_t k1, k2, k3, k4;
  205|  1.72M|            std::memcpy(&k1, p, 8);
  206|  1.72M|            std::memcpy(&k2, p + 8, 8);
  207|  1.72M|            std::memcpy(&k3, p + 16, 8);
  208|  1.72M|            std::memcpy(&k4, p + 24, 8);
  209|       |
  210|  1.72M|            k1 = k1 * prime2;
  211|  1.72M|            k1 = k1 ^ (k1 >> 47);
  212|  1.72M|            h1 = h1 ^ k1;
  213|  1.72M|            h1 = h1 * prime1;
  214|       |
  215|  1.72M|            k2 = k2 * prime3;
  216|  1.72M|            k2 = k2 ^ (k2 >> 47);
  217|  1.72M|            h2 = h2 ^ k2;
  218|  1.72M|            h2 = h2 * prime2;
  219|       |
  220|  1.72M|            k3 = k3 * prime4;
  221|  1.72M|            k3 = k3 ^ (k3 >> 47);
  222|  1.72M|            h3 = h3 ^ k3;
  223|  1.72M|            h3 = h3 * prime3;
  224|       |
  225|  1.72M|            k4 = k4 * prime5;
  226|  1.72M|            k4 = k4 ^ (k4 >> 47);
  227|  1.72M|            h4 = h4 ^ k4;
  228|  1.72M|            h4 = h4 * prime4;
  229|       |
  230|  1.72M|            p = p + 32;
  231|  1.72M|            len = len - 32;
  232|  1.72M|         } while (len >= 32);
  ------------------
  |  Branch (232:19): [True: 1.50M, False: 226k]
  ------------------
  233|       |
  234|   226k|         h = h1 + h2 + h3 + h4;
  235|   226k|      }
  236|       |
  237|  5.54M|      while (len >= 8) {
  ------------------
  |  Branch (237:14): [True: 3.21M, False: 2.33M]
  ------------------
  238|  3.21M|         uint64_t k;
  239|  3.21M|         std::memcpy(&k, p, 8);
  240|  3.21M|         k = k * prime2;
  241|  3.21M|         k = k ^ (k >> 47);
  242|  3.21M|         h = h ^ k;
  243|  3.21M|         h = h * prime1;
  244|  3.21M|         p = p + 8;
  245|  3.21M|         len = len - 8;
  246|  3.21M|      }
  247|       |
  248|  2.33M|      if (len > 0) {
  ------------------
  |  Branch (248:11): [True: 2.14M, False: 188k]
  ------------------
  249|  2.14M|         uint64_t k;
  250|  2.14M|         std::memcpy(&k, end - 8, 8);
  251|  2.14M|         k = k * prime2;
  252|  2.14M|         k = k ^ (k >> 47);
  253|  2.14M|         k = k * prime3;
  254|  2.14M|         h = h ^ k;
  255|  2.14M|      }
  256|       |
  257|  2.33M|      h = mix64(h);
  258|  2.33M|      return static_cast<uint32_t>(h) ^ static_cast<uint32_t>(h >> 32);
  259|  10.0M|   }
_ZN3glz9sweethash5mix64Em:
   33|  2.33M|   {
   34|  2.33M|      v = v ^ (v >> 33);
   35|  2.33M|      v = v * prime2;
   36|  2.33M|      v = v ^ (v >> 29);
   37|  2.33M|      v = v * prime3;
   38|  2.33M|      return v;
   39|  2.33M|   }

_ZN3glz12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEC2Ev:
  379|  7.35M|      generic_json() = default;
_ZN3glz12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEED2Ev:
  131|  19.0M|      ~generic_json() = default;
_ZN3glz12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEC2EOS3_:
  382|  11.7M|      generic_json(generic_json&& other) noexcept : data(std::move(other.data)) {}
_ZNK3glz12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEE4sizeEv:
  575|  7.89k|      {
  576|  7.89k|         if (auto* v = get_if<object_t>()) {
  ------------------
  |  Branch (576:20): [True: 15, False: 7.87k]
  ------------------
  577|     15|            return v->size();
  578|     15|         }
  579|  7.87k|         else if (auto* v = get_if<array_t>()) {
  ------------------
  |  Branch (579:25): [True: 48, False: 7.82k]
  ------------------
  580|     48|            return v->size();
  581|     48|         }
  582|  7.82k|         else if (auto* v = get_if<std::string>()) {
  ------------------
  |  Branch (582:25): [True: 825, False: 7.00k]
  ------------------
  583|    825|            return v->size();
  584|    825|         }
  585|  7.00k|         else {
  586|  7.00k|            return 0;
  587|  7.00k|         }
  588|  7.89k|      }
_ZNK3glz12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEE6get_ifINS2_IS3_EEEEPKT_v:
  182|  7.89k|      {
  183|  7.89k|         return std::get_if<T>(&data);
  184|  7.89k|      }
_ZNK3glz12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEE6get_ifINSt3__16vectorIS3_NS5_9allocatorIS3_EEEEEEPKT_v:
  182|  7.87k|      {
  183|  7.87k|         return std::get_if<T>(&data);
  184|  7.87k|      }
_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.1k|      {
   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.1k|         else {
   60|  31.1k|            using V = std::remove_cvref_t<T>;
   61|  31.1k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  31.1k|                                             end);
   63|  31.1k|         }
   64|  31.1k|      }
_ZN3glz4fromILj10ENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERS4_TkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
  150|  31.1k|      {
  151|  31.1k|         using V = std::decay_t<decltype(get_member(std::declval<Value>(), meta_wrapper_v<T>))>;
  152|  31.1k|         from<JSON, V>::template op<Opts>(get_member(std::forward<Value>(value), meta_wrapper_v<T>),
  153|  31.1k|                                          std::forward<Ctx>(ctx), std::forward<It0>(it), end);
  154|  31.1k|      }
_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.1k|      {
 3861|       |         if constexpr (tagging == variant_tagging_kind::adjacent) {
 3862|       |            read_adjacent<Options>(value, ctx, it, end);
 3863|       |         }
 3864|  31.1k|         else {
 3865|  31.1k|            read_deduced<Options>(value, ctx, it, end);
 3866|  31.1k|         }
 3867|  31.1k|      }
_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.1k|      {
 3872|  31.1k|         constexpr auto Opts = ws_handled_off<Options>();
 3873|  31.1k|         if constexpr (variant_is_auto_deducible<T>()) {
 3874|  31.1k|            if constexpr (not check_ws_handled(Options)) {
 3875|  31.1k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3875:20): [True: 17, False: 31.1k]
  ------------------
 3876|     17|                  return;
 3877|     17|               }
 3878|  31.1k|            }
 3879|       |
 3880|  31.1k|            switch (*it) {
 3881|     37|            case '\0':
  ------------------
  |  Branch (3881:13): [True: 37, False: 31.1k]
  ------------------
 3882|     37|               ctx.error = error_code::unexpected_end;
 3883|     37|               return;
 3884|  15.2k|            case '{': {
  ------------------
  |  Branch (3884:13): [True: 15.2k, False: 15.9k]
  ------------------
 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|  15.2k|               if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (3889:20): [True: 0, False: 15.2k]
  ------------------
 3890|      0|                  return;
 3891|      0|               }
 3892|       |
 3893|  15.2k|               ++it;
 3894|  15.2k|               if constexpr (not Opts.null_terminated) {
 3895|  15.2k|                  if (it == end) [[unlikely]] {
  ------------------
  |  Branch (3895:23): [True: 1, False: 15.2k]
  ------------------
 3896|      1|                     ctx.error = error_code::unexpected_end;
 3897|      1|                     return;
 3898|      1|                  }
 3899|  15.2k|               }
 3900|  15.2k|               using type_counts = variant_type_count<T>;
 3901|  15.2k|               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|  15.2k|               else if constexpr (n_object_candidates == 1 && tag_v<T>.empty()) {
 3907|  15.2k|                  constexpr auto first_idx = variant_first_object_candidate_v<Opts, T>;
 3908|  15.2k|                  using V = std::variant_alternative_t<first_idx, T>;
 3909|  15.2k|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (3909:23): [True: 15.2k, False: 1]
  ------------------
 3910|  15.2k|                  parse<JSON>::op<opening_handled<Opts>()>(std::get<V>(value), ctx, it, end);
 3911|  15.2k|                  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|  15.2k|            }
 4596|  4.96k|            case '[':
  ------------------
  |  Branch (4596:13): [True: 4.96k, False: 26.1k]
  ------------------
 4597|       |               // As with '{' above: the array reader each alternative goes through counts the level.
 4598|  4.96k|               process_variant_alternatives<T, is_variant_array>::template op<Opts>(value, ctx, it, end);
 4599|  4.96k|               break;
 4600|  2.59k|            case '"': {
  ------------------
  |  Branch (4600:13): [True: 2.59k, False: 28.5k]
  ------------------
 4601|  2.59k|               process_variant_alternatives<T, is_variant_str>::template op<Opts>(value, ctx, it, end);
 4602|  2.59k|               break;
 4603|  15.2k|            }
 4604|    105|            case 't':
  ------------------
  |  Branch (4604:13): [True: 105, False: 31.0k]
  ------------------
 4605|    312|            case 'f': {
  ------------------
  |  Branch (4605:13): [True: 207, False: 30.9k]
  ------------------
 4606|    312|               process_variant_alternatives<T, is_variant_bool>::template op<Opts>(value, ctx, it, end);
 4607|    312|               break;
 4608|    105|            }
 4609|    138|            case 'n':
  ------------------
  |  Branch (4609:13): [True: 138, False: 31.0k]
  ------------------
 4610|       |               if constexpr (variant_count_v<T, is_variant_null> == 0) {
 4611|       |                  ctx.error = error_code::no_matching_variant_type;
 4612|       |               }
 4613|    138|               else {
 4614|    138|                  constexpr auto first_idx = variant_first_index_v<T, is_variant_null>;
 4615|    138|                  using V = std::variant_alternative_t<first_idx, T>;
 4616|    138|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4616:23): [True: 0, False: 138]
  ------------------
 4617|    138|                  match<"null", Opts>(ctx, it, end);
 4618|    138|               }
 4619|    138|               break;
 4620|  7.87k|            default: {
  ------------------
  |  Branch (4620:13): [True: 7.87k, False: 23.2k]
  ------------------
 4621|       |               // Not bool, string, object, or array so must be number or null
 4622|  7.87k|               process_variant_alternatives<T, is_variant_num>::template op<Opts>(value, ctx, it, end);
 4623|  7.87k|            }
 4624|  31.1k|            }
 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.1k|      }
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEERNS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES4_EEEETkNS_10is_contextERNS_7contextERPKcSD_EEvOT0_OT1_OT2_T3_:
   49|  77.4k|      {
   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|  77.4k|         else {
   60|  77.4k|            using V = std::remove_cvref_t<T>;
   61|  77.4k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  77.4k|                                             end);
   63|  77.4k|         }
   64|  77.4k|      }
_ZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_:
 2791|  77.4k|      {
 2792|  77.4k|         static constexpr auto num_members = reflect<T>::size;
 2793|       |
 2794|  77.4k|         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|  77.4k|         const auto ws_start = it;
 2817|  77.4k|         if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2817:14): [True: 13, False: 77.4k]
  ------------------
 2818|     13|            return;
 2819|     13|         }
 2820|  77.4k|         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|  77.4k|         else {
 2895|  77.4k|            decltype(auto) fields = [&]() -> decltype(auto) {
 2896|  77.4k|               if constexpr ((glaze_object_t<T> || reflectable<T>) &&
 2897|  77.4k|                             (Opts.error_on_missing_keys || Opts.partial_read)) {
 2898|  77.4k|                  return bit_array<num_members>{};
 2899|  77.4k|               }
 2900|  77.4k|               else {
 2901|  77.4k|                  return nullptr;
 2902|  77.4k|               }
 2903|  77.4k|            }();
 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|  77.4k|            static constexpr bool tracks_include_keys = [] {
 2912|       |               // Nested so that reflecting over the members is only asked for when it can matter
 2913|  77.4k|               if constexpr ((glaze_object_t<T> || reflectable<T>) && Opts.error_on_missing_keys) {
 2914|  77.4k|                  return has_includer_member<T>;
 2915|  77.4k|               }
 2916|  77.4k|               else {
 2917|  77.4k|                  return false;
 2918|  77.4k|               }
 2919|  77.4k|            }();
 2920|  77.4k|            [[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|  77.4k|            [[maybe_unused]] const std::conditional_t<tracks_include_keys,
 2929|  77.4k|                                                      key_bits_scope<std::remove_reference_t<decltype(ctx)>>,
 2930|  77.4k|                                                      inert_key_bits_scope> published_bits{
 2931|  77.4k|               ctx, [&]() -> void* {
 2932|  77.4k|                  if constexpr (tracks_include_keys) {
 2933|  77.4k|                     return &fields;
 2934|  77.4k|                  }
 2935|  77.4k|                  else {
 2936|  77.4k|                     return nullptr;
 2937|  77.4k|                  }
 2938|  77.4k|               }()};
 2939|       |
 2940|  77.4k|            size_t read_count{}; // for partial_read
 2941|       |
 2942|  77.4k|            bool first = true;
 2943|  3.32M|            while (true) {
  ------------------
  |  Branch (2943:20): [True: 3.25M, 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|  3.25M|               if (*it == '}') {
  ------------------
  |  Branch (2980:20): [True: 5.00k, False: 3.25M]
  ------------------
 2981|  5.00k|                  --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.00k|                  ++it; // Increment after checking for missing keys so errors are within buffer bounds
 3018|  5.00k|                  if constexpr (not Opts.null_terminated) {
 3019|  5.00k|                     if (it == end) {
  ------------------
  |  Branch (3019:26): [True: 10, False: 4.99k]
  ------------------
 3020|     10|                        ctx.error = error_code::end_reached;
 3021|     10|                        return;
 3022|     10|                     }
 3023|  5.00k|                  }
 3024|  4.99k|                  return;
 3025|  5.00k|               }
 3026|  3.25M|               else if (first) {
  ------------------
  |  Branch (3026:25): [True: 72.5k, False: 3.18M]
  ------------------
 3027|  72.5k|                  first = false;
 3028|  72.5k|               }
 3029|  3.18M|               else {
 3030|  3.18M|                  if (match_invalid_end<',', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3030:23): [True: 1.82k, False: 3.17M]
  ------------------
 3031|  1.82k|                     return;
 3032|  1.82k|                  }
 3033|  3.17M|                  if constexpr (not Opts.null_terminated) {
 3034|  3.17M|                     if (it == end) [[unlikely]] {
  ------------------
  |  Branch (3034:26): [True: 0, False: 3.17M]
  ------------------
 3035|      0|                        ctx.error = error_code::unexpected_end;
 3036|      0|                        return;
 3037|      0|                     }
 3038|  3.17M|                  }
 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|  3.17M|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3047:23): [True: 12, False: 3.17M]
  ------------------
 3048|     12|                     return;
 3049|     12|                  }
 3050|  3.17M|               }
 3051|       |
 3052|  3.25M|               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|  3.25M|               else {
 3187|       |                  // For types like std::map, std::unordered_map
 3188|       |
 3189|  3.25M|                  auto reading = [&](auto&& key) {
 3190|  3.25M|                     if constexpr (Opts.partial_read) {
 3191|  3.25M|                        if (auto element = value.find(key); element != value.end()) {
 3192|  3.25M|                           ++read_count;
 3193|  3.25M|                           parse<JSON>::op<ws_handled<Opts>()>(element->second, ctx, it, end);
 3194|  3.25M|                        }
 3195|  3.25M|                        else {
 3196|  3.25M|                           skip_value<JSON>::op<Opts>(ctx, it, end);
 3197|  3.25M|                        }
 3198|  3.25M|                     }
 3199|  3.25M|                     else {
 3200|  3.25M|                        parse<JSON>::op<ws_handled<Opts>()>(value[key], ctx, it, end);
 3201|  3.25M|                     }
 3202|  3.25M|                  };
 3203|       |
 3204|       |                  // using Key = std::conditional_t<heterogeneous_map<T>, sv, typename T::key_type>;
 3205|  3.25M|                  using Key = typename T::key_type;
 3206|  3.25M|                  if constexpr (std::is_same_v<Key, std::string>) {
 3207|  3.25M|                     ctx.scratch.clear();
 3208|  3.25M|                     parse<JSON>::op<Opts>(ctx.scratch, ctx, it, end);
 3209|  3.25M|                     if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (3209:26): [True: 3.44k, False: 3.24M]
  ------------------
 3210|  3.44k|                        return;
 3211|       |
 3212|  3.24M|                     if (parse_ws_colon<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3212:26): [True: 2.83k, False: 3.24M]
  ------------------
 3213|  2.83k|                        return;
 3214|  2.83k|                     }
 3215|       |
 3216|  3.24M|                     reading(ctx.scratch);
 3217|       |                     if constexpr (Opts.partial_read) {
 3218|       |                        if (read_count == value.size()) {
 3219|       |                           return;
 3220|       |                        }
 3221|       |                     }
 3222|  3.24M|                     if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (3222:26): [True: 63.8k, False: 3.18M]
  ------------------
 3223|  63.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|  3.25M|               }
 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|  3.25M|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (3293:20): [True: 460, False: 3.25M]
  ------------------
 3294|    460|                  return;
 3295|    460|               }
 3296|  3.25M|            }
 3297|  77.4k|         }
 3298|  77.4k|      }
_ZZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_ENKUlvE_clEv:
 2895|  77.4k|            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|  77.4k|               else {
 2901|  77.4k|                  return nullptr;
 2902|  77.4k|               }
 2903|  77.4k|            }();
_ZZN3glz4fromILj10ENS_17ordered_small_mapINS_12generic_jsonILNS_8num_modeE0ES1_EEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj1EEETnNS_14string_literalEXtlNS9_ILm1EEEEERS5_TkNS_10is_contextERNS_7contextERPKcSF_EEvOT1_OT2_OT3_T4_ENKUlvE1_clEv:
 2931|  77.4k|               ctx, [&]() -> void* {
 2932|       |                  if constexpr (tracks_include_keys) {
 2933|       |                     return &fields;
 2934|       |                  }
 2935|  77.4k|                  else {
 2936|  77.4k|                     return nullptr;
 2937|  77.4k|                  }
 2938|  77.4k|               }()};
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEETkNS_10is_contextERNS_7contextERPKcSF_EEvOT0_OT1_OT2_T3_:
   49|  3.25M|      {
   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|  3.25M|         else {
   60|  3.25M|            using V = std::remove_cvref_t<T>;
   61|  3.25M|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  3.25M|                                             end);
   63|  3.25M|         }
   64|  3.25M|      }
_ZN3glz4fromILj10ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEERPKcSC_S7_TkNS_10is_contextERNS_7contextEEEvRT2_OT3_OT0_T1_:
  887|  3.25M|      {
  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|  3.25M|         else {
  901|  3.25M|            if constexpr (!check_opening_handled(Opts)) {
  902|  3.25M|               if constexpr (!check_ws_handled(Opts)) {
  903|  3.25M|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (903:23): [True: 0, False: 3.25M]
  ------------------
  904|      0|                     return;
  905|      0|                  }
  906|  3.25M|               }
  907|       |
  908|  3.25M|               if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (908:20): [True: 981, False: 3.25M]
  ------------------
  909|    981|                  return;
  910|    981|               }
  911|  3.25M|            }
  912|       |
  913|  3.25M|            if constexpr (not check_raw_string(Opts)) {
  914|  3.25M|               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|  3.25M|               const std::ptrdiff_t scan_min = chunk_min<8>(ctx.padded_input);
  921|       |
  922|  3.25M|               if (size_t(end - it) >= 8) {
  ------------------
  |  Branch (922:20): [True: 3.24M, False: 10.5k]
  ------------------
  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|  3.24M|                  const auto* const chunk_limit = end - scan_min;
  928|       |
  929|  3.24M|                  auto start = it;
  930|  3.24M|                  uint64_t ascii_acc{};
  931|  13.1M|                  while (it <= chunk_limit) {
  ------------------
  |  Branch (931:26): [True: 13.1M, False: 1.52k]
  ------------------
  932|  13.1M|                     uint64_t chunk;
  933|  13.1M|                     std::memcpy(&chunk, it, 8);
  934|       |                     if constexpr (std::endian::native == std::endian::big) {
  935|       |                        chunk = std::byteswap(chunk);
  936|       |                     }
  937|  13.1M|                     ascii_acc |= chunk;
  938|  13.1M|                     const uint64_t test_chars = has_quote(chunk);
  939|  13.1M|                     if (test_chars) {
  ------------------
  |  Branch (939:26): [True: 3.24M, False: 9.89M]
  ------------------
  940|  3.24M|                        it += (countr_zero(test_chars) >> 3);
  941|       |
  942|  3.24M|                        auto* prev = it - 1;
  943|  3.24M|                        while (*prev == '\\') {
  ------------------
  |  Branch (943:32): [True: 2.73k, False: 3.24M]
  ------------------
  944|  2.73k|                           --prev;
  945|  2.73k|                        }
  946|  3.24M|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (946:29): [True: 3.23M, False: 1.21k]
  ------------------
  947|  3.23M|                           goto continue_decode;
  948|  3.23M|                        }
  949|  1.21k|                        ++it; // skip the escaped quote
  950|  1.21k|                     }
  951|  9.89M|                     else {
  952|  9.89M|                        it += 8;
  953|  9.89M|                     }
  954|  13.1M|                  }
  955|       |
  956|  2.85k|                  while (it[-1] == '\\') [[unlikely]] {
  ------------------
  |  Branch (956:26): [True: 1.32k, False: 1.52k]
  ------------------
  957|       |                     // if we ended on an escape character then we need to rewind
  958|       |                     // because we lost our context
  959|  1.32k|                     --it;
  960|  1.32k|                  }
  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.53k|                  for (; it < end; ++it) {
  ------------------
  |  Branch (964:26): [True: 5.24k, False: 292]
  ------------------
  965|  5.24k|                     ascii_acc |= uint8_t(*it);
  966|  5.24k|                     if (*it == '"') {
  ------------------
  |  Branch (966:26): [True: 1.27k, False: 3.97k]
  ------------------
  967|  1.27k|                        auto* prev = it - 1;
  968|  2.26k|                        while (*prev == '\\') {
  ------------------
  |  Branch (968:32): [True: 989, False: 1.27k]
  ------------------
  969|    989|                           --prev;
  970|    989|                        }
  971|  1.27k|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (971:29): [True: 1.23k, False: 41]
  ------------------
  972|  1.23k|                           goto continue_decode;
  973|  1.23k|                        }
  974|  1.27k|                     }
  975|  5.24k|                  }
  976|       |
  977|    292|                  ctx.error = error_code::unexpected_end;
  978|    292|                  return;
  979|       |
  980|  3.24M|               continue_decode:
  981|       |
  982|  3.24M|                  if (validate_utf8_span<Opts>(ctx, start, it, ascii_acc)) [[unlikely]] {
  ------------------
  |  Branch (982:23): [True: 310, False: 3.23M]
  ------------------
  983|    310|                     return;
  984|    310|                  }
  985|       |
  986|  3.23M|                  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|  3.23M|                  bool pad = true;
  992|  3.23M|                  if constexpr (requires { value.capacity(); }) {
  993|  3.23M|                     const auto capacity = size_t(value.capacity());
  994|  3.23M|                     pad = capacity >= n + string_padding_bytes || capacity < n;
  ------------------
  |  Branch (994:28): [True: 3.22M, False: 14.9k]
  |  Branch (994:68): [True: 4.35k, False: 10.5k]
  ------------------
  995|  3.23M|                  }
  996|  3.23M|                  resize_unfilled(value, pad ? n + string_padding_bytes : n);
  ------------------
  |  Branch (996:42): [True: 3.22M, False: 10.5k]
  ------------------
  997|       |
  998|  3.23M|                  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|  3.23M|                  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|  3.23M|                  const auto* const copy_end = pad ? it : it - (std::min)(n, size_t(7));
  ------------------
  |  Branch (1007:48): [True: 3.22M, False: 10.5k]
  ------------------
 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|  15.0M|                  while (start < copy_end && start <= chunk_limit) {
  ------------------
  |  Branch (1015:26): [True: 11.8M, False: 3.23M]
  |  Branch (1015:46): [True: 11.8M, False: 473]
  ------------------
 1016|  11.8M|                     std::memcpy(p, start, 8);
 1017|  11.8M|                     uint64_t swar;
 1018|  11.8M|                     std::memcpy(&swar, p, 8);
 1019|       |                     if constexpr (std::endian::native == std::endian::big) {
 1020|       |                        swar = std::byteswap(swar);
 1021|       |                     }
 1022|       |
 1023|  11.8M|                     constexpr uint64_t lo7_mask = repeat_byte8(0b01111111);
 1024|  11.8M|                     const uint64_t lo7 = swar & lo7_mask;
 1025|  11.8M|                     const uint64_t backslash = (lo7 ^ repeat_byte8('\\')) + lo7_mask;
 1026|  11.8M|                     const uint64_t less_32 = (swar & repeat_byte8(0b01100000)) + lo7_mask;
 1027|  11.8M|                     uint64_t next = ~((backslash & less_32) | swar);
 1028|       |
 1029|  11.8M|                     next &= repeat_byte8(0b10000000);
 1030|  11.8M|                     if (next == 0) {
  ------------------
  |  Branch (1030:26): [True: 11.7M, False: 49.8k]
  ------------------
 1031|  11.7M|                        start += 8;
 1032|  11.7M|                        p += 8;
 1033|  11.7M|                        continue;
 1034|  11.7M|                     }
 1035|       |
 1036|  49.8k|                     next = countr_zero(next) >> 3;
 1037|  49.8k|                     start += next;
 1038|  49.8k|                     if (start >= it) {
  ------------------
  |  Branch (1038:26): [True: 4.71k, False: 45.1k]
  ------------------
 1039|  4.71k|                        break;
 1040|  4.71k|                     }
 1041|       |
 1042|  45.1k|                     if ((*start & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1042:26): [True: 201, False: 44.9k]
  ------------------
 1043|    201|                        ctx.error = error_code::syntax_error;
 1044|    201|                        value.resize(size_t(p - written_begin));
 1045|    201|                        return;
 1046|    201|                     }
 1047|  44.9k|                     ++start; // skip the escape
 1048|  44.9k|                     if (*start == 'u') {
  ------------------
  |  Branch (1048:26): [True: 38.2k, False: 6.68k]
  ------------------
 1049|  38.2k|                        ++start;
 1050|  38.2k|                        p += next;
 1051|  38.2k|                        const auto mark = start;
 1052|  38.2k|                        const auto decoded = handle_unicode_code_point(start, p, end);
 1053|  38.2k|                        if (decoded.written == 0) [[unlikely]] {
  ------------------
  |  Branch (1053:29): [True: 274, False: 37.9k]
  ------------------
 1054|    274|                           ctx.error = decoded.truncated ? error_code::unexpected_end
  ------------------
  |  Branch (1054:40): [True: 0, False: 274]
  ------------------
 1055|    274|                                                         : error_code::unicode_escape_conversion_failure;
 1056|    274|                           value.resize(size_t(p - written_begin));
 1057|    274|                           return;
 1058|    274|                        }
 1059|  37.9k|                        n += decoded.written;
 1060|       |                        // escape + u + unicode code points
 1061|  37.9k|                        n -= 2 + uint32_t(start - mark);
 1062|  37.9k|                     }
 1063|  6.68k|                     else {
 1064|  6.68k|                        p += next;
 1065|  6.68k|                        *p = char_unescape_table[uint8_t(*start)];
 1066|  6.68k|                        if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1066:29): [True: 39, False: 6.64k]
  ------------------
 1067|     39|                           ctx.error = error_code::invalid_escape;
 1068|     39|                           value.resize(size_t(p - written_begin));
 1069|     39|                           return;
 1070|     39|                        }
 1071|  6.64k|                        ++p;
 1072|  6.64k|                        ++start;
 1073|  6.64k|                        --n;
 1074|  6.64k|                     }
 1075|  44.9k|                  }
 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|  3.27M|                  while (start < it) {
  ------------------
  |  Branch (1079:26): [True: 33.7k, False: 3.23M]
  ------------------
 1080|  33.7k|                     if ((*start & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1080:26): [True: 16, False: 33.7k]
  ------------------
 1081|     16|                        ctx.error = error_code::syntax_error;
 1082|     16|                        value.resize(size_t(p - written_begin));
 1083|     16|                        return;
 1084|     16|                     }
 1085|  33.7k|                     if (*start == '\\') {
  ------------------
  |  Branch (1085:26): [True: 2.81k, False: 30.9k]
  ------------------
 1086|  2.81k|                        ++start; // skip the escape
 1087|  2.81k|                        if (*start == 'u') {
  ------------------
  |  Branch (1087:29): [True: 2.07k, False: 744]
  ------------------
 1088|  2.07k|                           ++start;
 1089|  2.07k|                           const auto mark = start;
 1090|  2.07k|                           const auto decoded = handle_unicode_code_point(start, p, end);
 1091|  2.07k|                           if (decoded.written == 0) [[unlikely]] {
  ------------------
  |  Branch (1091:32): [True: 132, False: 1.93k]
  ------------------
 1092|    132|                              ctx.error = decoded.truncated ? error_code::unexpected_end
  ------------------
  |  Branch (1092:43): [True: 0, False: 132]
  ------------------
 1093|    132|                                                            : error_code::unicode_escape_conversion_failure;
 1094|    132|                              value.resize(size_t(p - written_begin));
 1095|    132|                              return;
 1096|    132|                           }
 1097|  1.93k|                           n += decoded.written;
 1098|  1.93k|                           n -= 2 + uint32_t(start - mark);
 1099|  1.93k|                        }
 1100|    744|                        else {
 1101|    744|                           *p = char_unescape_table[uint8_t(*start)];
 1102|    744|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1102:32): [True: 28, False: 716]
  ------------------
 1103|     28|                              ctx.error = error_code::invalid_escape;
 1104|     28|                              value.resize(size_t(p - written_begin));
 1105|     28|                              return;
 1106|     28|                           }
 1107|    716|                           ++p;
 1108|    716|                           ++start;
 1109|    716|                           --n;
 1110|    716|                        }
 1111|  2.81k|                     }
 1112|  30.9k|                     else {
 1113|  30.9k|                        *p = *start;
 1114|  30.9k|                        ++p;
 1115|  30.9k|                        ++start;
 1116|  30.9k|                     }
 1117|  33.7k|                  }
 1118|       |
 1119|  3.23M|                  value.resize(n);
 1120|  3.23M|                  ++it;
 1121|  3.23M|               }
 1122|  10.5k|               else {
 1123|       |                  // For short strings
 1124|       |
 1125|  10.5k|                  std::array<char, 8> buffer{};
 1126|       |
 1127|  10.5k|                  auto* p = buffer.data();
 1128|  10.5k|                  const auto* const utf8_start = it;
 1129|       |
 1130|  18.2k|                  while (it < end) [[likely]] {
  ------------------
  |  Branch (1130:26): [True: 17.1k, False: 1.12k]
  ------------------
 1131|  17.1k|                     *p = *it;
 1132|  17.1k|                     if (*it == '"') {
  ------------------
  |  Branch (1132:26): [True: 8.75k, False: 8.40k]
  ------------------
 1133|  8.75k|                        if (validate_utf8_span<Opts>(ctx, utf8_start, it)) [[unlikely]] {
  ------------------
  |  Branch (1133:29): [True: 204, False: 8.54k]
  ------------------
 1134|    204|                           return;
 1135|    204|                        }
 1136|  8.54k|                        const size_t n = size_t(p - buffer.data());
 1137|  8.54k|#if __has_cpp_attribute(assume) >= 202207L
 1138|  8.54k|                        [[assume(n <= sizeof(buffer))]];
 1139|  8.54k|#endif
 1140|  8.54k|                        value.assign(buffer.data(), n);
 1141|  8.54k|                        ++it;
 1142|  8.54k|                        if constexpr (not Opts.null_terminated) {
 1143|  8.54k|                           if (it == end) {
  ------------------
  |  Branch (1143:32): [True: 150, False: 8.39k]
  ------------------
 1144|    150|                              ctx.error = error_code::end_reached;
 1145|    150|                              return;
 1146|    150|                           }
 1147|  8.54k|                        }
 1148|  8.39k|                        return;
 1149|  8.75k|                     }
 1150|  8.40k|                     else if (*it == '\\') {
  ------------------
  |  Branch (1150:31): [True: 337, False: 8.06k]
  ------------------
 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|    337|                        ++it; // skip the escape
 1156|    337|                        if (it == end) [[unlikely]] {
  ------------------
  |  Branch (1156:29): [True: 1, False: 336]
  ------------------
 1157|      1|                           ctx.error = error_code::unexpected_end;
 1158|      1|                           return;
 1159|      1|                        }
 1160|    336|                        if (*it == 'u') {
  ------------------
  |  Branch (1160:29): [True: 235, False: 101]
  ------------------
 1161|    235|                           ++it;
 1162|    235|                           if (it == end) [[unlikely]] {
  ------------------
  |  Branch (1162:32): [True: 1, False: 234]
  ------------------
 1163|      1|                              ctx.error = error_code::unexpected_end;
 1164|      1|                              return;
 1165|      1|                           }
 1166|    234|                           const auto decoded = handle_unicode_code_point(it, p, end);
 1167|    234|                           if (decoded.written == 0) [[unlikely]] {
  ------------------
  |  Branch (1167:32): [True: 116, False: 118]
  ------------------
 1168|    116|                              ctx.error = decoded.truncated ? error_code::unexpected_end
  ------------------
  |  Branch (1168:43): [True: 48, False: 68]
  ------------------
 1169|    116|                                                            : error_code::unicode_escape_conversion_failure;
 1170|    116|                              return;
 1171|    116|                           }
 1172|    234|                        }
 1173|    101|                        else {
 1174|    101|                           *p = char_unescape_table[uint8_t(*it)];
 1175|    101|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1175:32): [True: 17, False: 84]
  ------------------
 1176|     17|                              ctx.error = error_code::invalid_escape;
 1177|     17|                              return;
 1178|     17|                           }
 1179|     84|                           ++p;
 1180|     84|                           ++it;
 1181|     84|                        }
 1182|    336|                     }
 1183|  8.06k|                     else if ((*it & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1183:31): [True: 531, False: 7.53k]
  ------------------
 1184|    531|                        ctx.error = error_code::syntax_error;
 1185|    531|                        return;
 1186|    531|                     }
 1187|  7.53k|                     else {
 1188|  7.53k|                        ++it;
 1189|  7.53k|                        ++p;
 1190|  7.53k|                     }
 1191|  17.1k|                  }
 1192|       |
 1193|  1.12k|                  ctx.error = error_code::unexpected_end;
 1194|  1.12k|               }
 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|  3.25M|         }
 1211|  3.25M|      }
_ZN3glz14parse_ws_colonITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextENS_7contextERPKcS4_EEbRT0_OT1_T2_:
  159|  3.24M|   {
  160|  3.24M|      if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (160:11): [True: 139, False: 3.24M]
  ------------------
  161|    139|         return true;
  162|    139|      }
  163|  3.24M|      if (match_invalid_end<':', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (163:11): [True: 2.67k, False: 3.24M]
  ------------------
  164|  2.67k|         return true;
  165|  2.67k|      }
  166|  3.24M|      if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (166:11): [True: 24, False: 3.24M]
  ------------------
  167|     24|         return true;
  168|     24|      }
  169|  3.24M|      return false;
  170|  3.24M|   }
_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|  3.24M|                  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|  3.24M|                     else {
 3200|  3.24M|                        parse<JSON>::op<ws_handled<Opts>()>(value[key], ctx, it, end);
 3201|  3.24M|                     }
 3202|  3.24M|                  };
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERNS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEETkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
   49|  8.26M|      {
   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|  8.26M|         else {
   60|  8.26M|            using V = std::remove_cvref_t<T>;
   61|  8.26M|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  8.26M|                                             end);
   63|  8.26M|         }
   64|  8.26M|      }
_ZN3glz4fromILj10ENS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERS4_TkNS_10is_contextERNS_7contextERPKcSC_EEvOT0_OT1_OT2_T3_:
  150|  8.26M|      {
  151|  8.26M|         using V = std::decay_t<decltype(get_member(std::declval<Value>(), meta_wrapper_v<T>))>;
  152|  8.26M|         from<JSON, V>::template op<Opts>(get_member(std::forward<Value>(value), meta_wrapper_v<T>),
  153|  8.26M|                                          std::forward<Ctx>(ctx), std::forward<It0>(it), end);
  154|  8.26M|      }
_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|  8.26M|      {
 3861|       |         if constexpr (tagging == variant_tagging_kind::adjacent) {
 3862|       |            read_adjacent<Options>(value, ctx, it, end);
 3863|       |         }
 3864|  8.26M|         else {
 3865|  8.26M|            read_deduced<Options>(value, ctx, it, end);
 3866|  8.26M|         }
 3867|  8.26M|      }
_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|  8.26M|      {
 3872|  8.26M|         constexpr auto Opts = ws_handled_off<Options>();
 3873|  8.26M|         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|  8.26M|            switch (*it) {
 3881|  4.01k|            case '\0':
  ------------------
  |  Branch (3881:13): [True: 4.01k, False: 8.26M]
  ------------------
 3882|  4.01k|               ctx.error = error_code::unexpected_end;
 3883|  4.01k|               return;
 3884|  62.3k|            case '{': {
  ------------------
  |  Branch (3884:13): [True: 62.3k, False: 8.20M]
  ------------------
 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.3k|               if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (3889:20): [True: 18, False: 62.3k]
  ------------------
 3890|     18|                  return;
 3891|     18|               }
 3892|       |
 3893|  62.3k|               ++it;
 3894|  62.3k|               if constexpr (not Opts.null_terminated) {
 3895|  62.3k|                  if (it == end) [[unlikely]] {
  ------------------
  |  Branch (3895:23): [True: 72, False: 62.2k]
  ------------------
 3896|     72|                     ctx.error = error_code::unexpected_end;
 3897|     72|                     return;
 3898|     72|                  }
 3899|  62.3k|               }
 3900|  62.2k|               using type_counts = variant_type_count<T>;
 3901|  62.3k|               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.3k|               else if constexpr (n_object_candidates == 1 && tag_v<T>.empty()) {
 3907|  62.3k|                  constexpr auto first_idx = variant_first_object_candidate_v<Opts, T>;
 3908|  62.3k|                  using V = std::variant_alternative_t<first_idx, T>;
 3909|  62.3k|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (3909:23): [True: 61.7k, False: 650]
  ------------------
 3910|  62.3k|                  parse<JSON>::op<opening_handled<Opts>()>(std::get<V>(value), ctx, it, end);
 3911|  62.3k|                  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.3k|            }
 4596|  1.73M|            case '[':
  ------------------
  |  Branch (4596:13): [True: 1.73M, False: 6.53M]
  ------------------
 4597|       |               // As with '{' above: the array reader each alternative goes through counts the level.
 4598|  1.73M|               process_variant_alternatives<T, is_variant_array>::template op<Opts>(value, ctx, it, end);
 4599|  1.73M|               break;
 4600|  27.9k|            case '"': {
  ------------------
  |  Branch (4600:13): [True: 27.9k, False: 8.23M]
  ------------------
 4601|  27.9k|               process_variant_alternatives<T, is_variant_str>::template op<Opts>(value, ctx, it, end);
 4602|  27.9k|               break;
 4603|  62.3k|            }
 4604|  2.46k|            case 't':
  ------------------
  |  Branch (4604:13): [True: 2.46k, False: 8.26M]
  ------------------
 4605|  4.41k|            case 'f': {
  ------------------
  |  Branch (4605:13): [True: 1.95k, False: 8.26M]
  ------------------
 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.36k|            case 'n':
  ------------------
  |  Branch (4609:13): [True: 3.36k, False: 8.26M]
  ------------------
 4610|       |               if constexpr (variant_count_v<T, is_variant_null> == 0) {
 4611|       |                  ctx.error = error_code::no_matching_variant_type;
 4612|       |               }
 4613|  3.36k|               else {
 4614|  3.36k|                  constexpr auto first_idx = variant_first_index_v<T, is_variant_null>;
 4615|  3.36k|                  using V = std::variant_alternative_t<first_idx, T>;
 4616|  3.36k|                  if (!std::holds_alternative<V>(value)) value = V{};
  ------------------
  |  Branch (4616:23): [True: 1.07k, False: 2.29k]
  ------------------
 4617|  3.36k|                  match<"null", Opts>(ctx, it, end);
 4618|  3.36k|               }
 4619|  3.36k|               break;
 4620|  6.42M|            default: {
  ------------------
  |  Branch (4620:13): [True: 6.42M, False: 1.83M]
  ------------------
 4621|       |               // Not bool, string, object, or array so must be number or null
 4622|  6.42M|               process_variant_alternatives<T, is_variant_num>::template op<Opts>(value, ctx, it, end);
 4623|  6.42M|            }
 4624|  8.26M|            }
 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|  8.26M|      }
_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.74M|      {
 3521|  1.74M|         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.74M|         else {
 3527|  1.74M|            constexpr auto N = std::variant_size_v<Variant>;
 3528|  1.74M|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3529|  1.74M|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3530|       |
 3531|  1.74M|            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.74M|            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.74M|            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.74M|               size_t non_const_idx = 0;
 3588|       |
 3589|  1.74M|               for_each<N>([&]<size_t I>() {
 3590|  1.74M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3591|  1.74M|                     return;
 3592|  1.74M|                  }
 3593|  1.74M|                  using V = std::variant_alternative_t<I, Variant>;
 3594|  1.74M|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|  1.74M|                     auto copy_it{it};
 3596|  1.74M|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|  1.74M|                     if (!std::holds_alternative<V>(value)) {
 3598|  1.74M|                        value = V{};
 3599|  1.74M|                     }
 3600|  1.74M|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|  1.74M|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|  1.74M|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|  1.74M|                     }
 3604|  1.74M|                     if (!bool(ctx.error)) {
 3605|  1.74M|                        found_match = true;
 3606|  1.74M|                     }
 3607|  1.74M|                     else if constexpr (not Options.null_terminated) {
 3608|  1.74M|                        constexpr bool is_complete_type =
 3609|  1.74M|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|  1.74M|                        if constexpr (is_complete_type) {
 3612|  1.74M|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|  1.74M|                              found_match = true;
 3614|  1.74M|                              ctx.error = error_code::none;
 3615|  1.74M|                           }
 3616|  1.74M|                           else {
 3617|  1.74M|                              it = copy_it;
 3618|  1.74M|                              rewind_depth<Options>(ctx, copy_depth);
 3619|  1.74M|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|  1.74M|                                  not variant_alternative_exhausted(ctx)) {
 3621|  1.74M|                                 ctx.error = error_code::none;
 3622|  1.74M|                              }
 3623|  1.74M|                           }
 3624|  1.74M|                        }
 3625|  1.74M|                        else {
 3626|  1.74M|                           it = copy_it;
 3627|  1.74M|                           rewind_depth<Options>(ctx, copy_depth);
 3628|  1.74M|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|  1.74M|                               not variant_alternative_exhausted(ctx)) {
 3630|  1.74M|                              ctx.error = error_code::none;
 3631|  1.74M|                           }
 3632|  1.74M|                        }
 3633|  1.74M|                     }
 3634|  1.74M|                     else {
 3635|  1.74M|                        it = copy_it;
 3636|  1.74M|                        rewind_depth<Options>(ctx, copy_depth);
 3637|  1.74M|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|  1.74M|                            not variant_alternative_exhausted(ctx)) {
 3639|  1.74M|                           ctx.error = error_code::none;
 3640|  1.74M|                        }
 3641|  1.74M|                     }
 3642|  1.74M|                     ++non_const_idx;
 3643|  1.74M|                  }
 3644|  1.74M|               });
 3645|  1.74M|               if (!found_match) {
  ------------------
  |  Branch (3645:20): [True: 45.4k, False: 1.69M]
  ------------------
 3646|  45.4k|                  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|  45.4k|               }
 3654|       |            }
 3655|       |            else {
 3656|       |               ctx.error = error_code::no_matching_variant_type;
 3657|       |            }
 3658|  1.74M|         }
 3659|  1.74M|      }
_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.74M|               for_each<N>([&]<size_t I>() {
 3590|  1.74M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 1.74M]
  |  Branch (3590:38): [True: 0, False: 1.74M]
  |  Branch (3590:51): [True: 0, False: 1.74M]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  1.74M|                  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.74M|               });
_ZN3glz29variant_alternative_exhaustedITkNS_10is_contextENS_7contextEEEbRT_:
 3509|  21.7M|   {
 3510|  21.7M|      return ctx.error == error_code::exceeded_max_recursive_depth;
 3511|  21.7M|   }
_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.74M|               for_each<N>([&]<size_t I>() {
 3590|  1.74M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 1.74M]
  |  Branch (3590:38): [True: 0, False: 1.74M]
  |  Branch (3590:51): [True: 0, False: 1.74M]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  1.74M|                  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.74M|               });
_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.74M|               for_each<N>([&]<size_t I>() {
 3590|  1.74M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 1.74M]
  |  Branch (3590:38): [True: 0, False: 1.74M]
  |  Branch (3590:51): [True: 0, False: 1.74M]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  1.74M|                  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.74M|               });
_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.74M|               for_each<N>([&]<size_t I>() {
 3590|  1.74M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 1.74M]
  |  Branch (3590:38): [True: 0, False: 1.74M]
  |  Branch (3590:51): [True: 0, False: 1.74M]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  1.74M|                  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.74M|               });
_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.74M|               for_each<N>([&]<size_t I>() {
 3590|  1.74M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 1.74M]
  |  Branch (3590:38): [True: 0, False: 1.74M]
  |  Branch (3590:51): [True: 0, False: 1.74M]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  1.74M|                  using V = std::variant_alternative_t<I, Variant>;
 3594|  1.74M|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|  1.74M|                     auto copy_it{it};
 3596|  1.74M|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|  1.74M|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3597:26): [True: 1.40M, False: 331k]
  ------------------
 3598|  1.40M|                        value = V{};
 3599|  1.40M|                     }
 3600|  1.74M|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|  1.74M|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3601:26): [True: 45.4k, False: 1.69M]
  |  Branch (3601:45): [True: 0, False: 45.4k]
  ------------------
 3602|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|      0|                     }
 3604|  1.74M|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3604:26): [True: 1.69M, False: 45.4k]
  ------------------
 3605|  1.69M|                        found_match = true;
 3606|  1.69M|                     }
 3607|  45.4k|                     else if constexpr (not Options.null_terminated) {
 3608|  45.4k|                        constexpr bool is_complete_type =
 3609|  45.4k|                           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|  45.4k|                        else {
 3626|  45.4k|                           it = copy_it;
 3627|  45.4k|                           rewind_depth<Options>(ctx, copy_depth);
 3628|  45.4k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3628:32): [True: 0, False: 45.4k]
  |  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|  45.4k|                        }
 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.74M|                     ++non_const_idx;
 3643|  1.74M|                  }
 3644|  1.74M|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERNSt3__16vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS4_9allocatorIS9_EEEETkNS_10is_contextERNS_7contextERPKcSH_EEvOT0_OT1_OT2_T3_:
   49|  1.74M|      {
   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.74M|         else {
   60|  1.74M|            using V = std::remove_cvref_t<T>;
   61|  1.74M|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  1.74M|                                             end);
   63|  1.74M|         }
   64|  1.74M|      }
_ZN3glz4fromILj10ENSt3__16vectorINS_12generic_jsonILNS_8num_modeE0ENS_17ordered_small_mapEEENS1_9allocatorIS6_EEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERS9_TkNS_10is_contextERNS_7contextERPKcSH_EEvOT0_OT1_OT2_T3_:
 2050|  1.74M|      {
 2051|  1.74M|         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.74M|         if (match_invalid_end<'[', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2058:14): [True: 114, False: 1.74M]
  ------------------
 2059|    114|            return;
 2060|    114|         }
 2061|       |         // one nesting level (see enter_depth): counted in both modes so the limit binds,
 2062|       |         // released at each syntactic close below
 2063|  1.74M|         if (enter_depth(ctx)) [[unlikely]] {
  ------------------
  |  Branch (2063:14): [True: 14, False: 1.74M]
  ------------------
 2064|     14|            return;
 2065|     14|         }
 2066|       |
 2067|  1.74M|         const auto ws_start = it;
 2068|  1.74M|         if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2068:14): [True: 29, False: 1.74M]
  ------------------
 2069|     29|            return;
 2070|     29|         }
 2071|       |
 2072|  1.74M|         if (*it == ']') {
  ------------------
  |  Branch (2072:14): [True: 45.5k, False: 1.69M]
  ------------------
 2073|  45.5k|            --ctx.depth;
 2074|  45.5k|            ++it;
 2075|  45.5k|            if constexpr ((resizable<T> || is_inplace_vector<T>) && not check_append_arrays(Opts)) {
 2076|  45.5k|               value.clear();
 2077|       |
 2078|       |               if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2079|       |                  value.shrink_to_fit();
 2080|       |               }
 2081|  45.5k|            }
 2082|  45.5k|            return;
 2083|  45.5k|         }
 2084|       |
 2085|  1.69M|         const size_t ws_size = size_t(it - ws_start);
 2086|       |
 2087|  1.69M|         static constexpr bool should_append = (resizable<T> || is_inplace_vector<T>) && check_append_arrays(Opts);
  ------------------
  |  Branch (2087:49): [True: 1.69M, Folded]
  |  Branch (2087:65): [Folded, False: 0]
  |  Branch (2087:90): [Folded, False: 0]
  ------------------
 2088|  1.69M|         if constexpr (not should_append) {
 2089|  1.69M|            const auto n = value.size();
 2090|       |
 2091|  1.69M|            auto value_it = value.begin();
 2092|       |
 2093|  1.71M|            for (size_t i = 0; i < n; ++i) {
  ------------------
  |  Branch (2093:32): [True: 337k, False: 1.37M]
  ------------------
 2094|   337k|               parse<JSON>::op<ws_handled<Opts>()>(*value_it++, ctx, it, end);
 2095|   337k|               if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (2095:20): [True: 763, False: 336k]
  ------------------
 2096|    763|                  return;
 2097|   336k|               if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2097:20): [True: 26, False: 336k]
  ------------------
 2098|     26|                  return;
 2099|     26|               }
 2100|   336k|               if (*it == ',') {
  ------------------
  |  Branch (2100:20): [True: 15.5k, False: 320k]
  ------------------
 2101|  15.5k|                  ++it;
 2102|       |
 2103|  15.5k|                  if constexpr (!Opts.minified && !Opts.comments) {
 2104|  15.5k|                     if (ws_size && ws_size < size_t(end - it)) {
  ------------------
  |  Branch (2104:26): [True: 8.28k, False: 7.22k]
  |  Branch (2104:37): [True: 7.73k, False: 548]
  ------------------
 2105|  7.73k|                        skip_matching_ws(ws_start, it, ws_size);
 2106|  7.73k|                     }
 2107|  15.5k|                  }
 2108|       |
 2109|  15.5k|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2109:23): [True: 81, False: 15.4k]
  ------------------
 2110|     81|                     return;
 2111|     81|                  }
 2112|  15.5k|               }
 2113|   320k|               else if (*it == ']') {
  ------------------
  |  Branch (2113:25): [True: 320k, False: 120]
  ------------------
 2114|   320k|                  --ctx.depth;
 2115|   320k|                  ++it;
 2116|   320k|                  if constexpr (erasable<T>) {
 2117|   320k|                     value.erase(value_it,
 2118|   320k|                                 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|   320k|                  }
 2124|   320k|                  return;
 2125|   320k|               }
 2126|    120|               else [[unlikely]] {
 2127|    120|                  ctx.error = error_code::expected_bracket;
 2128|    120|                  return;
 2129|    120|               }
 2130|   336k|            }
 2131|  1.69M|         }
 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.69M|         else {
 2140|       |            // growing
 2141|  1.69M|            if constexpr (emplace_backable<T> || has_try_emplace_back<T>) {
 2142|  5.00M|               while (it < end) {
  ------------------
  |  Branch (2142:23): [True: 4.68M, False: 321k]
  ------------------
 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.68M|                  else {
 2169|  4.68M|                     parse<JSON>::op<ws_handled<Opts>()>(value.emplace_back(), ctx, it, end);
 2170|  4.68M|                  }
 2171|       |
 2172|  4.68M|                  if (bool(ctx.error)) [[unlikely]]
  ------------------
  |  Branch (2172:23): [True: 41.5k, False: 4.64M]
  ------------------
 2173|  41.5k|                     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.64M|                  if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2194:23): [True: 588, False: 4.64M]
  ------------------
 2195|    588|                     return;
 2196|    588|                  }
 2197|  4.64M|                  if (*it == ',') [[likely]] {
  ------------------
  |  Branch (2197:23): [True: 3.31M, False: 1.33M]
  ------------------
 2198|  3.31M|                     ++it;
 2199|       |
 2200|  3.31M|                     if constexpr (!Opts.minified && !Opts.comments) {
 2201|  3.31M|                        if (ws_size && ws_size < size_t(end - it)) {
  ------------------
  |  Branch (2201:29): [True: 35.7k, False: 3.27M]
  |  Branch (2201:40): [True: 35.0k, False: 691]
  ------------------
 2202|  35.0k|                           skip_matching_ws(ws_start, it, ws_size);
 2203|  35.0k|                        }
 2204|  3.31M|                     }
 2205|       |
 2206|  3.31M|                     if (skip_ws<Opts>(ctx, it, end)) {
  ------------------
  |  Branch (2206:26): [True: 174, False: 3.31M]
  ------------------
 2207|    174|                        return;
 2208|    174|                     }
 2209|  3.31M|                  }
 2210|  1.33M|                  else if (*it == ']') {
  ------------------
  |  Branch (2210:28): [True: 1.32M, False: 1.94k]
  ------------------
 2211|  1.32M|                     --ctx.depth;
 2212|  1.32M|                     ++it;
 2213|       |                     if constexpr (check_shrink_to_fit(Opts) && has_shrink_to_fit<T>) {
 2214|       |                        value.shrink_to_fit();
 2215|       |                     }
 2216|  1.32M|                     return;
 2217|  1.32M|                  }
 2218|  1.94k|                  else [[unlikely]] {
 2219|  1.94k|                     ctx.error = error_code::expected_bracket;
 2220|  1.94k|                     return;
 2221|  1.94k|                  }
 2222|  4.64M|               }
 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.69M|         }
 2239|  1.69M|      }
_ZN3glz12rewind_depthITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextENS_7contextEEEvRT0_j:
 3492|  52.4k|   {
 3493|  52.4k|      if (ctx.error == error_code::exceeded_max_recursive_depth) [[unlikely]] {
  ------------------
  |  Branch (3493:11): [True: 5.93k, False: 46.5k]
  ------------------
 3494|  5.93k|         return;
 3495|  5.93k|      }
 3496|       |      if constexpr (Opts.null_terminated) {
 3497|       |         ctx.depth = depth;
 3498|       |      }
 3499|  46.5k|      else {
 3500|  46.5k|         if (ctx.error != error_code::end_reached && ctx.error != error_code::unexpected_end) {
  ------------------
  |  Branch (3500:14): [True: 43.8k, False: 2.70k]
  |  Branch (3500:54): [True: 24.5k, False: 19.2k]
  ------------------
 3501|  24.5k|            ctx.depth = depth;
 3502|  24.5k|         }
 3503|  46.5k|      }
 3504|  46.5k|   }
_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.74M|               for_each<N>([&]<size_t I>() {
 3590|  1.74M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 1.69M, False: 45.4k]
  |  Branch (3590:38): [True: 0, False: 45.4k]
  |  Branch (3590:51): [True: 5.93k, False: 39.5k]
  ------------------
 3591|  1.70M|                     return;
 3592|  1.70M|                  }
 3593|  39.5k|                  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|  39.5k|               });
_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|  30.5k|      {
 3521|  30.5k|         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|  30.5k|         else {
 3527|  30.5k|            constexpr auto N = std::variant_size_v<Variant>;
 3528|  30.5k|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3529|  30.5k|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3530|       |
 3531|  30.5k|            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|  30.5k|            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|  30.5k|            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|  30.5k|               size_t non_const_idx = 0;
 3588|       |
 3589|  30.5k|               for_each<N>([&]<size_t I>() {
 3590|  30.5k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3591|  30.5k|                     return;
 3592|  30.5k|                  }
 3593|  30.5k|                  using V = std::variant_alternative_t<I, Variant>;
 3594|  30.5k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|  30.5k|                     auto copy_it{it};
 3596|  30.5k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|  30.5k|                     if (!std::holds_alternative<V>(value)) {
 3598|  30.5k|                        value = V{};
 3599|  30.5k|                     }
 3600|  30.5k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|  30.5k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|  30.5k|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|  30.5k|                     }
 3604|  30.5k|                     if (!bool(ctx.error)) {
 3605|  30.5k|                        found_match = true;
 3606|  30.5k|                     }
 3607|  30.5k|                     else if constexpr (not Options.null_terminated) {
 3608|  30.5k|                        constexpr bool is_complete_type =
 3609|  30.5k|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|  30.5k|                        if constexpr (is_complete_type) {
 3612|  30.5k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|  30.5k|                              found_match = true;
 3614|  30.5k|                              ctx.error = error_code::none;
 3615|  30.5k|                           }
 3616|  30.5k|                           else {
 3617|  30.5k|                              it = copy_it;
 3618|  30.5k|                              rewind_depth<Options>(ctx, copy_depth);
 3619|  30.5k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|  30.5k|                                  not variant_alternative_exhausted(ctx)) {
 3621|  30.5k|                                 ctx.error = error_code::none;
 3622|  30.5k|                              }
 3623|  30.5k|                           }
 3624|  30.5k|                        }
 3625|  30.5k|                        else {
 3626|  30.5k|                           it = copy_it;
 3627|  30.5k|                           rewind_depth<Options>(ctx, copy_depth);
 3628|  30.5k|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|  30.5k|                               not variant_alternative_exhausted(ctx)) {
 3630|  30.5k|                              ctx.error = error_code::none;
 3631|  30.5k|                           }
 3632|  30.5k|                        }
 3633|  30.5k|                     }
 3634|  30.5k|                     else {
 3635|  30.5k|                        it = copy_it;
 3636|  30.5k|                        rewind_depth<Options>(ctx, copy_depth);
 3637|  30.5k|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|  30.5k|                            not variant_alternative_exhausted(ctx)) {
 3639|  30.5k|                           ctx.error = error_code::none;
 3640|  30.5k|                        }
 3641|  30.5k|                     }
 3642|  30.5k|                     ++non_const_idx;
 3643|  30.5k|                  }
 3644|  30.5k|               });
 3645|  30.5k|               if (!found_match) {
  ------------------
  |  Branch (3645:20): [True: 2.35k, False: 28.1k]
  ------------------
 3646|  2.35k|                  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.35k|               }
 3654|       |            }
 3655|       |            else {
 3656|       |               ctx.error = error_code::no_matching_variant_type;
 3657|       |            }
 3658|  30.5k|         }
 3659|  30.5k|      }
_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|  30.5k|               for_each<N>([&]<size_t I>() {
 3590|  30.5k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 30.5k]
  |  Branch (3590:38): [True: 0, False: 30.5k]
  |  Branch (3590:51): [True: 0, False: 30.5k]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  30.5k|                  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|  30.5k|               });
_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|  30.5k|               for_each<N>([&]<size_t I>() {
 3590|  30.5k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 30.5k]
  |  Branch (3590:38): [True: 0, False: 30.5k]
  |  Branch (3590:51): [True: 0, False: 30.5k]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  30.5k|                  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|  30.5k|               });
_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|  30.5k|               for_each<N>([&]<size_t I>() {
 3590|  30.5k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 30.5k]
  |  Branch (3590:38): [True: 0, False: 30.5k]
  |  Branch (3590:51): [True: 0, False: 30.5k]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  30.5k|                  using V = std::variant_alternative_t<I, Variant>;
 3594|  30.5k|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|  30.5k|                     auto copy_it{it};
 3596|  30.5k|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|  30.5k|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3597:26): [True: 19.4k, False: 11.0k]
  ------------------
 3598|  19.4k|                        value = V{};
 3599|  19.4k|                     }
 3600|  30.5k|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|  30.5k|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3601:26): [True: 2.51k, False: 28.0k]
  |  Branch (3601:45): [True: 0, False: 2.51k]
  ------------------
 3602|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|      0|                     }
 3604|  30.5k|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3604:26): [True: 28.0k, False: 2.51k]
  ------------------
 3605|  28.0k|                        found_match = true;
 3606|  28.0k|                     }
 3607|  2.51k|                     else if constexpr (not Options.null_terminated) {
 3608|  2.51k|                        constexpr bool is_complete_type =
 3609|  2.51k|                           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.51k|                        if constexpr (is_complete_type) {
 3612|  2.51k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
  ------------------
  |  Branch (3612:32): [True: 157, False: 2.35k]
  |  Branch (3612:72): [True: 157, False: 0]
  |  Branch (3612:88): [True: 157, False: 0]
  ------------------
 3613|    157|                              found_match = true;
 3614|    157|                              ctx.error = error_code::none;
 3615|    157|                           }
 3616|  2.35k|                           else {
 3617|  2.35k|                              it = copy_it;
 3618|  2.35k|                              rewind_depth<Options>(ctx, copy_depth);
 3619|  2.35k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3619:35): [True: 0, False: 2.35k]
  |  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.35k|                           }
 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|  30.5k|                     ++non_const_idx;
 3643|  30.5k|                  }
 3644|  30.5k|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEETkNS_10is_contextERNS_7contextERPKcSF_EEvOT0_OT1_OT2_T3_:
   49|  30.5k|      {
   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|  30.5k|         else {
   60|  30.5k|            using V = std::remove_cvref_t<T>;
   61|  30.5k|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  30.5k|                                             end);
   63|  30.5k|         }
   64|  30.5k|      }
_ZN3glz4fromILj10ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERPKcSC_S7_TkNS_10is_contextERNS_7contextEEEvRT2_OT3_OT0_T1_:
  887|  30.5k|      {
  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|  30.5k|         else {
  901|  30.5k|            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|  30.5k|               if (match_invalid_end<'"', Opts>(ctx, it, end)) {
  ------------------
  |  Branch (908:20): [True: 94, False: 30.4k]
  ------------------
  909|     94|                  return;
  910|     94|               }
  911|  30.5k|            }
  912|       |
  913|  30.5k|            if constexpr (not check_raw_string(Opts)) {
  914|  30.5k|               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|  30.5k|               const std::ptrdiff_t scan_min = chunk_min<8>(ctx.padded_input);
  921|       |
  922|  30.5k|               if (size_t(end - it) >= 8) {
  ------------------
  |  Branch (922:20): [True: 28.9k, False: 1.55k]
  ------------------
  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|  28.9k|                  const auto* const chunk_limit = end - scan_min;
  928|       |
  929|  28.9k|                  auto start = it;
  930|  28.9k|                  uint64_t ascii_acc{};
  931|  7.41M|                  while (it <= chunk_limit) {
  ------------------
  |  Branch (931:26): [True: 7.41M, False: 1.12k]
  ------------------
  932|  7.41M|                     uint64_t chunk;
  933|  7.41M|                     std::memcpy(&chunk, it, 8);
  934|       |                     if constexpr (std::endian::native == std::endian::big) {
  935|       |                        chunk = std::byteswap(chunk);
  936|       |                     }
  937|  7.41M|                     ascii_acc |= chunk;
  938|  7.41M|                     const uint64_t test_chars = has_quote(chunk);
  939|  7.41M|                     if (test_chars) {
  ------------------
  |  Branch (939:26): [True: 28.8k, False: 7.38M]
  ------------------
  940|  28.8k|                        it += (countr_zero(test_chars) >> 3);
  941|       |
  942|  28.8k|                        auto* prev = it - 1;
  943|  32.5k|                        while (*prev == '\\') {
  ------------------
  |  Branch (943:32): [True: 3.63k, False: 28.8k]
  ------------------
  944|  3.63k|                           --prev;
  945|  3.63k|                        }
  946|  28.8k|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (946:29): [True: 27.8k, False: 1.04k]
  ------------------
  947|  27.8k|                           goto continue_decode;
  948|  27.8k|                        }
  949|  1.04k|                        ++it; // skip the escaped quote
  950|  1.04k|                     }
  951|  7.38M|                     else {
  952|  7.38M|                        it += 8;
  953|  7.38M|                     }
  954|  7.41M|                  }
  955|       |
  956|  2.68k|                  while (it[-1] == '\\') [[unlikely]] {
  ------------------
  |  Branch (956:26): [True: 1.55k, False: 1.12k]
  ------------------
  957|       |                     // if we ended on an escape character then we need to rewind
  958|       |                     // because we lost our context
  959|  1.55k|                     --it;
  960|  1.55k|                  }
  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.32k|                  for (; it < end; ++it) {
  ------------------
  |  Branch (964:26): [True: 5.13k, False: 192]
  ------------------
  965|  5.13k|                     ascii_acc |= uint8_t(*it);
  966|  5.13k|                     if (*it == '"') {
  ------------------
  |  Branch (966:26): [True: 981, False: 4.15k]
  ------------------
  967|    981|                        auto* prev = it - 1;
  968|  1.72k|                        while (*prev == '\\') {
  ------------------
  |  Branch (968:32): [True: 741, False: 981]
  ------------------
  969|    741|                           --prev;
  970|    741|                        }
  971|    981|                        if (size_t(it - prev) % 2) {
  ------------------
  |  Branch (971:29): [True: 936, False: 45]
  ------------------
  972|    936|                           goto continue_decode;
  973|    936|                        }
  974|    981|                     }
  975|  5.13k|                  }
  976|       |
  977|    192|                  ctx.error = error_code::unexpected_end;
  978|    192|                  return;
  979|       |
  980|  28.7k|               continue_decode:
  981|       |
  982|  28.7k|                  if (validate_utf8_span<Opts>(ctx, start, it, ascii_acc)) [[unlikely]] {
  ------------------
  |  Branch (982:23): [True: 287, False: 28.4k]
  ------------------
  983|    287|                     return;
  984|    287|                  }
  985|       |
  986|  28.4k|                  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|  28.4k|                  bool pad = true;
  992|  28.4k|                  if constexpr (requires { value.capacity(); }) {
  993|  28.4k|                     const auto capacity = size_t(value.capacity());
  994|  28.4k|                     pad = capacity >= n + string_padding_bytes || capacity < n;
  ------------------
  |  Branch (994:28): [True: 18.0k, False: 10.4k]
  |  Branch (994:68): [True: 6.06k, False: 4.36k]
  ------------------
  995|  28.4k|                  }
  996|  28.4k|                  resize_unfilled(value, pad ? n + string_padding_bytes : n);
  ------------------
  |  Branch (996:42): [True: 24.1k, False: 4.36k]
  ------------------
  997|       |
  998|  28.4k|                  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|  28.4k|                  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|  28.4k|                  const auto* const copy_end = pad ? it : it - (std::min)(n, size_t(7));
  ------------------
  |  Branch (1007:48): [True: 24.1k, False: 4.36k]
  ------------------
 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|   972k|                  while (start < copy_end && start <= chunk_limit) {
  ------------------
  |  Branch (1015:26): [True: 945k, False: 26.8k]
  |  Branch (1015:46): [True: 945k, False: 336]
  ------------------
 1016|   945k|                     std::memcpy(p, start, 8);
 1017|   945k|                     uint64_t swar;
 1018|   945k|                     std::memcpy(&swar, p, 8);
 1019|       |                     if constexpr (std::endian::native == std::endian::big) {
 1020|       |                        swar = std::byteswap(swar);
 1021|       |                     }
 1022|       |
 1023|   945k|                     constexpr uint64_t lo7_mask = repeat_byte8(0b01111111);
 1024|   945k|                     const uint64_t lo7 = swar & lo7_mask;
 1025|   945k|                     const uint64_t backslash = (lo7 ^ repeat_byte8('\\')) + lo7_mask;
 1026|   945k|                     const uint64_t less_32 = (swar & repeat_byte8(0b01100000)) + lo7_mask;
 1027|   945k|                     uint64_t next = ~((backslash & less_32) | swar);
 1028|       |
 1029|   945k|                     next &= repeat_byte8(0b10000000);
 1030|   945k|                     if (next == 0) {
  ------------------
  |  Branch (1030:26): [True: 936k, False: 9.42k]
  ------------------
 1031|   936k|                        start += 8;
 1032|   936k|                        p += 8;
 1033|   936k|                        continue;
 1034|   936k|                     }
 1035|       |
 1036|  9.42k|                     next = countr_zero(next) >> 3;
 1037|  9.42k|                     start += next;
 1038|  9.42k|                     if (start >= it) {
  ------------------
  |  Branch (1038:26): [True: 639, False: 8.78k]
  ------------------
 1039|    639|                        break;
 1040|    639|                     }
 1041|       |
 1042|  8.78k|                     if ((*start & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1042:26): [True: 260, False: 8.52k]
  ------------------
 1043|    260|                        ctx.error = error_code::syntax_error;
 1044|    260|                        value.resize(size_t(p - written_begin));
 1045|    260|                        return;
 1046|    260|                     }
 1047|  8.52k|                     ++start; // skip the escape
 1048|  8.52k|                     if (*start == 'u') {
  ------------------
  |  Branch (1048:26): [True: 6.05k, False: 2.47k]
  ------------------
 1049|  6.05k|                        ++start;
 1050|  6.05k|                        p += next;
 1051|  6.05k|                        const auto mark = start;
 1052|  6.05k|                        const auto decoded = handle_unicode_code_point(start, p, end);
 1053|  6.05k|                        if (decoded.written == 0) [[unlikely]] {
  ------------------
  |  Branch (1053:29): [True: 340, False: 5.71k]
  ------------------
 1054|    340|                           ctx.error = decoded.truncated ? error_code::unexpected_end
  ------------------
  |  Branch (1054:40): [True: 0, False: 340]
  ------------------
 1055|    340|                                                         : error_code::unicode_escape_conversion_failure;
 1056|    340|                           value.resize(size_t(p - written_begin));
 1057|    340|                           return;
 1058|    340|                        }
 1059|  5.71k|                        n += decoded.written;
 1060|       |                        // escape + u + unicode code points
 1061|  5.71k|                        n -= 2 + uint32_t(start - mark);
 1062|  5.71k|                     }
 1063|  2.47k|                     else {
 1064|  2.47k|                        p += next;
 1065|  2.47k|                        *p = char_unescape_table[uint8_t(*start)];
 1066|  2.47k|                        if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1066:29): [True: 71, False: 2.39k]
  ------------------
 1067|     71|                           ctx.error = error_code::invalid_escape;
 1068|     71|                           value.resize(size_t(p - written_begin));
 1069|     71|                           return;
 1070|     71|                        }
 1071|  2.39k|                        ++p;
 1072|  2.39k|                        ++start;
 1073|  2.39k|                        --n;
 1074|  2.39k|                     }
 1075|  8.52k|                  }
 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|  42.1k|                  while (start < it) {
  ------------------
  |  Branch (1079:26): [True: 14.5k, False: 27.5k]
  ------------------
 1080|  14.5k|                     if ((*start & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1080:26): [True: 32, False: 14.5k]
  ------------------
 1081|     32|                        ctx.error = error_code::syntax_error;
 1082|     32|                        value.resize(size_t(p - written_begin));
 1083|     32|                        return;
 1084|     32|                     }
 1085|  14.5k|                     if (*start == '\\') {
  ------------------
  |  Branch (1085:26): [True: 2.20k, False: 12.3k]
  ------------------
 1086|  2.20k|                        ++start; // skip the escape
 1087|  2.20k|                        if (*start == 'u') {
  ------------------
  |  Branch (1087:29): [True: 1.72k, False: 481]
  ------------------
 1088|  1.72k|                           ++start;
 1089|  1.72k|                           const auto mark = start;
 1090|  1.72k|                           const auto decoded = handle_unicode_code_point(start, p, end);
 1091|  1.72k|                           if (decoded.written == 0) [[unlikely]] {
  ------------------
  |  Branch (1091:32): [True: 170, False: 1.55k]
  ------------------
 1092|    170|                              ctx.error = decoded.truncated ? error_code::unexpected_end
  ------------------
  |  Branch (1092:43): [True: 0, False: 170]
  ------------------
 1093|    170|                                                            : error_code::unicode_escape_conversion_failure;
 1094|    170|                              value.resize(size_t(p - written_begin));
 1095|    170|                              return;
 1096|    170|                           }
 1097|  1.55k|                           n += decoded.written;
 1098|  1.55k|                           n -= 2 + uint32_t(start - mark);
 1099|  1.55k|                        }
 1100|    481|                        else {
 1101|    481|                           *p = char_unescape_table[uint8_t(*start)];
 1102|    481|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1102:32): [True: 33, False: 448]
  ------------------
 1103|     33|                              ctx.error = error_code::invalid_escape;
 1104|     33|                              value.resize(size_t(p - written_begin));
 1105|     33|                              return;
 1106|     33|                           }
 1107|    448|                           ++p;
 1108|    448|                           ++start;
 1109|    448|                           --n;
 1110|    448|                        }
 1111|  2.20k|                     }
 1112|  12.3k|                     else {
 1113|  12.3k|                        *p = *start;
 1114|  12.3k|                        ++p;
 1115|  12.3k|                        ++start;
 1116|  12.3k|                     }
 1117|  14.5k|                  }
 1118|       |
 1119|  27.5k|                  value.resize(n);
 1120|  27.5k|                  ++it;
 1121|  27.5k|               }
 1122|  1.55k|               else {
 1123|       |                  // For short strings
 1124|       |
 1125|  1.55k|                  std::array<char, 8> buffer{};
 1126|       |
 1127|  1.55k|                  auto* p = buffer.data();
 1128|  1.55k|                  const auto* const utf8_start = it;
 1129|       |
 1130|  3.58k|                  while (it < end) [[likely]] {
  ------------------
  |  Branch (1130:26): [True: 3.42k, False: 155]
  ------------------
 1131|  3.42k|                     *p = *it;
 1132|  3.42k|                     if (*it == '"') {
  ------------------
  |  Branch (1132:26): [True: 811, False: 2.61k]
  ------------------
 1133|    811|                        if (validate_utf8_span<Opts>(ctx, utf8_start, it)) [[unlikely]] {
  ------------------
  |  Branch (1133:29): [True: 224, False: 587]
  ------------------
 1134|    224|                           return;
 1135|    224|                        }
 1136|    587|                        const size_t n = size_t(p - buffer.data());
 1137|    587|#if __has_cpp_attribute(assume) >= 202207L
 1138|    587|                        [[assume(n <= sizeof(buffer))]];
 1139|    587|#endif
 1140|    587|                        value.assign(buffer.data(), n);
 1141|    587|                        ++it;
 1142|    587|                        if constexpr (not Opts.null_terminated) {
 1143|    587|                           if (it == end) {
  ------------------
  |  Branch (1143:32): [True: 157, False: 430]
  ------------------
 1144|    157|                              ctx.error = error_code::end_reached;
 1145|    157|                              return;
 1146|    157|                           }
 1147|    587|                        }
 1148|    430|                        return;
 1149|    811|                     }
 1150|  2.61k|                     else if (*it == '\\') {
  ------------------
  |  Branch (1150:31): [True: 389, False: 2.22k]
  ------------------
 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|    389|                        ++it; // skip the escape
 1156|    389|                        if (it == end) [[unlikely]] {
  ------------------
  |  Branch (1156:29): [True: 4, False: 385]
  ------------------
 1157|      4|                           ctx.error = error_code::unexpected_end;
 1158|      4|                           return;
 1159|      4|                        }
 1160|    385|                        if (*it == 'u') {
  ------------------
  |  Branch (1160:29): [True: 254, False: 131]
  ------------------
 1161|    254|                           ++it;
 1162|    254|                           if (it == end) [[unlikely]] {
  ------------------
  |  Branch (1162:32): [True: 2, False: 252]
  ------------------
 1163|      2|                              ctx.error = error_code::unexpected_end;
 1164|      2|                              return;
 1165|      2|                           }
 1166|    252|                           const auto decoded = handle_unicode_code_point(it, p, end);
 1167|    252|                           if (decoded.written == 0) [[unlikely]] {
  ------------------
  |  Branch (1167:32): [True: 122, False: 130]
  ------------------
 1168|    122|                              ctx.error = decoded.truncated ? error_code::unexpected_end
  ------------------
  |  Branch (1168:43): [True: 54, False: 68]
  ------------------
 1169|    122|                                                            : error_code::unicode_escape_conversion_failure;
 1170|    122|                              return;
 1171|    122|                           }
 1172|    252|                        }
 1173|    131|                        else {
 1174|    131|                           *p = char_unescape_table[uint8_t(*it)];
 1175|    131|                           if (*p == 0) [[unlikely]] {
  ------------------
  |  Branch (1175:32): [True: 34, False: 97]
  ------------------
 1176|     34|                              ctx.error = error_code::invalid_escape;
 1177|     34|                              return;
 1178|     34|                           }
 1179|     97|                           ++p;
 1180|     97|                           ++it;
 1181|     97|                        }
 1182|    385|                     }
 1183|  2.22k|                     else if ((*it & 0b11100000) == 0) [[unlikely]] {
  ------------------
  |  Branch (1183:31): [True: 429, False: 1.79k]
  ------------------
 1184|    429|                        ctx.error = error_code::syntax_error;
 1185|    429|                        return;
 1186|    429|                     }
 1187|  1.79k|                     else {
 1188|  1.79k|                        ++it;
 1189|  1.79k|                        ++p;
 1190|  1.79k|                     }
 1191|  3.42k|                  }
 1192|       |
 1193|    155|                  ctx.error = error_code::unexpected_end;
 1194|    155|               }
 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|  30.5k|         }
 1211|  30.5k|      }
_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|  30.5k|               for_each<N>([&]<size_t I>() {
 3590|  30.5k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 28.1k, False: 2.35k]
  |  Branch (3590:38): [True: 0, False: 2.35k]
  |  Branch (3590:51): [True: 0, False: 2.35k]
  ------------------
 3591|  28.1k|                     return;
 3592|  28.1k|                  }
 3593|  2.35k|                  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.35k|               });
_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|  30.5k|               for_each<N>([&]<size_t I>() {
 3590|  30.5k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 28.1k, False: 2.35k]
  |  Branch (3590:38): [True: 0, False: 2.35k]
  |  Branch (3590:51): [True: 0, False: 2.35k]
  ------------------
 3591|  28.1k|                     return;
 3592|  28.1k|                  }
 3593|  2.35k|                  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.35k|               });
_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|  30.5k|               for_each<N>([&]<size_t I>() {
 3590|  30.5k|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 28.1k, False: 2.35k]
  |  Branch (3590:38): [True: 0, False: 2.35k]
  |  Branch (3590:51): [True: 0, False: 2.35k]
  ------------------
 3591|  28.1k|                     return;
 3592|  28.1k|                  }
 3593|  2.35k|                  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.35k|               });
_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: 420, False: 4.30k]
  ------------------
 3646|    420|                  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|    420|               }
 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: 443, False: 4.28k]
  |  Branch (3601:45): [True: 0, False: 443]
  ------------------
 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: 443]
  ------------------
 3605|  4.28k|                        found_match = true;
 3606|  4.28k|                     }
 3607|    443|                     else if constexpr (not Options.null_terminated) {
 3608|    443|                        constexpr bool is_complete_type =
 3609|    443|                           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|    443|                        if constexpr (is_complete_type) {
 3612|    443|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
  ------------------
  |  Branch (3612:32): [True: 23, False: 420]
  |  Branch (3612:72): [True: 23, False: 0]
  |  Branch (3612:88): [True: 23, False: 0]
  ------------------
 3613|     23|                              found_match = true;
 3614|     23|                              ctx.error = error_code::none;
 3615|     23|                           }
 3616|    420|                           else {
 3617|    420|                              it = copy_it;
 3618|    420|                              rewind_depth<Options>(ctx, copy_depth);
 3619|    420|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3619:35): [True: 0, False: 420]
  |  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|    420|                           }
 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: 116, False: 4.60k]
  ------------------
  699|    116|               ctx.error = error_code::expected_true_or_false;
  700|    116|               return;
  701|    116|            }
  702|       |
  703|  4.60k|            uint32_t c;
  704|  4.60k|            static constexpr uint32_t u_true = 0b01100101'01110101'01110010'01110100;
  705|  4.60k|            static constexpr uint32_t u_fals = 0b01110011'01101100'01100001'01100110;
  706|  4.60k|            std::memcpy(&c, it, 4);
  707|       |            if constexpr (std::endian::native == std::endian::big) {
  708|       |               c = std::byteswap(c);
  709|       |            }
  710|  4.60k|            it += 4;
  711|  4.60k|            if (c == u_true) {
  ------------------
  |  Branch (711:17): [True: 2.39k, False: 2.21k]
  ------------------
  712|  2.39k|               value = true;
  713|  2.39k|            }
  714|  2.21k|            else if (it == end) [[unlikely]] {
  ------------------
  |  Branch (714:22): [True: 106, False: 2.11k]
  ------------------
  715|    106|               ctx.error = error_code::unexpected_end;
  716|    106|               return;
  717|    106|            }
  718|  2.11k|            else {
  719|  2.11k|               if (c == u_fals && (*it == 'e')) [[likely]] {
  ------------------
  |  Branch (719:20): [True: 1.94k, False: 163]
  |  Branch (719:35): [True: 1.91k, False: 35]
  ------------------
  720|  1.91k|                  value = false;
  721|  1.91k|                  ++it;
  722|  1.91k|               }
  723|    198|               else [[unlikely]] {
  724|    198|                  ctx.error = error_code::expected_true_or_false;
  725|    198|                  return;
  726|    198|               }
  727|  2.11k|            }
  728|  4.60k|         }
  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: 23, False: 4.70k]
  ------------------
  750|     23|                  ctx.error = error_code::end_reached;
  751|     23|                  return;
  752|     23|               }
  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: 420]
  |  Branch (3590:38): [True: 0, False: 420]
  |  Branch (3590:51): [True: 0, False: 420]
  ------------------
 3591|  4.30k|                     return;
 3592|  4.30k|                  }
 3593|    420|                  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|    420|               });
_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: 420]
  |  Branch (3590:38): [True: 0, False: 420]
  |  Branch (3590:51): [True: 0, False: 420]
  ------------------
 3591|  4.30k|                     return;
 3592|  4.30k|                  }
 3593|    420|                  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|    420|               });
_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.43M|      {
 3521|  6.43M|         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.43M|         else {
 3527|  6.43M|            constexpr auto N = std::variant_size_v<Variant>;
 3528|  6.43M|            constexpr auto const_count = variant_filtered_count_v<Variant, Trait, true>;
 3529|  6.43M|            constexpr auto non_const_count = variant_filtered_count_v<Variant, Trait, false>;
 3530|       |
 3531|  6.43M|            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.43M|            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.43M|            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.43M|               size_t non_const_idx = 0;
 3588|       |
 3589|  6.43M|               for_each<N>([&]<size_t I>() {
 3590|  6.43M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
 3591|  6.43M|                     return;
 3592|  6.43M|                  }
 3593|  6.43M|                  using V = std::variant_alternative_t<I, Variant>;
 3594|  6.43M|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|  6.43M|                     auto copy_it{it};
 3596|  6.43M|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|  6.43M|                     if (!std::holds_alternative<V>(value)) {
 3598|  6.43M|                        value = V{};
 3599|  6.43M|                     }
 3600|  6.43M|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|  6.43M|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
 3602|  6.43M|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|  6.43M|                     }
 3604|  6.43M|                     if (!bool(ctx.error)) {
 3605|  6.43M|                        found_match = true;
 3606|  6.43M|                     }
 3607|  6.43M|                     else if constexpr (not Options.null_terminated) {
 3608|  6.43M|                        constexpr bool is_complete_type =
 3609|  6.43M|                           num_t<V> || bool_t<V> || string_t<V> || std::is_enum_v<V> || tuple_t<V> || is_std_tuple<V>;
 3610|       |
 3611|  6.43M|                        if constexpr (is_complete_type) {
 3612|  6.43M|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
 3613|  6.43M|                              found_match = true;
 3614|  6.43M|                              ctx.error = error_code::none;
 3615|  6.43M|                           }
 3616|  6.43M|                           else {
 3617|  6.43M|                              it = copy_it;
 3618|  6.43M|                              rewind_depth<Options>(ctx, copy_depth);
 3619|  6.43M|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
 3620|  6.43M|                                  not variant_alternative_exhausted(ctx)) {
 3621|  6.43M|                                 ctx.error = error_code::none;
 3622|  6.43M|                              }
 3623|  6.43M|                           }
 3624|  6.43M|                        }
 3625|  6.43M|                        else {
 3626|  6.43M|                           it = copy_it;
 3627|  6.43M|                           rewind_depth<Options>(ctx, copy_depth);
 3628|  6.43M|                           if (non_const_idx + 1 < non_const_count && not exhausted &&
 3629|  6.43M|                               not variant_alternative_exhausted(ctx)) {
 3630|  6.43M|                              ctx.error = error_code::none;
 3631|  6.43M|                           }
 3632|  6.43M|                        }
 3633|  6.43M|                     }
 3634|  6.43M|                     else {
 3635|  6.43M|                        it = copy_it;
 3636|  6.43M|                        rewind_depth<Options>(ctx, copy_depth);
 3637|  6.43M|                        if (non_const_idx + 1 < non_const_count && not exhausted &&
 3638|  6.43M|                            not variant_alternative_exhausted(ctx)) {
 3639|  6.43M|                           ctx.error = error_code::none;
 3640|  6.43M|                        }
 3641|  6.43M|                     }
 3642|  6.43M|                     ++non_const_idx;
 3643|  6.43M|                  }
 3644|  6.43M|               });
 3645|  6.43M|               if (!found_match) {
  ------------------
  |  Branch (3645:20): [True: 4.26k, False: 6.43M]
  ------------------
 3646|  4.26k|                  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.26k|               }
 3654|       |            }
 3655|       |            else {
 3656|       |               ctx.error = error_code::no_matching_variant_type;
 3657|       |            }
 3658|  6.43M|         }
 3659|  6.43M|      }
_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.43M|               for_each<N>([&]<size_t I>() {
 3590|  6.43M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 6.43M]
  |  Branch (3590:38): [True: 0, False: 6.43M]
  |  Branch (3590:51): [True: 0, False: 6.43M]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  6.43M|                  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.43M|               });
_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.43M|               for_each<N>([&]<size_t I>() {
 3590|  6.43M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 0, False: 6.43M]
  |  Branch (3590:38): [True: 0, False: 6.43M]
  |  Branch (3590:51): [True: 0, False: 6.43M]
  ------------------
 3591|      0|                     return;
 3592|      0|                  }
 3593|  6.43M|                  using V = std::variant_alternative_t<I, Variant>;
 3594|  6.43M|                  if constexpr (Trait<V>::value && !glaze_const_value_t<V>) {
 3595|  6.43M|                     auto copy_it{it};
 3596|  6.43M|                     const auto copy_depth{ctx.depth}; // rewound with `it`; see the note above
 3597|  6.43M|                     if (!std::holds_alternative<V>(value)) {
  ------------------
  |  Branch (3597:26): [True: 5.88M, False: 556k]
  ------------------
 3598|  5.88M|                        value = V{};
 3599|  5.88M|                     }
 3600|  6.43M|                     parse<JSON>::op<ws_handled<Options>()>(std::get<V>(value), ctx, it, end);
 3601|  6.43M|                     if (bool(ctx.error) && !charge_speculation(ctx, size_t(it - copy_it))) {
  ------------------
  |  Branch (3601:26): [True: 7.36k, False: 6.42M]
  |  Branch (3601:45): [True: 0, False: 7.36k]
  ------------------
 3602|      0|                        exhausted = true; // only rejected attempts are charged; see charge_speculation
 3603|      0|                     }
 3604|  6.43M|                     if (!bool(ctx.error)) {
  ------------------
  |  Branch (3604:26): [True: 6.42M, False: 7.36k]
  ------------------
 3605|  6.42M|                        found_match = true;
 3606|  6.42M|                     }
 3607|  7.36k|                     else if constexpr (not Options.null_terminated) {
 3608|  7.36k|                        constexpr bool is_complete_type =
 3609|  7.36k|                           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.36k, 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.36k|                        if constexpr (is_complete_type) {
 3612|  7.36k|                           if (ctx.error == error_code::end_reached && it > copy_it && not speculation_exhausted(ctx)) {
  ------------------
  |  Branch (3612:32): [True: 3.10k, False: 4.26k]
  |  Branch (3612:72): [True: 3.10k, False: 0]
  |  Branch (3612:88): [True: 3.10k, False: 0]
  ------------------
 3613|  3.10k|                              found_match = true;
 3614|  3.10k|                              ctx.error = error_code::none;
 3615|  3.10k|                           }
 3616|  4.26k|                           else {
 3617|  4.26k|                              it = copy_it;
 3618|  4.26k|                              rewind_depth<Options>(ctx, copy_depth);
 3619|  4.26k|                              if (non_const_idx + 1 < non_const_count && not exhausted &&
  ------------------
  |  Branch (3619:35): [True: 0, False: 4.26k]
  |  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.26k|                           }
 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.43M|                     ++non_const_idx;
 3643|  6.43M|                  }
 3644|  6.43M|               });
_ZN3glz5parseILj10EE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERdTkNS_10is_contextERNS_7contextERPKcS8_EEvOT0_OT1_OT2_T3_:
   49|  6.43M|      {
   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.43M|         else {
   60|  6.43M|            using V = std::remove_cvref_t<T>;
   61|  6.43M|            from<JSON, V>::template op<Opts>(std::forward<T>(value), std::forward<Ctx>(ctx), std::forward<It0>(it),
   62|  6.43M|                                             end);
   63|  6.43M|         }
   64|  6.43M|      }
_ZN3glz4fromILj10EdE2opITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEERPKcRdTkNS_10is_contextERNS_7contextES5_EEvOT1_OT2_OT0_T3_:
  763|  6.43M|      {
  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.43M|         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.43M|         else {
  797|       |// float128_t requires std::from_chars for floating-point, unavailable on older Apple platforms (iOS < 16.3)
  798|  6.43M|#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.43M|            {
  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.43M|               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.43M|                  else {
  842|  6.43M|                     auto [ptr, ec] = glz::from_chars<Opts.null_terminated>(it, end, value);
  843|  6.43M|                     if (ec != std::errc()) [[unlikely]] {
  ------------------
  |  Branch (843:26): [True: 4.26k, False: 6.43M]
  ------------------
  844|  4.26k|                        ctx.error = error_code::parse_number_failure;
  845|  4.26k|                        return;
  846|  4.26k|                     }
  847|  6.43M|                     it = ptr;
  848|  6.43M|                  }
  849|  6.43M|               }
  850|  6.43M|            }
  851|  6.43M|         }
  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.43M|         else {
  871|  6.43M|            if constexpr (not Opts.null_terminated) {
  872|  6.43M|               if (it == end) {
  ------------------
  |  Branch (872:20): [True: 3.10k, False: 6.43M]
  ------------------
  873|  3.10k|                  ctx.error = error_code::end_reached;
  874|  3.10k|                  return;
  875|  3.10k|               }
  876|  6.43M|            }
  877|  6.43M|         }
  878|  6.43M|      }
_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.43M|               for_each<N>([&]<size_t I>() {
 3590|  6.43M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 6.43M, False: 4.26k]
  |  Branch (3590:38): [True: 0, False: 4.26k]
  |  Branch (3590:51): [True: 0, False: 4.26k]
  ------------------
 3591|  6.43M|                     return;
 3592|  6.43M|                  }
 3593|  4.26k|                  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.26k|               });
_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.43M|               for_each<N>([&]<size_t I>() {
 3590|  6.43M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 6.43M, False: 4.26k]
  |  Branch (3590:38): [True: 0, False: 4.26k]
  |  Branch (3590:51): [True: 0, False: 4.26k]
  ------------------
 3591|  6.43M|                     return;
 3592|  6.43M|                  }
 3593|  4.26k|                  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.26k|               });
_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.43M|               for_each<N>([&]<size_t I>() {
 3590|  6.43M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 6.43M, False: 4.26k]
  |  Branch (3590:38): [True: 0, False: 4.26k]
  |  Branch (3590:51): [True: 0, False: 4.26k]
  ------------------
 3591|  6.43M|                     return;
 3592|  6.43M|                  }
 3593|  4.26k|                  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.26k|               });
_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.43M|               for_each<N>([&]<size_t I>() {
 3590|  6.43M|                  if (found_match || exhausted || variant_alternative_exhausted(ctx)) {
  ------------------
  |  Branch (3590:23): [True: 6.43M, False: 4.26k]
  |  Branch (3590:38): [True: 0, False: 4.26k]
  |  Branch (3590:51): [True: 0, False: 4.26k]
  ------------------
 3591|  6.43M|                     return;
 3592|  6.43M|                  }
 3593|  4.26k|                  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.26k|               });
_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|  20.5M|   {
   87|  20.5M|      return has_zero(chunk ^ repeat_byte8('"'));
   88|  20.5M|   }
_ZN3glz8has_zeroEm:
   81|  20.5M|   {
   82|  20.5M|      return (((chunk - 0x0101010101010101ull) & ~chunk) & 0x8080808080808080ull);
   83|  20.5M|   }
_ZN3glz11countr_zeroEm:
   29|  3.32M|   {
   30|       |#ifdef _MSC_VER
   31|       |      return std::countr_zero(x);
   32|       |#else
   33|  3.32M|#if __has_builtin(__builtin_ctzll)
   34|  3.32M|      return __builtin_ctzll(x);
   35|       |#else
   36|       |      return std::countr_zero(x);
   37|       |#endif
   38|  3.32M|#endif
   39|  3.32M|   }

_ZN3glz10comparitorIL_ZZNS_5matchITnNS_14string_literalEXtlNS2_ILm5EEEtlA5_cLc110ELc117ELc108ELc108EEEETnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS9_EEvOT1_OT2_T3_E1SELm4EcEEbPKSB_:
  245|  3.41k|   {
  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.41k|      else if constexpr (N == 4) {
  286|  3.41k|         static constexpr auto packed = pack<Str, 4>();
  287|  3.41k|         uint32_t in;
  288|  3.41k|         std::memcpy(&in, other, 4);
  289|       |         if constexpr (std::endian::native == std::endian::big) {
  290|       |            in = std::byteswap(in);
  291|       |         }
  292|  3.41k|         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.41k|   }

_ZN3glz10fast_float4spanIKcEC2Ev:
  438|  12.8M|  constexpr span() : ptr(nullptr), length(0) {}
_ZN3glz10fast_float10is_integerIcEEbT_:
 1481|  7.95k|fastfloat_really_inline constexpr bool is_integer(UC c) noexcept {
 1482|  7.95k|  return !(c > UC('9') || c < UC('0'));
  ------------------
  |  Branch (1482:12): [True: 3, False: 7.94k]
  |  Branch (1482:27): [True: 58, False: 7.89k]
  ------------------
 1483|  7.95k|}
_ZN3glz10fast_float11digit_valueIcEEmT_:
 1489|  33.3M|fastfloat_really_inline constexpr uint64_t digit_value(UC c) noexcept {
 1490|  33.3M|  return uint64_t(uint8_t(c) - uint8_t('0'));
 1491|  33.3M|}
_ZN3glz10fast_float4spanIKcEC2EPS2_m:
  436|  6.48M|  constexpr span(T const *_ptr, size_t _length) : ptr(_ptr), length(_length) {}
_ZN3glz10fast_float26loop_parse_if_eight_digitsERPKcS2_Rm:
 1679|  47.8k|                           uint64_t &i) {
 1680|       |  // optimizes better than parse_if_eight_digits_unrolled() for UC = char.
 1681|  5.32M|  while ((std::distance(p, pend) >= 8) &&
  ------------------
  |  Branch (1681:10): [True: 5.32M, False: 3.21k]
  ------------------
 1682|  5.32M|         is_made_of_eight_digits_fast(read8_to_u64(p))) {
  ------------------
  |  Branch (1682:10): [True: 5.28M, False: 44.6k]
  ------------------
 1683|  5.28M|    i = i * 100000000 +
 1684|  5.28M|        parse_eight_digits_unrolled(read8_to_u64(
 1685|  5.28M|            p)); // in rare cases, this will overflow, but that's ok
 1686|  5.28M|    p += 8;
 1687|  5.28M|  }
 1688|  47.8k|}
_ZN3glz10fast_float28is_made_of_eight_digits_fastEm:
 1597|  5.32M|is_made_of_eight_digits_fast(uint64_t val) noexcept {
 1598|  5.32M|  return !((((val + 0x4646464646464646) | (val - 0x3030303030303030)) &
 1599|  5.32M|            0x8080808080808080));
 1600|  5.32M|}
_ZN3glz10fast_float12read8_to_u64IcEEmPKT_:
 1503|  12.5M|read8_to_u64(UC const *chars) {
 1504|  12.5M|  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|  12.5M|  uint64_t val;
 1513|  12.5M|  ::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|  12.5M|  return val;
 1519|  12.5M|}
_ZN3glz10fast_float27parse_eight_digits_unrolledEm:
 1575|  7.20M|parse_eight_digits_unrolled(uint64_t val) {
 1576|  7.20M|  uint64_t const mask = 0x000000FF000000FF;
 1577|  7.20M|  uint64_t const mul1 = 0x000F424000000064; // 100 + (1000000ULL << 32)
 1578|  7.20M|  uint64_t const mul2 = 0x0000271000000001; // 1 + (10000ULL << 32)
 1579|  7.20M|  val -= 0x3030303030303030;
 1580|  7.20M|  val = (val * 10) + (val >> 8); // val = (val * 2561) >> 8;
 1581|  7.20M|  val = (((val & mask) * mul1) + (((val >> 16) & mask) * mul2)) >> 32;
 1582|  7.20M|  return uint32_t(val);
 1583|  7.20M|}
_ZNK3glz10fast_float4spanIKcE3lenEv:
  440|   184k|  constexpr size_t len() const noexcept { return length; }
_ZN3glz10fast_float19from_chars_advancedIdcEENS0_19from_chars_result_tIT0_EERNS0_22parsed_number_string_tIS3_EERT_:
 4249|  6.43M|from_chars_advanced(parsed_number_string_t<UC> &pns, T &value) noexcept {
 4250|       |
 4251|  6.43M|  static_assert(is_supported_float_type<T>::value,
 4252|  6.43M|                "only some floating-point types are supported");
 4253|  6.43M|  static_assert(is_supported_char_type<UC>::value,
 4254|  6.43M|                "only char, wchar_t, char16_t and char32_t are supported");
 4255|       |
 4256|  6.43M|  from_chars_result_t<UC> answer;
 4257|       |
 4258|  6.43M|  answer.ec = std::errc(); // be optimistic
 4259|  6.43M|  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.43M|  if (binary_format<T>::min_exponent_fast_path() <= pns.exponent &&
  ------------------
  |  Branch (4265:7): [True: 6.42M, False: 12.3k]
  ------------------
 4266|  6.42M|      pns.exponent <= binary_format<T>::max_exponent_fast_path() &&
  ------------------
  |  Branch (4266:7): [True: 6.38M, False: 33.0k]
  ------------------
 4267|  6.38M|      !pns.too_many_digits) {
  ------------------
  |  Branch (4267:7): [True: 6.35M, False: 35.9k]
  ------------------
 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.35M|    if (!cpp20_and_in_constexpr() && detail::rounds_to_nearest()) {
  ------------------
  |  Branch (4275:9): [True: 6.35M, Folded]
  |  Branch (4275:38): [True: 6.35M, False: 0]
  ------------------
 4276|       |      // We have that fegetround() == FE_TONEAREST.
 4277|       |      // Next is Clinger's fast path.
 4278|  6.35M|      if (pns.mantissa <= binary_format<T>::max_mantissa_fast_path()) {
  ------------------
  |  Branch (4278:11): [True: 6.34M, False: 3.21k]
  ------------------
 4279|  6.34M|        value = T(pns.mantissa);
 4280|  6.34M|        if (pns.exponent < 0) {
  ------------------
  |  Branch (4280:13): [True: 6.24k, False: 6.34M]
  ------------------
 4281|  6.24k|          value = value / binary_format<T>::exact_power_of_ten(-pns.exponent);
 4282|  6.34M|        } else {
 4283|  6.34M|          value = value * binary_format<T>::exact_power_of_ten(pns.exponent);
 4284|  6.34M|        }
 4285|  6.34M|        if (pns.negative) {
  ------------------
  |  Branch (4285:13): [True: 4.42k, False: 6.34M]
  ------------------
 4286|  4.42k|          value = -value;
 4287|  4.42k|        }
 4288|  6.34M|        return answer;
 4289|  6.34M|      }
 4290|  6.35M|    } 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.35M|  }
 4313|  84.5k|  adjusted_mantissa am =
 4314|  84.5k|      compute_float<binary_format<T>>(pns.exponent, pns.mantissa);
 4315|  84.5k|  if (pns.too_many_digits && am.power2 >= 0) {
  ------------------
  |  Branch (4315:7): [True: 68.2k, False: 16.2k]
  |  Branch (4315:30): [True: 68.2k, False: 0]
  ------------------
 4316|  68.2k|    if (am != compute_float<binary_format<T>>(pns.exponent, pns.mantissa + 1)) {
  ------------------
  |  Branch (4316:9): [True: 57.7k, False: 10.5k]
  ------------------
 4317|  57.7k|      am = compute_error<binary_format<T>>(pns.exponent, pns.mantissa);
 4318|  57.7k|    }
 4319|  68.2k|  }
 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.5k|  if (am.power2 < 0) {
  ------------------
  |  Branch (4323:7): [True: 57.7k, False: 26.7k]
  ------------------
 4324|  57.7k|    am = digit_comp<T>(pns, am);
 4325|  57.7k|  }
 4326|  84.5k|  to_float(pns.negative, am, value);
 4327|       |  // Test for over/underflow.
 4328|  84.5k|  if ((pns.mantissa != 0 && am.mantissa == 0 && am.power2 == 0) ||
  ------------------
  |  Branch (4328:8): [True: 83.3k, False: 1.14k]
  |  Branch (4328:29): [True: 6.72k, False: 76.6k]
  |  Branch (4328:49): [True: 303, False: 6.42k]
  ------------------
 4329|  84.2k|      am.power2 == binary_format<T>::infinite_power()) {
  ------------------
  |  Branch (4329:7): [True: 393, False: 83.8k]
  ------------------
 4330|    696|    answer.ec = std::errc::result_out_of_range;
 4331|    696|  }
 4332|  84.5k|  return answer;
 4333|  6.43M|}
_ZN3glz10fast_float13binary_formatIdE22min_exponent_fast_pathEv:
  695|  6.43M|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.43M|  return -22;
  700|  6.43M|#endif
  701|  6.43M|}
_ZN3glz10fast_float13binary_formatIdE22max_exponent_fast_pathEv:
  767|  6.42M|inline constexpr int binary_format<double>::max_exponent_fast_path() {
  768|  6.42M|  return 22;
  769|  6.42M|}
_ZN3glz10fast_float6detail17rounds_to_nearestEv:
 4129|  6.35M|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.35M|  static float volatile fmin = (std::numeric_limits<float>::min)();
 4151|  6.35M|  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.35M|#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.35M|  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.35M|}
_ZN3glz10fast_float13binary_formatIdE22max_mantissa_fast_pathEv:
  777|  6.35M|inline constexpr uint64_t binary_format<double>::max_mantissa_fast_path() {
  778|  6.35M|  return uint64_t(2) << mantissa_explicit_bits();
  779|  6.35M|}
_ZN3glz10fast_float13binary_formatIdE22mantissa_explicit_bitsEv:
  713|  7.36M|inline constexpr int binary_format<double>::mantissa_explicit_bits() {
  714|  7.36M|  return 52;
  715|  7.36M|}
_ZN3glz10fast_float13binary_formatIdE18exact_power_of_tenEl:
 1057|  6.34M|binary_format<double>::exact_power_of_ten(int64_t power) {
 1058|       |  // Work around clang bug https://godbolt.org/z/zedh7rrhc
 1059|  6.34M|  return (void)powers_of_ten[0], powers_of_ten[power];
 1060|  6.34M|}
_ZN3glz10fast_float13compute_floatINS0_13binary_formatIdEEEENS0_17adjusted_mantissaElm:
 2852|   152k|compute_float(int64_t q, uint64_t w) noexcept {
 2853|   152k|  adjusted_mantissa answer;
 2854|   152k|  if ((w == 0) || (q < binary::smallest_power_of_ten())) {
  ------------------
  |  Branch (2854:7): [True: 1.14k, False: 151k]
  |  Branch (2854:19): [True: 342, False: 151k]
  ------------------
 2855|  1.49k|    answer.power2 = 0;
 2856|  1.49k|    answer.mantissa = 0;
 2857|       |    // result should be zero
 2858|  1.49k|    return answer;
 2859|  1.49k|  }
 2860|   151k|  if (q > binary::largest_power_of_ten()) {
  ------------------
  |  Branch (2860:7): [True: 465, False: 150k]
  ------------------
 2861|       |    // we want to get infinity:
 2862|    465|    answer.power2 = binary::infinite_power();
 2863|    465|    answer.mantissa = 0;
 2864|    465|    return answer;
 2865|    465|  }
 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|   150k|  int lz = leading_zeroes(w);
 2871|   150k|  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|   150k|  value128 product =
 2880|   150k|      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|   150k|  int upperbit = int(product.high >> 63);
 2891|   150k|  int shift = upperbit + 64 - binary::mantissa_explicit_bits() - 3;
 2892|       |
 2893|   150k|  answer.mantissa = product.high >> shift;
 2894|       |
 2895|   150k|  answer.power2 = int32_t(detail::power(int32_t(q)) + upperbit - lz -
 2896|   150k|                          binary::minimum_exponent());
 2897|   150k|  if (answer.power2 <= 0) { // we have a subnormal?
  ------------------
  |  Branch (2897:7): [True: 10.9k, False: 139k]
  ------------------
 2898|       |    // Here have that answer.power2 <= 0 so -answer.power2 >= 0
 2899|  10.9k|    if (-answer.power2 + 1 >=
  ------------------
  |  Branch (2899:9): [True: 12, False: 10.9k]
  ------------------
 2900|  10.9k|        64) { // if we have more than 64 bits below the minimum exponent, you
 2901|       |              // have a zero for sure.
 2902|     12|      answer.power2 = 0;
 2903|     12|      answer.mantissa = 0;
 2904|       |      // result should be zero
 2905|     12|      return answer;
 2906|     12|    }
 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|  10.9k|  }
 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|   139k|  if ((product.low <= 1) && (q >= binary::min_exponent_round_to_even()) &&
  ------------------
  |  Branch (2931:7): [True: 32.4k, False: 107k]
  |  Branch (2931:29): [True: 29.3k, False: 3.08k]
  ------------------
 2932|  29.3k|      (q <= binary::max_exponent_round_to_even()) &&
  ------------------
  |  Branch (2932:7): [True: 27.0k, False: 2.29k]
  ------------------
 2933|  27.0k|      ((answer.mantissa & 3) == 1)) { // we may fall between two floats!
  ------------------
  |  Branch (2933:7): [True: 13.1k, False: 13.9k]
  ------------------
 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.1k|    if ((answer.mantissa << shift) == product.high) {
  ------------------
  |  Branch (2939:9): [True: 9.35k, False: 3.80k]
  ------------------
 2940|  9.35k|      answer.mantissa &= ~uint64_t(1); // flip it so that we do not round up
 2941|  9.35k|    }
 2942|  13.1k|  }
 2943|       |
 2944|   139k|  answer.mantissa += (answer.mantissa & 1); // round up
 2945|   139k|  answer.mantissa >>= 1;
 2946|   139k|  if (answer.mantissa >= (uint64_t(2) << binary::mantissa_explicit_bits())) {
  ------------------
  |  Branch (2946:7): [True: 5.89k, False: 133k]
  ------------------
 2947|  5.89k|    answer.mantissa = (uint64_t(1) << binary::mantissa_explicit_bits());
 2948|  5.89k|    answer.power2++; // undo previous addition
 2949|  5.89k|  }
 2950|       |
 2951|   139k|  answer.mantissa &= ~(uint64_t(1) << binary::mantissa_explicit_bits());
 2952|   139k|  if (answer.power2 >= binary::infinite_power()) { // infinity
  ------------------
  |  Branch (2952:7): [True: 27, False: 139k]
  ------------------
 2953|     27|    answer.power2 = binary::infinite_power();
 2954|     27|    answer.mantissa = 0;
 2955|     27|  }
 2956|   139k|  return answer;
 2957|   150k|}
_ZN3glz10fast_float17adjusted_mantissaC2Ev:
  568|   268k|  adjusted_mantissa() = default;
_ZN3glz10fast_float13binary_formatIdE21smallest_power_of_tenEv:
 1077|   151k|inline constexpr int binary_format<double>::smallest_power_of_ten() {
 1078|   151k|  return -342;
 1079|   151k|}
_ZN3glz10fast_float13binary_formatIdE20largest_power_of_tenEv:
 1068|   151k|template <> inline constexpr int binary_format<double>::largest_power_of_ten() {
 1069|   151k|  return 308;
 1070|   151k|}
_ZN3glz10fast_float14leading_zeroesEm:
  488|   242k|leading_zeroes(uint64_t input_num) {
  489|   242k|  assert(input_num > 0);
  ------------------
  |  Branch (489:3): [True: 242k, False: 0]
  ------------------
  490|   242k|  if (cpp20_and_in_constexpr()) {
  ------------------
  |  Branch (490:7): [Folded, False: 242k]
  ------------------
  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|   242k|  return __builtin_clzll(input_num);
  505|   242k|#endif
  506|   242k|}
_ZN3glz10fast_float29compute_product_approximationILi55EEENS0_8value128Elm:
 2771|   208k|compute_product_approximation(int64_t q, uint64_t w) {
 2772|   208k|  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|   208k|  value128 firstproduct =
 2777|   208k|      full_multiplication(w, powers::power_of_five_128[index]);
 2778|   208k|  static_assert((bit_precision >= 0) && (bit_precision <= 64),
 2779|   208k|                " precision should  be in (0,64]");
 2780|   208k|  constexpr uint64_t precision_mask =
 2781|   208k|      (bit_precision < 64) ? (uint64_t(0xFFFFFFFFFFFFFFFF) >> bit_precision)
  ------------------
  |  Branch (2781:7): [True: 0, Folded]
  ------------------
 2782|   208k|                           : uint64_t(0xFFFFFFFFFFFFFFFF);
 2783|   208k|  if ((firstproduct.high & precision_mask) ==
  ------------------
  |  Branch (2783:7): [True: 46.9k, False: 161k]
  ------------------
 2784|   208k|      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.9k|    value128 secondproduct =
 2789|  46.9k|        full_multiplication(w, powers::power_of_five_128[index + 1]);
 2790|  46.9k|    firstproduct.low += secondproduct.high;
 2791|  46.9k|    if (secondproduct.high > firstproduct.low) {
  ------------------
  |  Branch (2791:9): [True: 11.6k, False: 35.2k]
  ------------------
 2792|  11.6k|      firstproduct.high++;
 2793|  11.6k|    }
 2794|  46.9k|  }
 2795|   208k|  return firstproduct;
 2796|   208k|}
_ZN3glz10fast_float19full_multiplicationEmm:
  540|   255k|full_multiplication(uint64_t a, uint64_t b) {
  541|   255k|  if (cpp20_and_in_constexpr()) {
  ------------------
  |  Branch (541:7): [Folded, False: 255k]
  ------------------
  542|      0|    value128 answer;
  543|      0|    answer.low = umul128_generic(a, b, &answer.high);
  544|      0|    return answer;
  545|      0|  }
  546|   255k|  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|   255k|  answer.low = uint64_t(r);
  558|   255k|  answer.high = uint64_t(r >> 64);
  559|       |#else
  560|       |  answer.low = umul128_generic(a, b, &answer.high);
  561|       |#endif
  562|   255k|  return answer;
  563|   255k|}
_ZN3glz10fast_float8value128C2Ev:
  454|   255k|  constexpr value128() : low(0), high(0) {}
_ZN3glz10fast_float6detail5powerEi:
 2814|   208k|constexpr fastfloat_really_inline int32_t power(int32_t q) noexcept {
 2815|   208k|  return (((152170 + 65536) * q) >> 16) + 63;
 2816|   208k|}
_ZN3glz10fast_float13binary_formatIdE16minimum_exponentEv:
  742|   266k|template <> inline constexpr int binary_format<double>::minimum_exponent() {
  743|   266k|  return -1023;
  744|   266k|}
_ZN3glz10fast_float13binary_formatIdE26min_exponent_round_to_evenEv:
  733|  32.4k|inline constexpr int binary_format<double>::min_exponent_round_to_even() {
  734|  32.4k|  return -4;
  735|  32.4k|}
_ZN3glz10fast_float13binary_formatIdE26max_exponent_round_to_evenEv:
  723|  29.3k|inline constexpr int binary_format<double>::max_exponent_round_to_even() {
  724|  29.3k|  return 23;
  725|  29.3k|}
_ZNK3glz10fast_float17adjusted_mantissaneERKS1_:
  574|  68.2k|  constexpr bool operator!=(adjusted_mantissa const &o) const {
  575|  68.2k|    return mantissa != o.mantissa || power2 != o.power2;
  ------------------
  |  Branch (575:12): [True: 57.7k, False: 10.5k]
  |  Branch (575:38): [True: 0, False: 10.5k]
  ------------------
  576|  68.2k|  }
_ZN3glz10fast_float13compute_errorINS0_13binary_formatIdEEEENS0_17adjusted_mantissaElm:
 2837|  57.7k|compute_error(int64_t q, uint64_t w) noexcept {
 2838|  57.7k|  int lz = leading_zeroes(w);
 2839|  57.7k|  w <<= lz;
 2840|  57.7k|  value128 product =
 2841|  57.7k|      compute_product_approximation<binary::mantissa_explicit_bits() + 3>(q, w);
 2842|  57.7k|  return compute_error_scaled<binary>(q, product.high, lz);
 2843|  57.7k|}
_ZN3glz10fast_float20compute_error_scaledINS0_13binary_formatIdEEEENS0_17adjusted_mantissaElmi:
 2823|  57.7k|compute_error_scaled(int64_t q, uint64_t w, int lz) noexcept {
 2824|  57.7k|  int hilz = int(w >> 63) ^ 1;
 2825|  57.7k|  adjusted_mantissa answer;
 2826|  57.7k|  answer.mantissa = w << hilz;
 2827|  57.7k|  int bias = binary::mantissa_explicit_bits() - binary::minimum_exponent();
 2828|  57.7k|  answer.power2 = int32_t(detail::power(int32_t(q)) + bias - hilz - lz - 62 +
 2829|  57.7k|                          invalid_am_bias);
 2830|  57.7k|  return answer;
 2831|  57.7k|}
_ZN3glz10fast_float10digit_compIdcEENS0_17adjusted_mantissaERNS0_22parsed_number_string_tIT0_EES2_:
 4034|  57.7k|digit_comp(parsed_number_string_t<UC> &num, adjusted_mantissa am) noexcept {
 4035|       |  // remove the invalid exponent bias
 4036|  57.7k|  am.power2 -= invalid_am_bias;
 4037|       |
 4038|  57.7k|  int32_t sci_exp = scientific_exponent(num);
 4039|  57.7k|  size_t max_digits = binary_format<T>::max_digits();
 4040|  57.7k|  size_t digits = 0;
 4041|  57.7k|  bigint bigmant;
 4042|  57.7k|  parse_mantissa(bigmant, num, max_digits, digits);
 4043|       |  // can't underflow, since digits is at most max_digits.
 4044|  57.7k|  int32_t exponent = sci_exp + 1 - int32_t(digits);
 4045|  57.7k|  if (exponent >= 0) {
  ------------------
  |  Branch (4045:7): [True: 17.1k, False: 40.6k]
  ------------------
 4046|  17.1k|    return positive_digit_comp<T>(bigmant, exponent);
 4047|  40.6k|  } else {
 4048|  40.6k|    return negative_digit_comp<T>(bigmant, am, exponent);
 4049|  40.6k|  }
 4050|  57.7k|}
_ZN3glz10fast_float19scientific_exponentIcEEiRNS0_22parsed_number_string_tIT_EE:
 3640|  57.7k|scientific_exponent(parsed_number_string_t<UC> &num) noexcept {
 3641|  57.7k|  uint64_t mantissa = num.mantissa;
 3642|  57.7k|  int32_t exponent = int32_t(num.exponent);
 3643|   288k|  while (mantissa >= 10000) {
  ------------------
  |  Branch (3643:10): [True: 231k, False: 57.7k]
  ------------------
 3644|   231k|    mantissa /= 10000;
 3645|   231k|    exponent += 4;
 3646|   231k|  }
 3647|   115k|  while (mantissa >= 100) {
  ------------------
  |  Branch (3647:10): [True: 57.7k, False: 57.7k]
  ------------------
 3648|  57.7k|    mantissa /= 100;
 3649|  57.7k|    exponent += 2;
 3650|  57.7k|  }
 3651|  57.7k|  while (mantissa >= 10) {
  ------------------
  |  Branch (3651:10): [True: 0, False: 57.7k]
  ------------------
 3652|      0|    mantissa /= 10;
 3653|      0|    exponent += 1;
 3654|      0|  }
 3655|  57.7k|  return exponent;
 3656|  57.7k|}
_ZN3glz10fast_float13binary_formatIdE10max_digitsEv:
 1085|  57.7k|template <> inline constexpr size_t binary_format<double>::max_digits() {
 1086|  57.7k|  return 769;
 1087|  57.7k|}
_ZN3glz10fast_float6bigintC2Ev:
 3399|  57.7k|  GLZ_FASTFLOAT_CONSTEXPR20 bigint() : vec() {}
_ZN3glz10fast_float8stackvecILt62EEC2Ev:
 3006|   590k|  stackvec() = default;
_ZN3glz10fast_float14parse_mantissaIcEEvRNS0_6bigintERNS0_22parsed_number_string_tIT_EEmRm:
 3859|  57.7k|               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.7k|  size_t counter = 0;
 3864|  57.7k|  digits = 0;
 3865|  57.7k|  limb value = 0;
 3866|  57.7k|#ifdef GLZ_FASTFLOAT_64BIT_LIMB
 3867|  57.7k|  size_t step = 19;
 3868|       |#else
 3869|       |  size_t step = 9;
 3870|       |#endif
 3871|       |
 3872|       |  // process all integer digits.
 3873|  57.7k|  UC const *p = num.integer.ptr;
 3874|  57.7k|  UC const *pend = p + num.integer.len();
 3875|  57.7k|  skip_zeros(p, pend);
 3876|       |  // process all digits, in increments of step per loop
 3877|   636k|  while (p != pend) {
  ------------------
  |  Branch (3877:10): [True: 591k, False: 45.0k]
  ------------------
 3878|  1.69M|    while ((std::distance(p, pend) >= 8) && (step - counter >= 8) &&
  ------------------
  |  Branch (3878:12): [True: 1.63M, False: 63.7k]
  |  Branch (3878:45): [True: 1.11M, False: 519k]
  ------------------
 3879|  1.11M|           (max_digits - digits >= 8)) {
  ------------------
  |  Branch (3879:12): [True: 1.10M, False: 8.67k]
  ------------------
 3880|  1.10M|      parse_eight_digits(p, value, counter, digits);
 3881|  1.10M|    }
 3882|  2.28M|    while (counter < step && p != pend && digits < max_digits) {
  ------------------
  |  Branch (3882:12): [True: 1.74M, False: 538k]
  |  Branch (3882:30): [True: 1.69M, False: 44.3k]
  |  Branch (3882:43): [True: 1.69M, False: 9.09k]
  ------------------
 3883|  1.69M|      parse_one_digit(p, value, counter, digits);
 3884|  1.69M|    }
 3885|   591k|    if (digits == max_digits) {
  ------------------
  |  Branch (3885:9): [True: 12.7k, False: 578k]
  ------------------
 3886|       |      // add the temporary value, then check if we've truncated any digits
 3887|  12.7k|      add_native(result, limb(powers_of_ten_uint64[counter]), value);
 3888|  12.7k|      bool truncated = is_truncated(p, pend);
 3889|  12.7k|      if (num.fraction.ptr != nullptr) {
  ------------------
  |  Branch (3889:11): [True: 9.94k, False: 2.76k]
  ------------------
 3890|  9.94k|        truncated |= is_truncated(num.fraction);
 3891|  9.94k|      }
 3892|  12.7k|      if (truncated) {
  ------------------
  |  Branch (3892:11): [True: 7.24k, False: 5.46k]
  ------------------
 3893|  7.24k|        round_up_bigint(result, digits);
 3894|  7.24k|      }
 3895|  12.7k|      return;
 3896|   578k|    } else {
 3897|   578k|      add_native(result, limb(powers_of_ten_uint64[counter]), value);
 3898|   578k|      counter = 0;
 3899|   578k|      value = 0;
 3900|   578k|    }
 3901|   591k|  }
 3902|       |
 3903|       |  // add our fraction digits, if they're available.
 3904|  45.0k|  if (num.fraction.ptr != nullptr) {
  ------------------
  |  Branch (3904:7): [True: 25.5k, False: 19.4k]
  ------------------
 3905|  25.5k|    p = num.fraction.ptr;
 3906|  25.5k|    pend = p + num.fraction.len();
 3907|  25.5k|    if (digits == 0) {
  ------------------
  |  Branch (3907:9): [True: 4.24k, False: 21.3k]
  ------------------
 3908|  4.24k|      skip_zeros(p, pend);
 3909|  4.24k|    }
 3910|       |    // process all digits, in increments of step per loop
 3911|   441k|    while (p != pend) {
  ------------------
  |  Branch (3911:12): [True: 425k, False: 15.8k]
  ------------------
 3912|  1.23M|      while ((std::distance(p, pend) >= 8) && (step - counter >= 8) &&
  ------------------
  |  Branch (3912:14): [True: 1.21M, False: 24.4k]
  |  Branch (3912:47): [True: 818k, False: 396k]
  ------------------
 3913|   818k|             (max_digits - digits >= 8)) {
  ------------------
  |  Branch (3913:14): [True: 814k, False: 4.14k]
  ------------------
 3914|   814k|        parse_eight_digits(p, value, counter, digits);
 3915|   814k|      }
 3916|  1.69M|      while (counter < step && p != pend && digits < max_digits) {
  ------------------
  |  Branch (3916:14): [True: 1.28M, False: 403k]
  |  Branch (3916:32): [True: 1.27M, False: 15.0k]
  |  Branch (3916:45): [True: 1.26M, False: 6.59k]
  ------------------
 3917|  1.26M|        parse_one_digit(p, value, counter, digits);
 3918|  1.26M|      }
 3919|   425k|      if (digits == max_digits) {
  ------------------
  |  Branch (3919:11): [True: 9.78k, False: 415k]
  ------------------
 3920|       |        // add the temporary value, then check if we've truncated any digits
 3921|  9.78k|        add_native(result, limb(powers_of_ten_uint64[counter]), value);
 3922|  9.78k|        bool truncated = is_truncated(p, pend);
 3923|  9.78k|        if (truncated) {
  ------------------
  |  Branch (3923:13): [True: 6.25k, False: 3.53k]
  ------------------
 3924|  6.25k|          round_up_bigint(result, digits);
 3925|  6.25k|        }
 3926|  9.78k|        return;
 3927|   415k|      } else {
 3928|   415k|        add_native(result, limb(powers_of_ten_uint64[counter]), value);
 3929|   415k|        counter = 0;
 3930|   415k|        value = 0;
 3931|   415k|      }
 3932|   425k|    }
 3933|  25.5k|  }
 3934|       |
 3935|  35.2k|  if (counter != 0) {
  ------------------
  |  Branch (3935:7): [True: 0, False: 35.2k]
  ------------------
 3936|      0|    add_native(result, limb(powers_of_ten_uint64[counter]), value);
 3937|      0|  }
 3938|  35.2k|}
_ZN3glz10fast_float10skip_zerosIcEEvRPKT_S4_:
 3773|  62.0k|skip_zeros(UC const *&first, UC const *last) noexcept {
 3774|  62.0k|  uint64_t val;
 3775|  63.5k|  while (!cpp20_and_in_constexpr() &&
  ------------------
  |  Branch (3775:10): [True: 63.5k, Folded]
  ------------------
 3776|  63.5k|         std::distance(first, last) >= int_cmp_len<UC>()) {
  ------------------
  |  Branch (3776:10): [True: 52.6k, False: 10.9k]
  ------------------
 3777|  52.6k|    ::memcpy(&val, first, sizeof(uint64_t));
 3778|  52.6k|    if (val != int_cmp_zeros<UC>()) {
  ------------------
  |  Branch (3778:9): [True: 51.1k, False: 1.55k]
  ------------------
 3779|  51.1k|      break;
 3780|  51.1k|    }
 3781|  1.55k|    first += int_cmp_len<UC>();
 3782|  1.55k|  }
 3783|  72.1k|  while (first != last) {
  ------------------
  |  Branch (3783:10): [True: 67.8k, False: 4.24k]
  ------------------
 3784|  67.8k|    if (*first != UC('0')) {
  ------------------
  |  Branch (3784:9): [True: 57.7k, False: 10.1k]
  ------------------
 3785|  57.7k|      break;
 3786|  57.7k|    }
 3787|  10.1k|    first++;
 3788|  10.1k|  }
 3789|  62.0k|}
_ZN3glz10fast_float11int_cmp_lenIcEEiv:
 1180|   563k|template <typename UC> constexpr int int_cmp_len() {
 1181|   563k|  return sizeof(uint64_t) / sizeof(UC);
 1182|   563k|}
_ZN3glz10fast_float13int_cmp_zerosIcEEmv:
 1170|   291k|template <typename UC> constexpr uint64_t int_cmp_zeros() {
 1171|   291k|  static_assert((sizeof(UC) == 1) || (sizeof(UC) == 2) || (sizeof(UC) == 4),
 1172|   291k|                "Unsupported character size");
 1173|   291k|  return (sizeof(UC) == 1) ? 0x3030303030303030
  ------------------
  |  Branch (1173:10): [True: 291k, Folded]
  ------------------
 1174|   291k|         : (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|   291k|}
_ZN3glz10fast_float18parse_eight_digitsIcEEvRPKT_RmS6_S6_:
 3824|  1.92M|                   size_t &count) noexcept {
 3825|  1.92M|  value = value * 100000000 + parse_eight_digits_unrolled(p);
 3826|  1.92M|  p += 8;
 3827|  1.92M|  counter += 8;
 3828|  1.92M|  count += 8;
 3829|  1.92M|}
_ZN3glz10fast_float27parse_eight_digits_unrolledIcEEjPKT_:
 1588|  1.92M|parse_eight_digits_unrolled(UC const *chars) noexcept {
 1589|  1.92M|  if (cpp20_and_in_constexpr() || !has_simd_opt<UC>()) {
  ------------------
  |  Branch (1589:7): [Folded, False: 0]
  |  Branch (1589:35): [True: 0, Folded]
  ------------------
 1590|  1.92M|    return parse_eight_digits_unrolled(read8_to_u64(chars)); // truncation okay
 1591|  1.92M|  }
 1592|      0|  return parse_eight_digits_unrolled(simd_read8_to_u64(chars));
 1593|  1.92M|}
_ZN3glz10fast_float15parse_one_digitIcEEvRPKT_RmS6_S6_:
 3834|  2.95M|                size_t &count) noexcept {
 3835|  2.95M|  value = value * 10 + limb(*p - UC('0'));
 3836|  2.95M|  p++;
 3837|  2.95M|  counter++;
 3838|  2.95M|  count++;
 3839|  2.95M|}
_ZN3glz10fast_float10add_nativeERNS0_6bigintEmm:
 3842|  1.03M|add_native(bigint &big, limb power, limb value) noexcept {
 3843|  1.03M|  big.mul(power);
 3844|  1.03M|  big.add(value);
 3845|  1.03M|}
_ZN3glz10fast_float6bigint3mulEm:
 3552|  1.03M|  GLZ_FASTFLOAT_CONSTEXPR20 bool mul(limb y) noexcept { return small_mul(vec, y); }
_ZN3glz10fast_float9small_mulILt62EEEbRNS0_8stackvecIXT_EEEm:
 3249|  1.75M|                                            limb y) noexcept {
 3250|  1.75M|  limb carry = 0;
 3251|  28.9M|  for (size_t index = 0; index < vec.len(); index++) {
  ------------------
  |  Branch (3251:26): [True: 27.2M, False: 1.75M]
  ------------------
 3252|  27.2M|    vec[index] = scalar_mul(vec[index], y, carry);
 3253|  27.2M|  }
 3254|  1.75M|  if (carry != 0) {
  ------------------
  |  Branch (3254:7): [True: 1.58M, False: 171k]
  ------------------
 3255|  1.58M|    GLZ_FASTFLOAT_TRY(vec.try_push(carry));
  ------------------
  |  |  354|  1.58M|  {                                                                            \
  |  |  355|  1.58M|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 1.58M]
  |  |  ------------------
  |  |  356|  1.58M|      return false;                                                            \
  |  |  357|  1.58M|  }
  ------------------
 3256|  1.58M|  }
 3257|  1.75M|  return true;
 3258|  1.75M|}
_ZNK3glz10fast_float8stackvecILt62EE3lenEv:
 3039|  36.7M|  constexpr size_t len() const noexcept { return length; }
_ZN3glz10fast_float10scalar_mulEmmRm:
 3196|  27.2M|scalar_mul(limb x, limb y, limb &carry) noexcept {
 3197|  27.2M|#ifdef GLZ_FASTFLOAT_64BIT_LIMB
 3198|  27.2M|#if defined(__SIZEOF_INT128__)
 3199|       |  // GCC and clang both define it as an extension.
 3200|  27.2M|  __uint128_t z = __uint128_t(x) * __uint128_t(y) + __uint128_t(carry);
 3201|  27.2M|  carry = limb(z >> limb_bits);
 3202|  27.2M|  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|  27.2M|}
_ZN3glz10fast_float8stackvecILt62EEixEm:
 3017|  67.1M|  GLZ_FASTFLOAT_CONSTEXPR14 limb &operator[](size_t index) noexcept {
 3018|  67.1M|    GLZ_FASTFLOAT_DEBUG_ASSERT(index < length);
  ------------------
  |  |  349|  67.1M|  { ((void)(x)); }
  ------------------
 3019|  67.1M|    return data[index];
 3020|  67.1M|  }
_ZN3glz10fast_float8stackvecILt62EE8try_pushEm:
 3052|  1.66M|  GLZ_FASTFLOAT_CONSTEXPR14 bool try_push(limb value) noexcept {
 3053|  1.66M|    if (len() < capacity()) {
  ------------------
  |  Branch (3053:9): [True: 1.66M, False: 0]
  ------------------
 3054|  1.66M|      push_unchecked(value);
 3055|  1.66M|      return true;
 3056|  1.66M|    } else {
 3057|      0|      return false;
 3058|      0|    }
 3059|  1.66M|  }
_ZNK3glz10fast_float8stackvecILt62EE8capacityEv:
 3043|  2.80M|  constexpr size_t capacity() const noexcept { return size; }
_ZN3glz10fast_float8stackvecILt62EE14push_uncheckedEm:
 3046|  1.70M|  GLZ_FASTFLOAT_CONSTEXPR14 void push_unchecked(limb value) noexcept {
 3047|  1.70M|    data[length] = value;
 3048|  1.70M|    length++;
 3049|  1.70M|  }
_ZN3glz10fast_float6bigint3addEm:
 3554|  1.03M|  GLZ_FASTFLOAT_CONSTEXPR20 bool add(limb y) noexcept { return small_add(vec, y); }
_ZN3glz10fast_float9small_addILt62EEEbRNS0_8stackvecIXT_EEEm:
 3242|  1.03M|small_add(stackvec<size> &vec, limb y) noexcept {
 3243|  1.03M|  return small_add_from(vec, y, 0);
 3244|  1.03M|}
_ZN3glz10fast_float14small_add_fromILt62EEEbRNS0_8stackvecIXT_EEEmm:
 3224|  1.03M|                                                 size_t start) noexcept {
 3225|  1.03M|  size_t index = start;
 3226|  1.03M|  limb carry = y;
 3227|  1.03M|  bool overflow;
 3228|  1.35M|  while (carry != 0 && index < vec.len()) {
  ------------------
  |  Branch (3228:10): [True: 392k, False: 967k]
  |  Branch (3228:24): [True: 329k, False: 63.0k]
  ------------------
 3229|   329k|    vec[index] = scalar_add(vec[index], carry, overflow);
 3230|   329k|    carry = limb(overflow);
 3231|   329k|    index += 1;
 3232|   329k|  }
 3233|  1.03M|  if (carry != 0) {
  ------------------
  |  Branch (3233:7): [True: 63.0k, False: 967k]
  ------------------
 3234|  63.0k|    GLZ_FASTFLOAT_TRY(vec.try_push(carry));
  ------------------
  |  |  354|  63.0k|  {                                                                            \
  |  |  355|  63.0k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 63.0k]
  |  |  ------------------
  |  |  356|  63.0k|      return false;                                                            \
  |  |  357|  63.0k|  }
  ------------------
 3235|  63.0k|  }
 3236|  1.03M|  return true;
 3237|  1.03M|}
_ZN3glz10fast_float10scalar_addEmmRb:
 3176|  7.84M|scalar_add(limb x, limb y, bool &overflow) noexcept {
 3177|  7.84M|  limb z;
 3178|       |// gcc and clang
 3179|  7.84M|#if defined(__has_builtin)
 3180|  7.84M|#if __has_builtin(__builtin_add_overflow)
 3181|  7.84M|  if (!cpp20_and_in_constexpr()) {
  ------------------
  |  Branch (3181:7): [True: 7.84M, Folded]
  ------------------
 3182|  7.84M|    overflow = __builtin_add_overflow(x, y, &z);
 3183|  7.84M|    return z;
 3184|  7.84M|  }
 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.84M|}
_ZN3glz10fast_float12is_truncatedIcEEbPKT_S4_:
 3795|  32.4k|is_truncated(UC const *first, UC const *last) noexcept {
 3796|       |  // do 8-bit optimizations, can just compare to 8 literal 0s.
 3797|  32.4k|  uint64_t val;
 3798|   265k|  while (!cpp20_and_in_constexpr() &&
  ------------------
  |  Branch (3798:10): [True: 265k, Folded]
  ------------------
 3799|   265k|         std::distance(first, last) >= int_cmp_len<UC>()) {
  ------------------
  |  Branch (3799:10): [True: 238k, False: 26.8k]
  ------------------
 3800|   238k|    ::memcpy(&val, first, sizeof(uint64_t));
 3801|   238k|    if (val != int_cmp_zeros<UC>()) {
  ------------------
  |  Branch (3801:9): [True: 5.54k, False: 233k]
  ------------------
 3802|  5.54k|      return true;
 3803|  5.54k|    }
 3804|   233k|    first += int_cmp_len<UC>();
 3805|   233k|  }
 3806|  68.7k|  while (first != last) {
  ------------------
  |  Branch (3806:10): [True: 53.2k, False: 15.4k]
  ------------------
 3807|  53.2k|    if (*first != UC('0')) {
  ------------------
  |  Branch (3807:9): [True: 11.4k, False: 41.8k]
  ------------------
 3808|  11.4k|      return true;
 3809|  11.4k|    }
 3810|  41.8k|    ++first;
 3811|  41.8k|  }
 3812|  15.4k|  return false;
 3813|  26.8k|}
_ZN3glz10fast_float12is_truncatedIcEEbNS0_4spanIKT_EE:
 3817|  9.94k|is_truncated(span<UC const> s) noexcept {
 3818|  9.94k|  return is_truncated(s.ptr, s.ptr + s.len());
 3819|  9.94k|}
_ZN3glz10fast_float15round_up_bigintERNS0_6bigintERm:
 3848|  13.5k|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.5k|  add_native(big, 10, 1);
 3852|  13.5k|  count++;
 3853|  13.5k|}
_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.7k|  GLZ_FASTFLOAT_CONSTEXPR20 bool pow5(uint32_t exp) noexcept {
 3561|       |    // multiply by a power of 5
 3562|  57.7k|    size_t large_length = sizeof(large_power_of_5) / sizeof(limb);
 3563|  57.7k|    limb_span large = limb_span(large_power_of_5, large_length);
 3564|   180k|    while (exp >= large_step) {
  ------------------
  |  Branch (3564:12): [True: 123k, False: 57.7k]
  ------------------
 3565|   123k|      GLZ_FASTFLOAT_TRY(large_mul(vec, large));
  ------------------
  |  |  354|   123k|  {                                                                            \
  |  |  355|   123k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 123k]
  |  |  ------------------
  |  |  356|   123k|      return false;                                                            \
  |  |  357|   123k|  }
  ------------------
 3566|   123k|      exp -= large_step;
 3567|   123k|    }
 3568|  57.7k|#ifdef GLZ_FASTFLOAT_64BIT_LIMB
 3569|  57.7k|    uint32_t small_step = 27;
 3570|  57.7k|    limb max_native = 7450580596923828125UL;
 3571|       |#else
 3572|       |    uint32_t small_step = 13;
 3573|       |    limb max_native = 1220703125U;
 3574|       |#endif
 3575|   121k|    while (exp >= small_step) {
  ------------------
  |  Branch (3575:12): [True: 64.0k, False: 57.7k]
  ------------------
 3576|  64.0k|      GLZ_FASTFLOAT_TRY(small_mul(vec, max_native));
  ------------------
  |  |  354|  64.0k|  {                                                                            \
  |  |  355|  64.0k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 64.0k]
  |  |  ------------------
  |  |  356|  64.0k|      return false;                                                            \
  |  |  357|  64.0k|  }
  ------------------
 3577|  64.0k|      exp -= small_step;
 3578|  64.0k|    }
 3579|  57.7k|    if (exp != 0) {
  ------------------
  |  Branch (3579:9): [True: 49.8k, False: 7.89k]
  ------------------
 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.8k|      GLZ_FASTFLOAT_TRY(small_mul(
  ------------------
  |  |  354|  49.8k|  {                                                                            \
  |  |  355|  49.8k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 49.8k]
  |  |  ------------------
  |  |  356|  49.8k|      return false;                                                            \
  |  |  357|  49.8k|  }
  ------------------
 3584|  49.8k|          vec, limb(((void)small_power_of_5[0], small_power_of_5[exp]))));
 3585|  49.8k|    }
 3586|       |
 3587|  57.7k|    return true;
 3588|  57.7k|  }
_ZN3glz10fast_float4spanImEC2EPKmm:
  436|   796k|  constexpr span(T const *_ptr, size_t _length) : ptr(_ptr), length(_length) {}
_ZN3glz10fast_float9large_mulILt62EEEbRNS0_8stackvecIXT_EEENS0_4spanImEE:
 3329|   123k|GLZ_FASTFLOAT_CONSTEXPR20 bool large_mul(stackvec<size> &x, limb_span y) noexcept {
 3330|   123k|  if (y.len() == 1) {
  ------------------
  |  Branch (3330:7): [True: 0, False: 123k]
  ------------------
 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|   123k|  } else {
 3333|   123k|    GLZ_FASTFLOAT_TRY(long_mul(x, y));
  ------------------
  |  |  354|   123k|  {                                                                            \
  |  |  355|   123k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 123k]
  |  |  ------------------
  |  |  356|   123k|      return false;                                                            \
  |  |  357|   123k|  }
  ------------------
 3334|   123k|  }
 3335|   123k|  return true;
 3336|   123k|}
_ZNK3glz10fast_float4spanImE3lenEv:
  440|  9.51M|  constexpr size_t len() const noexcept { return length; }
_ZNK3glz10fast_float4spanImEixEm:
  442|  5.95M|  GLZ_FASTFLOAT_CONSTEXPR14 const T &operator[](size_t index) const noexcept {
  443|  5.95M|    GLZ_FASTFLOAT_DEBUG_ASSERT(index < length);
  ------------------
  |  |  349|  5.95M|  { ((void)(x)); }
  ------------------
  444|  5.95M|    return ptr[index];
  445|  5.95M|  }
_ZN3glz10fast_float8long_mulILt62EEEbRNS0_8stackvecIXT_EEENS0_4spanImEE:
 3301|   123k|GLZ_FASTFLOAT_CONSTEXPR20 bool long_mul(stackvec<size> &x, limb_span y) noexcept {
 3302|   123k|  limb_span xs = limb_span(x.data, x.len());
 3303|   123k|  stackvec<size> z(xs);
 3304|   123k|  limb_span zs = limb_span(z.data, z.len());
 3305|       |
 3306|   123k|  if (y.len() != 0) {
  ------------------
  |  Branch (3306:7): [True: 123k, False: 0]
  ------------------
 3307|   123k|    limb y0 = y[0];
 3308|   123k|    GLZ_FASTFLOAT_TRY(small_mul(x, y0));
  ------------------
  |  |  354|   123k|  {                                                                            \
  |  |  355|   123k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 123k]
  |  |  ------------------
  |  |  356|   123k|      return false;                                                            \
  |  |  357|   123k|  }
  ------------------
 3309|   615k|    for (size_t index = 1; index < y.len(); index++) {
  ------------------
  |  Branch (3309:28): [True: 492k, False: 123k]
  ------------------
 3310|   492k|      limb yi = y[index];
 3311|   492k|      stackvec<size> zi;
 3312|   492k|      if (yi != 0) {
  ------------------
  |  Branch (3312:11): [True: 492k, False: 0]
  ------------------
 3313|       |        // re-use the same buffer throughout
 3314|   492k|        zi.set_len(0);
 3315|   492k|        GLZ_FASTFLOAT_TRY(zi.try_extend(zs));
  ------------------
  |  |  354|   492k|  {                                                                            \
  |  |  355|   492k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 492k]
  |  |  ------------------
  |  |  356|   492k|      return false;                                                            \
  |  |  357|   492k|  }
  ------------------
 3316|   492k|        GLZ_FASTFLOAT_TRY(small_mul(zi, yi));
  ------------------
  |  |  354|   492k|  {                                                                            \
  |  |  355|   492k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 492k]
  |  |  ------------------
  |  |  356|   492k|      return false;                                                            \
  |  |  357|   492k|  }
  ------------------
 3317|   492k|        limb_span zis = limb_span(zi.data, zi.len());
 3318|   492k|        GLZ_FASTFLOAT_TRY(large_add_from(x, zis, index));
  ------------------
  |  |  354|   492k|  {                                                                            \
  |  |  355|   492k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 492k]
  |  |  ------------------
  |  |  356|   492k|      return false;                                                            \
  |  |  357|   492k|  }
  ------------------
 3319|   492k|      }
 3320|   492k|    }
 3321|   123k|  }
 3322|       |
 3323|   123k|  x.normalize();
 3324|   123k|  return true;
 3325|   123k|}
_ZN3glz10fast_float8stackvecILt62EEC2ENS0_4spanImEE:
 3013|   123k|  GLZ_FASTFLOAT_CONSTEXPR20 stackvec(limb_span s) {
 3014|   123k|    GLZ_FASTFLOAT_ASSERT(try_extend(s));
  ------------------
  |  |  344|   123k|  { ((void)(x)); }
  ------------------
 3015|   123k|  }
_ZN3glz10fast_float8stackvecILt62EE7set_lenEm:
 3035|  1.63M|  GLZ_FASTFLOAT_CONSTEXPR14 void set_len(size_t len) noexcept {
 3036|  1.63M|    length = uint16_t(len);
 3037|  1.63M|  }
_ZN3glz10fast_float8stackvecILt62EE10try_extendENS0_4spanImEE:
 3069|   615k|  GLZ_FASTFLOAT_CONSTEXPR20 bool try_extend(limb_span s) noexcept {
 3070|   615k|    if (len() + s.len() <= capacity()) {
  ------------------
  |  Branch (3070:9): [True: 615k, False: 0]
  ------------------
 3071|   615k|      extend_unchecked(s);
 3072|   615k|      return true;
 3073|   615k|    } else {
 3074|      0|      return false;
 3075|      0|    }
 3076|   615k|  }
_ZN3glz10fast_float8stackvecILt62EE16extend_uncheckedENS0_4spanImEE:
 3062|   615k|  GLZ_FASTFLOAT_CONSTEXPR20 void extend_unchecked(limb_span s) noexcept {
 3063|   615k|    limb *ptr = data + length;
 3064|   615k|    std::copy_n(s.ptr, s.len(), ptr);
 3065|   615k|    set_len(len() + s.len());
 3066|   615k|  }
_ZN3glz10fast_float14large_add_fromILt62EEEbRNS0_8stackvecIXT_EEENS0_4spanImEEm:
 3264|   492k|                                          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|   492k|  if (x.len() < start || y.len() > x.len() - start) {
  ------------------
  |  Branch (3267:7): [True: 0, False: 492k]
  |  Branch (3267:26): [True: 487k, False: 4.39k]
  ------------------
 3268|   487k|    GLZ_FASTFLOAT_TRY(x.try_resize(y.len() + start, 0));
  ------------------
  |  |  354|   487k|  {                                                                            \
  |  |  355|   487k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 487k]
  |  |  ------------------
  |  |  356|   487k|      return false;                                                            \
  |  |  357|   487k|  }
  ------------------
 3269|   487k|  }
 3270|       |
 3271|   492k|  bool carry = false;
 3272|  5.82M|  for (size_t index = 0; index < y.len(); index++) {
  ------------------
  |  Branch (3272:26): [True: 5.33M, False: 492k]
  ------------------
 3273|  5.33M|    limb xi = x[index + start];
 3274|  5.33M|    limb yi = y[index];
 3275|  5.33M|    bool c1 = false;
 3276|  5.33M|    bool c2 = false;
 3277|  5.33M|    xi = scalar_add(xi, yi, c1);
 3278|  5.33M|    if (carry) {
  ------------------
  |  Branch (3278:9): [True: 2.17M, False: 3.15M]
  ------------------
 3279|  2.17M|      xi = scalar_add(xi, 1, c2);
 3280|  2.17M|    }
 3281|  5.33M|    x[index + start] = xi;
 3282|  5.33M|    carry = c1 | c2;
 3283|  5.33M|  }
 3284|       |
 3285|       |  // handle overflow
 3286|   492k|  if (carry) {
  ------------------
  |  Branch (3286:7): [True: 0, False: 492k]
  ------------------
 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|   492k|  return true;
 3290|   492k|}
_ZN3glz10fast_float8stackvecILt62EE10try_resizeEmm:
 3095|   487k|  GLZ_FASTFLOAT_CONSTEXPR20 bool try_resize(size_t new_len, limb value) noexcept {
 3096|   487k|    if (new_len > capacity()) {
  ------------------
  |  Branch (3096:9): [True: 0, False: 487k]
  ------------------
 3097|      0|      return false;
 3098|   487k|    } else {
 3099|   487k|      resize_unchecked(new_len, value);
 3100|   487k|      return true;
 3101|   487k|    }
 3102|   487k|  }
_ZN3glz10fast_float8stackvecILt62EE16resize_uncheckedEmm:
 3082|   487k|  void resize_unchecked(size_t new_len, limb value) noexcept {
 3083|   487k|    if (new_len > len()) {
  ------------------
  |  Branch (3083:9): [True: 487k, False: 0]
  ------------------
 3084|   487k|      size_t count = new_len - len();
 3085|   487k|      limb *first = data + len();
 3086|   487k|      limb *last = first + count;
 3087|   487k|      ::std::fill(first, last, value);
 3088|   487k|      set_len(new_len);
 3089|   487k|    } else {
 3090|      0|      set_len(new_len);
 3091|      0|    }
 3092|   487k|  }
_ZN3glz10fast_float8stackvecILt62EE9normalizeEv:
 3118|   163k|  GLZ_FASTFLOAT_CONSTEXPR14 void normalize() noexcept {
 3119|   163k|    while (len() > 0 && rindex(0) == 0) {
  ------------------
  |  Branch (3119:12): [True: 163k, False: 0]
  |  Branch (3119:25): [True: 0, False: 163k]
  ------------------
 3120|      0|      length--;
 3121|      0|    }
 3122|   163k|  }
_ZNK3glz10fast_float8stackvecILt62EE6rindexEm:
 3028|   221k|  GLZ_FASTFLOAT_CONSTEXPR14 const limb &rindex(size_t index) const noexcept {
 3029|   221k|    GLZ_FASTFLOAT_DEBUG_ASSERT(index < length);
  ------------------
  |  |  349|   221k|  { ((void)(x)); }
  ------------------
 3030|   221k|    size_t rindex = length - index - 1;
 3031|   221k|    return data[rindex];
 3032|   221k|  }
_ZN3glz10fast_float6bigint4pow2Ej:
 3557|  56.8k|  GLZ_FASTFLOAT_CONSTEXPR20 bool pow2(uint32_t exp) noexcept { return shl(exp); }
_ZN3glz10fast_float6bigint3shlEm:
 3519|  56.8k|  GLZ_FASTFLOAT_CONSTEXPR20 bool shl(size_t n) noexcept {
 3520|  56.8k|    size_t rem = n % limb_bits;
 3521|  56.8k|    size_t div = n / limb_bits;
 3522|  56.8k|    if (rem != 0) {
  ------------------
  |  Branch (3522:9): [True: 46.2k, False: 10.5k]
  ------------------
 3523|  46.2k|      GLZ_FASTFLOAT_TRY(shl_bits(rem));
  ------------------
  |  |  354|  46.2k|  {                                                                            \
  |  |  355|  46.2k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 46.2k]
  |  |  ------------------
  |  |  356|  46.2k|      return false;                                                            \
  |  |  357|  46.2k|  }
  ------------------
 3524|  46.2k|    }
 3525|  56.8k|    if (div != 0) {
  ------------------
  |  Branch (3525:9): [True: 35.1k, False: 21.6k]
  ------------------
 3526|  35.1k|      GLZ_FASTFLOAT_TRY(shl_limbs(div));
  ------------------
  |  |  354|  35.1k|  {                                                                            \
  |  |  355|  35.1k|    if (!(x))                                                                  \
  |  |  ------------------
  |  |  |  Branch (355:9): [True: 0, False: 35.1k]
  |  |  ------------------
  |  |  356|  35.1k|      return false;                                                            \
  |  |  357|  35.1k|  }
  ------------------
 3527|  35.1k|    }
 3528|  56.8k|    return true;
 3529|  56.8k|  }
_ZN3glz10fast_float6bigint8shl_bitsEm:
 3472|  46.2k|  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|  46.2k|    GLZ_FASTFLOAT_DEBUG_ASSERT(n != 0);
  ------------------
  |  |  349|  46.2k|  { ((void)(x)); }
  ------------------
 3479|  46.2k|    GLZ_FASTFLOAT_DEBUG_ASSERT(n < sizeof(limb) * 8);
  ------------------
  |  |  349|  46.2k|  { ((void)(x)); }
  ------------------
 3480|       |
 3481|  46.2k|    size_t shl = n;
 3482|  46.2k|    size_t shr = limb_bits - shl;
 3483|  46.2k|    limb prev = 0;
 3484|   733k|    for (size_t index = 0; index < vec.len(); index++) {
  ------------------
  |  Branch (3484:28): [True: 687k, False: 46.2k]
  ------------------
 3485|   687k|      limb xi = vec[index];
 3486|   687k|      vec[index] = (xi << shl) | (prev >> shr);
 3487|   687k|      prev = xi;
 3488|   687k|    }
 3489|       |
 3490|  46.2k|    limb carry = prev >> shr;
 3491|  46.2k|    if (carry != 0) {
  ------------------
  |  Branch (3491:9): [True: 11.6k, False: 34.6k]
  ------------------
 3492|  11.6k|      return vec.try_push(carry);
 3493|  11.6k|    }
 3494|  34.6k|    return true;
 3495|  46.2k|  }
_ZN3glz10fast_float6bigint9shl_limbsEm:
 3498|  35.1k|  GLZ_FASTFLOAT_CONSTEXPR20 bool shl_limbs(size_t n) noexcept {
 3499|  35.1k|    GLZ_FASTFLOAT_DEBUG_ASSERT(n != 0);
  ------------------
  |  |  349|  35.1k|  { ((void)(x)); }
  ------------------
 3500|  35.1k|    if (n + vec.len() > vec.capacity()) {
  ------------------
  |  Branch (3500:9): [True: 0, False: 35.1k]
  ------------------
 3501|      0|      return false;
 3502|  35.1k|    } else if (!vec.is_empty()) {
  ------------------
  |  Branch (3502:16): [True: 35.1k, False: 0]
  ------------------
 3503|       |      // move limbs
 3504|  35.1k|      limb *dst = vec.data + n;
 3505|  35.1k|      limb const *src = vec.data;
 3506|  35.1k|      std::copy_backward(src, src + vec.len(), dst + vec.len());
 3507|       |      // fill in empty limbs
 3508|  35.1k|      limb *first = vec.data;
 3509|  35.1k|      limb *last = first + n;
 3510|  35.1k|      ::std::fill(first, last, 0);
 3511|  35.1k|      vec.set_len(n + vec.len());
 3512|  35.1k|      return true;
 3513|  35.1k|    } else {
 3514|      0|      return true;
 3515|      0|    }
 3516|  35.1k|  }
_ZNK3glz10fast_float8stackvecILt62EE8is_emptyEv:
 3041|  52.3k|  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.22k, False: 12.9k]
  ------------------
 3423|  4.22k|      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.22k|uint64_hi64(uint64_t r0, bool &truncated) noexcept {
 3133|  4.22k|  truncated = false;
 3134|  4.22k|  int shl = leading_zeroes(r0);
 3135|  4.22k|  return r0 << shl;
 3136|  4.22k|}
_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.38k, False: 11.5k]
  ------------------
 3142|  1.38k|    truncated = r1 != 0;
 3143|  1.38k|    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.7k, False: 6.90k]
  ------------------
 3109|  10.7k|      if (rindex(index) != 0) {
  ------------------
  |  Branch (3109:11): [True: 6.03k, False: 4.68k]
  ------------------
 3110|  6.03k|        return true;
 3111|  6.03k|      }
 3112|  4.68k|      index++;
 3113|  4.68k|    }
 3114|  6.90k|    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.40k, False: 14.7k]
  ------------------
 3726|  17.1k|      (uint64_t(2) << binary_format<T>::mantissa_explicit_bits())) {
 3727|  2.40k|    am.mantissa = (uint64_t(1) << binary_format<T>::mantissa_explicit_bits());
 3728|  2.40k|    am.power2++;
 3729|  2.40k|  }
 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.63k, False: 3.72k]
  |  Branch (3955:45): [True: 4.63k, False: 5.00k]
  ------------------
 3956|  8.72k|                 (is_odd && is_halfway);
  ------------------
  |  Branch (3956:19): [True: 2.68k, False: 6.04k]
  |  Branch (3956:29): [True: 24, False: 2.66k]
  ------------------
 3957|  17.1k|        });
_ZN3glz10fast_float19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES2_i:
 3970|  40.6k|    bigint &bigmant, adjusted_mantissa am, int32_t exponent) noexcept {
 3971|  40.6k|  bigint &real_digits = bigmant;
 3972|  40.6k|  int32_t real_exp = exponent;
 3973|       |
 3974|       |  // get the value of `b`, rounded down, and get a bigint representation of b+h
 3975|  40.6k|  adjusted_mantissa am_b = am;
 3976|       |  // gcc7 buf: use a lambda to remove the noexcept qualifier bug with
 3977|       |  // -Wnoexcept-type.
 3978|  40.6k|  round<T>(am_b,
 3979|  40.6k|           [](adjusted_mantissa &a, int32_t shift) { round_down(a, shift); });
 3980|  40.6k|  T b;
 3981|  40.6k|  to_float(false, am_b, b);
 3982|  40.6k|  adjusted_mantissa theor = to_extended_halfway(b);
 3983|  40.6k|  bigint theor_digits(theor.mantissa);
 3984|  40.6k|  int32_t theor_exp = theor.power2;
 3985|       |
 3986|       |  // scale real digits and theor digits to be same power.
 3987|  40.6k|  int32_t pow2_exp = theor_exp - real_exp;
 3988|  40.6k|  uint32_t pow5_exp = uint32_t(-real_exp);
 3989|  40.6k|  if (pow5_exp != 0) {
  ------------------
  |  Branch (3989:7): [True: 40.6k, False: 0]
  ------------------
 3990|  40.6k|    GLZ_FASTFLOAT_ASSERT(theor_digits.pow5(pow5_exp));
  ------------------
  |  |  344|  40.6k|  { ((void)(x)); }
  ------------------
 3991|  40.6k|  }
 3992|  40.6k|  if (pow2_exp > 0) {
  ------------------
  |  Branch (3992:7): [True: 28.3k, False: 12.2k]
  ------------------
 3993|  28.3k|    GLZ_FASTFLOAT_ASSERT(theor_digits.pow2(uint32_t(pow2_exp)));
  ------------------
  |  |  344|  28.3k|  { ((void)(x)); }
  ------------------
 3994|  28.3k|  } else if (pow2_exp < 0) {
  ------------------
  |  Branch (3994:14): [True: 11.3k, False: 972]
  ------------------
 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.6k|  int ord = real_digits.compare(theor_digits);
 4000|  40.6k|  adjusted_mantissa answer = am;
 4001|  40.6k|  round<T>(answer, [ord](adjusted_mantissa &a, int32_t shift) {
 4002|  40.6k|    round_nearest_tie_even(
 4003|  40.6k|        a, shift, [ord](bool is_odd, bool _, bool __) -> bool {
 4004|  40.6k|          (void)_;  // not needed, since we've done our comparison
 4005|  40.6k|          (void)__; // not needed, since we've done our comparison
 4006|  40.6k|          if (ord > 0) {
 4007|  40.6k|            return true;
 4008|  40.6k|          } else if (ord < 0) {
 4009|  40.6k|            return false;
 4010|  40.6k|          } else {
 4011|  40.6k|            return is_odd;
 4012|  40.6k|          }
 4013|  40.6k|        });
 4014|  40.6k|  });
 4015|       |
 4016|  40.6k|  return answer;
 4017|  40.6k|}
_ZN3glz10fast_float5roundIdZNS0_19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES3_iEUlRS3_iE_EEvS6_T0_:
 3707|  40.6k|                                                         callback cb) noexcept {
 3708|  40.6k|  int32_t mantissa_shift = 64 - binary_format<T>::mantissa_explicit_bits() - 1;
 3709|  40.6k|  if (-am.power2 >= mantissa_shift) {
  ------------------
  |  Branch (3709:7): [True: 4.59k, False: 36.0k]
  ------------------
 3710|       |    // have a denormal float
 3711|  4.59k|    int32_t shift = -am.power2 + 1;
 3712|  4.59k|    cb(am, (std::min<int32_t>)(shift, 64));
 3713|       |    // check for round-up: if rounding-nearest carried us to the hidden bit.
 3714|  4.59k|    am.power2 = (am.mantissa <
  ------------------
  |  Branch (3714:17): [True: 4.59k, False: 0]
  ------------------
 3715|  4.59k|                 (uint64_t(1) << binary_format<T>::mantissa_explicit_bits()))
 3716|  4.59k|                    ? 0
 3717|  4.59k|                    : 1;
 3718|  4.59k|    return;
 3719|  4.59k|  }
 3720|       |
 3721|       |  // have a normal float, use the default shift.
 3722|  36.0k|  cb(am, mantissa_shift);
 3723|       |
 3724|       |  // check for carry
 3725|  36.0k|  if (am.mantissa >=
  ------------------
  |  Branch (3725:7): [True: 0, False: 36.0k]
  ------------------
 3726|  36.0k|      (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|  36.0k|  am.mantissa &= ~(uint64_t(1) << binary_format<T>::mantissa_explicit_bits());
 3733|  36.0k|  if (am.power2 >= binary_format<T>::infinite_power()) {
  ------------------
  |  Branch (3733:7): [True: 0, False: 36.0k]
  ------------------
 3734|      0|    am.power2 = binary_format<T>::infinite_power();
 3735|      0|    am.mantissa = 0;
 3736|      0|  }
 3737|  36.0k|}
_ZZN3glz10fast_float19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES2_iENKUlRS2_iE_clES5_i:
 3979|  40.6k|           [](adjusted_mantissa &a, int32_t shift) { round_down(a, shift); });
_ZN3glz10fast_float10round_downERNS0_17adjusted_mantissaEi:
 3762|  40.6k|round_down(adjusted_mantissa &am, int32_t shift) noexcept {
 3763|  40.6k|  if (shift == 64) {
  ------------------
  |  Branch (3763:7): [True: 1.03k, False: 39.5k]
  ------------------
 3764|  1.03k|    am.mantissa = 0;
 3765|  39.5k|  } else {
 3766|  39.5k|    am.mantissa >>= shift;
 3767|  39.5k|  }
 3768|  40.6k|  am.power2 += shift;
 3769|  40.6k|}
_ZN3glz10fast_float19to_extended_halfwayIdEENS0_17adjusted_mantissaET_:
 3696|  40.6k|to_extended_halfway(T value) noexcept {
 3697|  40.6k|  adjusted_mantissa am = to_extended(value);
 3698|  40.6k|  am.mantissa <<= 1;
 3699|  40.6k|  am.mantissa += 1;
 3700|  40.6k|  am.power2 -= 1;
 3701|  40.6k|  return am;
 3702|  40.6k|}
_ZN3glz10fast_float11to_extendedIdEENS0_17adjusted_mantissaET_:
 3661|  40.6k|to_extended(T value) noexcept {
 3662|  40.6k|  using equiv_uint = equiv_uint_t<T>;
 3663|  40.6k|  constexpr equiv_uint exponent_mask = binary_format<T>::exponent_mask();
 3664|  40.6k|  constexpr equiv_uint mantissa_mask = binary_format<T>::mantissa_mask();
 3665|  40.6k|  constexpr equiv_uint hidden_bit_mask = binary_format<T>::hidden_bit_mask();
 3666|       |
 3667|  40.6k|  adjusted_mantissa am;
 3668|  40.6k|  int32_t bias = binary_format<T>::mantissa_explicit_bits() -
 3669|  40.6k|                 binary_format<T>::minimum_exponent();
 3670|  40.6k|  equiv_uint bits;
 3671|  40.6k|#if GLZ_FASTFLOAT_HAS_BIT_CAST
 3672|  40.6k|  bits = std::bit_cast<equiv_uint>(value);
 3673|       |#else
 3674|       |  ::memcpy(&bits, &value, sizeof(T));
 3675|       |#endif
 3676|  40.6k|  if ((bits & exponent_mask) == 0) {
  ------------------
  |  Branch (3676:7): [True: 4.59k, False: 36.0k]
  ------------------
 3677|       |    // denormal
 3678|  4.59k|    am.power2 = 1 - bias;
 3679|  4.59k|    am.mantissa = bits & mantissa_mask;
 3680|  36.0k|  } else {
 3681|       |    // normal
 3682|  36.0k|    am.power2 = int32_t((bits & exponent_mask) >>
 3683|  36.0k|                        binary_format<T>::mantissa_explicit_bits());
 3684|  36.0k|    am.power2 -= bias;
 3685|  36.0k|    am.mantissa = (bits & mantissa_mask) | hidden_bit_mask;
 3686|  36.0k|  }
 3687|       |
 3688|  40.6k|  return am;
 3689|  40.6k|}
_ZN3glz10fast_float6bigintC2Em:
 3406|  40.6k|  GLZ_FASTFLOAT_CONSTEXPR20 bigint(uint64_t value) : vec() {
 3407|  40.6k|#ifdef GLZ_FASTFLOAT_64BIT_LIMB
 3408|  40.6k|    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.6k|    vec.normalize();
 3414|  40.6k|  }
_ZNK3glz10fast_float6bigint7compareERKS1_:
 3451|  40.6k|  GLZ_FASTFLOAT_CONSTEXPR20 int compare(bigint const &other) const noexcept {
 3452|  40.6k|    if (vec.len() > other.vec.len()) {
  ------------------
  |  Branch (3452:9): [True: 0, False: 40.6k]
  ------------------
 3453|      0|      return 1;
 3454|  40.6k|    } else if (vec.len() < other.vec.len()) {
  ------------------
  |  Branch (3454:16): [True: 0, False: 40.6k]
  ------------------
 3455|      0|      return -1;
 3456|  40.6k|    } else {
 3457|  84.4k|      for (size_t index = vec.len(); index > 0; index--) {
  ------------------
  |  Branch (3457:38): [True: 81.8k, False: 2.65k]
  ------------------
 3458|  81.8k|        limb xi = vec[index - 1];
 3459|  81.8k|        limb yi = other.vec[index - 1];
 3460|  81.8k|        if (xi > yi) {
  ------------------
  |  Branch (3460:13): [True: 13.6k, False: 68.1k]
  ------------------
 3461|  13.6k|          return 1;
 3462|  68.1k|        } else if (xi < yi) {
  ------------------
  |  Branch (3462:20): [True: 24.3k, False: 43.8k]
  ------------------
 3463|  24.3k|          return -1;
 3464|  24.3k|        }
 3465|  81.8k|      }
 3466|  2.65k|      return 0;
 3467|  40.6k|    }
 3468|  40.6k|  }
_ZNK3glz10fast_float8stackvecILt62EEixEm:
 3022|   163k|  GLZ_FASTFLOAT_CONSTEXPR14 const limb &operator[](size_t index) const noexcept {
 3023|   163k|    GLZ_FASTFLOAT_DEBUG_ASSERT(index < length);
  ------------------
  |  |  349|   163k|  { ((void)(x)); }
  ------------------
 3024|   163k|    return data[index];
 3025|   163k|  }
_ZN3glz10fast_float5roundIdZNS0_19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES3_iEUlRS3_iE0_EEvS6_T0_:
 3707|  40.6k|                                                         callback cb) noexcept {
 3708|  40.6k|  int32_t mantissa_shift = 64 - binary_format<T>::mantissa_explicit_bits() - 1;
 3709|  40.6k|  if (-am.power2 >= mantissa_shift) {
  ------------------
  |  Branch (3709:7): [True: 4.59k, False: 36.0k]
  ------------------
 3710|       |    // have a denormal float
 3711|  4.59k|    int32_t shift = -am.power2 + 1;
 3712|  4.59k|    cb(am, (std::min<int32_t>)(shift, 64));
 3713|       |    // check for round-up: if rounding-nearest carried us to the hidden bit.
 3714|  4.59k|    am.power2 = (am.mantissa <
  ------------------
  |  Branch (3714:17): [True: 4.59k, False: 6]
  ------------------
 3715|  4.59k|                 (uint64_t(1) << binary_format<T>::mantissa_explicit_bits()))
 3716|  4.59k|                    ? 0
 3717|  4.59k|                    : 1;
 3718|  4.59k|    return;
 3719|  4.59k|  }
 3720|       |
 3721|       |  // have a normal float, use the default shift.
 3722|  36.0k|  cb(am, mantissa_shift);
 3723|       |
 3724|       |  // check for carry
 3725|  36.0k|  if (am.mantissa >=
  ------------------
  |  Branch (3725:7): [True: 1.61k, False: 34.3k]
  ------------------
 3726|  36.0k|      (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|  36.0k|  am.mantissa &= ~(uint64_t(1) << binary_format<T>::mantissa_explicit_bits());
 3733|  36.0k|  if (am.power2 >= binary_format<T>::infinite_power()) {
  ------------------
  |  Branch (3733:7): [True: 0, False: 36.0k]
  ------------------
 3734|      0|    am.power2 = binary_format<T>::infinite_power();
 3735|      0|    am.mantissa = 0;
 3736|      0|  }
 3737|  36.0k|}
_ZZN3glz10fast_float19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES2_iENKUlRS2_iE0_clES5_i:
 4001|  40.6k|  round<T>(answer, [ord](adjusted_mantissa &a, int32_t shift) {
 4002|  40.6k|    round_nearest_tie_even(
 4003|  40.6k|        a, shift, [ord](bool is_odd, bool _, bool __) -> bool {
 4004|  40.6k|          (void)_;  // not needed, since we've done our comparison
 4005|  40.6k|          (void)__; // not needed, since we've done our comparison
 4006|  40.6k|          if (ord > 0) {
 4007|  40.6k|            return true;
 4008|  40.6k|          } else if (ord < 0) {
 4009|  40.6k|            return false;
 4010|  40.6k|          } else {
 4011|  40.6k|            return is_odd;
 4012|  40.6k|          }
 4013|  40.6k|        });
 4014|  40.6k|  });
_ZN3glz10fast_float22round_nearest_tie_evenIZZNS0_19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES3_iENKUlRS3_iE0_clES6_iEUlbbbE_EEvS6_iT_:
 3742|  40.6k|                       callback cb) noexcept {
 3743|  40.6k|  uint64_t const mask = (shift == 64) ? UINT64_MAX : (uint64_t(1) << shift) - 1;
  ------------------
  |  Branch (3743:25): [True: 1.03k, False: 39.5k]
  ------------------
 3744|  40.6k|  uint64_t const halfway = (shift == 0) ? 0 : uint64_t(1) << (shift - 1);
  ------------------
  |  Branch (3744:28): [True: 0, False: 40.6k]
  ------------------
 3745|  40.6k|  uint64_t truncated_bits = am.mantissa & mask;
 3746|  40.6k|  bool is_above = truncated_bits > halfway;
 3747|  40.6k|  bool is_halfway = truncated_bits == halfway;
 3748|       |
 3749|       |  // shift digits into position
 3750|  40.6k|  if (shift == 64) {
  ------------------
  |  Branch (3750:7): [True: 1.03k, False: 39.5k]
  ------------------
 3751|  1.03k|    am.mantissa = 0;
 3752|  39.5k|  } else {
 3753|  39.5k|    am.mantissa >>= shift;
 3754|  39.5k|  }
 3755|  40.6k|  am.power2 += shift;
 3756|       |
 3757|  40.6k|  bool is_odd = (am.mantissa & 1) == 1;
 3758|  40.6k|  am.mantissa += uint64_t(cb(is_odd, is_halfway, is_above));
 3759|  40.6k|}
_ZZZN3glz10fast_float19negative_digit_compIdEENS0_17adjusted_mantissaERNS0_6bigintES2_iENKUlRS2_iE0_clES5_iENKUlbbbE_clEbbb:
 4003|  40.6k|        a, shift, [ord](bool is_odd, bool _, bool __) -> bool {
 4004|  40.6k|          (void)_;  // not needed, since we've done our comparison
 4005|  40.6k|          (void)__; // not needed, since we've done our comparison
 4006|  40.6k|          if (ord > 0) {
  ------------------
  |  Branch (4006:15): [True: 13.6k, False: 26.9k]
  ------------------
 4007|  13.6k|            return true;
 4008|  26.9k|          } else if (ord < 0) {
  ------------------
  |  Branch (4008:22): [True: 24.3k, False: 2.65k]
  ------------------
 4009|  24.3k|            return false;
 4010|  24.3k|          } else {
 4011|  2.65k|            return is_odd;
 4012|  2.65k|          }
 4013|  40.6k|        });
_ZN3glz10fast_float8to_floatIdEEvbNS0_17adjusted_mantissaERT_:
 1131|   125k|to_float(bool negative, adjusted_mantissa am, T &value) {
 1132|   125k|  using equiv_uint = equiv_uint_t<T>;
 1133|   125k|  equiv_uint word = equiv_uint(am.mantissa);
 1134|   125k|  word = equiv_uint(word | equiv_uint(am.power2)
 1135|   125k|                               << binary_format<T>::mantissa_explicit_bits());
 1136|   125k|  word =
 1137|   125k|      equiv_uint(word | equiv_uint(negative) << binary_format<T>::sign_index());
 1138|   125k|#if GLZ_FASTFLOAT_HAS_BIT_CAST
 1139|   125k|  value = std::bit_cast<T>(word);
 1140|       |#else
 1141|       |  ::memcpy(&value, &word, sizeof(T));
 1142|       |#endif
 1143|   125k|}
_ZN3glz10fast_float13binary_formatIdE10sign_indexEv:
  758|   125k|template <> inline constexpr int binary_format<double>::sign_index() {
  759|   125k|  return 63;
  760|   125k|}
_ZN3glz10fast_float13binary_formatIdE14infinite_powerEv:
  750|   313k|template <> inline constexpr int binary_format<double>::infinite_power() {
  751|   313k|  return 0x7FF;
  752|   313k|}

_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.74M|   {
   28|  1.74M|      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.74M|         else {
   50|  1.74M|            [&]<size_t... I>(std::index_sequence<I...>) {
   51|  1.74M|               (void)(lambda.template operator()<I>(), ...);
   52|  1.74M|            }(std::make_index_sequence<N>{});
   53|  1.74M|         }
   54|  1.74M|      }
   55|  1.74M|   }
_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.74M|            [&]<size_t... I>(std::index_sequence<I...>) {
   51|  1.74M|               (void)(lambda.template operator()<I>(), ...);
   52|  1.74M|            }(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|  30.5k|   {
   28|  30.5k|      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|  30.5k|         else {
   50|  30.5k|            [&]<size_t... I>(std::index_sequence<I...>) {
   51|  30.5k|               (void)(lambda.template operator()<I>(), ...);
   52|  30.5k|            }(std::make_index_sequence<N>{});
   53|  30.5k|         }
   54|  30.5k|      }
   55|  30.5k|   }
_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|  30.5k|            [&]<size_t... I>(std::index_sequence<I...>) {
   51|  30.5k|               (void)(lambda.template operator()<I>(), ...);
   52|  30.5k|            }(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.43M|   {
   28|  6.43M|      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.43M|         else {
   50|  6.43M|            [&]<size_t... I>(std::index_sequence<I...>) {
   51|  6.43M|               (void)(lambda.template operator()<I>(), ...);
   52|  6.43M|            }(std::make_index_sequence<N>{});
   53|  6.43M|         }
   54|  6.43M|      }
   55|  6.43M|   }
_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.43M|            [&]<size_t... I>(std::index_sequence<I...>) {
   51|  6.43M|               (void)(lambda.template operator()<I>(), ...);
   52|  6.43M|            }(std::make_index_sequence<N>{});

_ZN3glz10from_charsILb0EdcEENS_10fast_float19from_chars_result_tIT1_EEPKS3_S6_RT0_:
  235|  6.43M|   {
  236|  6.43M|      using namespace glz::fast_float;
  237|  6.43M|      static_assert(is_supported_float_type<T>(), "only some floating-point types are supported");
  238|  6.43M|      static_assert(is_supported_char_type<UC>(), "only char, wchar_t, char16_t and char32_t are supported");
  239|       |
  240|  6.43M|      parsed_number_string_t<UC> pns = glz::parse_number_string<null_terminated, UC>(first, last);
  241|  6.43M|      if (!pns.valid) [[unlikely]] {
  ------------------
  |  Branch (241:11): [True: 3.57k, False: 6.43M]
  ------------------
  242|  3.57k|         return {.ptr = first, .ec = std::errc::invalid_argument};
  243|  3.57k|      }
  244|       |
  245|  6.43M|      return from_chars_advanced(pns, value);
  246|  6.43M|   }
_ZN3glz19parse_number_stringILb0EcEENS_10fast_float22parsed_number_string_tIT0_EEPKS3_S6_:
   18|  6.43M|   {
   19|  6.43M|      using namespace glz::fast_float;
   20|  6.43M|      static constexpr UC decimal_point = '.';
   21|       |
   22|  6.43M|      parsed_number_string_t<UC> answer;
   23|  6.43M|      answer.valid = false;
   24|  6.43M|      answer.too_many_digits = false;
   25|  6.43M|      answer.negative = (*p == UC('-'));
   26|  6.43M|      if (*p == UC('-')) { // C++17 20.19.3.(7.1) explicitly forbids '+' sign here
  ------------------
  |  Branch (26:11): [True: 7.96k, False: 6.42M]
  ------------------
   27|  7.96k|         ++p;
   28|       |
   29|  7.96k|         if constexpr (not null_terminated) {
   30|  7.96k|            if (p == pend) [[unlikely]] {
  ------------------
  |  Branch (30:17): [True: 11, False: 7.95k]
  ------------------
   31|     11|               return answer;
   32|     11|            }
   33|  7.96k|         }
   34|       |
   35|  7.96k|         if (!glz::fast_float::is_integer(*p)) [[unlikely]] { // a sign must be followed by an integer
  ------------------
  |  Branch (35:14): [True: 61, False: 7.90k]
  ------------------
   36|     61|            return answer;
   37|     61|         }
   38|  7.96k|      }
   39|  6.43M|      UC const* const start_digits = p;
   40|       |
   41|  6.43M|      uint64_t i = 0; // an unsigned int avoids signed overflows (which are bad)
   42|       |
   43|  6.43M|      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.43M|      else {
   53|  32.9M|         while ((p != pend) && (digit = glz::fast_float::digit_value(*p)) <= 9) {
  ------------------
  |  Branch (53:17): [True: 32.9M, False: 1.05k]
  |  Branch (53:32): [True: 26.5M, False: 6.43M]
  ------------------
   54|       |            // a multiplication by 10 is cheaper than an arbitrary integer
   55|       |            // multiplication
   56|  26.5M|            i = 10 * i + digit; // might overflow, we will handle the overflow later
   57|  26.5M|            ++p;
   58|  26.5M|         }
   59|  6.43M|      }
   60|       |
   61|  6.43M|      UC const* const end_of_integer_part = p;
   62|  6.43M|      int64_t digit_count = int64_t(end_of_integer_part - start_digits);
   63|  6.43M|      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.43M|      if (digit_count == 0 || (start_digits[0] == UC('0') && digit_count > 1)) {
  ------------------
  |  Branch (66:11): [True: 3.18k, False: 6.43M]
  |  Branch (66:32): [True: 2.78M, False: 3.65M]
  |  Branch (66:62): [True: 141, False: 2.78M]
  ------------------
   67|  3.31k|         return answer;
   68|  3.31k|      }
   69|       |
   70|  6.43M|      int64_t exponent = 0;
   71|  6.43M|      const bool has_decimal_point = [&] {
   72|  6.43M|         if constexpr (null_terminated) {
   73|  6.43M|            return (*p == decimal_point);
   74|  6.43M|         }
   75|  6.43M|         else {
   76|  6.43M|            return (p != pend) && (*p == decimal_point);
   77|  6.43M|         }
   78|  6.43M|      }();
   79|  6.43M|      if (has_decimal_point) {
  ------------------
  |  Branch (79:11): [True: 47.8k, False: 6.38M]
  ------------------
   80|  47.8k|         ++p;
   81|  47.8k|         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.8k|         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.8k|         else {
   93|   186k|            while ((p != pend) && (digit = glz::fast_float::digit_value(*p)) <= 9) {
  ------------------
  |  Branch (93:20): [True: 185k, False: 1.04k]
  |  Branch (93:35): [True: 138k, False: 46.8k]
  ------------------
   94|   138k|               ++p;
   95|   138k|               i = i * 10 + digit; // in rare cases, this will overflow, but that's ok
   96|   138k|            }
   97|  47.8k|         }
   98|  47.8k|         exponent = before - p;
   99|  47.8k|         answer.fraction = glz::fast_float::span<const UC>(before, size_t(p - before));
  100|  47.8k|         digit_count -= exponent;
  101|  47.8k|      }
  102|       |      // at least 1 digit in fractional part
  103|  6.43M|      if (has_decimal_point && exponent == 0) {
  ------------------
  |  Branch (103:11): [True: 47.8k, False: 6.38M]
  |  Branch (103:32): [True: 63, False: 47.7k]
  ------------------
  104|     63|         return answer;
  105|     63|      }
  106|       |
  107|  6.43M|      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.43M|      else {
  141|  6.43M|         if ((p != pend) && ((UC('e') == *p) || (UC('E') == *p))) {
  ------------------
  |  Branch (141:14): [True: 6.43M, False: 2.07k]
  |  Branch (141:30): [True: 21.7k, False: 6.40M]
  |  Branch (141:49): [True: 23.8k, False: 6.38M]
  ------------------
  142|  45.5k|            ++p;
  143|  45.5k|            bool neg_exp = false;
  144|  45.5k|            if ((p != pend) && (UC('-') == *p)) {
  ------------------
  |  Branch (144:17): [True: 45.5k, False: 10]
  |  Branch (144:32): [True: 23.6k, False: 21.9k]
  ------------------
  145|  23.6k|               neg_exp = true;
  146|  23.6k|               ++p;
  147|  23.6k|            }
  148|  21.9k|            else if ((p != pend) && (UC('+') == *p)) { // '+' on exponent is allowed by C++17 20.19.3.(7.1)
  ------------------
  |  Branch (148:22): [True: 21.9k, False: 10]
  |  Branch (148:37): [True: 1.71k, False: 20.1k]
  ------------------
  149|  1.71k|               ++p;
  150|  1.71k|            }
  151|  45.5k|            if ((p == pend) || (digit = glz::fast_float::digit_value(*p)) > 9) [[unlikely]] {
  ------------------
  |  Branch (151:17): [True: 23, False: 45.4k]
  |  Branch (151:32): [True: 97, False: 45.4k]
  ------------------
  152|    120|               return answer;
  153|    120|            }
  154|  45.4k|            else {
  155|   119k|               do {
  156|   119k|                  if (exp_number < 0x10000000) {
  ------------------
  |  Branch (156:23): [True: 118k, False: 1.83k]
  ------------------
  157|   118k|                     exp_number = 10 * exp_number + digit;
  158|   118k|                  }
  159|   119k|                  ++p;
  160|   119k|               } while ((p != pend) && (digit = glz::fast_float::digit_value(*p)) <= 9);
  ------------------
  |  Branch (160:25): [True: 118k, False: 1.25k]
  |  Branch (160:40): [True: 74.5k, False: 44.1k]
  ------------------
  161|  45.4k|               if (neg_exp) {
  ------------------
  |  Branch (161:20): [True: 23.5k, False: 21.8k]
  ------------------
  162|  23.5k|                  exp_number = -exp_number;
  163|  23.5k|               }
  164|  45.4k|               exponent += exp_number;
  165|  45.4k|            }
  166|  45.5k|         }
  167|  6.43M|      }
  168|       |
  169|  6.43M|      answer.lastmatch = p;
  170|  6.43M|      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.43M|      if (digit_count > 19) { // this is uncommon
  ------------------
  |  Branch (177:11): [True: 69.5k, False: 6.36M]
  ------------------
  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|  69.5k|         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|  69.5k|         else {
  192|  3.64M|            while ((start != pend) && (*start == UC('0') || *start == decimal_point)) {
  ------------------
  |  Branch (192:20): [True: 3.64M, False: 29]
  |  Branch (192:40): [True: 3.55M, False: 91.6k]
  |  Branch (192:61): [True: 22.2k, False: 69.4k]
  ------------------
  193|  3.57M|               if (*start == UC('0')) {
  ------------------
  |  Branch (193:20): [True: 3.55M, False: 22.2k]
  ------------------
  194|  3.55M|                  --digit_count;
  195|  3.55M|               }
  196|  3.57M|               ++start;
  197|  3.57M|            }
  198|  69.5k|         }
  199|       |
  200|  69.5k|         if (digit_count > 19) {
  ------------------
  |  Branch (200:14): [True: 68.2k, False: 1.23k]
  ------------------
  201|  68.2k|            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|  68.2k|            i = 0;
  206|  68.2k|            p = answer.integer.ptr;
  207|  68.2k|            UC const* int_end = p + answer.integer.len();
  208|  68.2k|            const uint64_t minimal_nineteen_digit_integer{1000000000000000000};
  209|  1.08M|            while ((i < minimal_nineteen_digit_integer) && (p != int_end)) {
  ------------------
  |  Branch (209:20): [True: 1.04M, False: 45.6k]
  |  Branch (209:60): [True: 1.02M, False: 22.6k]
  ------------------
  210|  1.02M|               i = i * 10 + uint64_t(*p - UC('0'));
  211|  1.02M|               ++p;
  212|  1.02M|            }
  213|  68.2k|            if (i >= minimal_nineteen_digit_integer) { // We have a big integers
  ------------------
  |  Branch (213:17): [True: 45.6k, False: 22.6k]
  ------------------
  214|  45.6k|               exponent = end_of_integer_part - p + exp_number;
  215|  45.6k|            }
  216|  22.6k|            else { // We have a value with a fractional component.
  217|  22.6k|               p = answer.fraction.ptr;
  218|  22.6k|               UC const* frac_end = p + answer.fraction.len();
  219|   325k|               while ((i < minimal_nineteen_digit_integer) && (p != frac_end)) {
  ------------------
  |  Branch (219:23): [True: 302k, False: 22.6k]
  |  Branch (219:63): [True: 302k, False: 0]
  ------------------
  220|   302k|                  i = i * 10 + uint64_t(*p - UC('0'));
  221|   302k|                  ++p;
  222|   302k|               }
  223|  22.6k|               exponent = answer.fraction.ptr - p + exp_number;
  224|  22.6k|            }
  225|       |            // We have now corrected both exponent and i, to a truncated value
  226|  68.2k|         }
  227|  69.5k|      }
  228|  6.43M|      answer.exponent = exponent;
  229|  6.43M|      answer.mantissa = i;
  230|  6.43M|      return answer;
  231|  6.43M|   }
_ZZN3glz19parse_number_stringILb0EcEENS_10fast_float22parsed_number_string_tIT0_EEPKS3_S6_ENKUlvE_clEv:
   71|  6.43M|      const bool has_decimal_point = [&] {
   72|       |         if constexpr (null_terminated) {
   73|       |            return (*p == decimal_point);
   74|       |         }
   75|  6.43M|         else {
   76|  6.43M|            return (p != pend) && (*p == decimal_point);
  ------------------
  |  Branch (76:20): [True: 6.43M, False: 1.02k]
  |  Branch (76:35): [True: 47.8k, False: 6.38M]
  ------------------
   77|  6.43M|         }
   78|  6.43M|      }();

_ZN3glz7skip_wsIXtlNS_7ws_optsEEETkNS_10is_contextERNS_7contextERPKcS5_EEbOT0_OT1_T2_:
  663|  26.2M|   {
  664|  26.2M|      using namespace glz::detail;
  665|       |
  666|  26.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|  26.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|  26.2M|            else {
  706|  45.5M|               while (it < end && whitespace_table[uint8_t(*it)]) {
  ------------------
  |  Branch (706:23): [True: 45.5M, False: 1.58k]
  |  Branch (706:35): [True: 19.2M, False: 26.2M]
  ------------------
  707|  19.2M|                  ++it;
  708|  19.2M|               }
  709|  26.2M|               if (it == end) [[unlikely]] {
  ------------------
  |  Branch (709:20): [True: 1.58k, False: 26.2M]
  ------------------
  710|  1.58k|                  ctx.error = error_code::end_reached;
  711|  1.58k|                  return true;
  712|  1.58k|               }
  713|  26.2M|            }
  714|  26.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|  26.2M|      return false;
  727|  26.2M|   }
_ZN3glz17match_invalid_endILc44EXtlNS_22match_invalid_end_optsEEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  470|  3.18M|   {
  471|  3.18M|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (471:11): [True: 1.68k, False: 3.17M]
  ------------------
  472|       |         if constexpr (C == '"') {
  473|       |            ctx.error = error_code::expected_quote;
  474|       |         }
  475|  1.68k|         else if constexpr (C == ',') {
  476|  1.68k|            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.68k|         return true;
  491|  1.68k|      }
  492|  3.17M|      else [[likely]] {
  493|  3.17M|         ++it;
  494|  3.17M|      }
  495|  3.17M|      if constexpr (not Opts.null_terminated) {
  496|  3.17M|         if (it == end) [[unlikely]] {
  ------------------
  |  Branch (496:14): [True: 145, False: 3.17M]
  ------------------
  497|    145|            ctx.error = error_code::unexpected_end;
  498|    145|            return true;
  499|    145|         }
  500|  3.17M|      }
  501|  3.17M|      return false;
  502|  3.18M|   }
_ZN3glz17match_invalid_endILc34EXtlNS_22match_invalid_end_optsEEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  470|  3.28M|   {
  471|  3.28M|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (471:11): [True: 915, False: 3.28M]
  ------------------
  472|    915|         if constexpr (C == '"') {
  473|    915|            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|    915|         return true;
  491|    915|      }
  492|  3.28M|      else [[likely]] {
  493|  3.28M|         ++it;
  494|  3.28M|      }
  495|  3.28M|      if constexpr (not Opts.null_terminated) {
  496|  3.28M|         if (it == end) [[unlikely]] {
  ------------------
  |  Branch (496:14): [True: 160, False: 3.28M]
  ------------------
  497|    160|            ctx.error = error_code::unexpected_end;
  498|    160|            return true;
  499|    160|         }
  500|  3.28M|      }
  501|  3.28M|      return false;
  502|  3.28M|   }
_ZN3glz9chunk_minILm8EEElb:
   47|  3.28M|   {
   48|  3.28M|      static_assert(Width <= padding_bytes);
   49|  3.28M|      return padded ? 1 : std::ptrdiff_t(Width);
  ------------------
  |  Branch (49:14): [True: 0, False: 3.28M]
  ------------------
   50|  3.28M|   }
_ZN3glz18validate_utf8_spanITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextEccEEbOT0_PKT1_PKT2_m:
  873|  3.24M|   {
  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|  3.24M|      else {
  881|  3.24M|         if ((ascii_acc & repeat_byte8(0b10000000)) == 0) {
  ------------------
  |  Branch (881:14): [True: 3.09M, False: 152k]
  ------------------
  882|  3.09M|            return false; // pure ASCII is trivially well formed UTF-8
  883|  3.09M|         }
  884|   152k|         if (!validate_utf8(start, size_t(fin - start))) [[unlikely]] {
  ------------------
  |  Branch (884:14): [True: 514, False: 152k]
  ------------------
  885|    514|            ctx.error = error_code::invalid_utf8;
  886|    514|            return true;
  887|    514|         }
  888|   152k|         return false;
  889|   152k|      }
  890|  3.24M|   }
_ZN3glz13validate_utf8IcEEbPKT_m:
  842|   166k|   {
  843|   166k|      const uint8_t* it = reinterpret_cast<const uint8_t*>(str);
  844|   166k|      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|   166k|      return validate_utf8_scalar(it, end);
  856|   166k|   }
_ZN3glz20validate_utf8_scalarEPKhS1_:
  793|   166k|   {
  794|  5.64M|      while (it < end) {
  ------------------
  |  Branch (794:14): [True: 5.47M, False: 165k]
  ------------------
  795|       |         // Optimistic SWAR check for ASCII
  796|  5.47M|         if (it + 8 <= end) {
  ------------------
  |  Branch (796:14): [True: 5.13M, False: 344k]
  ------------------
  797|  5.13M|            uint64_t chunk;
  798|  5.13M|            std::memcpy(&chunk, it, 8);
  799|  5.13M|            if ((chunk & glz::repeat_byte8(0x80)) == 0) {
  ------------------
  |  Branch (799:17): [True: 5.02M, False: 109k]
  ------------------
  800|  5.02M|               it += 8;
  801|  5.02M|               continue;
  802|  5.02M|            }
  803|  5.13M|         }
  804|       |
  805|       |         // Byte-by-byte validation (standard conformant)
  806|   454k|         uint8_t byte = *it;
  807|       |
  808|   454k|         if (byte < 0x80) {
  ------------------
  |  Branch (808:14): [True: 320k, False: 133k]
  ------------------
  809|   320k|            it++;
  810|   320k|         }
  811|   133k|         else if ((byte & 0xE0) == 0xC0) {
  ------------------
  |  Branch (811:19): [True: 116k, False: 16.7k]
  ------------------
  812|       |            // 2-byte sequence
  813|   116k|            if (it + 2 > end || (it[1] & 0xC0) != 0x80) return false;
  ------------------
  |  Branch (813:17): [True: 38, False: 116k]
  |  Branch (813:33): [True: 81, False: 116k]
  ------------------
  814|   116k|            if (byte < 0xC2) return false; // Overlong
  ------------------
  |  Branch (814:17): [True: 39, False: 116k]
  ------------------
  815|   116k|            it += 2;
  816|   116k|         }
  817|  16.7k|         else if ((byte & 0xF0) == 0xE0) {
  ------------------
  |  Branch (817:19): [True: 9.65k, False: 7.08k]
  ------------------
  818|       |            // 3-byte sequence
  819|  9.65k|            if (it + 3 > end || (it[1] & 0xC0) != 0x80 || (it[2] & 0xC0) != 0x80) return false;
  ------------------
  |  Branch (819:17): [True: 28, False: 9.63k]
  |  Branch (819:33): [True: 69, False: 9.56k]
  |  Branch (819:59): [True: 55, False: 9.50k]
  ------------------
  820|  9.50k|            if (byte == 0xE0 && it[1] < 0xA0) return false; // Overlong
  ------------------
  |  Branch (820:17): [True: 3.61k, False: 5.88k]
  |  Branch (820:33): [True: 79, False: 3.53k]
  ------------------
  821|  9.42k|            if (byte == 0xED && it[1] >= 0xA0) return false; // Surrogate
  ------------------
  |  Branch (821:17): [True: 2.32k, False: 7.10k]
  |  Branch (821:33): [True: 40, False: 2.28k]
  ------------------
  822|  9.38k|            it += 3;
  823|  9.38k|         }
  824|  7.08k|         else if ((byte & 0xF8) == 0xF0) {
  ------------------
  |  Branch (824:19): [True: 6.81k, False: 266]
  ------------------
  825|       |            // 4-byte sequence
  826|  6.81k|            if (it + 4 > end || (it[1] & 0xC0) != 0x80 || (it[2] & 0xC0) != 0x80 || (it[3] & 0xC0) != 0x80)
  ------------------
  |  Branch (826:17): [True: 33, False: 6.78k]
  |  Branch (826:33): [True: 59, False: 6.72k]
  |  Branch (826:59): [True: 49, False: 6.67k]
  |  Branch (826:85): [True: 51, False: 6.62k]
  ------------------
  827|    192|               return false;
  828|  6.62k|            if (byte == 0xF0 && it[1] < 0x90) return false; // Overlong
  ------------------
  |  Branch (828:17): [True: 2.72k, False: 3.89k]
  |  Branch (828:33): [True: 64, False: 2.66k]
  ------------------
  829|  6.55k|            if (byte == 0xF4 && it[1] >= 0x90) return false; // > U+10FFFF
  ------------------
  |  Branch (829:17): [True: 1.67k, False: 4.88k]
  |  Branch (829:33): [True: 36, False: 1.63k]
  ------------------
  830|  6.52k|            if (byte > 0xF4) return false; // > U+10FFFF
  ------------------
  |  Branch (830:17): [True: 38, False: 6.48k]
  ------------------
  831|  6.48k|            it += 4;
  832|  6.48k|         }
  833|    266|         else {
  834|    266|            return false;
  835|    266|         }
  836|   454k|      }
  837|       |
  838|   165k|      return true;
  839|   166k|   }
_ZN3glz25handle_unicode_code_pointIccEENS_14unicode_resultERPKT_RPT0_S4_:
  347|  48.5k|   {
  348|  48.5k|      using namespace unicode;
  349|       |
  350|  48.5k|      if (end - it <= 4) [[unlikely]] {
  ------------------
  |  Branch (350:11): [True: 268, False: 48.2k]
  ------------------
  351|    268|         return {0, escape_prefix_intact<false>(it, end)};
  352|    268|      }
  353|  48.2k|      const uint32_t high = hex_to_u32(it);
  354|  48.2k|      if (high == 0xFFFFFFFFu) [[unlikely]] {
  ------------------
  |  Branch (354:11): [True: 208, False: 48.0k]
  ------------------
  355|    208|         return {};
  356|    208|      }
  357|  48.0k|      it += 4; // skip the code point characters
  358|       |
  359|  48.0k|      uint32_t code_point;
  360|       |
  361|  48.0k|      if ((high & generic_surrogate_mask) == generic_surrogate_value) {
  ------------------
  |  Branch (361:11): [True: 3.51k, False: 44.5k]
  ------------------
  362|       |         // surrogate pair code points
  363|  3.51k|         if ((high & surrogate_mask) != high_surrogate_value) {
  ------------------
  |  Branch (363:14): [True: 72, False: 3.44k]
  ------------------
  364|     72|            return {};
  365|     72|         }
  366|       |
  367|  3.44k|         if (end - it <= 6) [[unlikely]] {
  ------------------
  |  Branch (367:14): [True: 263, False: 3.18k]
  ------------------
  368|    263|            return {0, escape_prefix_intact<true>(it, end)};
  369|    263|         }
  370|       |         // The next two characters must be `\u`
  371|  3.18k|         uint16_t u;
  372|  3.18k|         std::memcpy(&u, it, 2);
  373|  3.18k|         if (u != to_uint16_t(R"(\u)")) [[unlikely]] {
  ------------------
  |  Branch (373:14): [True: 254, False: 2.93k]
  ------------------
  374|    254|            return {};
  375|    254|         }
  376|  2.93k|         it += 2;
  377|       |         // verify that second unicode escape sequence is present
  378|  2.93k|         const uint32_t low = hex_to_u32(it);
  379|  2.93k|         if (low == 0xFFFFFFFFu) [[unlikely]] {
  ------------------
  |  Branch (379:14): [True: 29, False: 2.90k]
  ------------------
  380|     29|            return {};
  381|     29|         }
  382|  2.90k|         it += 4;
  383|       |
  384|  2.90k|         if ((low & surrogate_mask) != low_surrogate_value) [[unlikely]] {
  ------------------
  |  Branch (384:14): [True: 60, False: 2.84k]
  ------------------
  385|     60|            return {};
  386|     60|         }
  387|       |
  388|  2.84k|         code_point = (high & surrogate_codepoint_mask) << surrogate_codepoint_bits;
  389|  2.84k|         code_point |= (low & surrogate_codepoint_mask);
  390|  2.84k|         code_point += surrogate_codepoint_offset;
  391|  2.84k|      }
  392|  44.5k|      else {
  393|  44.5k|         code_point = high;
  394|  44.5k|      }
  395|  47.3k|      const uint32_t offset = code_point_to_utf8(code_point, dst);
  396|  47.3k|      dst += offset;
  397|  47.3k|      return {offset, false};
  398|  48.0k|   }
_ZN3glz20escape_prefix_intactILb0EccEEbPKT0_PKT1_:
  329|    268|   {
  330|    268|      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|    800|      for (size_t i = 0; i < n; ++i) {
  ------------------
  |  Branch (338:26): [True: 700, False: 100]
  ------------------
  339|    700|         if (digit_hex_table[uint8_t(it[i])] == 255) return false;
  ------------------
  |  Branch (339:14): [True: 168, False: 532]
  ------------------
  340|    700|      }
  341|    100|      return true;
  342|    268|   }
_ZN3glz10hex_to_u32EPKc:
  224|  51.2k|   {
  225|  51.2k|      constexpr auto& t = digit_hex_table;
  226|  51.2k|      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|  51.2k|      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|  51.2k|      if (chunk & repeat_byte4(0b11110000u)) [[unlikely]] {
  ------------------
  |  Branch (234:11): [True: 237, False: 50.9k]
  ------------------
  235|    237|         return 0xFFFFFFFFu;
  236|    237|      }
  237|       |
  238|       |      // now pack into first four bytes of uint32_t
  239|  50.9k|      uint32_t packed{};
  240|  50.9k|      packed |= (chunk & 0x0000000F);
  241|  50.9k|      packed |= (chunk & 0x00000F00) >> 4;
  242|  50.9k|      packed |= (chunk & 0x000F0000) >> 8;
  243|  50.9k|      packed |= (chunk & 0x0F000000) >> 12;
  244|  50.9k|      return packed;
  245|  51.2k|   }
_ZN3glz20escape_prefix_intactILb1EccEEbPKT0_PKT1_:
  329|    263|   {
  330|    263|      auto n = size_t(end - it);
  331|    263|      if constexpr (ExpectOpener) {
  332|    263|         if (n > 0 && it[0] != '\\') return false;
  ------------------
  |  Branch (332:14): [True: 263, False: 0]
  |  Branch (332:23): [True: 154, False: 109]
  ------------------
  333|    109|         if (n > 1 && it[1] != 'u') return false;
  ------------------
  |  Branch (333:14): [True: 107, False: 2]
  |  Branch (333:23): [True: 55, False: 52]
  ------------------
  334|     54|         if (n < 2) return true;
  ------------------
  |  Branch (334:14): [True: 2, False: 52]
  ------------------
  335|     52|         it += 2;
  336|     52|         n -= 2;
  337|     52|      }
  338|    312|      for (size_t i = 0; i < n; ++i) {
  ------------------
  |  Branch (338:26): [True: 101, False: 211]
  ------------------
  339|    101|         if (digit_hex_table[uint8_t(it[i])] == 255) return false;
  ------------------
  |  Branch (339:14): [True: 52, False: 49]
  ------------------
  340|    101|      }
  341|    211|      return true;
  342|    263|   }
_ZN3glz18code_point_to_utf8IcEEjjPT_:
  249|  47.3k|   {
  250|  47.3k|      if (code_point <= 0x7F) {
  ------------------
  |  Branch (250:11): [True: 32.3k, False: 15.0k]
  ------------------
  251|  32.3k|         c[0] = Char(code_point);
  252|  32.3k|         return 1;
  253|  32.3k|      }
  254|  15.0k|      if (code_point <= 0x7FF) {
  ------------------
  |  Branch (254:11): [True: 5.97k, False: 9.09k]
  ------------------
  255|  5.97k|         c[0] = Char(0xC0 | ((code_point >> 6) & 0x1F));
  256|  5.97k|         c[1] = Char(0x80 | (code_point & 0x3F));
  257|  5.97k|         return 2;
  258|  5.97k|      }
  259|  9.09k|      if (code_point <= 0xFFFF) {
  ------------------
  |  Branch (259:11): [True: 6.25k, False: 2.84k]
  ------------------
  260|  6.25k|         c[0] = Char(0xE0 | ((code_point >> 12) & 0x0F));
  261|  6.25k|         c[1] = Char(0x80 | ((code_point >> 6) & 0x3F));
  262|  6.25k|         c[2] = Char(0x80 | (code_point & 0x3F));
  263|  6.25k|         return 3;
  264|  6.25k|      }
  265|  2.84k|      if (code_point <= 0x10FFFF) {
  ------------------
  |  Branch (265:11): [True: 2.84k, False: 0]
  ------------------
  266|  2.84k|         c[0] = Char(0xF0 | ((code_point >> 18) & 0x07));
  267|  2.84k|         c[1] = Char(0x80 | ((code_point >> 12) & 0x3F));
  268|  2.84k|         c[2] = Char(0x80 | ((code_point >> 6) & 0x3F));
  269|  2.84k|         c[3] = Char(0x80 | (code_point & 0x3F));
  270|  2.84k|         return 4;
  271|  2.84k|      }
  272|      0|      return 0;
  273|  2.84k|   }
_ZN3glz17match_invalid_endILc58EXtlNS_22match_invalid_end_optsEEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  470|  3.24M|   {
  471|  3.24M|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (471:11): [True: 1.15k, False: 3.24M]
  ------------------
  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.15k|         else if constexpr (C == ':') {
  479|  1.15k|            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.15k|         return true;
  491|  1.15k|      }
  492|  3.24M|      else [[likely]] {
  493|  3.24M|         ++it;
  494|  3.24M|      }
  495|  3.24M|      if constexpr (not Opts.null_terminated) {
  496|  3.24M|         if (it == end) [[unlikely]] {
  ------------------
  |  Branch (496:14): [True: 1.51k, False: 3.24M]
  ------------------
  497|  1.51k|            ctx.error = error_code::unexpected_end;
  498|  1.51k|            return true;
  499|  1.51k|         }
  500|  3.24M|      }
  501|  3.24M|      return false;
  502|  3.24M|   }
_ZN3glz17match_invalid_endILc91EXtlNS_22match_invalid_end_optsEEETkNS_10is_contextENS_7contextERPKcS4_EEbRT1_OT2_T3_:
  470|  1.74M|   {
  471|  1.74M|      if (*it != C) [[unlikely]] {
  ------------------
  |  Branch (471:11): [True: 0, False: 1.74M]
  ------------------
  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.74M|      else [[likely]] {
  493|  1.74M|         ++it;
  494|  1.74M|      }
  495|  1.74M|      if constexpr (not Opts.null_terminated) {
  496|  1.74M|         if (it == end) [[unlikely]] {
  ------------------
  |  Branch (496:14): [True: 114, False: 1.74M]
  ------------------
  497|    114|            ctx.error = error_code::unexpected_end;
  498|    114|            return true;
  499|    114|         }
  500|  1.74M|      }
  501|  1.74M|      return false;
  502|  1.74M|   }
_ZN3glz16skip_matching_wsIcRPKcEEvPKT_OT0_m:
  730|  42.7k|   {
  731|  42.7k|      if (length > 7) {
  ------------------
  |  Branch (731:11): [True: 10.7k, False: 32.0k]
  ------------------
  732|  10.7k|         uint64_t v[2];
  733|  14.3k|         while (length > 8) {
  ------------------
  |  Branch (733:17): [True: 7.98k, False: 6.40k]
  ------------------
  734|  7.98k|            std::memcpy(v, ws, 8);
  735|  7.98k|            std::memcpy(v + 1, it, 8);
  736|  7.98k|            if (v[0] != v[1]) {
  ------------------
  |  Branch (736:17): [True: 4.36k, False: 3.62k]
  ------------------
  737|  4.36k|               return;
  738|  4.36k|            }
  739|  3.62k|            length -= 8;
  740|  3.62k|            ws += 8;
  741|  3.62k|            it += 8;
  742|  3.62k|         }
  743|       |
  744|  6.40k|         const auto shift = 8 - length;
  745|  6.40k|         ws -= shift;
  746|  6.40k|         it -= shift;
  747|       |
  748|  6.40k|         std::memcpy(v, ws, 8);
  749|  6.40k|         std::memcpy(v + 1, it, 8);
  750|  6.40k|         if (v[0] != v[1]) {
  ------------------
  |  Branch (750:14): [True: 4.17k, False: 2.22k]
  ------------------
  751|  4.17k|            return;
  752|  4.17k|         }
  753|  2.22k|         it += 8;
  754|  2.22k|         return;
  755|  6.40k|      }
  756|  32.0k|      {
  757|  32.0k|         constexpr uint64_t n{sizeof(uint32_t)};
  758|  32.0k|         if (length >= n) {
  ------------------
  |  Branch (758:14): [True: 19.5k, False: 12.5k]
  ------------------
  759|  19.5k|            uint32_t v[2];
  760|  19.5k|            std::memcpy(v, ws, n);
  761|  19.5k|            std::memcpy(v + 1, it, n);
  762|  19.5k|            if (v[0] != v[1]) {
  ------------------
  |  Branch (762:17): [True: 11.4k, False: 8.01k]
  ------------------
  763|  11.4k|               return;
  764|  11.4k|            }
  765|  8.01k|            length -= n;
  766|  8.01k|            ws += n;
  767|  8.01k|            it += n;
  768|  8.01k|         }
  769|  32.0k|      }
  770|  20.5k|      {
  771|  20.5k|         constexpr uint64_t n{sizeof(uint16_t)};
  772|  20.5k|         if (length >= n) {
  ------------------
  |  Branch (772:14): [True: 4.78k, False: 15.7k]
  ------------------
  773|  4.78k|            uint16_t v[2];
  774|  4.78k|            std::memcpy(v, ws, n);
  775|  4.78k|            std::memcpy(v + 1, it, n);
  776|  4.78k|            if (v[0] != v[1]) {
  ------------------
  |  Branch (776:17): [True: 2.44k, False: 2.34k]
  ------------------
  777|  2.44k|               return;
  778|  2.44k|            }
  779|       |            // length -= n;
  780|       |            // ws += n;
  781|  2.34k|            it += n;
  782|  2.34k|         }
  783|  20.5k|      }
  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|  20.5k|   }
_ZN3glz18validate_utf8_spanITnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1ELb0ELb0ELb0ELb0ELj4EEETkNS_10is_contextERNS_7contextEccEEbOT0_PKT1_PKT2_m:
  873|  29.5k|   {
  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|  29.5k|      else {
  881|  29.5k|         if ((ascii_acc & repeat_byte8(0b10000000)) == 0) {
  ------------------
  |  Branch (881:14): [True: 15.3k, False: 14.2k]
  ------------------
  882|  15.3k|            return false; // pure ASCII is trivially well formed UTF-8
  883|  15.3k|         }
  884|  14.2k|         if (!validate_utf8(start, size_t(fin - start))) [[unlikely]] {
  ------------------
  |  Branch (884:14): [True: 511, False: 13.7k]
  ------------------
  885|    511|            ctx.error = error_code::invalid_utf8;
  886|    511|            return true;
  887|    511|         }
  888|  13.7k|         return false;
  889|  14.2k|      }
  890|  29.5k|   }
_ZN3glz5matchITnNS_14string_literalEXtlNS1_ILm5EEEtlA5_cLc110ELc117ELc108ELc108EEEETnDaXtlNS_4optsELj10ELb0ELb0ELb1ELb1EEETkNS_10is_contextERNS_7contextERPKcS8_EEvOT1_OT2_T3_:
  539|  3.50k|   {
  540|  3.50k|      static constexpr auto S = str.sv();
  541|  3.50k|      if ((end - it < std::ptrdiff_t(str.size())) || not comparitor<S>(it)) [[unlikely]] {
  ------------------
  |  Branch (541:11): [True: 95, False: 3.41k]
  |  Branch (541:54): [True: 280, False: 3.13k]
  ------------------
  542|    375|         ctx.error = error_code::syntax_error;
  543|    375|      }
  544|  3.13k|      else [[likely]] {
  545|  3.13k|         it += str.size();
  546|  3.13k|      }
  547|  3.50k|   }

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

