_ZN7httplib6detail18parse_range_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_6vectorINS1_4pairIllEENS5_ISC_EEEE:
 7785|    462|inline bool parse_range_header(const std::string &s, Ranges &ranges) try {
 7786|    462|#endif
 7787|    462|  auto is_valid = [](const std::string &str) {
 7788|    462|    return std::all_of(str.cbegin(), str.cend(),
 7789|    462|                       [](unsigned char c) { return std::isdigit(c); });
 7790|    462|  };
 7791|       |
 7792|    462|  if (s.size() > 7 && s.compare(0, 6, "bytes=") == 0) {
  ------------------
  |  Branch (7792:7): [True: 457, False: 5]
  |  Branch (7792:23): [True: 439, False: 18]
  ------------------
 7793|    439|    const auto pos = static_cast<size_t>(6);
 7794|    439|    const auto len = static_cast<size_t>(s.size() - 6);
 7795|    439|    auto all_valid_ranges = true;
 7796|    439|    split(&s[pos], &s[pos + len], ',', [&](const char *b, const char *e) {
 7797|    439|      if (!all_valid_ranges) { return; }
 7798|       |
 7799|    439|      const auto it = std::find(b, e, '-');
 7800|    439|      if (it == e) {
 7801|    439|        all_valid_ranges = false;
 7802|    439|        return;
 7803|    439|      }
 7804|       |
 7805|    439|      const auto lhs = std::string(b, it);
 7806|    439|      const auto rhs = std::string(it + 1, e);
 7807|    439|      if (!is_valid(lhs) || !is_valid(rhs)) {
 7808|    439|        all_valid_ranges = false;
 7809|    439|        return;
 7810|    439|      }
 7811|       |
 7812|    439|      ssize_t first = -1;
 7813|    439|      if (!lhs.empty()) {
 7814|    439|        ssize_t v;
 7815|    439|        auto res = detail::from_chars(lhs.data(), lhs.data() + lhs.size(), v);
 7816|    439|        if (res.ec == std::errc{}) { first = v; }
 7817|    439|      }
 7818|       |
 7819|    439|      ssize_t last = -1;
 7820|    439|      if (!rhs.empty()) {
 7821|    439|        ssize_t v;
 7822|    439|        auto res = detail::from_chars(rhs.data(), rhs.data() + rhs.size(), v);
 7823|    439|        if (res.ec == std::errc{}) { last = v; }
 7824|    439|      }
 7825|       |
 7826|    439|      if ((first == -1 && last == -1) ||
 7827|    439|          (first != -1 && last != -1 && first > last)) {
 7828|    439|        all_valid_ranges = false;
 7829|    439|        return;
 7830|    439|      }
 7831|       |
 7832|    439|      ranges.emplace_back(first, last);
 7833|    439|    });
 7834|    439|    return all_valid_ranges && !ranges.empty();
  ------------------
  |  Branch (7834:12): [True: 190, False: 249]
  |  Branch (7834:32): [True: 190, False: 0]
  ------------------
 7835|    439|  }
 7836|     23|  return false;
 7837|       |#ifdef CPPHTTPLIB_NO_EXCEPTIONS
 7838|       |}
 7839|       |#else
 7840|    462|} catch (...) { return false; }
_ZN7httplib6detail5splitEPKcS2_cNSt3__18functionIFvS2_S2_EEE:
 5212|   116k|                  std::function<void(const char *, const char *)> fn) {
 5213|   116k|  return split(b, e, d, (std::numeric_limits<size_t>::max)(), std::move(fn));
 5214|   116k|}
_ZN7httplib6detail5splitEPKcS2_cmNSt3__18functionIFvS2_S2_EEE:
 5217|   116k|                  std::function<void(const char *, const char *)> fn) {
 5218|   116k|  size_t i = 0;
 5219|   116k|  size_t beg = 0;
 5220|   116k|  size_t count = 1;
 5221|       |
 5222|  10.6M|  while (e ? (b + i < e) : (b[i] != '\0')) {
  ------------------
  |  Branch (5222:10): [True: 10.6M, False: 0]
  |  Branch (5222:10): [True: 10.4M, False: 116k]
  ------------------
 5223|  10.4M|    if (b[i] == d && count < m) {
  ------------------
  |  Branch (5223:9): [True: 942k, False: 9.54M]
  |  Branch (5223:22): [True: 942k, False: 0]
  ------------------
 5224|   942k|      auto r = trim(b, e, beg, i);
 5225|   942k|      if (r.first < r.second) { fn(&b[r.first], &b[r.second]); }
  ------------------
  |  Branch (5225:11): [True: 817k, False: 125k]
  ------------------
 5226|   942k|      beg = i + 1;
 5227|   942k|      count++;
 5228|   942k|    }
 5229|  10.4M|    i++;
 5230|  10.4M|  }
 5231|       |
 5232|   116k|  if (i) {
  ------------------
  |  Branch (5232:7): [True: 116k, False: 6]
  ------------------
 5233|   116k|    auto r = trim(b, e, beg, i);
 5234|   116k|    if (r.first < r.second) { fn(&b[r.first], &b[r.second]); }
  ------------------
  |  Branch (5234:9): [True: 114k, False: 1.42k]
  ------------------
 5235|   116k|  }
 5236|   116k|}
_ZN7httplib6detail4trimEPKcS2_mm:
 5168|  3.75M|                                      size_t right) {
 5169|  3.76M|  while (b + left < e && is_space_or_tab(b[left])) {
  ------------------
  |  Branch (5169:10): [True: 3.76M, False: 3.95k]
  |  Branch (5169:26): [True: 13.7k, False: 3.74M]
  ------------------
 5170|  13.7k|    left++;
 5171|  13.7k|  }
 5172|  3.76M|  while (right > 0 && is_space_or_tab(b[right - 1])) {
  ------------------
  |  Branch (5172:10): [True: 3.76M, False: 2.22k]
  |  Branch (5172:23): [True: 16.0k, False: 3.75M]
  ------------------
 5173|  16.0k|    right--;
 5174|  16.0k|  }
 5175|  3.75M|  return std::make_pair(left, right);
 5176|  3.75M|}
