_Z16htole32_internalj:
   39|  2.85M|{
   40|       |    if constexpr (std::endian::native == std::endian::big) return internal_bswap_32(host_32bits);
   41|  2.85M|        else return host_32bits;
   42|  2.85M|}
_Z16le32toh_internalj:
   49|  2.66M|{
   50|       |    if constexpr (std::endian::native == std::endian::big) return internal_bswap_32(little_endian_32bits);
   51|  2.66M|        else return little_endian_32bits;
   52|  2.66M|}

_ZN15ChaCha20Aligned6SetKeyE4SpanIKSt4byteE:
   26|  6.63k|{
   27|  6.63k|    assert(key.size() == KEYLEN);
   28|  6.63k|    input[0] = ReadLE32(key.data() + 0);
   29|  6.63k|    input[1] = ReadLE32(key.data() + 4);
   30|  6.63k|    input[2] = ReadLE32(key.data() + 8);
   31|  6.63k|    input[3] = ReadLE32(key.data() + 12);
   32|  6.63k|    input[4] = ReadLE32(key.data() + 16);
   33|  6.63k|    input[5] = ReadLE32(key.data() + 20);
   34|  6.63k|    input[6] = ReadLE32(key.data() + 24);
   35|  6.63k|    input[7] = ReadLE32(key.data() + 28);
   36|  6.63k|    input[8] = 0;
   37|  6.63k|    input[9] = 0;
   38|  6.63k|    input[10] = 0;
   39|  6.63k|    input[11] = 0;
   40|  6.63k|}
_ZN15ChaCha20AlignedD2Ev:
   43|    342|{
   44|    342|    memory_cleanse(input, sizeof(input));
   45|    342|}
_ZN15ChaCha20AlignedC2E4SpanIKSt4byteE:
   48|    342|{
   49|    342|    SetKey(key);
   50|    342|}
_ZN15ChaCha20Aligned4SeekENSt3__14pairIjmEEj:
   53|  6.28k|{
   54|  6.28k|    input[8] = block_counter;
   55|  6.28k|    input[9] = nonce.first;
   56|  6.28k|    input[10] = nonce.second;
   57|  6.28k|    input[11] = nonce.second >> 32;
   58|  6.28k|}
_ZN8ChaCha209KeystreamE4SpanISt4byteE:
  283|  6.28k|{
  284|  6.28k|    if (out.empty()) return;
  ------------------
  |  Branch (284:9): [True: 0, False: 6.28k]
  ------------------
  285|  6.28k|    if (m_bufleft) {
  ------------------
  |  Branch (285:9): [True: 756, False: 5.53k]
  ------------------
  286|    756|        unsigned reuse = std::min<size_t>(m_bufleft, out.size());
  287|    756|        std::copy(m_buffer.end() - m_bufleft, m_buffer.end() - m_bufleft + reuse, out.begin());
  288|    756|        m_bufleft -= reuse;
  289|    756|        out = out.subspan(reuse);
  290|    756|    }
  291|  6.28k|    if (out.size() >= m_aligned.BLOCKLEN) {
  ------------------
  |  Branch (291:9): [True: 0, False: 6.28k]
  ------------------
  292|      0|        size_t blocks = out.size() / m_aligned.BLOCKLEN;
  293|      0|        m_aligned.Keystream(out.first(blocks * m_aligned.BLOCKLEN));
  294|      0|        out = out.subspan(blocks * m_aligned.BLOCKLEN);
  295|      0|    }
  296|  6.28k|    if (!out.empty()) {
  ------------------
  |  Branch (296:9): [True: 5.70k, False: 585]
  ------------------
  297|  5.70k|        m_aligned.Keystream(m_buffer);
  298|  5.70k|        std::copy(m_buffer.begin(), m_buffer.begin() + out.size(), out.begin());
  299|  5.70k|        m_bufleft = m_aligned.BLOCKLEN - out.size();
  300|  5.70k|    }
  301|  6.28k|}
_ZN8ChaCha205CryptE4SpanIKSt4byteES0_IS1_E:
  304|  28.2k|{
  305|  28.2k|    assert(input.size() == output.size());
  306|       |
  307|  28.2k|    if (!input.size()) return;
  ------------------
  |  Branch (307:9): [True: 17.1k, False: 11.1k]
  ------------------
  308|  11.1k|    if (m_bufleft) {
  ------------------
  |  Branch (308:9): [True: 9.44k, False: 1.66k]
  ------------------
  309|  9.44k|        unsigned reuse = std::min<size_t>(m_bufleft, input.size());
  310|   292k|        for (unsigned i = 0; i < reuse; i++) {
  ------------------
  |  Branch (310:30): [True: 283k, False: 9.44k]
  ------------------
  311|   283k|            output[i] = input[i] ^ m_buffer[m_aligned.BLOCKLEN - m_bufleft + i];
  312|   283k|        }
  313|  9.44k|        m_bufleft -= reuse;
  314|  9.44k|        output = output.subspan(reuse);
  315|  9.44k|        input = input.subspan(reuse);
  316|  9.44k|    }
  317|  11.1k|    if (input.size() >= m_aligned.BLOCKLEN) {
  ------------------
  |  Branch (317:9): [True: 7.89k, False: 3.21k]
  ------------------
  318|  7.89k|        size_t blocks = input.size() / m_aligned.BLOCKLEN;
  319|  7.89k|        m_aligned.Crypt(input.first(blocks * m_aligned.BLOCKLEN), output.first(blocks * m_aligned.BLOCKLEN));
  320|  7.89k|        output = output.subspan(blocks * m_aligned.BLOCKLEN);
  321|  7.89k|        input = input.subspan(blocks * m_aligned.BLOCKLEN);
  322|  7.89k|    }
  323|  11.1k|    if (!input.empty()) {
  ------------------
  |  Branch (323:9): [True: 9.56k, False: 1.54k]
  ------------------
  324|  9.56k|        m_aligned.Keystream(m_buffer);
  325|   300k|        for (unsigned i = 0; i < input.size(); i++) {
  ------------------
  |  Branch (325:30): [True: 291k, False: 9.56k]
  ------------------
  326|   291k|            output[i] = input[i] ^ m_buffer[i];
  327|   291k|        }
  328|  9.56k|        m_bufleft = m_aligned.BLOCKLEN - input.size();
  329|  9.56k|    }
  330|  11.1k|}
