_Z9burtlemixRjS_S_:
   28|   755k|{
   29|   755k|  a -= b;
   30|   755k|  a -= c;
   31|   755k|  a ^= (c >> 13);
   32|   755k|  b -= c;
   33|   755k|  b -= a;
   34|   755k|  b ^= (a << 8);
   35|   755k|  c -= a;
   36|   755k|  c -= b;
   37|   755k|  c ^= (b >> 13);
   38|   755k|  a -= b;
   39|   755k|  a -= c;
   40|   755k|  a ^= (c >> 12);
   41|   755k|  b -= c;
   42|   755k|  b -= a;
   43|   755k|  b ^= (a << 16);
   44|   755k|  c -= a;
   45|   755k|  c -= b;
   46|   755k|  c ^= (b >> 5);
   47|   755k|  a -= b;
   48|   755k|  a -= c;
   49|   755k|  a ^= (c >> 3);
   50|   755k|  b -= c;
   51|   755k|  b -= a;
   52|   755k|  b ^= (a << 10);
   53|   755k|  c -= a;
   54|   755k|  c -= b;
   55|   755k|  c ^= (b >> 15);
   56|   755k|}
_Z6burtlePKhjj:
   59|  27.5k|{
   60|  27.5k|  uint32_t a, b, c, len;
   61|       |
   62|       |  /* Set up the internal state */
   63|  27.5k|  len = length;
   64|  27.5k|  a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */
   65|  27.5k|  c = initval; /* the previous hash value */
   66|       |
   67|       |  /*---------------------------------------- handle most of the key */
   68|   412k|  while (len >= 12) {
  ------------------
  |  Branch (68:10): [True: 384k, False: 27.5k]
  ------------------
   69|   384k|    a += (k[0] + ((uint32_t)k[1] << 8) + ((uint32_t)k[2] << 16) + ((uint32_t)k[3] << 24));
   70|   384k|    b += (k[4] + ((uint32_t)k[5] << 8) + ((uint32_t)k[6] << 16) + ((uint32_t)k[7] << 24));
   71|   384k|    c += (k[8] + ((uint32_t)k[9] << 8) + ((uint32_t)k[10] << 16) + ((uint32_t)k[11] << 24));
   72|   384k|    burtlemix(a, b, c);
   73|   384k|    k += 12;
   74|   384k|    len -= 12;
   75|   384k|  }
   76|       |
   77|       |  /*------------------------------------- handle the last 11 bytes */
   78|  27.5k|  c += length;
   79|  27.5k|  switch (len) { /* all the case statements fall through */
  ------------------
  |  Branch (79:11): [True: 1.22k, False: 26.3k]
  ------------------
   80|    465|  case 11:
  ------------------
  |  Branch (80:3): [True: 465, False: 27.0k]
  ------------------
   81|    465|    c += ((uint32_t)k[10] << 24);
   82|       |    /* fall-through */
   83|  2.97k|  case 10:
  ------------------
  |  Branch (83:3): [True: 2.50k, False: 25.0k]
  ------------------
   84|  2.97k|    c += ((uint32_t)k[9] << 16);
   85|       |    /* fall-through */
   86|  5.60k|  case 9:
  ------------------
  |  Branch (86:3): [True: 2.63k, False: 24.9k]
  ------------------
   87|  5.60k|    c += ((uint32_t)k[8] << 8);
   88|       |    /* the first byte of c is reserved for the length */
   89|       |    /* fall-through */
   90|  6.75k|  case 8:
  ------------------
  |  Branch (90:3): [True: 1.14k, False: 26.3k]
  ------------------
   91|  6.75k|    b += ((uint32_t)k[7] << 24);
   92|       |    /* fall-through */
   93|  7.07k|  case 7:
  ------------------
  |  Branch (93:3): [True: 320, False: 27.2k]
  ------------------
   94|  7.07k|    b += ((uint32_t)k[6] << 16);
   95|       |    /* fall-through */
   96|  7.54k|  case 6:
  ------------------
  |  Branch (96:3): [True: 470, False: 27.0k]
  ------------------
   97|  7.54k|    b += ((uint32_t)k[5] << 8);
   98|       |    /* fall-through */
   99|  8.86k|  case 5:
  ------------------
  |  Branch (99:3): [True: 1.31k, False: 26.2k]
  ------------------
  100|  8.86k|    b += k[4];
  101|       |    /* fall-through */
  102|  22.1k|  case 4:
  ------------------
  |  Branch (102:3): [True: 13.3k, False: 14.2k]
  ------------------
  103|  22.1k|    a += ((uint32_t)k[3] << 24);
  104|       |    /* fall-through */
  105|  24.7k|  case 3:
  ------------------
  |  Branch (105:3): [True: 2.61k, False: 24.9k]
  ------------------
  106|  24.7k|    a += ((uint32_t)k[2] << 16);
  107|       |    /* fall-through */
  108|  25.7k|  case 2:
  ------------------
  |  Branch (108:3): [True: 945, False: 26.5k]
  ------------------
  109|  25.7k|    a += ((uint32_t)k[1] << 8);
  110|       |    /* fall-through */
  111|  26.3k|  case 1:
  ------------------
  |  Branch (111:3): [True: 601, False: 26.9k]
  ------------------
  112|  26.3k|    a += k[0];
  113|       |    /* case 0: nothing left to add */
  114|  27.5k|  }
  115|  27.5k|  burtlemix(a, b, c);
  116|       |  /*-------------------------------------------- report the result */
  117|  27.5k|  return c;
  118|  27.5k|}