_ZN7httplib6detail15is_space_or_tabEc:
 5023|  7.52M|inline bool is_space_or_tab(char c) { return c == ' ' || c == '\t'; }
  ------------------
  |  Branch (5023:46): [True: 28.7k, False: 7.50M]
  |  Branch (5023:58): [True: 1.07k, False: 7.49M]
  ------------------
_ZZN7httplib6detail18parse_range_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_6vectorINS1_4pairIllEENS5_ISC_EEEEENKUlPKcSH_E_clESH_SH_:
 7796|  7.23k|    split(&s[pos], &s[pos + len], ',', [&](const char *b, const char *e) {
 7797|  7.23k|      if (!all_valid_ranges) { return; }
  ------------------
  |  Branch (7797:11): [True: 830, False: 6.40k]
  ------------------
 7798|       |
 7799|  6.40k|      const auto it = std::find(b, e, '-');
 7800|  6.40k|      if (it == e) {
  ------------------
  |  Branch (7800:11): [True: 55, False: 6.35k]
  ------------------
 7801|     55|        all_valid_ranges = false;
 7802|     55|        return;
 7803|     55|      }
 7804|       |
 7805|  6.35k|      const auto lhs = std::string(b, it);
 7806|  6.35k|      const auto rhs = std::string(it + 1, e);
 7807|  6.35k|      if (!is_valid(lhs) || !is_valid(rhs)) {
  ------------------
  |  Branch (7807:11): [True: 11, False: 6.33k]
  |  Branch (7807:29): [True: 23, False: 6.31k]
  ------------------
 7808|     34|        all_valid_ranges = false;
 7809|     34|        return;
 7810|     34|      }
 7811|       |
 7812|  6.31k|      ssize_t first = -1;
 7813|  6.31k|      if (!lhs.empty()) {
  ------------------
  |  Branch (7813:11): [True: 4.47k, False: 1.84k]
  ------------------
 7814|  4.47k|        ssize_t v;
 7815|  4.47k|        auto res = detail::from_chars(lhs.data(), lhs.data() + lhs.size(), v);
 7816|  4.47k|        if (res.ec == std::errc{}) { first = v; }
  ------------------
  |  Branch (7816:13): [True: 3.67k, False: 800]
  ------------------
 7817|  4.47k|      }
 7818|       |
 7819|  6.31k|      ssize_t last = -1;
 7820|  6.31k|      if (!rhs.empty()) {
  ------------------
  |  Branch (7820:11): [True: 3.52k, False: 2.79k]
  ------------------
 7821|  3.52k|        ssize_t v;
 7822|  3.52k|        auto res = detail::from_chars(rhs.data(), rhs.data() + rhs.size(), v);
 7823|  3.52k|        if (res.ec == std::errc{}) { last = v; }
  ------------------
  |  Branch (7823:13): [True: 3.42k, False: 97]
  ------------------
 7824|  3.52k|      }
 7825|       |
 7826|  6.31k|      if ((first == -1 && last == -1) ||
  ------------------
  |  Branch (7826:12): [True: 2.64k, False: 3.67k]
  |  Branch (7826:27): [True: 57, False: 2.58k]
  ------------------
 7827|  6.25k|          (first != -1 && last != -1 && first > last)) {
  ------------------
  |  Branch (7827:12): [True: 3.67k, False: 2.58k]
  |  Branch (7827:27): [True: 841, False: 2.83k]
  |  Branch (7827:41): [True: 103, False: 738]
  ------------------
 7828|    160|        all_valid_ranges = false;
 7829|    160|        return;
 7830|    160|      }
 7831|       |
 7832|  6.15k|      ranges.emplace_back(first, last);
 7833|  6.15k|    });
_ZZN7httplib6detail18parse_range_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_6vectorINS1_4pairIllEENS5_ISC_EEEEENKUlS9_E_clES9_:
 7787|  12.6k|  auto is_valid = [](const std::string &str) {
 7788|  12.6k|    return std::all_of(str.cbegin(), str.cend(),
 7789|  12.6k|                       [](unsigned char c) { return std::isdigit(c); });
 7790|  12.6k|  };
_ZZZN7httplib6detail18parse_range_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_6vectorINS1_4pairIllEENS5_ISC_EEEEENKUlS9_E_clES9_ENKUlhE_clEh:
 7789|  48.1k|                       [](unsigned char c) { return std::isdigit(c); });
