_Z9burtlemixRjS_S_:
   28|   759k|{
   29|   759k|  a -= b;
   30|   759k|  a -= c;
   31|   759k|  a ^= (c >> 13);
   32|   759k|  b -= c;
   33|   759k|  b -= a;
   34|   759k|  b ^= (a << 8);
   35|   759k|  c -= a;
   36|   759k|  c -= b;
   37|   759k|  c ^= (b >> 13);
   38|   759k|  a -= b;
   39|   759k|  a -= c;
   40|   759k|  a ^= (c >> 12);
   41|   759k|  b -= c;
   42|   759k|  b -= a;
   43|   759k|  b ^= (a << 16);
   44|   759k|  c -= a;
   45|   759k|  c -= b;
   46|   759k|  c ^= (b >> 5);
   47|   759k|  a -= b;
   48|   759k|  a -= c;
   49|   759k|  a ^= (c >> 3);
   50|   759k|  b -= c;
   51|   759k|  b -= a;
   52|   759k|  b ^= (a << 10);
   53|   759k|  c -= a;
   54|   759k|  c -= b;
   55|   759k|  c ^= (b >> 15);
   56|   759k|}
_Z6burtlePKhjj:
   59|  20.0k|{
   60|  20.0k|  uint32_t a, b, c, len;
   61|       |
   62|       |  /* Set up the internal state */
   63|  20.0k|  len = length;
   64|  20.0k|  a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */
   65|  20.0k|  c = initval; /* the previous hash value */
   66|       |
   67|       |  /*---------------------------------------- handle most of the key */
   68|   315k|  while (len >= 12) {
  ------------------
  |  Branch (68:10): [True: 295k, False: 20.0k]
  ------------------
   69|   295k|    a += (k[0] + ((uint32_t)k[1] << 8) + ((uint32_t)k[2] << 16) + ((uint32_t)k[3] << 24));
   70|   295k|    b += (k[4] + ((uint32_t)k[5] << 8) + ((uint32_t)k[6] << 16) + ((uint32_t)k[7] << 24));
   71|   295k|    c += (k[8] + ((uint32_t)k[9] << 8) + ((uint32_t)k[10] << 16) + ((uint32_t)k[11] << 24));
   72|   295k|    burtlemix(a, b, c);
   73|   295k|    k += 12;
   74|   295k|    len -= 12;
   75|   295k|  }
   76|       |
   77|       |  /*------------------------------------- handle the last 11 bytes */
   78|  20.0k|  c += length;
   79|  20.0k|  switch (len) { /* all the case statements fall through */
  ------------------
  |  Branch (79:11): [True: 936, False: 19.0k]
  ------------------
   80|    262|  case 11:
  ------------------
  |  Branch (80:3): [True: 262, False: 19.7k]
  ------------------
   81|    262|    c += ((uint32_t)k[10] << 24);
   82|       |    /* fall-through */
   83|  2.73k|  case 10:
  ------------------
  |  Branch (83:3): [True: 2.46k, False: 17.5k]
  ------------------
   84|  2.73k|    c += ((uint32_t)k[9] << 16);
   85|       |    /* fall-through */
   86|  4.59k|  case 9:
  ------------------
  |  Branch (86:3): [True: 1.86k, False: 18.1k]
  ------------------
   87|  4.59k|    c += ((uint32_t)k[8] << 8);
   88|       |    /* the first byte of c is reserved for the length */
   89|       |    /* fall-through */
   90|  5.36k|  case 8:
  ------------------
  |  Branch (90:3): [True: 770, False: 19.2k]
  ------------------
   91|  5.36k|    b += ((uint32_t)k[7] << 24);
   92|       |    /* fall-through */
   93|  5.65k|  case 7:
  ------------------
  |  Branch (93:3): [True: 289, False: 19.7k]
  ------------------
   94|  5.65k|    b += ((uint32_t)k[6] << 16);
   95|       |    /* fall-through */
   96|  6.06k|  case 6:
  ------------------
  |  Branch (96:3): [True: 405, False: 19.6k]
  ------------------
   97|  6.06k|    b += ((uint32_t)k[5] << 8);
   98|       |    /* fall-through */
   99|  7.23k|  case 5:
  ------------------
  |  Branch (99:3): [True: 1.17k, False: 18.8k]
  ------------------
  100|  7.23k|    b += k[4];
  101|       |    /* fall-through */
  102|  15.5k|  case 4:
  ------------------
  |  Branch (102:3): [True: 8.27k, False: 11.7k]
  ------------------
  103|  15.5k|    a += ((uint32_t)k[3] << 24);
  104|       |    /* fall-through */
  105|  17.6k|  case 3:
  ------------------
  |  Branch (105:3): [True: 2.14k, False: 17.8k]
  ------------------
  106|  17.6k|    a += ((uint32_t)k[2] << 16);
  107|       |    /* fall-through */
  108|  18.3k|  case 2:
  ------------------
  |  Branch (108:3): [True: 659, False: 19.3k]
  ------------------
  109|  18.3k|    a += ((uint32_t)k[1] << 8);
  110|       |    /* fall-through */
  111|  19.0k|  case 1:
  ------------------
  |  Branch (111:3): [True: 786, False: 19.2k]
  ------------------
  112|  19.0k|    a += k[0];
  113|       |    /* case 0: nothing left to add */
  114|  20.0k|  }
  115|  20.0k|  burtlemix(a, b, c);
  116|       |  /*-------------------------------------------- report the result */
  117|  20.0k|  return c;
  118|  20.0k|}