_ZN8ChaCha20D2Ev:
  333|    342|{
  334|    342|    memory_cleanse(m_buffer.data(), m_buffer.size());
  335|    342|}
_ZN8ChaCha206SetKeyE4SpanIKSt4byteE:
  338|  6.28k|{
  339|  6.28k|    m_aligned.SetKey(key);
  340|  6.28k|    m_bufleft = 0;
  341|  6.28k|    memory_cleanse(m_buffer.data(), m_buffer.size());
  342|  6.28k|}
_ZN10FSChaCha20C2E4SpanIKSt4byteEj:
  345|    342|    m_chacha20(key), m_rekey_interval(rekey_interval)
  346|    342|{
  347|    342|    assert(key.size() == KEYLEN);
  348|    342|}
_ZN10FSChaCha205CryptE4SpanIKSt4byteES0_IS1_E:
  351|  28.2k|{
  352|  28.2k|    assert(input.size() == output.size());
  353|       |
  354|       |    // Invoke internal stream cipher for actual encryption/decryption.
  355|  28.2k|    m_chacha20.Crypt(input, output);
  356|       |
  357|       |    // Rekey after m_rekey_interval encryptions/decryptions.
  358|  28.2k|    if (++m_chunk_counter == m_rekey_interval) {
  ------------------
  |  Branch (358:9): [True: 6.28k, False: 21.9k]
  ------------------
  359|       |        // Get new key from the stream cipher.
  360|  6.28k|        std::byte new_key[KEYLEN];
  361|  6.28k|        m_chacha20.Keystream(new_key);
  362|       |        // Update its key.
  363|  6.28k|        m_chacha20.SetKey(new_key);
  364|       |        // Wipe the key (a copy remains inside m_chacha20, where it'll be wiped on the next rekey
  365|       |        // or on destruction).
  366|  6.28k|        memory_cleanse(new_key, sizeof(new_key));
  367|       |        // Set the nonce for the new section of output.
  368|  6.28k|        m_chacha20.Seek({0, ++m_rekey_counter}, 0);
  369|       |        // Reset the chunk counter.
  370|  6.28k|        m_chunk_counter = 0;
  371|  6.28k|    }
  372|  28.2k|}
_ZN15ChaCha20Aligned9KeystreamE4SpanISt4byteE:
   61|  15.2k|{
   62|  15.2k|    std::byte* c = output.data();
   63|  15.2k|    size_t blocks = output.size() / BLOCKLEN;
   64|  15.2k|    assert(blocks * BLOCKLEN == output.size());
   65|       |
   66|  15.2k|    uint32_t x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
   67|  15.2k|    uint32_t j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
   68|       |
   69|  15.2k|    if (!blocks) return;
  ------------------
  |  Branch (69:9): [True: 0, False: 15.2k]
  ------------------
   70|       |
   71|  15.2k|    j4 = input[0];
   72|  15.2k|    j5 = input[1];
   73|  15.2k|    j6 = input[2];
   74|  15.2k|    j7 = input[3];
   75|  15.2k|    j8 = input[4];
   76|  15.2k|    j9 = input[5];
   77|  15.2k|    j10 = input[6];
   78|  15.2k|    j11 = input[7];
   79|  15.2k|    j12 = input[8];
   80|  15.2k|    j13 = input[9];
   81|  15.2k|    j14 = input[10];
   82|  15.2k|    j15 = input[11];
   83|       |
   84|  15.2k|    for (;;) {
   85|  15.2k|        x0 = 0x61707865;
   86|  15.2k|        x1 = 0x3320646e;
   87|  15.2k|        x2 = 0x79622d32;
   88|  15.2k|        x3 = 0x6b206574;
   89|  15.2k|        x4 = j4;
   90|  15.2k|        x5 = j5;
   91|  15.2k|        x6 = j6;
   92|  15.2k|        x7 = j7;
   93|  15.2k|        x8 = j8;
   94|  15.2k|        x9 = j9;
   95|  15.2k|        x10 = j10;
   96|  15.2k|        x11 = j11;
   97|  15.2k|        x12 = j12;
   98|  15.2k|        x13 = j13;
   99|  15.2k|        x14 = j14;
  100|  15.2k|        x15 = j15;
  101|       |
  102|       |        // The 20 inner ChaCha20 rounds are unrolled here for performance.
  103|  15.2k|        REPEAT10(
  ------------------
  |  |   23|  15.2k|#define REPEAT10(a) do { {a}; {a}; {a}; {a}; {a}; {a}; {a}; {a}; {a}; {a}; } while(0)
  |  |  ------------------
  |  |  |  Branch (23:84): [Folded - Ignored]
  |  |  ------------------
  ------------------
  104|  15.2k|            QUARTERROUND( x0, x4, x8,x12);
  105|  15.2k|            QUARTERROUND( x1, x5, x9,x13);
  106|  15.2k|            QUARTERROUND( x2, x6,x10,x14);
  107|  15.2k|            QUARTERROUND( x3, x7,x11,x15);
  108|  15.2k|            QUARTERROUND( x0, x5,x10,x15);
  109|  15.2k|            QUARTERROUND( x1, x6,x11,x12);
  110|  15.2k|            QUARTERROUND( x2, x7, x8,x13);
  111|  15.2k|            QUARTERROUND( x3, x4, x9,x14);
  112|  15.2k|        );
  113|       |
  114|  15.2k|        x0 += 0x61707865;
  115|  15.2k|        x1 += 0x3320646e;
  116|  15.2k|        x2 += 0x79622d32;
  117|  15.2k|        x3 += 0x6b206574;
  118|  15.2k|        x4 += j4;
  119|  15.2k|        x5 += j5;
  120|  15.2k|        x6 += j6;
  121|  15.2k|        x7 += j7;
  122|  15.2k|        x8 += j8;
  123|  15.2k|        x9 += j9;
  124|  15.2k|        x10 += j10;
  125|  15.2k|        x11 += j11;
  126|  15.2k|        x12 += j12;
  127|  15.2k|        x13 += j13;
  128|  15.2k|        x14 += j14;
  129|  15.2k|        x15 += j15;
  130|       |
  131|  15.2k|        ++j12;
  132|  15.2k|        if (!j12) ++j13;
  ------------------
  |  Branch (132:13): [True: 0, False: 15.2k]
  ------------------
  133|       |
  134|  15.2k|        WriteLE32(c + 0, x0);
  135|  15.2k|        WriteLE32(c + 4, x1);
  136|  15.2k|        WriteLE32(c + 8, x2);
  137|  15.2k|        WriteLE32(c + 12, x3);
  138|  15.2k|        WriteLE32(c + 16, x4);
  139|  15.2k|        WriteLE32(c + 20, x5);
  140|  15.2k|        WriteLE32(c + 24, x6);
  141|  15.2k|        WriteLE32(c + 28, x7);
  142|  15.2k|        WriteLE32(c + 32, x8);
  143|  15.2k|        WriteLE32(c + 36, x9);
  144|  15.2k|        WriteLE32(c + 40, x10);
  145|  15.2k|        WriteLE32(c + 44, x11);
  146|  15.2k|        WriteLE32(c + 48, x12);
  147|  15.2k|        WriteLE32(c + 52, x13);
  148|  15.2k|        WriteLE32(c + 56, x14);
  149|  15.2k|        WriteLE32(c + 60, x15);
  150|       |
  151|  15.2k|        if (blocks == 1) {
  ------------------
  |  Branch (151:13): [True: 15.2k, False: 0]
  ------------------
  152|  15.2k|            input[8] = j12;
  153|  15.2k|            input[9] = j13;
  154|  15.2k|            return;
  155|  15.2k|        }
  156|      0|        blocks -= 1;
  157|      0|        c += BLOCKLEN;
  158|      0|    }
  159|  15.2k|}