_ZN7httplib6detail10from_charsIlEENS0_17from_chars_resultIT_EEPKcS6_RS3_i:
  649|  7.99k|                                       T &value, int base = 10) {
  650|  7.99k|  value = 0;
  651|  7.99k|  const char *p = first;
  652|  7.99k|  bool negative = false;
  653|       |
  654|  7.99k|  if (p != last && *p == '-') {
  ------------------
  |  Branch (654:7): [True: 7.99k, False: 0]
  |  Branch (654:20): [True: 0, False: 7.99k]
  ------------------
  655|      0|    negative = true;
  656|      0|    ++p;
  657|      0|  }
  658|  7.99k|  if (p == last) { return {first, std::errc::invalid_argument}; }
  ------------------
  |  Branch (658:7): [True: 0, False: 7.99k]
  ------------------
  659|       |
  660|  7.99k|  T result = 0;
  661|  40.7k|  for (; p != last; ++p) {
  ------------------
  |  Branch (661:10): [True: 33.6k, False: 7.10k]
  ------------------
  662|  33.6k|    char c = *p;
  663|  33.6k|    int digit = -1;
  664|  33.6k|    if ('0' <= c && c <= '9') {
  ------------------
  |  Branch (664:9): [True: 33.6k, False: 0]
  |  Branch (664:21): [True: 33.6k, False: 0]
  ------------------
  665|  33.6k|      digit = c - '0';
  666|  33.6k|    } else if ('a' <= c && c <= 'z') {
  ------------------
  |  Branch (666:16): [True: 0, False: 0]
  |  Branch (666:28): [True: 0, False: 0]
  ------------------
  667|      0|      digit = c - 'a' + 10;
  668|      0|    } else if ('A' <= c && c <= 'Z') {
  ------------------
  |  Branch (668:16): [True: 0, False: 0]
  |  Branch (668:28): [True: 0, False: 0]
  ------------------
  669|      0|      digit = c - 'A' + 10;
  670|      0|    } else {
  671|      0|      break;
  672|      0|    }
  673|       |
  674|  33.6k|    if (digit < 0 || digit >= base) { break; }
  ------------------
  |  Branch (674:9): [True: 0, False: 33.6k]
  |  Branch (674:22): [True: 0, False: 33.6k]
  ------------------
  675|  33.6k|    if (result > ((std::numeric_limits<T>::max)() - digit) / base) {
  ------------------
  |  Branch (675:9): [True: 897, False: 32.7k]
  ------------------
  676|    897|      return {p, std::errc::result_out_of_range};
  677|    897|    }
  678|  32.7k|    result = result * base + digit;
  679|  32.7k|  }
  680|       |
  681|  7.10k|  if (p == first || (negative && p == first + 1)) {
  ------------------
  |  Branch (681:7): [True: 0, False: 7.10k]
  |  Branch (681:22): [True: 0, False: 7.10k]
  |  Branch (681:34): [True: 0, False: 0]
  ------------------
  682|      0|    return {first, std::errc::invalid_argument};
  683|      0|  }
  684|       |
  685|  7.10k|  value = negative ? -result : result;
  ------------------
  |  Branch (685:11): [True: 0, False: 7.10k]
  ------------------
  686|  7.10k|  return {p, std::errc{}};
  687|  7.10k|}
_ZN7httplib6detail19parse_accept_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_6vectorIS7_NS5_IS7_EEEE:
 7844|    971|                                std::vector<std::string> &content_types) {
 7845|    971|  content_types.clear();
 7846|       |
 7847|       |  // Empty string is considered valid (no preference)
 7848|    971|  if (s.empty()) { return true; }
  ------------------
  |  Branch (7848:7): [True: 0, False: 971]
  ------------------
 7849|       |
 7850|       |  // Check for invalid patterns: leading/trailing commas or consecutive commas
 7851|    971|  if (s.front() == ',' || s.back() == ',' ||
  ------------------
  |  Branch (7851:7): [True: 2, False: 969]
  |  Branch (7851:27): [True: 1, False: 968]
  ------------------
 7852|    968|      s.find(",,") != std::string::npos) {
  ------------------
  |  Branch (7852:7): [True: 18, False: 950]
  ------------------
 7853|     21|    return false;
 7854|     21|  }
 7855|       |
 7856|    950|  struct AcceptEntry {
 7857|    950|    std::string media_type;
 7858|    950|    double quality;
 7859|    950|    int order;
 7860|    950|  };
 7861|       |
 7862|    950|  std::vector<AcceptEntry> entries;
 7863|    950|  int order = 0;
 7864|    950|  bool has_invalid_entry = false;
 7865|       |
 7866|       |  // Split by comma and parse each entry
 7867|    950|  split(s.data(), s.data() + s.size(), ',', [&](const char *b, const char *e) {
 7868|    950|    std::string entry(b, e);
 7869|    950|    entry = trim_copy(entry);
 7870|       |
 7871|    950|    if (entry.empty()) {
 7872|    950|      has_invalid_entry = true;
 7873|    950|      return;
 7874|    950|    }
 7875|       |
 7876|    950|    AcceptEntry accept_entry;
 7877|    950|    accept_entry.order = order++;
 7878|       |
 7879|    950|    if (!parse_quality(entry.data(), entry.data() + entry.size(),
 7880|    950|                       accept_entry.media_type, accept_entry.quality)) {
 7881|    950|      has_invalid_entry = true;
 7882|    950|      return;
 7883|    950|    }
 7884|       |
 7885|       |    // Remove additional parameters from media type
 7886|    950|    accept_entry.media_type = extract_media_type(accept_entry.media_type);
 7887|       |
 7888|       |    // Basic validation of media type format
 7889|    950|    if (accept_entry.media_type.empty()) {
 7890|    950|      has_invalid_entry = true;
 7891|    950|      return;
 7892|    950|    }
 7893|       |
 7894|       |    // Check for basic media type format (should contain '/' or be '*')
 7895|    950|    if (accept_entry.media_type != "*" &&
 7896|    950|        accept_entry.media_type.find('/') == std::string::npos) {
 7897|    950|      has_invalid_entry = true;
 7898|    950|      return;
 7899|    950|    }
 7900|       |
 7901|    950|    entries.push_back(std::move(accept_entry));
 7902|    950|  });
 7903|       |
 7904|       |  // Return false if any invalid entry was found
 7905|    950|  if (has_invalid_entry) { return false; }
  ------------------
  |  Branch (7905:7): [True: 431, False: 519]
  ------------------
 7906|       |
 7907|       |  // Sort by quality (descending), then by original order (ascending)
 7908|    519|  std::sort(entries.begin(), entries.end(),
 7909|    519|            [](const AcceptEntry &a, const AcceptEntry &b) {
 7910|    519|              if (a.quality != b.quality) {
 7911|    519|                return a.quality > b.quality; // Higher quality first
 7912|    519|              }
 7913|    519|              return a.order < b.order; // Earlier order first for same quality
 7914|    519|            });
 7915|       |
 7916|       |  // Extract sorted media types
 7917|    519|  content_types.reserve(entries.size());
 7918|   591k|  for (auto &entry : entries) {
  ------------------
  |  Branch (7918:20): [True: 591k, False: 519]
  ------------------
 7919|   591k|    content_types.push_back(std::move(entry.media_type));
 7920|   591k|  }
 7921|       |
 7922|    519|  return true;
 7923|    950|}