_Z8burtleCIPKhjj:
  121|  2.00k|{
  122|  2.00k|  uint32_t a, b, c, len;
  123|       |
  124|       |  /* Set up the internal state */
  125|  2.00k|  len = length;
  126|  2.00k|  a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */
  127|  2.00k|  c = initval; /* the previous hash value */
  128|       |
  129|       |  /*---------------------------------------- handle most of the key */
  130|   443k|  while (len >= 12) {
  ------------------
  |  Branch (130:10): [True: 441k, False: 2.00k]
  ------------------
  131|   441k|    a += (dns_tolower(k[0]) + ((uint32_t)dns_tolower(k[1]) << 8) + ((uint32_t)dns_tolower(k[2]) << 16) + ((uint32_t)dns_tolower(k[3]) << 24));
  132|   441k|    b += (dns_tolower(k[4]) + ((uint32_t)dns_tolower(k[5]) << 8) + ((uint32_t)dns_tolower(k[6]) << 16) + ((uint32_t)dns_tolower(k[7]) << 24));
  133|   441k|    c += (dns_tolower(k[8]) + ((uint32_t)dns_tolower(k[9]) << 8) + ((uint32_t)dns_tolower(k[10]) << 16) + ((uint32_t)dns_tolower(k[11]) << 24));
  134|   441k|    burtlemix(a, b, c);
  135|   441k|    k += 12;
  136|   441k|    len -= 12;
  137|   441k|  }
  138|       |
  139|       |  /*------------------------------------- handle the last 11 bytes */
  140|  2.00k|  c += length;
  141|  2.00k|  switch (len) { /* all the case statements fall through */
  ------------------
  |  Branch (141:11): [True: 84, False: 1.92k]
  ------------------
  142|     54|  case 11:
  ------------------
  |  Branch (142:3): [True: 54, False: 1.95k]
  ------------------
  143|     54|    c += ((uint32_t)dns_tolower(k[10]) << 24);
  144|       |    /* fall-through */
  145|    124|  case 10:
  ------------------
  |  Branch (145:3): [True: 70, False: 1.93k]
  ------------------
  146|    124|    c += ((uint32_t)dns_tolower(k[9]) << 16);
  147|       |    /* fall-through */
  148|    162|  case 9:
  ------------------
  |  Branch (148:3): [True: 38, False: 1.96k]
  ------------------
  149|    162|    c += ((uint32_t)dns_tolower(k[8]) << 8);
  150|       |    /* the first byte of c is reserved for the length */
  151|       |    /* fall-through */
  152|    258|  case 8:
  ------------------
  |  Branch (152:3): [True: 96, False: 1.91k]
  ------------------
  153|    258|    b += ((uint32_t)dns_tolower(k[7]) << 24);
  154|       |    /* fall-through */
  155|    336|  case 7:
  ------------------
  |  Branch (155:3): [True: 78, False: 1.92k]
  ------------------
  156|    336|    b += ((uint32_t)dns_tolower(k[6]) << 16);
  157|       |    /* fall-through */
  158|    418|  case 6:
  ------------------
  |  Branch (158:3): [True: 82, False: 1.92k]
  ------------------
  159|    418|    b += ((uint32_t)dns_tolower(k[5]) << 8);
  160|       |    /* fall-through */
  161|    502|  case 5:
  ------------------
  |  Branch (161:3): [True: 84, False: 1.92k]
  ------------------
  162|    502|    b += dns_tolower(k[4]);
  163|       |    /* fall-through */
  164|    616|  case 4:
  ------------------
  |  Branch (164:3): [True: 114, False: 1.89k]
  ------------------
  165|    616|    a += ((uint32_t)dns_tolower(k[3]) << 24);
  166|       |    /* fall-through */
  167|    688|  case 3:
  ------------------
  |  Branch (167:3): [True: 72, False: 1.93k]
  ------------------
  168|    688|    a += ((uint32_t)dns_tolower(k[2]) << 16);
  169|       |    /* fall-through */
  170|    764|  case 2:
  ------------------
  |  Branch (170:3): [True: 76, False: 1.93k]
  ------------------
  171|    764|    a += ((uint32_t)dns_tolower(k[1]) << 8);
  172|       |    /* fall-through */
  173|  1.92k|  case 1:
  ------------------
  |  Branch (173:3): [True: 1.15k, False: 848]
  ------------------
  174|  1.92k|    a += dns_tolower(k[0]);
  175|       |    /* case 0: nothing left to add */
  176|  2.00k|  }
  177|  2.00k|  burtlemix(a, b, c);
  178|       |  /*-------------------------------------------- report the result */
  179|  2.00k|  return c;
  180|  2.00k|}