_ZN15ChaCha20Aligned5CryptE4SpanIKSt4byteES0_IS1_E:
  162|  7.89k|{
  163|  7.89k|    assert(in_bytes.size() == out_bytes.size());
  164|  7.89k|    const std::byte* m = in_bytes.data();
  165|  7.89k|    std::byte* c = out_bytes.data();
  166|  7.89k|    size_t blocks = out_bytes.size() / BLOCKLEN;
  167|  7.89k|    assert(blocks * BLOCKLEN == out_bytes.size());
  168|       |
  169|  7.89k|    uint32_t x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
  170|  7.89k|    uint32_t j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
  171|       |
  172|  7.89k|    if (!blocks) return;
  ------------------
  |  Branch (172:9): [True: 0, False: 7.89k]
  ------------------
  173|       |
  174|  7.89k|    j4 = input[0];
  175|  7.89k|    j5 = input[1];
  176|  7.89k|    j6 = input[2];
  177|  7.89k|    j7 = input[3];
  178|  7.89k|    j8 = input[4];
  179|  7.89k|    j9 = input[5];
  180|  7.89k|    j10 = input[6];
  181|  7.89k|    j11 = input[7];
  182|  7.89k|    j12 = input[8];
  183|  7.89k|    j13 = input[9];
  184|  7.89k|    j14 = input[10];
  185|  7.89k|    j15 = input[11];
  186|       |
  187|   163k|    for (;;) {
  188|   163k|        x0 = 0x61707865;
  189|   163k|        x1 = 0x3320646e;
  190|   163k|        x2 = 0x79622d32;
  191|   163k|        x3 = 0x6b206574;
  192|   163k|        x4 = j4;
  193|   163k|        x5 = j5;
  194|   163k|        x6 = j6;
  195|   163k|        x7 = j7;
  196|   163k|        x8 = j8;
  197|   163k|        x9 = j9;
  198|   163k|        x10 = j10;
  199|   163k|        x11 = j11;
  200|   163k|        x12 = j12;
  201|   163k|        x13 = j13;
  202|   163k|        x14 = j14;
  203|   163k|        x15 = j15;
  204|       |
  205|       |        // The 20 inner ChaCha20 rounds are unrolled here for performance.
  206|   163k|        REPEAT10(
  ------------------
  |  |   23|   163k|#define REPEAT10(a) do { {a}; {a}; {a}; {a}; {a}; {a}; {a}; {a}; {a}; {a}; } while(0)
  |  |  ------------------
  |  |  |  Branch (23:84): [Folded - Ignored]
  |  |  ------------------
  ------------------
  207|   163k|            QUARTERROUND( x0, x4, x8,x12);
  208|   163k|            QUARTERROUND( x1, x5, x9,x13);
  209|   163k|            QUARTERROUND( x2, x6,x10,x14);
  210|   163k|            QUARTERROUND( x3, x7,x11,x15);
  211|   163k|            QUARTERROUND( x0, x5,x10,x15);
  212|   163k|            QUARTERROUND( x1, x6,x11,x12);
  213|   163k|            QUARTERROUND( x2, x7, x8,x13);
  214|   163k|            QUARTERROUND( x3, x4, x9,x14);
  215|   163k|        );
  216|       |
  217|   163k|        x0 += 0x61707865;
  218|   163k|        x1 += 0x3320646e;
  219|   163k|        x2 += 0x79622d32;
  220|   163k|        x3 += 0x6b206574;
  221|   163k|        x4 += j4;
  222|   163k|        x5 += j5;
  223|   163k|        x6 += j6;
  224|   163k|        x7 += j7;
  225|   163k|        x8 += j8;
  226|   163k|        x9 += j9;
  227|   163k|        x10 += j10;
  228|   163k|        x11 += j11;
  229|   163k|        x12 += j12;
  230|   163k|        x13 += j13;
  231|   163k|        x14 += j14;
  232|   163k|        x15 += j15;
  233|       |
  234|   163k|        x0 ^= ReadLE32(m + 0);
  235|   163k|        x1 ^= ReadLE32(m + 4);
  236|   163k|        x2 ^= ReadLE32(m + 8);
  237|   163k|        x3 ^= ReadLE32(m + 12);
  238|   163k|        x4 ^= ReadLE32(m + 16);
  239|   163k|        x5 ^= ReadLE32(m + 20);
  240|   163k|        x6 ^= ReadLE32(m + 24);
  241|   163k|        x7 ^= ReadLE32(m + 28);
  242|   163k|        x8 ^= ReadLE32(m + 32);
  243|   163k|        x9 ^= ReadLE32(m + 36);
  244|   163k|        x10 ^= ReadLE32(m + 40);
  245|   163k|        x11 ^= ReadLE32(m + 44);
  246|   163k|        x12 ^= ReadLE32(m + 48);
  247|   163k|        x13 ^= ReadLE32(m + 52);
  248|   163k|        x14 ^= ReadLE32(m + 56);
  249|   163k|        x15 ^= ReadLE32(m + 60);
  250|       |
  251|   163k|        ++j12;
  252|   163k|        if (!j12) ++j13;
  ------------------
  |  Branch (252:13): [True: 0, False: 163k]
  ------------------
  253|       |
  254|   163k|        WriteLE32(c + 0, x0);
  255|   163k|        WriteLE32(c + 4, x1);
  256|   163k|        WriteLE32(c + 8, x2);
  257|   163k|        WriteLE32(c + 12, x3);
  258|   163k|        WriteLE32(c + 16, x4);
  259|   163k|        WriteLE32(c + 20, x5);
  260|   163k|        WriteLE32(c + 24, x6);
  261|   163k|        WriteLE32(c + 28, x7);
  262|   163k|        WriteLE32(c + 32, x8);
  263|   163k|        WriteLE32(c + 36, x9);
  264|   163k|        WriteLE32(c + 40, x10);
  265|   163k|        WriteLE32(c + 44, x11);
  266|   163k|        WriteLE32(c + 48, x12);
  267|   163k|        WriteLE32(c + 52, x13);
  268|   163k|        WriteLE32(c + 56, x14);
  269|   163k|        WriteLE32(c + 60, x15);
  270|       |
  271|   163k|        if (blocks == 1) {
  ------------------
  |  Branch (271:13): [True: 7.89k, False: 155k]
  ------------------
  272|  7.89k|            input[8] = j12;
  273|  7.89k|            input[9] = j13;
  274|  7.89k|            return;
  275|  7.89k|        }
  276|   155k|        blocks -= 1;
  277|   155k|        c += BLOCKLEN;
  278|   155k|        m += BLOCKLEN;
  279|   155k|    }
  280|  7.89k|}