_ZZN7httplib6detail19parse_accept_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_6vectorIS7_NS5_IS7_EEEEENKUlPKcSF_E_clESF_SF_:
 7867|   683k|  split(s.data(), s.data() + s.size(), ',', [&](const char *b, const char *e) {
 7868|   683k|    std::string entry(b, e);
 7869|   683k|    entry = trim_copy(entry);
 7870|       |
 7871|   683k|    if (entry.empty()) {
  ------------------
  |  Branch (7871:9): [True: 0, False: 683k]
  ------------------
 7872|      0|      has_invalid_entry = true;
 7873|      0|      return;
 7874|      0|    }
 7875|       |
 7876|   683k|    AcceptEntry accept_entry;
 7877|   683k|    accept_entry.order = order++;
 7878|       |
 7879|   683k|    if (!parse_quality(entry.data(), entry.data() + entry.size(),
  ------------------
  |  Branch (7879:9): [True: 2.33k, False: 681k]
  ------------------
 7880|   683k|                       accept_entry.media_type, accept_entry.quality)) {
 7881|  2.33k|      has_invalid_entry = true;
 7882|  2.33k|      return;
 7883|  2.33k|    }
 7884|       |
 7885|       |    // Remove additional parameters from media type
 7886|   681k|    accept_entry.media_type = extract_media_type(accept_entry.media_type);
 7887|       |
 7888|       |    // Basic validation of media type format
 7889|   681k|    if (accept_entry.media_type.empty()) {
  ------------------
  |  Branch (7889:9): [True: 0, False: 681k]
  ------------------
 7890|      0|      has_invalid_entry = true;
 7891|      0|      return;
 7892|      0|    }
 7893|       |
 7894|       |    // Check for basic media type format (should contain '/' or be '*')
 7895|   681k|    if (accept_entry.media_type != "*" &&
  ------------------
  |  Branch (7895:9): [True: 432k, False: 248k]
  ------------------
 7896|   432k|        accept_entry.media_type.find('/') == std::string::npos) {
  ------------------
  |  Branch (7896:9): [True: 3.45k, False: 429k]
  ------------------
 7897|  3.45k|      has_invalid_entry = true;
 7898|  3.45k|      return;
 7899|  3.45k|    }
 7900|       |
 7901|   677k|    entries.push_back(std::move(accept_entry));
 7902|   677k|  });
_ZN7httplib6detail9trim_copyERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 5178|  1.46M|inline std::string trim_copy(const std::string &s) {
 5179|  1.46M|  auto r = trim(s.data(), s.data() + s.size(), 0, s.size());
 5180|  1.46M|  return s.substr(r.first, r.second - r.first);
 5181|  1.46M|}
_ZN7httplib6detail13parse_qualityEPKcS2_RNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERd:
 6570|   683k|                          double &quality) {
 6571|   683k|  quality = 1.0;
 6572|   683k|  token.clear();
 6573|       |
 6574|       |  // Split on first ';': left = token name, right = parameters
 6575|   683k|  const char *params_b = nullptr;
 6576|   683k|  std::size_t params_len = 0;
 6577|       |
 6578|   683k|  divide(
 6579|   683k|      b, static_cast<std::size_t>(e - b), ';',
 6580|   683k|      [&](const char *lb, std::size_t llen, const char *rb, std::size_t rlen) {
 6581|   683k|        auto r = trim(lb, lb + llen, 0, llen);
 6582|   683k|        if (r.first < r.second) { token.assign(lb + r.first, lb + r.second); }
 6583|   683k|        params_b = rb;
 6584|   683k|        params_len = rlen;
 6585|   683k|      });
 6586|       |
 6587|   683k|  if (token.empty()) { return false; }
  ------------------
  |  Branch (6587:7): [True: 393, False: 683k]
  ------------------
 6588|   683k|  if (params_len == 0) { return true; }
  ------------------
  |  Branch (6588:7): [True: 580k, False: 102k]
  ------------------
 6589|       |
 6590|       |  // Scan parameters for q= (stops on first match)
 6591|   102k|  bool invalid = false;
 6592|   102k|  split_find(params_b, params_b + params_len, ';',
 6593|   102k|             (std::numeric_limits<size_t>::max)(),
 6594|   102k|             [&](const char *pb, const char *pe) -> bool {
 6595|       |               // Match exactly "q=" or "Q=" (not "query=" etc.)
 6596|   102k|               auto len = static_cast<size_t>(pe - pb);
 6597|   102k|               if (len < 2) { return false; }
 6598|   102k|               if ((pb[0] != 'q' && pb[0] != 'Q') || pb[1] != '=') {
 6599|   102k|                 return false;
 6600|   102k|               }
 6601|       |
 6602|       |               // Trim the value portion
 6603|   102k|               auto r = trim(pb, pe, 2, len);
 6604|   102k|               if (r.first >= r.second) {
 6605|   102k|                 invalid = true;
 6606|   102k|                 return true;
 6607|   102k|               }
 6608|       |
 6609|   102k|               double v = 0.0;
 6610|   102k|               auto res = from_chars(pb + r.first, pb + r.second, v);
 6611|   102k|               if (res.ec != std::errc{} || v < 0.0 || v > 1.0) {
 6612|   102k|                 invalid = true;
 6613|   102k|                 return true;
 6614|   102k|               }
 6615|   102k|               quality = v;
 6616|   102k|               return true;
 6617|   102k|             });
 6618|       |
 6619|   102k|  return !invalid;
 6620|   683k|}
_ZN7httplib6detail6divideEPKcmcNSt3__18functionIFvS2_mS2_mEEE:
 5193|   683k|           fn) {
 5194|   683k|  const auto it = std::find(data, data + size, d);
 5195|   683k|  const auto found = static_cast<std::size_t>(it != data + size);
 5196|   683k|  const auto lhs_data = data;
 5197|   683k|  const auto lhs_size = static_cast<std::size_t>(it - data);
 5198|   683k|  const auto rhs_data = it + found;
 5199|   683k|  const auto rhs_size = size - lhs_size - found;
 5200|       |
 5201|   683k|  fn(lhs_data, lhs_size, rhs_data, rhs_size);
 5202|   683k|}