_ZN17dnsheader_alignedC2EPKv:
  195|  2.66k|  {
  196|  2.66k|    if (reinterpret_cast<uintptr_t>(mem) % sizeof(uint32_t) == 0) {  // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
  ------------------
  |  Branch (196:9): [True: 2.13k, False: 526]
  ------------------
  197|  2.13k|      d_p = reinterpret_cast<const dnsheader*>(mem);  // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
  198|  2.13k|    }
  199|    526|    else {
  200|    526|      memcpy(&d_h, mem, sizeof(dnsheader));
  201|    526|      d_p = &d_h;
  202|    526|    }
  203|  2.66k|  }
_ZNK17dnsheader_aligned3getEv:
  206|  2.66k|  {
  207|  2.66k|    return d_p;
  208|  2.66k|  }

_ZN7DNSNameC2ENSt3__117basic_string_viewIcNS0_11char_traitsIcEEEE:
   57|      4|{
   58|      4|  const char* p = sw.data();
   59|      4|  size_t length = sw.length();
   60|       |
   61|      4|  if(length == 0 || (length == 1 && p[0]=='.')) {
  ------------------
  |  Branch (61:6): [True: 0, False: 4]
  |  Branch (61:22): [True: 4, False: 0]
  |  Branch (61:37): [True: 2, False: 2]
  ------------------
   62|      2|    d_storage.assign(1, '\0');
   63|      2|  } else {
   64|      2|    if(!std::memchr(p, '\\', length)) {
  ------------------
  |  Branch (64:8): [True: 2, False: 0]
  ------------------
   65|      2|      unsigned char lenpos=0;
   66|      2|      unsigned char labellen=0;
   67|      2|      const char* const pbegin=p, *pend=p+length;
   68|       |
   69|      2|      d_storage.reserve(length+1);
   70|      4|      for(auto iter = pbegin; iter != pend; ) {
  ------------------
  |  Branch (70:31): [True: 2, False: 2]
  ------------------
   71|      2|        lenpos = d_storage.size();
   72|      2|        if(*iter=='.')
  ------------------
  |  Branch (72:12): [True: 0, False: 2]
  ------------------
   73|      0|          throwSafeRangeError("Found . in wrong position in DNSName: ", p, length);
   74|      2|        d_storage.append(1, '\0');
   75|      2|        labellen=0;
   76|      2|        auto begiter=iter;
   77|      4|        for(; iter != pend && *iter!='.'; ++iter) {
  ------------------
  |  Branch (77:15): [True: 2, False: 2]
  |  Branch (77:31): [True: 2, False: 0]
  ------------------
   78|      2|          labellen++;
   79|      2|        }
   80|      2|        d_storage.append(begiter,iter);
   81|      2|        if(iter != pend)
  ------------------
  |  Branch (81:12): [True: 0, False: 2]
  ------------------
   82|      0|          ++iter;
   83|      2|        if(labellen > 63)
  ------------------
  |  Branch (83:12): [True: 0, False: 2]
  ------------------
   84|      0|          throwSafeRangeError("label too long to append: ", p, length);
   85|       |
   86|      2|        if(iter-pbegin > static_cast<ptrdiff_t>(s_maxDNSNameLength - 1)) // reserve two bytes, one for length and one for the root label
  ------------------
  |  Branch (86:12): [True: 0, False: 2]
  ------------------
   87|      0|          throwSafeRangeError("name too long to append: ", p, length);
   88|       |
   89|      2|        d_storage[lenpos]=labellen;
   90|      2|      }
   91|      2|      d_storage.append(1, '\0');
   92|      2|    }
   93|      0|    else {
   94|      0|      d_storage=segmentDNSNameRaw(p, length);
   95|      0|      if(d_storage.size() > s_maxDNSNameLength) {
  ------------------
  |  Branch (95:10): [True: 0, False: 0]
  ------------------
   96|      0|        throwSafeRangeError("name too long: ", p, length);
   97|      0|      }
   98|      0|    }
   99|      2|  }
  100|      4|}
_ZN7DNSNameC2EPKciibPtS2_Pjt:
  104|  2.00k|{
  105|  2.00k|  if (offset >= len)
  ------------------
  |  Branch (105:7): [True: 0, False: 2.00k]
  ------------------
  106|      0|    throw std::range_error("Trying to read past the end of the buffer ("+std::to_string(offset)+ " >= "+std::to_string(len)+")");
  107|       |
  108|  2.00k|  if(!uncompress) {
  ------------------
  |  Branch (108:6): [True: 2.00k, False: 0]
  ------------------
  109|  2.00k|    if(const void * fnd=memchr(pos+offset, 0, len-offset)) {
  ------------------
  |  Branch (109:21): [True: 1.83k, False: 170]
  ------------------
  110|  1.83k|      d_storage.reserve(2+(const char*)fnd-(pos+offset));
  111|  1.83k|    }
  112|  2.00k|  }
  113|       |
  114|  2.00k|  packetParser(pos, len, offset, uncompress, qtype, qclass, consumed, 0, minOffset);
  115|  2.00k|}