_ZN8ChaCha20C2E4SpanIKSt4byteE:
   92|    342|    ChaCha20(Span<const std::byte> key) noexcept : m_aligned(key) {}
_ZN8ChaCha204SeekENSt3__14pairIjmEEj:
  105|  6.28k|    {
  106|  6.28k|        m_aligned.Seek(nonce, block_counter);
  107|  6.28k|        m_bufleft = 0;
  108|  6.28k|    }

_Z9WriteLE32ITk8ByteTypeSt4byteEvPT_j:
   51|  2.85M|{
   52|  2.85M|    uint32_t v = htole32_internal(x);
   53|  2.85M|    memcpy(ptr, &v, 4);
   54|  2.85M|}
_Z8ReadLE32ITk8ByteTypeSt4byteEjPKT_:
   28|  2.66M|{
   29|  2.66M|    uint32_t x;
   30|  2.66M|    memcpy(&x, ptr, 4);
   31|  2.66M|    return le32toh_internal(x);
   32|  2.66M|}

_ZNK4SpanIKSt4byteE5firstEm:
  206|  7.89k|    {
  207|  7.89k|        ASSERT_IF_DEBUG(size() >= count);
  208|  7.89k|        return Span<C>(m_data, count);
  209|  7.89k|    }
_ZNK4SpanISt4byteE5firstEm:
  206|  7.89k|    {
  207|  7.89k|        ASSERT_IF_DEBUG(size() >= count);
  208|  7.89k|        return Span<C>(m_data, count);
  209|  7.89k|    }
_ZNK4SpanIKSt4byteE4sizeEv:
  187|   449k|    constexpr std::size_t size() const noexcept { return m_size; }
_ZNK4SpanIKSt4byteE4dataEv:
  174|  60.9k|    constexpr C* data() const noexcept { return m_data; }
_ZNK4SpanISt4byteE4sizeEv:
  187|   141k|    constexpr std::size_t size() const noexcept { return m_size; }
_ZNK4SpanISt4byteEixEm:
  191|   574k|    {
  192|   574k|        ASSERT_IF_DEBUG(size() > pos);
  193|   574k|        return m_data[pos];
  194|   574k|    }