_ZZN7httplib6detail13parse_qualityEPKcS2_RNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERdENKUlS2_mS2_mE_clES2_mS2_m:
 6580|   683k|      [&](const char *lb, std::size_t llen, const char *rb, std::size_t rlen) {
 6581|   683k|        auto r = trim(lb, lb + llen, 0, llen);
 6582|   683k|        if (r.first < r.second) { token.assign(lb + r.first, lb + r.second); }
  ------------------
  |  Branch (6582:13): [True: 683k, False: 393]
  ------------------
 6583|   683k|        params_b = rb;
 6584|   683k|        params_len = rlen;
 6585|   683k|      });
_ZN7httplib6detail10split_findEPKcS2_cmNSt3__18functionIFbS2_S2_EEE:
 5239|   102k|                       std::function<bool(const char *, const char *)> fn) {
 5240|   102k|  size_t i = 0;
 5241|   102k|  size_t beg = 0;
 5242|   102k|  size_t count = 1;
 5243|       |
 5244|  1.85M|  while (e ? (b + i < e) : (b[i] != '\0')) {
  ------------------
  |  Branch (5244:10): [True: 1.85M, False: 0]
  |  Branch (5244:10): [True: 1.75M, False: 98.3k]
  ------------------
 5245|  1.75M|    if (b[i] == d && count < m) {
  ------------------
  |  Branch (5245:9): [True: 436k, False: 1.32M]
  |  Branch (5245:22): [True: 436k, False: 0]
  ------------------
 5246|   436k|      auto r = trim(b, e, beg, i);
 5247|   436k|      if (r.first < r.second) {
  ------------------
  |  Branch (5247:11): [True: 230k, False: 205k]
  ------------------
 5248|   230k|        auto found = fn(&b[r.first], &b[r.second]);
 5249|   230k|        if (found) { return true; }
  ------------------
  |  Branch (5249:13): [True: 3.95k, False: 226k]
  ------------------
 5250|   230k|      }
 5251|   432k|      beg = i + 1;
 5252|   432k|      count++;
 5253|   432k|    }
 5254|  1.75M|    i++;
 5255|  1.75M|  }
 5256|       |
 5257|  98.3k|  if (i) {
  ------------------
  |  Branch (5257:7): [True: 98.3k, False: 0]
  ------------------
 5258|  98.3k|    auto r = trim(b, e, beg, i);
 5259|  98.3k|    if (r.first < r.second) {
  ------------------
  |  Branch (5259:9): [True: 96.7k, False: 1.58k]
  ------------------
 5260|  96.7k|      auto found = fn(&b[r.first], &b[r.second]);
 5261|  96.7k|      if (found) { return true; }
  ------------------
  |  Branch (5261:11): [True: 6.61k, False: 90.1k]
  ------------------
 5262|  96.7k|    }
 5263|  98.3k|  }
 5264|       |
 5265|  91.7k|  return false;
 5266|  98.3k|}
_ZZN7httplib6detail13parse_qualityEPKcS2_RNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEERdENKUlS2_S2_E_clES2_S2_:
 6594|   327k|             [&](const char *pb, const char *pe) -> bool {
 6595|       |               // Match exactly "q=" or "Q=" (not "query=" etc.)
 6596|   327k|               auto len = static_cast<size_t>(pe - pb);
 6597|   327k|               if (len < 2) { return false; }
  ------------------
  |  Branch (6597:20): [True: 263k, False: 63.9k]
  ------------------
 6598|  63.9k|               if ((pb[0] != 'q' && pb[0] != 'Q') || pb[1] != '=') {
  ------------------
  |  Branch (6598:21): [True: 57.5k, False: 6.38k]
  |  Branch (6598:37): [True: 52.5k, False: 5.03k]
  |  Branch (6598:54): [True: 842, False: 10.5k]
  ------------------
 6599|  53.3k|                 return false;
 6600|  53.3k|               }
 6601|       |
 6602|       |               // Trim the value portion
 6603|  10.5k|               auto r = trim(pb, pe, 2, len);
 6604|  10.5k|               if (r.first >= r.second) {
  ------------------
  |  Branch (6604:20): [True: 409, False: 10.1k]
  ------------------
 6605|    409|                 invalid = true;
 6606|    409|                 return true;
 6607|    409|               }
 6608|       |
 6609|  10.1k|               double v = 0.0;
 6610|  10.1k|               auto res = from_chars(pb + r.first, pb + r.second, v);
 6611|  10.1k|               if (res.ec != std::errc{} || v < 0.0 || v > 1.0) {
  ------------------
  |  Branch (6611:20): [True: 905, False: 9.25k]
  |  Branch (6611:45): [True: 225, False: 9.03k]
  |  Branch (6611:56): [True: 405, False: 8.62k]
  ------------------
 6612|  1.53k|                 invalid = true;
 6613|  1.53k|                 return true;
 6614|  1.53k|               }
 6615|  8.62k|               quality = v;
 6616|  8.62k|               return true;
 6617|  10.1k|             });
_ZN7httplib6detail10from_charsEPKcS2_Rd:
  691|  10.1k|                                            double &value) {
  692|  10.1k|  std::string s(first, last);
  693|  10.1k|  char *endptr = nullptr;
  694|  10.1k|  errno = 0;
  695|  10.1k|  value = std::strtod(s.c_str(), &endptr);
  696|  10.1k|  if (endptr == s.c_str()) { return {first, std::errc::invalid_argument}; }
  ------------------
  |  Branch (696:7): [True: 489, False: 9.67k]
  ------------------
  697|  9.67k|  if (errno == ERANGE) {
  ------------------
  |  Branch (697:7): [True: 416, False: 9.25k]
  ------------------
  698|    416|    return {first + (endptr - s.c_str()), std::errc::result_out_of_range};
  699|    416|  }
  700|  9.25k|  return {first + (endptr - s.c_str()), std::errc{}};
  701|  9.67k|}