_Z8burtleCIPKhjj:
  121|  1.79k|{
  122|  1.79k|  uint32_t a, b, c, len;
  123|       |
  124|       |  /* Set up the internal state */
  125|  1.79k|  len = length;
  126|  1.79k|  a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */
  127|  1.79k|  c = initval; /* the previous hash value */
  128|       |
  129|       |  /*---------------------------------------- handle most of the key */
  130|   343k|  while (len >= 12) {
  ------------------
  |  Branch (130:10): [True: 341k, False: 1.79k]
  ------------------
  131|   341k|    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|   341k|    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|   341k|    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|   341k|    burtlemix(a, b, c);
  135|   341k|    k += 12;
  136|   341k|    len -= 12;
  137|   341k|  }
  138|       |
  139|       |  /*------------------------------------- handle the last 11 bytes */
  140|  1.79k|  c += length;
  141|  1.79k|  switch (len) { /* all the case statements fall through */
  ------------------
  |  Branch (141:11): [True: 88, False: 1.70k]
  ------------------
  142|     60|  case 11:
  ------------------
  |  Branch (142:3): [True: 60, False: 1.73k]
  ------------------
  143|     60|    c += ((uint32_t)dns_tolower(k[10]) << 24);
  144|       |    /* fall-through */
  145|    140|  case 10:
  ------------------
  |  Branch (145:3): [True: 80, False: 1.71k]
  ------------------
  146|    140|    c += ((uint32_t)dns_tolower(k[9]) << 16);
  147|       |    /* fall-through */
  148|    182|  case 9:
  ------------------
  |  Branch (148:3): [True: 42, False: 1.75k]
  ------------------
  149|    182|    c += ((uint32_t)dns_tolower(k[8]) << 8);
  150|       |    /* the first byte of c is reserved for the length */
  151|       |    /* fall-through */
  152|    264|  case 8:
  ------------------
  |  Branch (152:3): [True: 82, False: 1.71k]
  ------------------
  153|    264|    b += ((uint32_t)dns_tolower(k[7]) << 24);
  154|       |    /* fall-through */
  155|    342|  case 7:
  ------------------
  |  Branch (155:3): [True: 78, False: 1.71k]
  ------------------
  156|    342|    b += ((uint32_t)dns_tolower(k[6]) << 16);
  157|       |    /* fall-through */
  158|    424|  case 6:
  ------------------
  |  Branch (158:3): [True: 82, False: 1.71k]
  ------------------
  159|    424|    b += ((uint32_t)dns_tolower(k[5]) << 8);
  160|       |    /* fall-through */
  161|    502|  case 5:
  ------------------
  |  Branch (161:3): [True: 78, False: 1.71k]
  ------------------
  162|    502|    b += dns_tolower(k[4]);
  163|       |    /* fall-through */
  164|    598|  case 4:
  ------------------
  |  Branch (164:3): [True: 96, False: 1.69k]
  ------------------
  165|    598|    a += ((uint32_t)dns_tolower(k[3]) << 24);
  166|       |    /* fall-through */
  167|    678|  case 3:
  ------------------
  |  Branch (167:3): [True: 80, False: 1.71k]
  ------------------
  168|    678|    a += ((uint32_t)dns_tolower(k[2]) << 16);
  169|       |    /* fall-through */
  170|    760|  case 2:
  ------------------
  |  Branch (170:3): [True: 82, False: 1.71k]
  ------------------
  171|    760|    a += ((uint32_t)dns_tolower(k[1]) << 8);
  172|       |    /* fall-through */
  173|  1.70k|  case 1:
  ------------------
  |  Branch (173:3): [True: 946, False: 848]
  ------------------
  174|  1.70k|    a += dns_tolower(k[0]);
  175|       |    /* case 0: nothing left to add */
  176|  1.79k|  }
  177|  1.79k|  burtlemix(a, b, c);
  178|       |  /*-------------------------------------------- report the result */
  179|  1.79k|  return c;
  180|  1.79k|}