_ZN7DNSName12packetParserEPKciibPtS2_Pjit:
  119|  2.00k|{
  120|  2.00k|  const unsigned char* pos=(const unsigned char*)qpos;
  121|  2.00k|  unsigned char labellen;
  122|  2.00k|  const unsigned char *opos = pos;
  123|       |
  124|  2.00k|  if (offset >= len)
  ------------------
  |  Branch (124:7): [True: 0, False: 2.00k]
  ------------------
  125|      0|    throw std::range_error("Trying to read past the end of the buffer ("+std::to_string(offset)+ " >= "+std::to_string(len)+")");
  126|  2.00k|  if (offset < (int) minOffset)
  ------------------
  |  Branch (126:7): [True: 0, False: 2.00k]
  ------------------
  127|      0|    throw std::range_error("Trying to read before the beginning of the buffer ("+std::to_string(offset)+ " < "+std::to_string(minOffset)+")");
  128|       |
  129|  2.00k|  const unsigned char* end = pos + len;
  130|  2.00k|  pos += offset;
  131|  10.1k|  while((labellen=*pos++) && pos < end) { // "scan and copy"
  ------------------
  |  Branch (131:9): [True: 8.97k, False: 1.19k]
  |  Branch (131:30): [True: 8.69k, False: 274]
  ------------------
  132|  8.69k|    if(labellen >= 0xc0) {
  ------------------
  |  Branch (132:8): [True: 206, False: 8.49k]
  ------------------
  133|    206|      if(!uncompress)
  ------------------
  |  Branch (133:10): [True: 206, False: 0]
  ------------------
  134|    206|        throw std::range_error("Found compressed label, instructed not to follow");
  135|       |
  136|      0|      labellen &= (~0xc0);
  137|      0|      int newpos = (labellen << 8) + *(const unsigned char*)pos;
  138|       |
  139|      0|      if(newpos < offset) {
  ------------------
  |  Branch (139:10): [True: 0, False: 0]
  ------------------
  140|      0|        if(newpos < (int) minOffset)
  ------------------
  |  Branch (140:12): [True: 0, False: 0]
  ------------------
  141|      0|          throw std::range_error("Invalid label position during decompression ("+std::to_string(newpos)+ " < "+std::to_string(minOffset)+")");
  142|      0|        if (++depth > 100)
  ------------------
  |  Branch (142:13): [True: 0, False: 0]
  ------------------
  143|      0|          throw std::range_error("Abort label decompression after 100 redirects");
  144|      0|        packetParser((const char*)opos, len, newpos, true, nullptr, nullptr, nullptr, depth, minOffset);
  145|      0|      } else
  146|      0|        throw std::range_error("Found a forward reference during label decompression");
  147|      0|      pos++;
  148|      0|      break;
  149|  8.49k|    } else if(labellen & 0xc0) {
  ------------------
  |  Branch (149:15): [True: 296, False: 8.19k]
  ------------------
  150|    296|      throw std::range_error("Found an invalid label length in qname (only one of the first two bits is set)");
  151|    296|    }
  152|  8.19k|    if (pos + labellen < end) {
  ------------------
  |  Branch (152:9): [True: 8.16k, False: 36]
  ------------------
  153|  8.16k|      appendRawLabel((const char*)pos, labellen);
  154|  8.16k|    }
  155|     36|    else
  156|     36|      throw std::range_error("Found an invalid label length in qname");
  157|  8.16k|    pos+=labellen;
  158|  8.16k|  }
  159|  1.46k|  if(d_storage.empty())
  ------------------
  |  Branch (159:6): [True: 1.09k, False: 370]
  ------------------
  160|  1.09k|    d_storage.append(1, (char)0); // we just parsed the root
  161|  1.46k|  if(consumed)
  ------------------
  |  Branch (161:6): [True: 0, False: 1.46k]
  ------------------
  162|      0|    *consumed = pos - opos - offset;
  163|  1.46k|  if(qtype) {
  ------------------
  |  Branch (163:6): [True: 0, False: 1.46k]
  ------------------
  164|      0|    if (pos + 2 > end) {
  ------------------
  |  Branch (164:9): [True: 0, False: 0]
  ------------------
  165|      0|      throw std::range_error("Trying to read qtype past the end of the buffer ("+std::to_string((pos - opos) + 2)+ " > "+std::to_string(len)+")");
  166|      0|    }
  167|      0|    *qtype=(*(const unsigned char*)pos)*256 + *((const unsigned char*)pos+1);
  168|      0|  }
  169|  1.46k|  pos+=2;
  170|  1.46k|  if(qclass) {
  ------------------
  |  Branch (170:6): [True: 0, False: 1.46k]
  ------------------
  171|      0|    if (pos + 2 > end) {
  ------------------
  |  Branch (171:9): [True: 0, False: 0]
  ------------------
  172|      0|      throw std::range_error("Trying to read qclass past the end of the buffer ("+std::to_string((pos - opos) + 2)+ " > "+std::to_string(len)+")");
  173|      0|    }
  174|      0|    *qclass=(*(const unsigned char*)pos)*256 + *((const unsigned char*)pos+1);
  175|      0|  }
  176|  1.46k|}