_ZZN7httplib6detail19parse_accept_headerERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_6vectorIS7_NS5_IS7_EEEEENKUlRKZNS0_19parse_accept_headerES9_SD_E11AcceptEntrySG_E_clESG_SG_:
 7909|  11.2M|            [](const AcceptEntry &a, const AcceptEntry &b) {
 7910|  11.2M|              if (a.quality != b.quality) {
  ------------------
  |  Branch (7910:19): [True: 29.5k, False: 11.2M]
  ------------------
 7911|  29.5k|                return a.quality > b.quality; // Higher quality first
 7912|  29.5k|              }
 7913|  11.2M|              return a.order < b.order; // Earlier order first for same quality
 7914|  11.2M|            });
_ZN7httplib6detail18extract_media_typeERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEPNS1_3mapIS7_S7_NS1_4lessIS7_EENS5_INS1_4pairIS8_S7_EEEEEE:
 6511|   682k|                   std::map<std::string, std::string> *params = nullptr) {
 6512|       |  // Extract type/subtype from Content-Type value (RFC 2045)
 6513|       |  // e.g. "application/json; charset=utf-8" -> "application/json"
 6514|   682k|  auto media_type = content_type;
 6515|   682k|  auto semicolon_pos = media_type.find(';');
 6516|   682k|  if (semicolon_pos != std::string::npos) {
  ------------------
  |  Branch (6516:7): [True: 255, False: 682k]
  ------------------
 6517|    255|    auto param_str = media_type.substr(semicolon_pos + 1);
 6518|    255|    media_type = media_type.substr(0, semicolon_pos);
 6519|       |
 6520|    255|    if (params) {
  ------------------
  |  Branch (6520:9): [True: 202, False: 53]
  ------------------
 6521|       |      // Parse parameters: key=value pairs separated by ';'
 6522|    202|      split(param_str.data(), param_str.data() + param_str.size(), ';',
 6523|    202|            [&](const char *b, const char *e) {
 6524|    202|              std::string key;
 6525|    202|              std::string val;
 6526|    202|              split(b, e, '=', [&](const char *b2, const char *e2) {
 6527|    202|                if (key.empty()) {
 6528|    202|                  key.assign(b2, e2);
 6529|    202|                } else {
 6530|    202|                  val.assign(b2, e2);
 6531|    202|                }
 6532|    202|              });
 6533|    202|              if (!key.empty()) {
 6534|    202|                params->emplace(trim_copy(key), trim_double_quotes_copy(val));
 6535|    202|              }
 6536|    202|            });
 6537|    202|    }
 6538|    255|  }
 6539|       |
 6540|       |  // Trim whitespace from media type
 6541|   682k|  return trim_copy(media_type);
 6542|   682k|}
_ZZN7httplib6detail18extract_media_typeERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEPNS1_3mapIS7_S7_NS1_4lessIS7_EENS5_INS1_4pairIS8_S7_EEEEEEENKUlPKcSJ_E_clESJ_SJ_:
 6523|  99.7k|            [&](const char *b, const char *e) {
 6524|  99.7k|              std::string key;
 6525|  99.7k|              std::string val;
 6526|  99.7k|              split(b, e, '=', [&](const char *b2, const char *e2) {
 6527|  99.7k|                if (key.empty()) {
 6528|  99.7k|                  key.assign(b2, e2);
 6529|  99.7k|                } else {
 6530|  99.7k|                  val.assign(b2, e2);
 6531|  99.7k|                }
 6532|  99.7k|              });
 6533|  99.7k|              if (!key.empty()) {
  ------------------
  |  Branch (6533:19): [True: 99.1k, False: 624]
  ------------------
 6534|  99.1k|                params->emplace(trim_copy(key), trim_double_quotes_copy(val));
 6535|  99.1k|              }
 6536|  99.7k|            });
_ZZZN7httplib6detail18extract_media_typeERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEPNS1_3mapIS7_S7_NS1_4lessIS7_EENS5_INS1_4pairIS8_S7_EEEEEEENKUlPKcSJ_E_clESJ_SJ_ENKUlSJ_SJ_E_clESJ_SJ_:
 6526|   100k|              split(b, e, '=', [&](const char *b2, const char *e2) {
 6527|   100k|                if (key.empty()) {
  ------------------
  |  Branch (6527:21): [True: 99.1k, False: 1.07k]
  ------------------
 6528|  99.1k|                  key.assign(b2, e2);
 6529|  99.1k|                } else {
 6530|  1.07k|                  val.assign(b2, e2);
 6531|  1.07k|                }
 6532|   100k|              });
_ZN7httplib6detail23trim_double_quotes_copyERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 5183|   127k|inline std::string trim_double_quotes_copy(const std::string &s) {
 5184|   127k|  if (s.length() >= 2 && s.front() == '"' && s.back() == '"') {
  ------------------
  |  Branch (5184:7): [True: 11.9k, False: 115k]
  |  Branch (5184:26): [True: 491, False: 11.4k]
  |  Branch (5184:46): [True: 136, False: 355]
  ------------------
 5185|    136|    return s.substr(1, s.size() - 2);
 5186|    136|  }
 5187|   127k|  return s;
 5188|   127k|}
_ZN7httplib6detail24parse_multipart_boundaryERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERS7_:
 7749|    181|                                     std::string &boundary) {
 7750|    181|  std::map<std::string, std::string> params;
 7751|    181|  extract_media_type(content_type, &params);
 7752|    181|  auto it = params.find("boundary");
 7753|    181|  if (it == params.end()) { return false; }
  ------------------
  |  Branch (7753:7): [True: 180, False: 1]
  ------------------
 7754|      1|  boundary = it->second;
 7755|      1|  return !boundary.empty();
 7756|    181|}