_ZN17dnsheader_alignedC2EPKv:
  195|  2.40k|  {
  196|  2.40k|    if (reinterpret_cast<uintptr_t>(mem) % sizeof(uint32_t) == 0) {
  ------------------
  |  Branch (196:9): [True: 2.27k, False: 124]
  ------------------
  197|  2.27k|      d_p = reinterpret_cast<const dnsheader*>(mem);
  198|  2.27k|    }
  199|    124|    else {
  200|    124|      memcpy(&d_h, mem, sizeof(dnsheader));
  201|    124|      d_p = &d_h;
  202|    124|    }
  203|  2.40k|  }
_ZNK17dnsheader_aligned3getEv:
  206|  2.40k|  {
  207|  2.40k|    return d_p;
  208|  2.40k|  }

_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|  1.79k|{
  105|  1.79k|  if (offset >= len)
  ------------------
  |  Branch (105:7): [True: 0, False: 1.79k]
  ------------------
  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|  1.79k|  if(!uncompress) {
  ------------------
  |  Branch (108:6): [True: 1.79k, False: 0]
  ------------------
  109|  1.79k|    if(const void * fnd=memchr(pos+offset, 0, len-offset)) {
  ------------------
  |  Branch (109:21): [True: 1.69k, False: 96]
  ------------------
  110|  1.69k|      d_storage.reserve(2+(const char*)fnd-(pos+offset));
  111|  1.69k|    }
  112|  1.79k|  }
  113|       |
  114|  1.79k|  packetParser(pos, len, offset, uncompress, qtype, qclass, consumed, 0, minOffset);
  115|  1.79k|}