_ZNK7DNSName10wirelengthEv:
  246|  1.43k|size_t DNSName::wirelength() const {
  247|  1.43k|  return d_storage.length();
  248|  1.43k|}
_ZN7DNSName14appendRawLabelEPKcj:
  345|  8.16k|{
  346|  8.16k|  if(length==0)
  ------------------
  |  Branch (346:6): [True: 0, False: 8.16k]
  ------------------
  347|      0|    throw std::range_error("no such thing as an empty label to append");
  348|  8.16k|  if(length > 63)
  ------------------
  |  Branch (348:6): [True: 0, False: 8.16k]
  ------------------
  349|      0|    throw std::range_error("label too long to append");
  350|  8.16k|  if(d_storage.size() + length > s_maxDNSNameLength - 1) // reserve one byte for the label length
  ------------------
  |  Branch (350:6): [True: 30, False: 8.13k]
  ------------------
  351|     30|    throw std::range_error("name too long to append");
  352|       |
  353|  8.13k|  if(d_storage.empty()) {
  ------------------
  |  Branch (353:6): [True: 818, False: 7.31k]
  ------------------
  354|    818|    d_storage.append(1, (char)length);
  355|    818|  }
  356|  7.31k|  else {
  357|  7.31k|    *d_storage.rbegin()=(char)length;
  358|  7.31k|  }
  359|  8.13k|  d_storage.append(start, length);
  360|  8.13k|  d_storage.append(1, (char)0);
  361|  8.13k|}

_Z11dns_tolowerh:
   55|  5.30M|{
   56|  5.30M|  return dns_tolower_table[c];
   57|  5.30M|}

_Z17getNextEDNSOptionPKcmRtS1_:
   27|  27.9k|{
   28|  27.9k|  if (data == nullptr || dataLen < (sizeof(uint16_t) + sizeof(uint16_t))) {
  ------------------
  |  Branch (28:7): [True: 0, False: 27.9k]
  |  Branch (28:26): [True: 282, False: 27.6k]
  ------------------
   29|    282|    return false;
   30|    282|  }
   31|       |
   32|  27.6k|  size_t pos = 0;
   33|  27.6k|  const uint8_t* p = reinterpret_cast<const uint8_t*>(data);
   34|       |
   35|  27.6k|  optionCode = (static_cast<uint16_t>(p[pos]) * 256) + p[pos + 1];
   36|  27.6k|  pos += EDNS_OPTION_CODE_SIZE;
  ------------------
  |  |  226|  27.6k|#define EDNS_OPTION_CODE_SIZE (2)
  ------------------
   37|       |
   38|  27.6k|  optionLen = (static_cast<uint16_t>(p[pos]) * 256) + p[pos + 1];
   39|  27.6k|  pos += EDNS_OPTION_LENGTH_SIZE;
  ------------------
  |  |  227|  27.6k|#define EDNS_OPTION_LENGTH_SIZE (2)
  ------------------
   40|  27.6k|  (void) pos;
   41|       |
   42|  27.6k|  return true;
   43|  27.9k|}

LLVMFuzzerTestOneInput:
   31|  1.01k|{
   32|       |
   33|  1.01k|  if (size > std::numeric_limits<uint16_t>::max() || size < sizeof(dnsheader)) {
  ------------------
  |  Branch (33:7): [True: 6, False: 1.01k]
  |  Branch (33:54): [True: 7, False: 1.00k]
  ------------------
   34|     13|    return 0;
   35|     13|  }
   36|       |
   37|  1.00k|  std::string input(reinterpret_cast<const char*>(data), size);
   38|       |
   39|       |  /* auth's version */
   40|  1.00k|  try {
   41|  1.00k|    static const std::unordered_set<uint16_t> optionsToIgnore{EDNSOptionCode::COOKIE};
   42|       |
   43|  1.00k|    PacketCache::canHashPacket(input, optionsToIgnore);
   44|  1.00k|    DNSName qname(input.data(), input.size(), sizeof(dnsheader), false);
   45|  1.00k|    PacketCache::queryMatches(input, input, qname, optionsToIgnore);
   46|  1.00k|  }
   47|  1.00k|  catch (const std::exception& e) {
   48|    286|  }
   49|  1.00k|  catch (const PDNSException& e) {
   50|      0|  }
   51|       |
   52|       |  /* recursor's version */
   53|  1.00k|  try {
   54|  1.00k|    static const std::unordered_set<uint16_t> optionsToIgnore{EDNSOptionCode::COOKIE, EDNSOptionCode::ECS};
   55|       |
   56|  1.00k|    PacketCache::canHashPacket(input, optionsToIgnore);
   57|  1.00k|    DNSName qname(input.data(), input.size(), sizeof(dnsheader), false);
   58|  1.00k|    PacketCache::queryMatches(input, input, qname, optionsToIgnore);
   59|  1.00k|  }
   60|  1.00k|  catch (const std::exception& e) {
   61|    286|  }
   62|  1.00k|  catch (const PDNSException& e) {
   63|      0|  }
   64|       |
   65|  1.00k|  return 0;
   66|  1.00k|}