_ZNK4SpanIKSt4byteEixEm:
  191|   574k|    {
  192|   574k|        ASSERT_IF_DEBUG(size() > pos);
  193|   574k|        return m_data[pos];
  194|   574k|    }
_ZNK4SpanISt4byteE4dataEv:
  174|  23.1k|    constexpr C* data() const noexcept { return m_data; }
_ZNK4SpanISt4byteE7subspanEm:
  196|  18.1k|    {
  197|  18.1k|        ASSERT_IF_DEBUG(size() >= offset);
  198|  18.1k|        return Span<C>(m_data + offset, m_size - offset);
  199|  18.1k|    }
_ZN4SpanIKSt4byteEC2IS1_TnNSt3__19enable_ifIXsr3std14is_convertibleIPA_T_PA_S1_EE5valueEiE4typeELi0EEEPS6_m:
  119|  25.2k|    constexpr Span(T* begin, std::size_t size) noexcept : m_data(begin), m_size(size) {}
_ZN4SpanISt4byteEC2IS0_TnNSt3__19enable_ifIXsr3std14is_convertibleIPA_T_PA_S0_EE5valueEiE4typeELi0EEEPS5_m:
  119|  25.9k|    constexpr Span(T* begin, std::size_t size) noexcept : m_data(begin), m_size(size) {}
_ZN4SpanIKSt4byteEC2INSt3__16vectorIS0_NS4_9allocatorIS0_EEEEEERT_NS4_9enable_ifIXaaaantsr7is_SpanIS9_EE5valuesr3std14is_convertibleIPA_NS4_14remove_pointerIDTcldtclsr3stdE7declvalISA_EE4dataEEE4typeEPA_S1_EE5valuesr3std14is_convertibleIDTcldtclsr3stdE7declvalISA_EE4sizeEEmEE5valueEDnE4typeE:
  165|  28.6k|        : m_data(other.data()), m_size(other.size()){}
_ZN4SpanISt4byteEC2INSt3__16vectorIS0_NS3_9allocatorIS0_EEEEEERT_NS3_9enable_ifIXaaaantsr7is_SpanIS8_EE5valuesr3std14is_convertibleIPA_NS3_14remove_pointerIDTcldtclsr3stdE7declvalIS9_EE4dataEEE4typeEPA_S0_EE5valuesr3std14is_convertibleIDTcldtclsr3stdE7declvalIS9_EE4sizeEEmEE5valueEDnE4typeE:
  165|  28.2k|        : m_data(other.data()), m_size(other.size()){}
_ZNK4SpanISt4byteE5beginEv:
  175|  6.45k|    constexpr C* begin() const noexcept { return m_data; }
_ZNK4SpanIKSt4byteE7subspanEm:
  196|  17.3k|    {
  197|  17.3k|        ASSERT_IF_DEBUG(size() >= offset);
  198|  17.3k|        return Span<C>(m_data + offset, m_size - offset);
  199|  17.3k|    }
_ZNK4SpanISt4byteE5emptyEv:
  189|  12.5k|    constexpr bool empty() const noexcept { return size() == 0; }
_ZN4SpanISt4byteEC2INSt3__15arrayIS0_Lm64EEEEERT_NS3_9enable_ifIXaaaantsr7is_SpanIS6_EE5valuesr3std14is_convertibleIPA_NS3_14remove_pointerIDTcldtclsr3stdE7declvalIS7_EE4dataEEE4typeEPA_S0_EE5valuesr3std14is_convertibleIDTcldtclsr3stdE7declvalIS7_EE4sizeEEmEE5valueEDnE4typeE:
  165|  15.2k|        : m_data(other.data()), m_size(other.size()){}
_ZNK4SpanIKSt4byteE5emptyEv:
  189|  11.1k|    constexpr bool empty() const noexcept { return size() == 0; }
_ZN4SpanISt4byteEC2ILi32EEERAT__S0_:
  151|  6.28k|    constexpr Span(C (&a)[N]) noexcept : m_data(a), m_size(N) {}
_ZN4SpanIKSt4byteEC2ILi32EEERAT__S1_:
  151|  6.28k|    constexpr Span(C (&a)[N]) noexcept : m_data(a), m_size(N) {}

_Z14memory_cleansePvm:
   15|  13.2k|{
   16|       |#if defined(WIN32)
   17|       |    /* SecureZeroMemory is guaranteed not to be optimized out. */
   18|       |    SecureZeroMemory(ptr, len);
   19|       |#else
   20|  13.2k|    std::memset(ptr, 0, len);
   21|       |
   22|       |    /* Memory barrier that scares the compiler away from optimizing out the memset.
   23|       |     *
   24|       |     * Quoting Adam Langley <agl@google.com> in commit ad1907fe73334d6c696c8539646c21b11178f20f
   25|       |     * in BoringSSL (ISC License):
   26|       |     *    As best as we can tell, this is sufficient to break any optimisations that
   27|       |     *    might try to eliminate "superfluous" memsets.
   28|       |     * This method is used in memzero_explicit() the Linux kernel, too. Its advantage is that it
   29|       |     * is pretty efficient because the compiler can still implement the memset() efficiently,
   30|       |     * just not remove it entirely. See "Dead Store Elimination (Still) Considered Harmful" by
   31|       |     * Yang et al. (USENIX Security 2017) for more background.
   32|       |     */
   33|  13.2k|    __asm__ __volatile__("" : : "r"(ptr) : "memory");
   34|  13.2k|#endif
   35|  13.2k|}

_ZN18FuzzedDataProviderC2EPKhm:
   37|    342|      : data_ptr_(data), remaining_bytes_(size) {}