_ZN7DNSName12packetParserEPKciibPtS2_Pjit:
  119|  1.79k|{
  120|  1.79k|  const unsigned char* pos=(const unsigned char*)qpos;
  121|  1.79k|  unsigned char labellen;
  122|  1.79k|  const unsigned char *opos = pos;
  123|       |
  124|  1.79k|  if (offset >= len)
  ------------------
  |  Branch (124:7): [True: 0, False: 1.79k]
  ------------------
  125|      0|    throw std::range_error("Trying to read past the end of the buffer ("+std::to_string(offset)+ " >= "+std::to_string(len)+")");
  126|  1.79k|  if (offset < (int) minOffset)
  ------------------
  |  Branch (126:7): [True: 0, False: 1.79k]
  ------------------
  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|  1.79k|  const unsigned char* end = pos + len;
  130|  1.79k|  pos += offset;
  131|  10.6k|  while((labellen=*pos++) && pos < end) { // "scan and copy"
  ------------------
  |  Branch (131:9): [True: 9.56k, False: 1.08k]
  |  Branch (131:30): [True: 9.34k, False: 220]
  ------------------
  132|  9.34k|    if(labellen >= 0xc0) {
  ------------------
  |  Branch (132:8): [True: 236, False: 9.10k]
  ------------------
  133|    236|      if(!uncompress)
  ------------------
  |  Branch (133:10): [True: 236, False: 0]
  ------------------
  134|    236|        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|  9.10k|    } else if(labellen & 0xc0) {
  ------------------
  |  Branch (149:15): [True: 192, False: 8.91k]
  ------------------
  150|    192|      throw std::range_error("Found an invalid label length in qname (only one of the first two bits is set)");
  151|    192|    }
  152|  8.91k|    if (pos + labellen < end) {
  ------------------
  |  Branch (152:9): [True: 8.84k, False: 66]
  ------------------
  153|  8.84k|      appendRawLabel((const char*)pos, labellen);
  154|  8.84k|    }
  155|     66|    else
  156|     66|      throw std::range_error("Found an invalid label length in qname");
  157|  8.84k|    pos+=labellen;
  158|  8.84k|  }
  159|  1.30k|  if(d_storage.empty())
  ------------------
  |  Branch (159:6): [True: 896, False: 404]
  ------------------
  160|    896|    d_storage.append(1, (char)0); // we just parsed the root
  161|  1.30k|  if(consumed)
  ------------------
  |  Branch (161:6): [True: 0, False: 1.30k]
  ------------------
  162|      0|    *consumed = pos - opos - offset;
  163|  1.30k|  if(qtype) {
  ------------------
  |  Branch (163:6): [True: 0, False: 1.30k]
  ------------------
  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.30k|  pos+=2;
  170|  1.30k|  if(qclass) {
  ------------------
  |  Branch (170:6): [True: 0, False: 1.30k]
  ------------------
  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.30k|}
_ZNK7DNSName10wirelengthEv:
  246|  1.25k|size_t DNSName::wirelength() const {
  247|  1.25k|  return d_storage.length();
  248|  1.25k|}
_ZN7DNSName14appendRawLabelEPKcj:
  341|  8.84k|{
  342|  8.84k|  if(length==0)
  ------------------
  |  Branch (342:6): [True: 0, False: 8.84k]
  ------------------
  343|      0|    throw std::range_error("no such thing as an empty label to append");
  344|  8.84k|  if(length > 63)
  ------------------
  |  Branch (344:6): [True: 0, False: 8.84k]
  ------------------
  345|      0|    throw std::range_error("label too long to append");
  346|  8.84k|  if(d_storage.size() + length > s_maxDNSNameLength - 1) // reserve one byte for the label length
  ------------------
  |  Branch (346:6): [True: 46, False: 8.80k]
  ------------------
  347|     46|    throw std::range_error("name too long to append");
  348|       |
  349|  8.80k|  if(d_storage.empty()) {
  ------------------
  |  Branch (349:6): [True: 822, False: 7.97k]
  ------------------
  350|    822|    d_storage.append(1, (char)length);
  351|    822|  }
  352|  7.97k|  else {
  353|  7.97k|    *d_storage.rbegin()=(char)length;
  354|  7.97k|  }
  355|  8.80k|  d_storage.append(start, length);
  356|  8.80k|  d_storage.append(1, (char)0);
  357|  8.80k|}

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

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

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

_ZN11PacketCache13canHashPacketERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEERKNS0_13unordered_setItNS0_4hashItEENS0_8equal_toItEENS4_ItEEEE:
  133|  1.79k|  {
  134|  1.79k|    size_t pos = 0;
  135|  1.79k|    uint32_t currentHash = hashHeaderAndQName(packet, pos);
  136|       |
  137|  1.79k|    if (pos >= packet.size()) {
  ------------------
  |  Branch (137:9): [True: 646, False: 1.15k]
  ------------------
  138|    646|      return currentHash;
  139|    646|    }
  140|       |
  141|  1.15k|    return hashAfterQname(packet, currentHash, pos, optionsToSkip);
  142|  1.79k|  }
_ZN11PacketCache18hashHeaderAndQNameERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEERm:
  107|  1.79k|  {
  108|  1.79k|    const size_t packetSize = packet.size();
  109|  1.79k|    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|  79.5k|    for (pos = sizeof(dnsheader); pos < packetSize; ) {
  ------------------
  |  Branch (116:35): [True: 78.9k, False: 572]
  ------------------
  117|  78.9k|      const unsigned char labelLen = static_cast<unsigned char>(packet.at(pos));
  118|  78.9k|      ++pos;
  119|  78.9k|      if (labelLen == 0) {
  ------------------
  |  Branch (119:11): [True: 1.22k, False: 77.7k]
  ------------------
  120|  1.22k|        break;
  121|  1.22k|      }
  122|  77.7k|      pos = std::min(pos + labelLen, packetSize);
  123|  77.7k|    }
  124|  1.79k|    return burtleCI(reinterpret_cast<const unsigned char*>(&packet.at(sizeof(dnsheader))), pos - sizeof(dnsheader), currentHash);
  125|  1.79k|  }
_ZN11PacketCache14hashAfterQnameERKNSt3__117basic_string_viewIcNS0_11char_traitsIcEEEEjmRKNS0_13unordered_setItNS0_4hashItEENS0_8equal_toItEENS0_9allocatorItEEEE:
   37|  1.14k|  {
   38|  1.14k|    const size_t packetSize = packet.size();
   39|  1.14k|    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.14k|    const struct dnsheader *dh = dnsheaderdata.get();
   49|  1.14k|    if (ntohs(dh->qdcount) != 1 || ntohs(dh->ancount) != 0 || ntohs(dh->nscount) != 0 || ntohs(dh->arcount) != 1 || (pos + 15) >= packetSize) {
  ------------------
  |  Branch (49:9): [True: 96, False: 1.05k]
  |  Branch (49:36): [True: 20, False: 1.03k]
  |  Branch (49:63): [True: 8, False: 1.02k]
  |  Branch (49:90): [True: 12, False: 1.01k]
  |  Branch (49:117): [True: 50, False: 962]
  ------------------
   50|    186|      if (packetSize > pos) {
  ------------------
  |  Branch (50:11): [True: 186, False: 0]
  ------------------
   51|    186|        currentHash = burtle(reinterpret_cast<const unsigned char*>(&packet.at(pos)), packetSize - pos, currentHash);
   52|    186|      }
   53|    186|      return currentHash;
   54|    186|    }
   55|       |
   56|    962|    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|    962|    pos += 13;
   61|       |
   62|    962|    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|    962|    pos += 2;
   66|       |
   67|    962|    if (rdLen > (packetSize - pos)) {
  ------------------
  |  Branch (67:9): [True: 202, False: 760]
  ------------------
   68|    202|      if (pos < packetSize) {
  ------------------
  |  Branch (68:11): [True: 202, False: 0]
  ------------------
   69|    202|        currentHash = burtle(reinterpret_cast<const unsigned char*>(&packet.at(pos)), packetSize - pos, currentHash);
   70|    202|      }
   71|    202|      return currentHash;
   72|    202|    }
   73|       |
   74|    760|    uint16_t rdataRead = 0;
   75|    760|    uint16_t optionCode;
   76|    760|    uint16_t optionLen;
   77|       |
   78|  24.5k|    while (pos < packetSize && rdataRead < rdLen && getNextEDNSOption(&packet.at(pos), rdLen - rdataRead, optionCode, optionLen)) {
  ------------------
  |  Branch (78:12): [True: 24.3k, False: 122]
  |  Branch (78:32): [True: 24.2k, False: 118]
  |  Branch (78:53): [True: 24.1k, False: 164]
  ------------------
   79|  24.1k|      if (optionLen > (rdLen - rdataRead - 4)) {
  ------------------
  |  Branch (79:11): [True: 356, False: 23.7k]
  ------------------
   80|    356|        if (packetSize > pos) {
  ------------------
  |  Branch (80:13): [True: 356, False: 0]
  ------------------
   81|    356|          currentHash = burtle(reinterpret_cast<const unsigned char*>(&packet.at(pos)), packetSize - pos, currentHash);
   82|    356|        }
   83|    356|        return currentHash;
   84|    356|      }
   85|       |
   86|  23.7k|      if (optionsToSkip.count(optionCode) == 0) {
  ------------------
  |  Branch (86:11): [True: 22.5k, False: 1.16k]
  ------------------
   87|       |        /* hash the option code, length and content */
   88|  22.5k|        currentHash = burtle(reinterpret_cast<const unsigned char*>(&packet.at(pos)), 4 + optionLen, currentHash);
   89|  22.5k|      }
   90|  1.16k|      else {
   91|       |        /* skip option: hash only its code and length */
   92|  1.16k|        currentHash = burtle(reinterpret_cast<const unsigned char*>(&packet.at(pos)), 4, currentHash);
   93|  1.16k|      }
   94|       |
   95|  23.7k|      pos += 4 + optionLen;
   96|  23.7k|      rdataRead += 4 + optionLen;
   97|  23.7k|    }
   98|       |
   99|    404|    if (pos < packetSize) {
  ------------------
  |  Branch (99:9): [True: 282, False: 122]
  ------------------
  100|    282|      currentHash = burtle(reinterpret_cast<const unsigned char*>(&packet.at(pos)), packetSize - pos, currentHash);
  101|    282|    }
  102|       |
  103|    404|    return currentHash;
  104|    760|  }
_ZN11PacketCache12queryMatchesERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEES8_RK7DNSNameRKNS0_13unordered_setItNS0_4hashItEENS0_8equal_toItEENS4_ItEEEE:
  154|  1.25k|  {
  155|  1.25k|    const size_t querySize = query.size();
  156|  1.25k|    const size_t cachedQuerySize = cachedQuery.size();
  157|  1.25k|    if (querySize != cachedQuerySize) {
  ------------------
  |  Branch (157:9): [True: 0, False: 1.25k]
  ------------------
  158|      0|      return false;
  159|      0|    }
  160|       |
  161|  1.25k|    if (!queryHeaderMatches(cachedQuery, query)) {
  ------------------
  |  Branch (161:9): [True: 0, False: 1.25k]
  ------------------
  162|      0|      return false;
  163|      0|    }
  164|       |
  165|  1.25k|    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.25k|    const dnsheader_aligned dnsheaderdata(query.data());
  173|  1.25k|    const struct dnsheader* dh = dnsheaderdata.get();
  174|  1.25k|    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: 310, False: 944]
  |  Branch (174:36): [True: 30, False: 914]
  |  Branch (174:63): [True: 16, False: 898]
  |  Branch (174:90): [True: 18, False: 880]
  |  Branch (174:117): [True: 44, False: 836]
  |  Branch (174:144): [True: 0, False: 836]
  ------------------
  175|    418|      return cachedQuery.compare(pos, cachedQuerySize - pos, query, pos, querySize - pos) == 0;
  176|    418|    }
  177|       |
  178|       |    /* compare up to the first option, if any */
  179|    836|    if (cachedQuery.compare(pos, 15, query, pos, 15) != 0) {
  ------------------
  |  Branch (179:9): [True: 0, False: 836]
  ------------------
  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|    836|    pos += 13;
  187|       |
  188|    836|    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|    836|    pos += sizeof(uint16_t);
  192|       |
  193|    836|    if (rdLen > (querySize - pos)) {
  ------------------
  |  Branch (193:9): [True: 206, False: 630]
  ------------------
  194|       |      /* something is wrong, let's just compare everything */
  195|    206|      return cachedQuery.compare(pos, cachedQuerySize - pos, query, pos, querySize - pos) == 0;
  196|    206|    }
  197|       |
  198|    630|    uint16_t rdataRead = 0;
  199|    630|    uint16_t optionCode;
  200|    630|    uint16_t optionLen;
  201|       |
  202|  17.3k|    while (pos < querySize && rdataRead < rdLen && getNextEDNSOption(&query.at(pos), rdLen - rdataRead, optionCode, optionLen)) {
  ------------------
  |  Branch (202:12): [True: 17.1k, False: 192]
  |  Branch (202:31): [True: 17.0k, False: 116]
  |  Branch (202:52): [True: 16.9k, False: 118]
  ------------------
  203|  16.9k|      if (optionLen > (rdLen - rdataRead)) {
  ------------------
  |  Branch (203:11): [True: 204, False: 16.7k]
  ------------------
  204|    204|        return cachedQuery.compare(pos, cachedQuerySize - pos, query, pos, querySize - pos) == 0;
  205|    204|      }
  206|       |
  207|       |      /* compare the option code and length */
  208|  16.7k|      if (cachedQuery.compare(pos, 4, query, pos, 4) != 0) {
  ------------------
  |  Branch (208:11): [True: 0, False: 16.7k]
  ------------------
  209|      0|        return false;
  210|      0|      }
  211|  16.7k|      pos += 4;
  212|  16.7k|      rdataRead += 4;
  213|       |
  214|  16.7k|      if (optionLen > 0 && optionsToIgnore.count(optionCode) == 0) {
  ------------------
  |  Branch (214:11): [True: 7.56k, False: 9.17k]
  |  Branch (214:28): [True: 7.14k, False: 415]
  ------------------
  215|  7.14k|        if (cachedQuery.compare(pos, optionLen, query, pos, optionLen) != 0) {
  ------------------
  |  Branch (215:13): [True: 0, False: 7.14k]
  ------------------
  216|      0|          return false;
  217|      0|        }
  218|  7.14k|      }
  219|  16.7k|      pos += optionLen;
  220|  16.7k|      rdataRead += optionLen;
  221|  16.7k|    }
  222|       |
  223|    426|    if (pos >= querySize) {
  ------------------
  |  Branch (223:9): [True: 192, False: 234]
  ------------------
  224|    192|        return true;
  225|    192|    }
  226|       |
  227|    234|    return cachedQuery.compare(pos, cachedQuerySize - pos, query, pos, querySize - pos) == 0;
  228|    426|  }
_ZN11PacketCache18queryHeaderMatchesERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEES8_:
  145|  1.25k|  {
  146|  1.25k|    if (cachedQuery.size() != query.size()) {
  ------------------
  |  Branch (146:9): [True: 0, False: 1.25k]
  ------------------
  147|      0|      return false;
  148|      0|    }
  149|       |
  150|  1.25k|    return (cachedQuery.compare(/* skip the ID */ 2, sizeof(dnsheader) - 2, query, 2, sizeof(dnsheader) - 2) == 0);
  151|  1.25k|  }

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|    128|  for (const auto& n : names) {
  ------------------
  |  Branch (106:22): [True: 128, False: 2]
  ------------------
  107|    128|    ret.emplace(n.second, n.first);
  108|    128|  }
  109|      2|  return ret;
  110|      2|}

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