_ZN11PacketCache13canHashPacketERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEERKNS0_13unordered_setItNS0_4hashItEENS0_8equal_toItEENS4_ItEEEE:
  133|  2.01k|  {
  134|  2.01k|    size_t pos = 0;
  135|  2.01k|    uint32_t currentHash = hashHeaderAndQName(packet, pos);
  136|       |
  137|  2.01k|    if (pos >= packet.size()) {
  ------------------
  |  Branch (137:9): [True: 782, False: 1.22k]
  ------------------
  138|    782|      return currentHash;
  139|    782|    }
  140|       |
  141|  1.22k|    return hashAfterQname(packet, currentHash, pos, optionsToSkip);
  142|  2.01k|  }
_ZN11PacketCache18hashHeaderAndQNameERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEERm:
  107|  2.01k|  {
  108|  2.01k|    const size_t packetSize = packet.size();
  109|  2.01k|    assert(packetSize >= sizeof(dnsheader));
  110|       |    // Quite some bits in the header are actually irrelevant for
  111|       |    // incoming queries.  If we ever change that and ignore them for
  112|       |    // hashing, don't forget to also adapt the `queryHeaderMatches`
  113|       |    // code, as it should be consistent with the hash function.
  114|      0|    uint32_t currentHash = burtle(reinterpret_cast<const unsigned char*>(&packet.at(2)), sizeof(dnsheader) - 2, 0); // rest of dnsheader, skip id
  115|       |
  116|  99.0k|    for (pos = sizeof(dnsheader); pos < packetSize; ) {
  ------------------
  |  Branch (116:35): [True: 98.4k, False: 648]
  ------------------
  117|  98.4k|      const unsigned char labelLen = static_cast<unsigned char>(packet.at(pos));
  118|  98.4k|      ++pos;
  119|  98.4k|      if (labelLen == 0) {
  ------------------
  |  Branch (119:11): [True: 1.36k, False: 97.0k]
  ------------------
  120|  1.36k|        break;
  121|  1.36k|      }
  122|  97.0k|      pos = std::min(pos + labelLen, packetSize);
  123|  97.0k|    }
  124|  2.01k|    return burtleCI(reinterpret_cast<const unsigned char*>(&packet.at(sizeof(dnsheader))), pos - sizeof(dnsheader), currentHash);
  125|  2.01k|  }