_ZN18FuzzedDataProvider22ConsumeIntegralInRangeIiEET_S1_S1_:
  205|  28.2k|T FuzzedDataProvider::ConsumeIntegralInRange(T min, T max) {
  206|  28.2k|  static_assert(std::is_integral<T>::value, "An integral type is required.");
  207|  28.2k|  static_assert(sizeof(T) <= sizeof(uint64_t), "Unsupported integral type.");
  208|       |
  209|  28.2k|  if (min > max)
  ------------------
  |  Branch (209:7): [True: 0, False: 28.2k]
  ------------------
  210|      0|    abort();
  211|       |
  212|       |  // Use the biggest type possible to hold the range and the result.
  213|  28.2k|  uint64_t range = static_cast<uint64_t>(max) - static_cast<uint64_t>(min);
  214|  28.2k|  uint64_t result = 0;
  215|  28.2k|  size_t offset = 0;
  216|       |
  217|  84.6k|  while (offset < sizeof(T) * CHAR_BIT && (range >> offset) > 0 &&
  ------------------
  |  Branch (217:10): [True: 84.6k, False: 0]
  |  Branch (217:43): [True: 56.4k, False: 28.2k]
  ------------------
  218|  84.6k|         remaining_bytes_ != 0) {
  ------------------
  |  Branch (218:10): [True: 56.4k, False: 61]
  ------------------
  219|       |    // Pull bytes off the end of the seed data. Experimentally, this seems to
  220|       |    // allow the fuzzer to more easily explore the input space. This makes
  221|       |    // sense, since it works by modifying inputs that caused new code to run,
  222|       |    // and this data is often used to encode length of data read by
  223|       |    // |ConsumeBytes|. Separating out read lengths makes it easier modify the
  224|       |    // contents of the data that is actually read.
  225|  56.4k|    --remaining_bytes_;
  226|  56.4k|    result = (result << CHAR_BIT) | data_ptr_[remaining_bytes_];
  227|  56.4k|    offset += CHAR_BIT;
  228|  56.4k|  }
  229|       |
  230|       |  // Avoid division by 0, in case |range + 1| results in overflow.
  231|  28.2k|  if (range != std::numeric_limits<decltype(range)>::max())
  ------------------
  |  Branch (231:7): [True: 28.2k, False: 0]
  ------------------
  232|  28.2k|    result = result % (range + 1);
  233|       |
  234|  28.2k|  return static_cast<T>(static_cast<uint64_t>(min) + result);
  235|  28.2k|}
_ZN18FuzzedDataProvider22ConsumeIntegralInRangeIjEET_S1_S1_:
  205|    342|T FuzzedDataProvider::ConsumeIntegralInRange(T min, T max) {
  206|    342|  static_assert(std::is_integral<T>::value, "An integral type is required.");
  207|    342|  static_assert(sizeof(T) <= sizeof(uint64_t), "Unsupported integral type.");
  208|       |
  209|    342|  if (min > max)
  ------------------
  |  Branch (209:7): [True: 0, False: 342]
  ------------------
  210|      0|    abort();
  211|       |
  212|       |  // Use the biggest type possible to hold the range and the result.
  213|    342|  uint64_t range = static_cast<uint64_t>(max) - static_cast<uint64_t>(min);
  214|    342|  uint64_t result = 0;
  215|    342|  size_t offset = 0;
  216|       |
  217|    981|  while (offset < sizeof(T) * CHAR_BIT && (range >> offset) > 0 &&
  ------------------
  |  Branch (217:10): [True: 981, False: 0]
  |  Branch (217:43): [True: 662, False: 319]
  ------------------
  218|    981|         remaining_bytes_ != 0) {
  ------------------
  |  Branch (218:10): [True: 639, False: 23]
  ------------------
  219|       |    // Pull bytes off the end of the seed data. Experimentally, this seems to
  220|       |    // allow the fuzzer to more easily explore the input space. This makes
  221|       |    // sense, since it works by modifying inputs that caused new code to run,
  222|       |    // and this data is often used to encode length of data read by
  223|       |    // |ConsumeBytes|. Separating out read lengths makes it easier modify the
  224|       |    // contents of the data that is actually read.
  225|    639|    --remaining_bytes_;
  226|    639|    result = (result << CHAR_BIT) | data_ptr_[remaining_bytes_];
  227|    639|    offset += CHAR_BIT;
  228|    639|  }
  229|       |
  230|       |  // Avoid division by 0, in case |range + 1| results in overflow.
  231|    342|  if (range != std::numeric_limits<decltype(range)>::max())
  ------------------
  |  Branch (231:7): [True: 342, False: 0]
  ------------------
  232|    342|    result = result % (range + 1);
  233|       |
  234|    342|  return static_cast<T>(static_cast<uint64_t>(min) + result);
  235|    342|}
_ZN18FuzzedDataProvider15ConsumeIntegralIhEET_v:
  195|  28.6k|template <typename T> T FuzzedDataProvider::ConsumeIntegral() {
  196|  28.6k|  return ConsumeIntegralInRange(std::numeric_limits<T>::min(),
  197|  28.6k|                                std::numeric_limits<T>::max());
  198|  28.6k|}