_ZN7httplib6detail24parse_disposition_paramsERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_8multimapIS7_S7_NS1_4lessIS7_EENS5_INS1_4pairIS8_S7_EEEEEE:
 7758|    499|inline void parse_disposition_params(const std::string &s, Params &params) {
 7759|    499|  std::set<std::string> cache;
 7760|    499|  split(s.data(), s.data() + s.size(), ';', [&](const char *b, const char *e) {
 7761|    499|    std::string kv(b, e);
 7762|    499|    if (cache.find(kv) != cache.end()) { return; }
 7763|    499|    cache.insert(kv);
 7764|       |
 7765|    499|    std::string key;
 7766|    499|    std::string val;
 7767|    499|    split(b, e, '=', [&](const char *b2, const char *e2) {
 7768|    499|      if (key.empty()) {
 7769|    499|        key.assign(b2, e2);
 7770|    499|      } else {
 7771|    499|        val.assign(b2, e2);
 7772|    499|      }
 7773|    499|    });
 7774|       |
 7775|    499|    if (!key.empty()) {
 7776|    499|      params.emplace(trim_double_quotes_copy((key)),
 7777|    499|                     trim_double_quotes_copy((val)));
 7778|    499|    }
 7779|    499|  });
 7780|    499|}
_ZZN7httplib6detail24parse_disposition_paramsERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_8multimapIS7_S7_NS1_4lessIS7_EENS5_INS1_4pairIS8_S7_EEEEEEENKUlPKcSJ_E_clESJ_SJ_:
 7760|  23.3k|  split(s.data(), s.data() + s.size(), ';', [&](const char *b, const char *e) {
 7761|  23.3k|    std::string kv(b, e);
 7762|  23.3k|    if (cache.find(kv) != cache.end()) { return; }
  ------------------
  |  Branch (7762:9): [True: 8.96k, False: 14.3k]
  ------------------
 7763|  14.3k|    cache.insert(kv);
 7764|       |
 7765|  14.3k|    std::string key;
 7766|  14.3k|    std::string val;
 7767|  14.3k|    split(b, e, '=', [&](const char *b2, const char *e2) {
 7768|  14.3k|      if (key.empty()) {
 7769|  14.3k|        key.assign(b2, e2);
 7770|  14.3k|      } else {
 7771|  14.3k|        val.assign(b2, e2);
 7772|  14.3k|      }
 7773|  14.3k|    });
 7774|       |
 7775|  14.3k|    if (!key.empty()) {
  ------------------
  |  Branch (7775:9): [True: 14.2k, False: 138]
  ------------------
 7776|  14.2k|      params.emplace(trim_double_quotes_copy((key)),
 7777|  14.2k|                     trim_double_quotes_copy((val)));
 7778|  14.2k|    }
 7779|  14.3k|  });
_ZZZN7httplib6detail24parse_disposition_paramsERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEERNS1_8multimapIS7_S7_NS1_4lessIS7_EENS5_INS1_4pairIS8_S7_EEEEEEENKUlPKcSJ_E_clESJ_SJ_ENKUlSJ_SJ_E_clESJ_SJ_:
 7767|  17.8k|    split(b, e, '=', [&](const char *b2, const char *e2) {
 7768|  17.8k|      if (key.empty()) {
  ------------------
  |  Branch (7768:11): [True: 14.2k, False: 3.56k]
  ------------------
 7769|  14.2k|        key.assign(b2, e2);
 7770|  14.2k|      } else {
 7771|  3.56k|        val.assign(b2, e2);
 7772|  3.56k|      }
 7773|  17.8k|    });
_ZN7httplib6detail15parse_http_dateERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 4457|      2|inline time_t parse_http_date(const std::string &date_str) {
 4458|      2|  struct tm tm_buf;
 4459|       |
 4460|       |  // Create a classic locale object once for all parsing attempts
 4461|      2|  const std::locale classic_locale = std::locale::classic();
 4462|       |
 4463|       |  // Try to parse using std::get_time (C++11, cross-platform)
 4464|      2|  auto try_parse = [&](const char *fmt) -> bool {
 4465|      2|    std::istringstream ss(date_str);
 4466|      2|    ss.imbue(classic_locale);
 4467|       |
 4468|      2|    memset(&tm_buf, 0, sizeof(tm_buf));
 4469|      2|    ss >> std::get_time(&tm_buf, fmt);
 4470|       |
 4471|      2|    return !ss.fail();
 4472|      2|  };
 4473|       |
 4474|       |  // RFC 9110 preferred format (HTTP-date): "Sun, 06 Nov 1994 08:49:37 GMT"
 4475|      2|  if (!try_parse("%a, %d %b %Y %H:%M:%S")) {
  ------------------
  |  Branch (4475:7): [True: 2, False: 0]
  ------------------
 4476|       |    // RFC 850 format: "Sunday, 06-Nov-94 08:49:37 GMT"
 4477|      2|    if (!try_parse("%A, %d-%b-%y %H:%M:%S")) {
  ------------------
  |  Branch (4477:9): [True: 2, False: 0]
  ------------------
 4478|       |      // asctime format: "Sun Nov  6 08:49:37 1994"
 4479|      2|      if (!try_parse("%a %b %d %H:%M:%S %Y")) {
  ------------------
  |  Branch (4479:11): [True: 2, False: 0]
  ------------------
 4480|      2|        return static_cast<time_t>(-1);
 4481|      2|      }
 4482|      2|    }
 4483|      2|  }
 4484|       |
 4485|       |#ifdef _WIN32
 4486|       |  return _mkgmtime(&tm_buf);
 4487|       |#elif defined _AIX
 4488|       |  return mktime(&tm_buf);
 4489|       |#else
 4490|      0|  return timegm(&tm_buf);
 4491|      2|#endif
 4492|      2|}
_ZZN7httplib6detail15parse_http_dateERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEENKUlPKcE_clESB_:
 4464|      6|  auto try_parse = [&](const char *fmt) -> bool {
 4465|      6|    std::istringstream ss(date_str);
 4466|      6|    ss.imbue(classic_locale);
 4467|       |
 4468|      6|    memset(&tm_buf, 0, sizeof(tm_buf));
 4469|      6|    ss >> std::get_time(&tm_buf, fmt);
 4470|       |
 4471|      6|    return !ss.fail();
 4472|      6|  };