_ZN11PacketCache14hashAfterQnameERKNSt3__117basic_string_viewIcNS0_11char_traitsIcEEEEjmRKNS0_13unordered_setItNS0_4hashItEENS0_8equal_toItEENS0_9allocatorItEEEE:
   37|  1.22k|  {
   38|  1.22k|    const size_t packetSize = packet.size();
   39|  1.22k|    assert(packetSize >= sizeof(dnsheader));
   40|       |
   41|       |    /* we need at least 2 (QTYPE) + 2 (QCLASS)
   42|       |
   43|       |       + OPT root label (1), type (2), class (2) and ttl (4)
   44|       |       + the OPT RR rdlen (2)
   45|       |       = 15
   46|       |    */
   47|      0|    const dnsheader_aligned dnsheaderdata(packet.data());
   48|  1.22k|    const struct dnsheader *dh = dnsheaderdata.get();
   49|  1.22k|    if (ntohs(dh->qdcount) != 1 || ntohs(dh->ancount) != 0 || ntohs(dh->nscount) != 0 || ntohs(dh->arcount) != 1 || (pos + 15) >= packetSize) {
  ------------------
  |  Branch (49:9): [True: 140, False: 1.08k]
  |  Branch (49:36): [True: 62, False: 1.02k]
  |  Branch (49:63): [True: 46, False: 976]
  |  Branch (49:90): [True: 46, False: 930]
  |  Branch (49:117): [True: 44, False: 886]
  ------------------
   50|    338|      if (packetSize > pos) {
  ------------------
  |  Branch (50:11): [True: 338, False: 0]
  ------------------
   51|    338|        currentHash = burtle(reinterpret_cast<const unsigned char*>(&packet.at(pos)), packetSize - pos, currentHash);
   52|    338|      }
   53|    338|      return currentHash;
   54|    338|    }
   55|       |
   56|    886|    currentHash = burtle(reinterpret_cast<const unsigned char*>(&packet.at(pos)), 15, currentHash);
   57|       |    /* skip the qtype (2), qclass (2) */
   58|       |    /* root label (1), type (2), class (2) and ttl (4) */
   59|       |    /* already hashed above */
   60|    886|    pos += 13;
   61|       |
   62|    886|    const uint16_t rdLen = ((static_cast<uint16_t>(packet.at(pos)) * 256) + static_cast<uint16_t>(packet.at(pos + 1)));
   63|       |    /* skip the rd length */
   64|       |    /* already hashed above */
   65|    886|    pos += 2;
   66|       |
   67|    886|    if (rdLen > (packetSize - pos)) {
  ------------------
  |  Branch (67:9): [True: 164, False: 722]
  ------------------
   68|    164|      if (pos < packetSize) {
  ------------------
  |  Branch (68:11): [True: 164, False: 0]
  ------------------
   69|    164|        currentHash = burtle(reinterpret_cast<const unsigned char*>(&packet.at(pos)), packetSize - pos, currentHash);
   70|    164|      }
   71|    164|      return currentHash;
   72|    164|    }
   73|       |
   74|    722|    uint16_t rdataRead = 0;
   75|    722|    uint16_t optionCode;
   76|    722|    uint16_t optionLen;
   77|       |
   78|  16.7k|    while (pos < packetSize && rdataRead < rdLen && getNextEDNSOption(&packet.at(pos), rdLen - rdataRead, optionCode, optionLen)) {
  ------------------
  |  Branch (78:12): [True: 16.6k, False: 100]
  |  Branch (78:32): [True: 16.5k, False: 106]
  |  Branch (78:53): [True: 16.3k, False: 172]
  ------------------
   79|  16.3k|      if (optionLen > (rdLen - rdataRead - 4)) {
  ------------------
  |  Branch (79:11): [True: 344, False: 16.0k]
  ------------------
   80|    344|        if (packetSize > pos) {
  ------------------
  |  Branch (80:13): [True: 344, False: 0]
  ------------------
   81|    344|          currentHash = burtle(reinterpret_cast<const unsigned char*>(&packet.at(pos)), packetSize - pos, currentHash);
   82|    344|        }
   83|    344|        return currentHash;
   84|    344|      }
   85|       |
   86|  16.0k|      if (optionsToSkip.count(optionCode) == 0) {
  ------------------
  |  Branch (86:11): [True: 15.1k, False: 867]
  ------------------
   87|       |        /* hash the option code, length and content */
   88|  15.1k|        currentHash = burtle(reinterpret_cast<const unsigned char*>(&packet.at(pos)), 4 + optionLen, currentHash);
   89|  15.1k|      }
   90|    867|      else {
   91|       |        /* skip option: hash only its code and length */
   92|    867|        currentHash = burtle(reinterpret_cast<const unsigned char*>(&packet.at(pos)), 4, currentHash);
   93|    867|      }
   94|       |
   95|  16.0k|      pos += 4 + optionLen;
   96|  16.0k|      rdataRead += 4 + optionLen;
   97|  16.0k|    }
   98|       |
   99|    378|    if (pos < packetSize) {
  ------------------
  |  Branch (99:9): [True: 278, False: 100]
  ------------------
  100|    278|      currentHash = burtle(reinterpret_cast<const unsigned char*>(&packet.at(pos)), packetSize - pos, currentHash);
  101|    278|    }
  102|       |
  103|    378|    return currentHash;
  104|    722|  }