_ZN18FuzzedDataProvider22ConsumeIntegralInRangeIhEET_S1_S1_:
  205|  28.6k|T FuzzedDataProvider::ConsumeIntegralInRange(T min, T max) {
  206|  28.6k|  static_assert(std::is_integral<T>::value, "An integral type is required.");
  207|  28.6k|  static_assert(sizeof(T) <= sizeof(uint64_t), "Unsupported integral type.");
  208|       |
  209|  28.6k|  if (min > max)
  ------------------
  |  Branch (209:7): [True: 0, False: 28.6k]
  ------------------
  210|      0|    abort();
  211|       |
  212|       |  // Use the biggest type possible to hold the range and the result.
  213|  28.6k|  uint64_t range = static_cast<uint64_t>(max) - static_cast<uint64_t>(min);
  214|  28.6k|  uint64_t result = 0;
  215|  28.6k|  size_t offset = 0;
  216|       |
  217|  56.9k|  while (offset < sizeof(T) * CHAR_BIT && (range >> offset) > 0 &&
  ------------------
  |  Branch (217:10): [True: 28.6k, False: 28.3k]
  |  Branch (217:43): [True: 28.6k, False: 0]
  ------------------
  218|  56.9k|         remaining_bytes_ != 0) {
  ------------------
  |  Branch (218:10): [True: 28.3k, False: 292]
  ------------------
  219|       |    // Pull bytes off the end of the seed data. Experimentally, this seems to
  220|       |    // allow the fuzzer to more easily explore the input space. This makes
  221|       |    // sense, since it works by modifying inputs that caused new code to run,
  222|       |    // and this data is often used to encode length of data read by
  223|       |    // |ConsumeBytes|. Separating out read lengths makes it easier modify the
  224|       |    // contents of the data that is actually read.
  225|  28.3k|    --remaining_bytes_;
  226|  28.3k|    result = (result << CHAR_BIT) | data_ptr_[remaining_bytes_];
  227|  28.3k|    offset += CHAR_BIT;
  228|  28.3k|  }
  229|       |
  230|       |  // Avoid division by 0, in case |range + 1| results in overflow.
  231|  28.6k|  if (range != std::numeric_limits<decltype(range)>::max())
  ------------------
  |  Branch (231:7): [True: 28.6k, False: 0]
  ------------------
  232|  28.6k|    result = result % (range + 1);
  233|       |
  234|  28.6k|  return static_cast<T>(static_cast<uint64_t>(min) + result);
  235|  28.6k|}
_ZN18FuzzedDataProvider11ConsumeBoolEv:
  289|  28.6k|inline bool FuzzedDataProvider::ConsumeBool() {
  290|  28.6k|  return 1 & ConsumeIntegral<uint8_t>();
  291|  28.6k|}
_ZN18FuzzedDataProvider14CopyAndAdvanceEPvm:
  339|  11.4k|                                               size_t num_bytes) {
  340|  11.4k|  std::memcpy(destination, data_ptr_, num_bytes);
  341|  11.4k|  Advance(num_bytes);
  342|  11.4k|}
_ZN18FuzzedDataProvider7AdvanceEm:
  344|  11.4k|inline void FuzzedDataProvider::Advance(size_t num_bytes) {
  345|  11.4k|  if (num_bytes > remaining_bytes_)
  ------------------
  |  Branch (345:7): [True: 0, False: 11.4k]
  ------------------
  346|      0|    abort();
  347|       |
  348|  11.4k|  data_ptr_ += num_bytes;
  349|  11.4k|  remaining_bytes_ -= num_bytes;
  350|  11.4k|}
_ZN18FuzzedDataProvider12ConsumeBytesISt4byteEENSt3__16vectorIT_NS2_9allocatorIS4_EEEEm:
  109|  28.6k|std::vector<T> FuzzedDataProvider::ConsumeBytes(size_t num_bytes) {
  110|  28.6k|  num_bytes = std::min(num_bytes, remaining_bytes_);
  111|  28.6k|  return ConsumeBytes<T>(num_bytes, num_bytes);
  112|  28.6k|}
_ZN18FuzzedDataProvider12ConsumeBytesISt4byteEENSt3__16vectorIT_NS2_9allocatorIS4_EEEEmm:
  353|  28.6k|std::vector<T> FuzzedDataProvider::ConsumeBytes(size_t size, size_t num_bytes) {
  354|  28.6k|  static_assert(sizeof(T) == sizeof(uint8_t), "Incompatible data type.");
  355|       |
  356|       |  // The point of using the size-based constructor below is to increase the
  357|       |  // odds of having a vector object with capacity being equal to the length.
  358|       |  // That part is always implementation specific, but at least both libc++ and
  359|       |  // libstdc++ allocate the requested number of bytes in that constructor,
  360|       |  // which seems to be a natural choice for other implementations as well.
  361|       |  // To increase the odds even more, we also call |shrink_to_fit| below.
  362|  28.6k|  std::vector<T> result(size);
  363|  28.6k|  if (size == 0) {
  ------------------
  |  Branch (363:7): [True: 17.1k, False: 11.4k]
  ------------------
  364|  17.1k|    if (num_bytes != 0)
  ------------------
  |  Branch (364:9): [True: 0, False: 17.1k]
  ------------------
  365|      0|      abort();
  366|  17.1k|    return result;
  367|  17.1k|  }
  368|       |
  369|  11.4k|  CopyAndAdvance(result.data(), num_bytes);
  370|       |
  371|       |  // Even though |shrink_to_fit| is also implementation specific, we expect it
  372|       |  // to provide an additional assurance in case vector's constructor allocated
  373|       |  // a buffer which is larger than the actual amount of data we put inside it.
  374|  11.4k|  result.shrink_to_fit();
  375|  11.4k|  return result;
  376|  28.6k|}

_Z29crypto_fschacha20_fuzz_targetNSt3__14spanIKhLm18446744073709551615EEE:
  139|    342|{
  140|    342|    FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
  141|       |
  142|    342|    auto key = fuzzed_data_provider.ConsumeBytes<std::byte>(FSChaCha20::KEYLEN);
  143|    342|    key.resize(FSChaCha20::KEYLEN);
  144|       |
  145|    342|    auto fsc20 = FSChaCha20{key, fuzzed_data_provider.ConsumeIntegralInRange<uint32_t>(1, 1024)};
  146|       |
  147|    342|    LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000)
  ------------------
  |  |   23|  28.6k|    for (unsigned _count{limit}; (condition) && _count; --_count)
  |  |  ------------------
  |  |  |  Branch (23:34): [True: 28.2k, False: 341]
  |  |  |  Branch (23:49): [True: 28.2k, False: 1]
  |  |  ------------------
  ------------------
  148|  28.2k|    {
  149|  28.2k|        auto input = fuzzed_data_provider.ConsumeBytes<std::byte>(fuzzed_data_provider.ConsumeIntegralInRange(0, 4096));
  150|  28.2k|        std::vector<std::byte> output;
  151|  28.2k|        output.resize(input.size());
  152|  28.2k|        fsc20.Crypt(input, output);
  153|  28.2k|    }
  154|    342|}