_ZN7httplib6detail25can_compress_content_typeERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 6544|    752|inline bool can_compress_content_type(const std::string &content_type) {
 6545|    752|  using udl::operator""_t;
 6546|       |
 6547|    752|  auto mime_type = extract_media_type(content_type);
 6548|    752|  auto tag = str2tag(mime_type);
 6549|       |
 6550|    752|  switch (tag) {
 6551|      1|  case "image/svg+xml"_t:
  ------------------
  |  Branch (6551:3): [True: 1, False: 751]
  ------------------
 6552|      1|  case "application/javascript"_t:
  ------------------
  |  Branch (6552:3): [True: 0, False: 752]
  ------------------
 6553|      2|  case "application/x-javascript"_t:
  ------------------
  |  Branch (6553:3): [True: 1, False: 751]
  ------------------
 6554|      2|  case "application/json"_t:
  ------------------
  |  Branch (6554:3): [True: 0, False: 752]
  ------------------
 6555|      3|  case "application/ld+json"_t:
  ------------------
  |  Branch (6555:3): [True: 1, False: 751]
  ------------------
 6556|      4|  case "application/xml"_t:
  ------------------
  |  Branch (6556:3): [True: 1, False: 751]
  ------------------
 6557|      5|  case "application/xhtml+xml"_t:
  ------------------
  |  Branch (6557:3): [True: 1, False: 751]
  ------------------
 6558|      6|  case "application/rss+xml"_t:
  ------------------
  |  Branch (6558:3): [True: 1, False: 751]
  ------------------
 6559|      7|  case "application/atom+xml"_t:
  ------------------
  |  Branch (6559:3): [True: 1, False: 751]
  ------------------
 6560|      8|  case "application/xslt+xml"_t:
  ------------------
  |  Branch (6560:3): [True: 1, False: 751]
  ------------------
 6561|      9|  case "application/protobuf"_t: return true;
  ------------------
  |  Branch (6561:3): [True: 1, False: 751]
  ------------------
 6562|       |
 6563|      1|  case "text/event-stream"_t: return false;
  ------------------
  |  Branch (6563:3): [True: 1, False: 751]
  ------------------
 6564|       |
 6565|    742|  default: return !mime_type.rfind("text/", 0);
  ------------------
  |  Branch (6565:3): [True: 742, False: 10]
  ------------------
 6566|    752|  }
 6567|    752|}
_ZN7httplib6detail7str2tagERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 6422|    752|inline unsigned int str2tag(const std::string &s) {
 6423|       |  // Iterative form of str2tag_core: the recursive constexpr version is kept
 6424|       |  // for compile-time UDL evaluation of short string literals, but at runtime
 6425|       |  // we may receive arbitrarily long inputs (e.g. fuzzed Content-Type) that
 6426|       |  // would blow the stack with one frame per character.
 6427|    752|  unsigned int h = 0;
 6428|   926k|  for (auto c : s) {
  ------------------
  |  Branch (6428:15): [True: 926k, False: 752]
  ------------------
 6429|   926k|    h = (((std::numeric_limits<unsigned int>::max)() >> 6) & h * 33) ^
 6430|   926k|        static_cast<unsigned char>(c);
 6431|   926k|  }
 6432|    752|  return h;
 6433|    752|}

LLVMFuzzerTestOneInput:
    7|  2.90k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
    8|  2.90k|  if (size < 2) return 0;
  ------------------
  |  Branch (8:7): [True: 1, False: 2.90k]
  ------------------
    9|       |
   10|  2.90k|  uint8_t selector = data[0];
   11|  2.90k|  const char *payload = reinterpret_cast<const char *>(data + 1);
   12|  2.90k|  size_t payload_size = size - 1;
   13|  2.90k|  std::string input(payload, payload_size);
   14|       |
   15|  2.90k|  switch (selector % 7) {
  ------------------
  |  Branch (15:11): [True: 2.90k, False: 0]
  ------------------
   16|    462|  case 0: {
  ------------------
  |  Branch (16:3): [True: 462, False: 2.43k]
  ------------------
   17|       |    // parse_range_header
   18|    462|    httplib::Ranges ranges;
   19|    462|    httplib::detail::parse_range_header(input, ranges);
   20|    462|    break;
   21|      0|  }
   22|    971|  case 1: {
  ------------------
  |  Branch (22:3): [True: 971, False: 1.93k]
  ------------------
   23|       |    // parse_accept_header
   24|    971|    std::vector<std::string> content_types;
   25|    971|    httplib::detail::parse_accept_header(input, content_types);
   26|    971|    break;
   27|      0|  }
   28|     34|  case 2: {
  ------------------
  |  Branch (28:3): [True: 34, False: 2.86k]
  ------------------
   29|       |    // extract_media_type with params
   30|     34|    std::map<std::string, std::string> params;
   31|     34|    httplib::detail::extract_media_type(input, &params);
   32|     34|    break;
   33|      0|  }
   34|    181|  case 3: {
  ------------------
  |  Branch (34:3): [True: 181, False: 2.72k]
  ------------------
   35|       |    // parse_multipart_boundary
   36|    181|    std::string boundary;
   37|    181|    httplib::detail::parse_multipart_boundary(input, boundary);
   38|    181|    break;
   39|      0|  }
   40|    499|  case 4: {
  ------------------
  |  Branch (40:3): [True: 499, False: 2.40k]
  ------------------
   41|       |    // parse_disposition_params
   42|    499|    httplib::Params params;
   43|    499|    httplib::detail::parse_disposition_params(input, params);
   44|    499|    break;
   45|      0|  }
   46|      2|  case 5: {
  ------------------
  |  Branch (46:3): [True: 2, False: 2.89k]
  ------------------
   47|       |    // parse_http_date
   48|      2|    httplib::detail::parse_http_date(input);
   49|      2|    break;
   50|      0|  }
   51|    752|  case 6: {
  ------------------
  |  Branch (51:3): [True: 752, False: 2.14k]
  ------------------
   52|       |    // can_compress_content_type
   53|    752|    httplib::detail::can_compress_content_type(input);
   54|    752|    break;
   55|      0|  }
   56|  2.90k|  }
   57|       |
   58|  2.90k|  return 0;
   59|  2.90k|}