_ZN11PacketCache12queryMatchesERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEES8_RK7DNSNameRKNS0_13unordered_setItNS0_4hashItEENS0_8equal_toItEENS4_ItEEEE:
  154|  1.43k|  {
  155|  1.43k|    const size_t querySize = query.size();
  156|  1.43k|    const size_t cachedQuerySize = cachedQuery.size();
  157|  1.43k|    if (querySize != cachedQuerySize) {
  ------------------
  |  Branch (157:9): [True: 0, False: 1.43k]
  ------------------
  158|      0|      return false;
  159|      0|    }
  160|       |
  161|  1.43k|    if (!queryHeaderMatches(cachedQuery, query)) {
  ------------------
  |  Branch (161:9): [True: 0, False: 1.43k]
  ------------------
  162|      0|      return false;
  163|      0|    }
  164|       |
  165|  1.43k|    size_t pos = sizeof(dnsheader) + qname.wirelength();
  166|       |
  167|       |    /* we need at least 2 (QTYPE) + 2 (QCLASS)
  168|       |       + OPT root label (1), type (2), class (2) and ttl (4)
  169|       |       + the OPT RR rdlen (2)
  170|       |       = 15
  171|       |    */
  172|  1.43k|    const dnsheader_aligned dnsheaderdata(query.data());
  173|  1.43k|    const struct dnsheader* dh = dnsheaderdata.get();
  174|  1.43k|    if (ntohs(dh->qdcount) != 1 || ntohs(dh->ancount) != 0 || ntohs(dh->nscount) != 0 || ntohs(dh->arcount) != 1 || (pos + 15) >= querySize || optionsToIgnore.empty()) {
  ------------------
  |  Branch (174:9): [True: 354, False: 1.08k]
  |  Branch (174:36): [True: 108, False: 976]
  |  Branch (174:63): [True: 86, False: 890]
  |  Branch (174:90): [True: 92, False: 798]
  |  Branch (174:117): [True: 46, False: 752]
  |  Branch (174:144): [True: 0, False: 752]
  ------------------
  175|    686|      return cachedQuery.compare(pos, cachedQuerySize - pos, query, pos, querySize - pos) == 0;
  176|    686|    }
  177|       |
  178|       |    /* compare up to the first option, if any */
  179|    752|    if (cachedQuery.compare(pos, 15, query, pos, 15) != 0) {
  ------------------
  |  Branch (179:9): [True: 0, False: 752]
  ------------------
  180|      0|      return false;
  181|      0|    }
  182|       |
  183|       |    /* skip the qtype (2), qclass (2) */
  184|       |    /* root label (1), type (2), class (2) and ttl (4) */
  185|       |    /* already compared above */
  186|    752|    pos += 13;
  187|       |
  188|    752|    const uint16_t rdLen = ((static_cast<unsigned char>(query.at(pos)) * 256) + static_cast<unsigned char>(query.at(pos + 1)));
  189|       |    /* skip the rd length */
  190|       |    /* already compared above */
  191|    752|    pos += sizeof(uint16_t);
  192|       |
  193|    752|    if (rdLen > (querySize - pos)) {
  ------------------
  |  Branch (193:9): [True: 184, False: 568]
  ------------------
  194|       |      /* something is wrong, let's just compare everything */
  195|    184|      return cachedQuery.compare(pos, cachedQuerySize - pos, query, pos, querySize - pos) == 0;
  196|    184|    }
  197|       |
  198|    568|    uint16_t rdataRead = 0;
  199|    568|    uint16_t optionCode;
  200|    568|    uint16_t optionLen;
  201|       |
  202|  11.6k|    while (pos < querySize && rdataRead < rdLen && getNextEDNSOption(&query.at(pos), rdLen - rdataRead, optionCode, optionLen)) {
  ------------------
  |  Branch (202:12): [True: 11.4k, False: 178]
  |  Branch (202:31): [True: 11.3k, False: 100]
  |  Branch (202:52): [True: 11.2k, False: 110]
  ------------------
  203|  11.2k|      if (optionLen > (rdLen - rdataRead)) {
  ------------------
  |  Branch (203:11): [True: 180, False: 11.1k]
  ------------------
  204|    180|        return cachedQuery.compare(pos, cachedQuerySize - pos, query, pos, querySize - pos) == 0;
  205|    180|      }
  206|       |
  207|       |      /* compare the option code and length */
  208|  11.1k|      if (cachedQuery.compare(pos, 4, query, pos, 4) != 0) {
  ------------------
  |  Branch (208:11): [True: 0, False: 11.1k]
  ------------------
  209|      0|        return false;
  210|      0|      }
  211|  11.1k|      pos += 4;
  212|  11.1k|      rdataRead += 4;
  213|       |
  214|  11.1k|      if (optionLen > 0 && optionsToIgnore.count(optionCode) == 0) {
  ------------------
  |  Branch (214:11): [True: 5.26k, False: 5.84k]
  |  Branch (214:28): [True: 4.91k, False: 348]
  ------------------
  215|  4.91k|        if (cachedQuery.compare(pos, optionLen, query, pos, optionLen) != 0) {
  ------------------
  |  Branch (215:13): [True: 0, False: 4.91k]
  ------------------
  216|      0|          return false;
  217|      0|        }
  218|  4.91k|      }
  219|  11.1k|      pos += optionLen;
  220|  11.1k|      rdataRead += optionLen;
  221|  11.1k|    }
  222|       |
  223|    388|    if (pos >= querySize) {
  ------------------
  |  Branch (223:9): [True: 178, False: 210]
  ------------------
  224|    178|        return true;
  225|    178|    }
  226|       |
  227|    210|    return cachedQuery.compare(pos, cachedQuerySize - pos, query, pos, querySize - pos) == 0;
  228|    388|  }
_ZN11PacketCache18queryHeaderMatchesERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEES8_:
  145|  1.43k|  {
  146|  1.43k|    if (cachedQuery.size() != query.size()) {
  ------------------
  |  Branch (146:9): [True: 0, False: 1.43k]
  ------------------
  147|      0|      return false;
  148|      0|    }
  149|       |
  150|  1.43k|    return (cachedQuery.compare(/* skip the ID */ 2, sizeof(dnsheader) - 2, query, 2, sizeof(dnsheader) - 2) == 0);
  151|  1.43k|  }

qtype.cc:_ZL12swapElementsRKNSt3__13mapIKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEtNS_4lessIS7_EENS4_INS_4pairIS7_tEEEEEE:
  103|      2|static map<uint16_t, const string> swapElements(const map<const string, uint16_t>& names) {
  104|      2|  map<uint16_t, const string> ret;
  105|       |
  106|    130|  for (const auto& n : names) {
  ------------------
  |  Branch (106:22): [True: 130, False: 2]
  ------------------
  107|    130|    ret.emplace(n.second, n.first);
  108|    130|  }
  109|      2|  return ret;
  110|      2|}

_ZN7StatBagC2Ev:
   40|      2|{
   41|      2|  d_doRings=false;
   42|      2|  d_allowRedeclare=false;
   43|      2|}