LLVMFuzzerTestOneInput:
  222|    342|{
  223|    342|    test_one_input({data, size});
  224|    342|    return 0;
  225|    342|}
fuzz.cpp:_ZL14test_one_inputNSt3__14spanIKhLm18446744073709551615EEE:
   83|    342|{
   84|    342|    CheckGlobals check{};
   85|    342|    (*Assert(g_test_one_input))(buffer);
  ------------------
  |  |   85|    342|#define Assert(val) inline_assertion_check<true>(val, __FILE__, __LINE__, __func__, #val)
  ------------------
   86|    342|}

_ZN12CheckGlobalsC2Ev:
   56|    342|CheckGlobals::CheckGlobals() : m_impl(std::make_unique<CheckGlobalsImpl>()) {}
_ZN12CheckGlobalsD2Ev:
   57|    342|CheckGlobals::~CheckGlobals() = default;
_ZN16CheckGlobalsImplC2Ev:
   17|    342|    {
   18|    342|        g_used_g_prng = false;
   19|    342|        g_seeded_g_prng_zero = false;
   20|    342|        g_used_system_time = false;
   21|    342|        SetMockTime(0s);
   22|    342|    }
_ZN16CheckGlobalsImplD2Ev:
   24|    342|    {
   25|    342|        if (g_used_g_prng && !g_seeded_g_prng_zero) {
  ------------------
  |  Branch (25:13): [True: 0, False: 342]
  |  Branch (25:30): [True: 0, False: 0]
  ------------------
   26|      0|            std::cerr << "\n\n"
   27|      0|                         "The current fuzz target used the global random state.\n\n"
   28|       |
   29|      0|                         "This is acceptable, but requires the fuzz target to call \n"
   30|      0|                         "SeedRandomStateForTest(SeedRand::ZEROS) in the first line \n"
   31|      0|                         "of the FUZZ_TARGET function.\n\n"
   32|       |
   33|      0|                         "An alternative solution would be to avoid any use of globals.\n\n"
   34|       |
   35|      0|                         "Without a solution, fuzz instability and non-determinism can lead \n"
   36|      0|                         "to non-reproducible bugs or inefficient fuzzing.\n\n"
   37|      0|                      << std::endl;
   38|      0|            std::abort(); // Abort, because AFL may try to recover from a std::exit
   39|      0|        }
   40|       |
   41|    342|        if (g_used_system_time) {
  ------------------
  |  Branch (41:13): [True: 0, False: 342]
  ------------------
   42|      0|            std::cerr << "\n\n"
   43|      0|                         "The current fuzz target accessed system time.\n\n"
   44|       |
   45|      0|                         "This is acceptable, but requires the fuzz target to call \n"
   46|      0|                         "SetMockTime() at the beginning of processing the fuzz input.\n\n"
   47|       |
   48|      0|                         "Without setting mock time, time-dependent behavior can lead \n"
   49|      0|                         "to non-reproducible bugs or inefficient fuzzing.\n\n"
   50|      0|                      << std::endl;
   51|      0|            std::abort();
   52|      0|        }
   53|    342|    }

_Z22inline_assertion_checkILb1EbEOT0_S1_PKciS3_S3_:
   52|    342|{
   53|    342|    if (IS_ASSERT || std::is_constant_evaluated() || G_FUZZING
  ------------------
  |  Branch (53:9): [Folded - Ignored]
  |  Branch (53:22): [Folded - Ignored]
  |  Branch (53:54): [Folded - Ignored]
  ------------------
   54|       |#ifdef ABORT_ON_FAILED_ASSUME
   55|       |        || true
   56|       |#endif
   57|    342|    ) {
   58|    342|        if (!val) {
  ------------------
  |  Branch (58:13): [True: 0, False: 342]
  ------------------
   59|      0|            assertion_fail(file, line, func, assertion);
   60|      0|        }
   61|    342|    }
   62|    342|    return std::forward<T>(val);
   63|    342|}
_Z22inline_assertion_checkILb1ERPKNSt3__18functionIFvNS0_4spanIKhLm18446744073709551615EEEEEEEOT0_SB_PKciSD_SD_:
   52|    342|{
   53|    342|    if (IS_ASSERT || std::is_constant_evaluated() || G_FUZZING
  ------------------
  |  Branch (53:9): [Folded - Ignored]
  |  Branch (53:22): [Folded - Ignored]
  |  Branch (53:54): [Folded - Ignored]
  ------------------
   54|       |#ifdef ABORT_ON_FAILED_ASSUME
   55|       |        || true
   56|       |#endif
   57|    342|    ) {
   58|    342|        if (!val) {
  ------------------
  |  Branch (58:13): [True: 0, False: 342]
  ------------------
   59|      0|            assertion_fail(file, line, func, assertion);
   60|      0|        }
   61|    342|    }
   62|    342|    return std::forward<T>(val);
   63|    342|}

_Z11SetMockTimeNSt3__16chrono8durationIxNS_5ratioILl1ELl1EEEEE:
   42|    342|{
   43|    342|    Assert(mock_time_in >= 0s);
  ------------------
  |  |   85|    342|#define Assert(val) inline_assertion_check<true>(val, __FILE__, __LINE__, __func__, #val)
  ------------------
   44|    342|    g_mock_time.store(mock_time_in, std::memory_order_relaxed);
   45|    342|}

