LLVMFuzzerTestOneInput:
   47|  1.44k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   48|       |
   49|       |    /* Create the parser state */
   50|  1.44k|    uWS::WebSocketState<true> state;
   51|       |
   52|  1.44k|    makeChunked(makePadded(data, size), size, [&state](const uint8_t *data, size_t size) {
   53|       |        /* Parse it */
   54|  1.44k|        uWS::WebSocketProtocol<true, Impl>::consume((char *) data, size, &state, nullptr);
   55|  1.44k|    });
   56|       |
   57|  1.44k|    return 0;
   58|  1.44k|}
WebSocket.cpp:_ZZ22LLVMFuzzerTestOneInputENK3$_0clEPKhm:
   52|  82.9k|    makeChunked(makePadded(data, size), size, [&state](const uint8_t *data, size_t size) {
   53|       |        /* Parse it */
   54|  82.9k|        uWS::WebSocketProtocol<true, Impl>::consume((char *) data, size, &state, nullptr);
   55|  82.9k|    });
_ZN4Impl13setCompressedEPN3uWS14WebSocketStateILb1EEEPv:
   22|  7.57k|    static bool setCompressed(uWS::WebSocketState<true> *wState, void *s) {
   23|       |        /* We support it */
   24|  7.57k|        return true;
   25|  7.57k|    }
_ZN4Impl10forceCloseEPN3uWS14WebSocketStateILb1EEEPvNSt3__117basic_string_viewIcNS5_11char_traitsIcEEEE:
   27|  66.2k|    static void forceClose(uWS::WebSocketState<true> *wState, void *s, std::string_view reason = {}) {
   28|       |
   29|  66.2k|    }
_ZN4Impl19refusePayloadLengthEmPN3uWS14WebSocketStateILb1EEEPv:
   11|  31.2k|    static bool refusePayloadLength(uint64_t length, uWS::WebSocketState<true> *wState, void *s) {
   12|       |
   13|       |        /* We need a limit */
   14|  31.2k|        if (length > 16000) {
  ------------------
  |  Branch (14:13): [True: 577, False: 30.6k]
  ------------------
   15|    577|            return true;
   16|    577|        }
   17|       |
   18|       |        /* Return ok */
   19|  30.6k|        return false;
   20|  31.2k|    }
_ZN4Impl14handleFragmentEPcmjibPN3uWS14WebSocketStateILb1EEEPv:
   31|  40.8k|    static bool handleFragment(char *data, size_t length, unsigned int remainingBytes, int opCode, bool fin, uWS::WebSocketState<true> *webSocketState, void *s) {
   32|       |
   33|  40.8k|        if (opCode == uWS::TEXT) {
  ------------------
  |  Branch (33:13): [True: 16.6k, False: 24.2k]
  ------------------
   34|  16.6k|            if (!uWS::protocol::isValidUtf8((unsigned char *)data, length)) {
  ------------------
  |  Branch (34:17): [True: 7.75k, False: 8.87k]
  ------------------
   35|       |                /* Return break */
   36|  7.75k|                return true;
   37|  7.75k|            }
   38|  24.2k|        } else if (opCode == uWS::CLOSE) {
  ------------------
  |  Branch (38:20): [True: 16.3k, False: 7.86k]
  ------------------
   39|  16.3k|            uWS::protocol::parseClosePayload((char *)data, length);
   40|  16.3k|        }
   41|       |
   42|       |        /* Return ok */
   43|  33.1k|        return false;
   44|  40.8k|    }

WebSocket.cpp:_ZL11makeChunkedPKhmNSt3__18functionIFvS0_mEEE:
   28|  1.44k|static inline void makeChunked(const uint8_t *data, size_t size, std::function<void(const uint8_t *data, size_t size)> cb) {
   29|       |    /* First byte determines chunk size; 0 is all that remains, 1-255 is small chunk */
   30|  84.3k|    for (int i = 0; i < size; ) {
  ------------------
  |  Branch (30:21): [True: 82.9k, False: 1.44k]
  ------------------
   31|  82.9k|        unsigned int chunkSize = data[i++];
   32|  82.9k|        if (!chunkSize) {
  ------------------
  |  Branch (32:13): [True: 426, False: 82.5k]
  ------------------
   33|    426|            chunkSize = size - i;
   34|  82.5k|        } else {
   35|  82.5k|            chunkSize = std::min<int>(chunkSize, size - i);
   36|  82.5k|        }
   37|       |
   38|  82.9k|        cb(data + i, chunkSize);
   39|  82.9k|        i += chunkSize;
   40|  82.9k|    }
   41|  1.44k|}
WebSocket.cpp:_ZL10makePaddedPKhm:
   11|  1.44k|static inline const uint8_t *makePadded(const uint8_t *data, size_t size) {
   12|  1.44k|    static int paddedLength = 512 * 1024;
   13|  1.44k|    static char *padded = new char[128 + paddedLength + 128];
   14|       |
   15|       |    /* Increase landing area if required */
   16|  1.44k|    if (paddedLength < size) {
  ------------------
  |  Branch (16:9): [True: 12, False: 1.43k]
  ------------------
   17|     12|        delete [] padded;
   18|     12|        paddedLength = size;
   19|     12|        padded = new char [128 + paddedLength + 128];
   20|     12|    }
   21|       |
   22|  1.44k|    memcpy(padded + 128, data, size);
   23|       |
   24|  1.44k|    return (uint8_t *) padded + 128;
   25|  1.44k|}

_ZN3uWS14WebSocketStateILb1EE5StateC2Ev:
   72|  1.44k|        State() {
   73|  1.44k|            wantsHead = true;
   74|  1.44k|            spillLength = 0;
   75|  1.44k|            opStack = -1;
   76|  1.44k|            lastFin = true;
   77|  1.44k|        }
_ZN3uWS17WebSocketProtocolILb1E4ImplE7consumeEPcjPNS_14WebSocketStateILb1EEEPv:
  463|  82.9k|    static inline void consume(char *src, unsigned int length, WebSocketState<isServer> *wState, void *user) {
  464|  82.9k|        if (wState->state.spillLength) {
  ------------------
  |  Branch (464:13): [True: 21.7k, False: 61.1k]
  ------------------
  465|  21.7k|            src -= wState->state.spillLength;
  466|  21.7k|            length += wState->state.spillLength;
  467|  21.7k|            memcpy(src, wState->state.spill, wState->state.spillLength);
  468|  21.7k|        }
  469|  82.9k|        if (wState->state.wantsHead) {
  ------------------
  |  Branch (469:13): [True: 72.7k, False: 10.1k]
  ------------------
  470|  77.4k|            parseNext:
  471|  99.3k|            while (length >= SHORT_MESSAGE_HEADER) {
  ------------------
  |  Branch (471:20): [True: 97.4k, False: 1.86k]
  ------------------
  472|       |
  473|       |                // invalid reserved bits / invalid opcodes / invalid control frames / set compressed frame
  474|  97.4k|                if ((rsv1(src) && !Impl::setCompressed(wState, user)) || rsv23(src) || (getOpCode(src) > 2 && getOpCode(src) < 8) ||
  ------------------
  |  Branch (474:22): [True: 7.57k, False: 89.9k]
  |  Branch (474:35): [True: 0, False: 7.57k]
  |  Branch (474:74): [True: 45.1k, False: 52.3k]
  |  Branch (474:89): [True: 33.4k, False: 18.9k]
  |  Branch (474:111): [True: 13.7k, False: 19.6k]
  ------------------
  475|  97.4k|                    getOpCode(src) > 10 || (getOpCode(src) > 2 && (!isFin(src) || payloadLength(src) > 125))) {
  ------------------
  |  Branch (475:21): [True: 2.22k, False: 36.3k]
  |  Branch (475:45): [True: 17.3k, False: 18.9k]
  |  Branch (475:68): [True: 430, False: 16.9k]
  |  Branch (475:83): [True: 292, False: 16.6k]
  ------------------
  476|  61.8k|                    Impl::forceClose(wState, user, ERR_PROTOCOL);
  477|  61.8k|                    return;
  478|  61.8k|                }
  479|       |
  480|  35.6k|                if (payloadLength(src) < 126) {
  ------------------
  |  Branch (480:21): [True: 27.7k, False: 7.83k]
  ------------------
  481|  27.7k|                    if (consumeMessage<SHORT_MESSAGE_HEADER, uint8_t>(payloadLength(src), src, length, wState, user)) {
  ------------------
  |  Branch (481:25): [True: 7.92k, False: 19.8k]
  ------------------
  482|  7.92k|                        return;
  483|  7.92k|                    }
  484|  27.7k|                } else if (payloadLength(src) == 126) {
  ------------------
  |  Branch (484:28): [True: 4.20k, False: 3.63k]
  ------------------
  485|  4.20k|                    if (length < MEDIUM_MESSAGE_HEADER) {
  ------------------
  |  Branch (485:25): [True: 280, False: 3.92k]
  ------------------
  486|    280|                        break;
  487|  3.92k|                    } else if(consumeMessage<MEDIUM_MESSAGE_HEADER, uint16_t>(protocol::cond_byte_swap<uint16_t>(protocol::bit_cast<uint16_t>(src + 2)), src, length, wState, user)) {
  ------------------
  |  Branch (487:31): [True: 2.76k, False: 1.15k]
  ------------------
  488|  2.76k|                        return;
  489|  2.76k|                    }
  490|  4.20k|                } else if (length < LONG_MESSAGE_HEADER) {
  ------------------
  |  Branch (490:28): [True: 278, False: 3.36k]
  ------------------
  491|    278|                    break;
  492|  3.36k|                } else if (consumeMessage<LONG_MESSAGE_HEADER, uint64_t>(protocol::cond_byte_swap<uint64_t>(protocol::bit_cast<uint64_t>(src + 2)), src, length, wState, user)) {
  ------------------
  |  Branch (492:28): [True: 2.48k, False: 872]
  ------------------
  493|  2.48k|                    return;
  494|  2.48k|                }
  495|  35.6k|            }
  496|  2.42k|            if (length) {
  ------------------
  |  Branch (496:17): [True: 1.47k, False: 955]
  ------------------
  497|  1.47k|                memcpy(wState->state.spill, src, length);
  498|  1.47k|                wState->state.spillLength = length & 0xf;
  499|  1.47k|            }
  500|  10.1k|        } else if (consumeContinuation(src, length, wState, user)) {
  ------------------
  |  Branch (500:20): [True: 4.74k, False: 5.45k]
  ------------------
  501|  4.74k|            goto parseNext;
  502|  4.74k|        }
  503|  82.9k|    }
_ZN3uWS17WebSocketProtocolILb1E4ImplE4rsv1EPc:
  279|  97.4k|    static inline bool rsv1(char *frame) {return *((unsigned char *) frame) & 64;}
_ZN3uWS17WebSocketProtocolILb1E4ImplE5rsv23EPc:
  278|  97.4k|    static inline bool rsv23(char *frame) {return *((unsigned char *) frame) & 48;}
_ZN3uWS17WebSocketProtocolILb1E4ImplE9getOpCodeEPc:
  276|   220k|    static inline unsigned char getOpCode(char *frame) {return *((unsigned char *) frame) & 15;}
_ZN3uWS17WebSocketProtocolILb1E4ImplE5isFinEPc:
  275|  79.3k|    static inline bool isFin(char *frame) {return *((unsigned char *) frame) & 128;}
_ZN3uWS17WebSocketProtocolILb1E4ImplE13payloadLengthEPc:
  277|  88.1k|    static inline unsigned char payloadLength(char *frame) {return ((unsigned char *) frame)[1] & 127;}
_ZN3uWS17WebSocketProtocolILb1E4ImplE14consumeMessageILj6EhEEbT0_RPcRjPNS_14WebSocketStateILb1EEEPv:
  345|  27.7k|    static inline bool consumeMessage(T payLength, char *&src, unsigned int &length, WebSocketState<isServer> *wState, void *user) {
  346|  27.7k|        if (getOpCode(src)) {
  ------------------
  |  Branch (346:13): [True: 21.7k, False: 6.05k]
  ------------------
  347|  21.7k|            if (wState->state.opStack == 1 || (!wState->state.lastFin && getOpCode(src) < 2)) {
  ------------------
  |  Branch (347:17): [True: 699, False: 21.0k]
  |  Branch (347:48): [True: 1.14k, False: 19.8k]
  |  Branch (347:74): [True: 390, False: 751]
  ------------------
  348|  1.08k|                Impl::forceClose(wState, user, ERR_PROTOCOL);
  349|  1.08k|                return true;
  350|  1.08k|            }
  351|  20.6k|            wState->state.opCode[++wState->state.opStack] = (OpCode) getOpCode(src);
  352|  20.6k|        } else if (wState->state.opStack == -1) {
  ------------------
  |  Branch (352:20): [True: 1.33k, False: 4.71k]
  ------------------
  353|  1.33k|            Impl::forceClose(wState, user, ERR_PROTOCOL);
  354|  1.33k|            return true;
  355|  1.33k|        }
  356|  25.3k|        wState->state.lastFin = isFin(src);
  357|       |
  358|  25.3k|        if (Impl::refusePayloadLength(payLength, wState, user)) {
  ------------------
  |  Branch (358:13): [True: 0, False: 25.3k]
  ------------------
  359|      0|            Impl::forceClose(wState, user, ERR_TOO_BIG_MESSAGE);
  360|      0|            return true;
  361|      0|        }
  362|       |
  363|  25.3k|        if (payLength + MESSAGE_HEADER <= length) {
  ------------------
  |  Branch (363:13): [True: 21.6k, False: 3.67k]
  ------------------
  364|  21.6k|            bool fin = isFin(src);
  365|  21.6k|            if (isServer) {
  ------------------
  |  Branch (365:17): [Folded - Ignored]
  ------------------
  366|       |                /* This guy can never be assumed to be perfectly aligned since we can get multiple messages in one read */
  367|  21.6k|                unmaskImpreciseCopyMask<MESSAGE_HEADER>(src + MESSAGE_HEADER, (unsigned int) payLength);
  368|  21.6k|                if (Impl::handleFragment(src, payLength, 0, wState->state.opCode[wState->state.opStack], fin, wState, user)) {
  ------------------
  |  Branch (368:21): [True: 1.82k, False: 19.8k]
  ------------------
  369|  1.82k|                    return true;
  370|  1.82k|                }
  371|  21.6k|            } else {
  372|      0|                if (Impl::handleFragment(src + MESSAGE_HEADER, payLength, 0, wState->state.opCode[wState->state.opStack], isFin(src), wState, user)) {
  ------------------
  |  Branch (372:21): [True: 0, False: 0]
  ------------------
  373|      0|                    return true;
  374|      0|                }
  375|      0|            }
  376|       |
  377|  19.8k|            if (fin) {
  ------------------
  |  Branch (377:17): [True: 17.2k, False: 2.64k]
  ------------------
  378|  17.2k|                wState->state.opStack--;
  379|  17.2k|            }
  380|       |
  381|  19.8k|            src += payLength + MESSAGE_HEADER;
  382|  19.8k|            length -= (unsigned int) (payLength + MESSAGE_HEADER);
  383|  19.8k|            wState->state.spillLength = 0;
  384|  19.8k|            return false;
  385|  21.6k|        } else {
  386|  3.67k|            wState->state.spillLength = 0;
  387|  3.67k|            wState->state.wantsHead = false;
  388|  3.67k|            wState->remainingBytes = (unsigned int) (payLength - length + MESSAGE_HEADER);
  389|  3.67k|            bool fin = isFin(src);
  390|  3.67k|            if constexpr (isServer) {
  391|  3.67k|                memcpy(wState->mask, src + MESSAGE_HEADER - 4, 4);
  392|  3.67k|                uint64_t mask;
  393|  3.67k|                memcpy(&mask, src + MESSAGE_HEADER - 4, 4);
  394|  3.67k|                memcpy(((char *)&mask) + 4, src + MESSAGE_HEADER - 4, 4);
  395|  3.67k|                unmaskImprecise8<0>(src + MESSAGE_HEADER, mask, length);
  396|  3.67k|                rotateMask(4 - (length - MESSAGE_HEADER) % 4, wState->mask);
  397|  3.67k|            }
  398|  3.67k|            Impl::handleFragment(src + MESSAGE_HEADER, length - MESSAGE_HEADER, wState->remainingBytes, wState->state.opCode[wState->state.opStack], fin, wState, user);
  399|  3.67k|            return true;
  400|  3.67k|        }
  401|  25.3k|    }
_ZN3uWS17WebSocketProtocolILb1E4ImplE23unmaskImpreciseCopyMaskILi6EEEvPcj:
  313|  21.6k|    static inline void unmaskImpreciseCopyMask(char *src, unsigned int length) {
  314|       |        if constexpr (HEADER_SIZE != 6) {
  315|       |            char mask[8] = {src[-4], src[-3], src[-2], src[-1], src[-4], src[-3], src[-2], src[-1]};
  316|       |            uint64_t maskInt;
  317|       |            memcpy(&maskInt, mask, 8);
  318|       |            unmaskImprecise8<HEADER_SIZE>(src, maskInt, length);
  319|  21.6k|        } else {
  320|  21.6k|            char mask[4] = {src[-4], src[-3], src[-2], src[-1]};
  321|  21.6k|            uint32_t maskInt;
  322|  21.6k|            memcpy(&maskInt, mask, 4);
  323|  21.6k|            unmaskImprecise4<HEADER_SIZE>(src, maskInt, length);
  324|  21.6k|        }
  325|  21.6k|    }
_ZN3uWS17WebSocketProtocolILb1E4ImplE16unmaskImprecise4ILi6EEEvPcjj:
  302|  21.6k|    static inline void unmaskImprecise4(char *src, uint32_t mask, unsigned int length) {
  303|  97.9k|        for (unsigned int n = (length >> 2) + 1; n; n--) {
  ------------------
  |  Branch (303:50): [True: 76.2k, False: 21.6k]
  ------------------
  304|  76.2k|            uint32_t loaded;
  305|  76.2k|            memcpy(&loaded, src, 4);
  306|  76.2k|            loaded ^= mask;
  307|  76.2k|            memcpy(src - DESTINATION, &loaded, 4);
  308|  76.2k|            src += 4;
  309|  76.2k|        }
  310|  21.6k|    }
WebSocket.cpp:_ZN3uWS8protocolL11isValidUtf8EPhm:
  122|  18.4k|{
  123|  21.1k|    for (unsigned char *e = s + length; s != e; ) {
  ------------------
  |  Branch (123:41): [True: 17.0k, False: 4.05k]
  ------------------
  124|  17.0k|        if (s + 16 <= e) {
  ------------------
  |  Branch (124:13): [True: 5.12k, False: 11.9k]
  ------------------
  125|  5.12k|            uint64_t tmp[2];
  126|  5.12k|            memcpy(tmp, s, 16);
  127|  5.12k|            if (((tmp[0] & 0x8080808080808080) | (tmp[1] & 0x8080808080808080)) == 0) {
  ------------------
  |  Branch (127:17): [True: 444, False: 4.68k]
  ------------------
  128|    444|                s += 16;
  129|    444|                continue;
  130|    444|            }
  131|  5.12k|        }
  132|       |
  133|  25.1k|        while (!(*s & 0x80)) {
  ------------------
  |  Branch (133:16): [True: 13.4k, False: 11.6k]
  ------------------
  134|  13.4k|            if (++s == e) {
  ------------------
  |  Branch (134:17): [True: 4.97k, False: 8.51k]
  ------------------
  135|  4.97k|                return true;
  136|  4.97k|            }
  137|  13.4k|        }
  138|       |
  139|  11.6k|        if ((s[0] & 0x60) == 0x40) {
  ------------------
  |  Branch (139:13): [True: 2.53k, False: 9.10k]
  ------------------
  140|  2.53k|            if (s + 1 >= e || (s[1] & 0xc0) != 0x80 || (s[0] & 0xfe) == 0xc0) {
  ------------------
  |  Branch (140:17): [True: 660, False: 1.87k]
  |  Branch (140:31): [True: 645, False: 1.22k]
  |  Branch (140:56): [True: 354, False: 871]
  ------------------
  141|  1.65k|                return false;
  142|  1.65k|            }
  143|    871|            s += 2;
  144|  9.10k|        } else if ((s[0] & 0xf0) == 0xe0) {
  ------------------
  |  Branch (144:20): [True: 2.79k, False: 6.31k]
  ------------------
  145|  2.79k|            if (s + 2 >= e || (s[1] & 0xc0) != 0x80 || (s[2] & 0xc0) != 0x80 ||
  ------------------
  |  Branch (145:17): [True: 784, False: 2.01k]
  |  Branch (145:31): [True: 604, False: 1.40k]
  |  Branch (145:56): [True: 332, False: 1.07k]
  ------------------
  146|  2.79k|                    (s[0] == 0xe0 && (s[1] & 0xe0) == 0x80) || (s[0] == 0xed && (s[1] & 0xe0) == 0xa0)) {
  ------------------
  |  Branch (146:22): [True: 444, False: 632]
  |  Branch (146:38): [True: 234, False: 210]
  |  Branch (146:65): [True: 414, False: 428]
  |  Branch (146:81): [True: 194, False: 220]
  ------------------
  147|  2.14k|                return false;
  148|  2.14k|            }
  149|    648|            s += 3;
  150|  6.31k|        } else if ((s[0] & 0xf8) == 0xf0) {
  ------------------
  |  Branch (150:20): [True: 2.49k, False: 3.81k]
  ------------------
  151|  2.49k|            if (s + 3 >= e || (s[1] & 0xc0) != 0x80 || (s[2] & 0xc0) != 0x80 || (s[3] & 0xc0) != 0x80 ||
  ------------------
  |  Branch (151:17): [True: 275, False: 2.22k]
  |  Branch (151:31): [True: 254, False: 1.96k]
  |  Branch (151:56): [True: 206, False: 1.76k]
  |  Branch (151:81): [True: 431, False: 1.33k]
  ------------------
  152|  2.49k|                    (s[0] == 0xf0 && (s[1] & 0xf0) == 0x80) || (s[0] == 0xf4 && s[1] > 0x8f) || s[0] > 0xf4) {
  ------------------
  |  Branch (152:22): [True: 413, False: 919]
  |  Branch (152:38): [True: 199, False: 214]
  |  Branch (152:65): [True: 489, False: 644]
  |  Branch (152:81): [True: 211, False: 278]
  |  Branch (152:97): [True: 197, False: 725]
  ------------------
  153|  1.77k|                return false;
  154|  1.77k|            }
  155|    725|            s += 4;
  156|  3.81k|        } else {
  157|  3.81k|            return false;
  158|  3.81k|        }
  159|  11.6k|    }
  160|  4.05k|    return true;
  161|  18.4k|}
WebSocket.cpp:_ZN3uWS8protocolL17parseClosePayloadEPcm:
  169|  16.3k|static inline CloseFrame parseClosePayload(char *src, size_t length) {
  170|       |    /* If we get no code or message, default to reporting 1005 no status code present */
  171|  16.3k|    CloseFrame cf = {1005, nullptr, 0};
  172|  16.3k|    if (length >= 2) {
  ------------------
  |  Branch (172:9): [True: 14.7k, False: 1.61k]
  ------------------
  173|  14.7k|        memcpy(&cf.code, src, 2);
  174|  14.7k|        cf = {cond_byte_swap<uint16_t>(cf.code), src + 2, length - 2};
  175|  14.7k|        if (cf.code < 1000 || cf.code > 4999 || (cf.code > 1011 && cf.code < 4000) ||
  ------------------
  |  Branch (175:13): [True: 4.85k, False: 9.92k]
  |  Branch (175:31): [True: 4.39k, False: 5.52k]
  |  Branch (175:50): [True: 2.73k, False: 2.79k]
  |  Branch (175:68): [True: 2.34k, False: 394]
  ------------------
  176|  14.7k|            (cf.code >= 1004 && cf.code <= 1006) || !isValidUtf8((unsigned char *) cf.message, cf.length)) {
  ------------------
  |  Branch (176:14): [True: 2.80k, False: 385]
  |  Branch (176:33): [True: 1.39k, False: 1.40k]
  |  Branch (176:53): [True: 1.63k, False: 158]
  ------------------
  177|       |            /* Even though we got a WebSocket close frame, it in itself is abnormal */
  178|  14.6k|            return {1006, (char *) ERR_INVALID_CLOSE_PAYLOAD.data(), ERR_INVALID_CLOSE_PAYLOAD.length()};
  179|  14.6k|        }
  180|  14.7k|    }
  181|  1.76k|    return cf;
  182|  16.3k|}
_ZN3uWS17WebSocketProtocolILb1E4ImplE16unmaskImprecise8ILi0EEEvPcmj:
  290|  5.29k|    static inline void unmaskImprecise8(char *src, uint64_t mask, unsigned int length) {
  291|  37.9k|        for (unsigned int n = (length >> 3) + 1; n; n--) {
  ------------------
  |  Branch (291:50): [True: 32.6k, False: 5.29k]
  ------------------
  292|  32.6k|            uint64_t loaded;
  293|  32.6k|            memcpy(&loaded, src, 8);
  294|  32.6k|            loaded ^= mask;
  295|  32.6k|            memcpy(src - DESTINATION, &loaded, 8);
  296|  32.6k|            src += 8;
  297|  32.6k|        }
  298|  5.29k|    }
_ZN3uWS17WebSocketProtocolILb1E4ImplE10rotateMaskEjPc:
  327|  6.39k|    static inline void rotateMask(unsigned int offset, char *mask) {
  328|  6.39k|        char originalMask[4] = {mask[0], mask[1], mask[2], mask[3]};
  329|  6.39k|        mask[(0 + offset) % 4] = originalMask[0];
  330|  6.39k|        mask[(1 + offset) % 4] = originalMask[1];
  331|  6.39k|        mask[(2 + offset) % 4] = originalMask[2];
  332|  6.39k|        mask[(3 + offset) % 4] = originalMask[3];
  333|  6.39k|    }
_ZN3uWS17WebSocketProtocolILb1E4ImplE14consumeMessageILj8EtEEbT0_RPcRjPNS_14WebSocketStateILb1EEEPv:
  345|  3.92k|    static inline bool consumeMessage(T payLength, char *&src, unsigned int &length, WebSocketState<isServer> *wState, void *user) {
  346|  3.92k|        if (getOpCode(src)) {
  ------------------
  |  Branch (346:13): [True: 1.49k, False: 2.42k]
  ------------------
  347|  1.49k|            if (wState->state.opStack == 1 || (!wState->state.lastFin && getOpCode(src) < 2)) {
  ------------------
  |  Branch (347:17): [True: 229, False: 1.26k]
  |  Branch (347:48): [True: 421, False: 844]
  |  Branch (347:74): [True: 209, False: 212]
  ------------------
  348|    438|                Impl::forceClose(wState, user, ERR_PROTOCOL);
  349|    438|                return true;
  350|    438|            }
  351|  1.05k|            wState->state.opCode[++wState->state.opStack] = (OpCode) getOpCode(src);
  352|  2.42k|        } else if (wState->state.opStack == -1) {
  ------------------
  |  Branch (352:20): [True: 319, False: 2.10k]
  ------------------
  353|    319|            Impl::forceClose(wState, user, ERR_PROTOCOL);
  354|    319|            return true;
  355|    319|        }
  356|  3.16k|        wState->state.lastFin = isFin(src);
  357|       |
  358|  3.16k|        if (Impl::refusePayloadLength(payLength, wState, user)) {
  ------------------
  |  Branch (358:13): [True: 241, False: 2.92k]
  ------------------
  359|    241|            Impl::forceClose(wState, user, ERR_TOO_BIG_MESSAGE);
  360|    241|            return true;
  361|    241|        }
  362|       |
  363|  2.92k|        if (payLength + MESSAGE_HEADER <= length) {
  ------------------
  |  Branch (363:13): [True: 2.13k, False: 786]
  ------------------
  364|  2.13k|            bool fin = isFin(src);
  365|  2.13k|            if (isServer) {
  ------------------
  |  Branch (365:17): [Folded - Ignored]
  ------------------
  366|       |                /* This guy can never be assumed to be perfectly aligned since we can get multiple messages in one read */
  367|  2.13k|                unmaskImpreciseCopyMask<MESSAGE_HEADER>(src + MESSAGE_HEADER, (unsigned int) payLength);
  368|  2.13k|                if (Impl::handleFragment(src, payLength, 0, wState->state.opCode[wState->state.opStack], fin, wState, user)) {
  ------------------
  |  Branch (368:21): [True: 980, False: 1.15k]
  ------------------
  369|    980|                    return true;
  370|    980|                }
  371|  2.13k|            } else {
  372|      0|                if (Impl::handleFragment(src + MESSAGE_HEADER, payLength, 0, wState->state.opCode[wState->state.opStack], isFin(src), wState, user)) {
  ------------------
  |  Branch (372:21): [True: 0, False: 0]
  ------------------
  373|      0|                    return true;
  374|      0|                }
  375|      0|            }
  376|       |
  377|  1.15k|            if (fin) {
  ------------------
  |  Branch (377:17): [True: 735, False: 421]
  ------------------
  378|    735|                wState->state.opStack--;
  379|    735|            }
  380|       |
  381|  1.15k|            src += payLength + MESSAGE_HEADER;
  382|  1.15k|            length -= (unsigned int) (payLength + MESSAGE_HEADER);
  383|  1.15k|            wState->state.spillLength = 0;
  384|  1.15k|            return false;
  385|  2.13k|        } else {
  386|    786|            wState->state.spillLength = 0;
  387|    786|            wState->state.wantsHead = false;
  388|    786|            wState->remainingBytes = (unsigned int) (payLength - length + MESSAGE_HEADER);
  389|    786|            bool fin = isFin(src);
  390|    786|            if constexpr (isServer) {
  391|    786|                memcpy(wState->mask, src + MESSAGE_HEADER - 4, 4);
  392|    786|                uint64_t mask;
  393|    786|                memcpy(&mask, src + MESSAGE_HEADER - 4, 4);
  394|    786|                memcpy(((char *)&mask) + 4, src + MESSAGE_HEADER - 4, 4);
  395|    786|                unmaskImprecise8<0>(src + MESSAGE_HEADER, mask, length);
  396|    786|                rotateMask(4 - (length - MESSAGE_HEADER) % 4, wState->mask);
  397|    786|            }
  398|    786|            Impl::handleFragment(src + MESSAGE_HEADER, length - MESSAGE_HEADER, wState->remainingBytes, wState->state.opCode[wState->state.opStack], fin, wState, user);
  399|    786|            return true;
  400|    786|        }
  401|  2.92k|    }
_ZN3uWS17WebSocketProtocolILb1E4ImplE23unmaskImpreciseCopyMaskILi8EEEvPcj:
  313|  2.13k|    static inline void unmaskImpreciseCopyMask(char *src, unsigned int length) {
  314|  2.13k|        if constexpr (HEADER_SIZE != 6) {
  315|  2.13k|            char mask[8] = {src[-4], src[-3], src[-2], src[-1], src[-4], src[-3], src[-2], src[-1]};
  316|  2.13k|            uint64_t maskInt;
  317|  2.13k|            memcpy(&maskInt, mask, 8);
  318|  2.13k|            unmaskImprecise8<HEADER_SIZE>(src, maskInt, length);
  319|       |        } else {
  320|       |            char mask[4] = {src[-4], src[-3], src[-2], src[-1]};
  321|       |            uint32_t maskInt;
  322|       |            memcpy(&maskInt, mask, 4);
  323|       |            unmaskImprecise4<HEADER_SIZE>(src, maskInt, length);
  324|       |        }
  325|  2.13k|    }
_ZN3uWS17WebSocketProtocolILb1E4ImplE16unmaskImprecise8ILi8EEEvPcmj:
  290|  2.13k|    static inline void unmaskImprecise8(char *src, uint64_t mask, unsigned int length) {
  291|  34.7k|        for (unsigned int n = (length >> 3) + 1; n; n--) {
  ------------------
  |  Branch (291:50): [True: 32.6k, False: 2.13k]
  ------------------
  292|  32.6k|            uint64_t loaded;
  293|  32.6k|            memcpy(&loaded, src, 8);
  294|  32.6k|            loaded ^= mask;
  295|  32.6k|            memcpy(src - DESTINATION, &loaded, 8);
  296|  32.6k|            src += 8;
  297|  32.6k|        }
  298|  2.13k|    }
_ZN3uWS8protocol14cond_byte_swapItEET_S2_:
   97|  18.6k|T cond_byte_swap(T value) {
   98|  18.6k|    static_assert(std::is_trivially_copyable<T>::value, "T must be trivially copyable");
   99|  18.6k|    uint32_t endian_test = 1;
  100|  18.6k|    if (*reinterpret_cast<char*>(&endian_test)) {
  ------------------
  |  Branch (100:9): [True: 18.6k, False: 0]
  ------------------
  101|  18.6k|        uint8_t src[sizeof(T)];
  102|  18.6k|        uint8_t dst[sizeof(T)];
  103|       |
  104|  18.6k|        std::memcpy(src, &value, sizeof(T));
  105|  56.0k|        for (size_t i = 0; i < sizeof(T); ++i) {
  ------------------
  |  Branch (105:28): [True: 37.3k, False: 18.6k]
  ------------------
  106|  37.3k|            dst[i] = src[sizeof(T) - 1 - i];
  107|  37.3k|        }
  108|       |
  109|  18.6k|        T result;
  110|  18.6k|        std::memcpy(&result, dst, sizeof(T));
  111|  18.6k|        return result;
  112|  18.6k|    }
  113|      0|    return value;
  114|  18.6k|}
_ZN3uWS8protocol8bit_castItEET_Pc:
   89|  3.92k|T bit_cast(char *c) {
   90|  3.92k|    T val;
   91|  3.92k|    memcpy(&val, c, sizeof(T));
   92|  3.92k|    return val;
   93|  3.92k|}
_ZN3uWS17WebSocketProtocolILb1E4ImplE14consumeMessageILj14EmEEbT0_RPcRjPNS_14WebSocketStateILb1EEEPv:
  345|  3.36k|    static inline bool consumeMessage(T payLength, char *&src, unsigned int &length, WebSocketState<isServer> *wState, void *user) {
  346|  3.36k|        if (getOpCode(src)) {
  ------------------
  |  Branch (346:13): [True: 1.85k, False: 1.50k]
  ------------------
  347|  1.85k|            if (wState->state.opStack == 1 || (!wState->state.lastFin && getOpCode(src) < 2)) {
  ------------------
  |  Branch (347:17): [True: 194, False: 1.66k]
  |  Branch (347:48): [True: 474, False: 1.18k]
  |  Branch (347:74): [True: 218, False: 256]
  ------------------
  348|    412|                Impl::forceClose(wState, user, ERR_PROTOCOL);
  349|    412|                return true;
  350|    412|            }
  351|  1.44k|            wState->state.opCode[++wState->state.opStack] = (OpCode) getOpCode(src);
  352|  1.50k|        } else if (wState->state.opStack == -1) {
  ------------------
  |  Branch (352:20): [True: 194, False: 1.31k]
  ------------------
  353|    194|            Impl::forceClose(wState, user, ERR_PROTOCOL);
  354|    194|            return true;
  355|    194|        }
  356|  2.75k|        wState->state.lastFin = isFin(src);
  357|       |
  358|  2.75k|        if (Impl::refusePayloadLength(payLength, wState, user)) {
  ------------------
  |  Branch (358:13): [True: 336, False: 2.41k]
  ------------------
  359|    336|            Impl::forceClose(wState, user, ERR_TOO_BIG_MESSAGE);
  360|    336|            return true;
  361|    336|        }
  362|       |
  363|  2.41k|        if (payLength + MESSAGE_HEADER <= length) {
  ------------------
  |  Branch (363:13): [True: 1.58k, False: 837]
  ------------------
  364|  1.58k|            bool fin = isFin(src);
  365|  1.58k|            if (isServer) {
  ------------------
  |  Branch (365:17): [Folded - Ignored]
  ------------------
  366|       |                /* This guy can never be assumed to be perfectly aligned since we can get multiple messages in one read */
  367|  1.58k|                unmaskImpreciseCopyMask<MESSAGE_HEADER>(src + MESSAGE_HEADER, (unsigned int) payLength);
  368|  1.58k|                if (Impl::handleFragment(src, payLength, 0, wState->state.opCode[wState->state.opStack], fin, wState, user)) {
  ------------------
  |  Branch (368:21): [True: 709, False: 872]
  ------------------
  369|    709|                    return true;
  370|    709|                }
  371|  1.58k|            } else {
  372|      0|                if (Impl::handleFragment(src + MESSAGE_HEADER, payLength, 0, wState->state.opCode[wState->state.opStack], isFin(src), wState, user)) {
  ------------------
  |  Branch (372:21): [True: 0, False: 0]
  ------------------
  373|      0|                    return true;
  374|      0|                }
  375|      0|            }
  376|       |
  377|    872|            if (fin) {
  ------------------
  |  Branch (377:17): [True: 584, False: 288]
  ------------------
  378|    584|                wState->state.opStack--;
  379|    584|            }
  380|       |
  381|    872|            src += payLength + MESSAGE_HEADER;
  382|    872|            length -= (unsigned int) (payLength + MESSAGE_HEADER);
  383|    872|            wState->state.spillLength = 0;
  384|    872|            return false;
  385|  1.58k|        } else {
  386|    837|            wState->state.spillLength = 0;
  387|    837|            wState->state.wantsHead = false;
  388|    837|            wState->remainingBytes = (unsigned int) (payLength - length + MESSAGE_HEADER);
  389|    837|            bool fin = isFin(src);
  390|    837|            if constexpr (isServer) {
  391|    837|                memcpy(wState->mask, src + MESSAGE_HEADER - 4, 4);
  392|    837|                uint64_t mask;
  393|    837|                memcpy(&mask, src + MESSAGE_HEADER - 4, 4);
  394|    837|                memcpy(((char *)&mask) + 4, src + MESSAGE_HEADER - 4, 4);
  395|    837|                unmaskImprecise8<0>(src + MESSAGE_HEADER, mask, length);
  396|    837|                rotateMask(4 - (length - MESSAGE_HEADER) % 4, wState->mask);
  397|    837|            }
  398|    837|            Impl::handleFragment(src + MESSAGE_HEADER, length - MESSAGE_HEADER, wState->remainingBytes, wState->state.opCode[wState->state.opStack], fin, wState, user);
  399|    837|            return true;
  400|    837|        }
  401|  2.41k|    }
_ZN3uWS17WebSocketProtocolILb1E4ImplE23unmaskImpreciseCopyMaskILi14EEEvPcj:
  313|  1.58k|    static inline void unmaskImpreciseCopyMask(char *src, unsigned int length) {
  314|  1.58k|        if constexpr (HEADER_SIZE != 6) {
  315|  1.58k|            char mask[8] = {src[-4], src[-3], src[-2], src[-1], src[-4], src[-3], src[-2], src[-1]};
  316|  1.58k|            uint64_t maskInt;
  317|  1.58k|            memcpy(&maskInt, mask, 8);
  318|  1.58k|            unmaskImprecise8<HEADER_SIZE>(src, maskInt, length);
  319|       |        } else {
  320|       |            char mask[4] = {src[-4], src[-3], src[-2], src[-1]};
  321|       |            uint32_t maskInt;
  322|       |            memcpy(&maskInt, mask, 4);
  323|       |            unmaskImprecise4<HEADER_SIZE>(src, maskInt, length);
  324|       |        }
  325|  1.58k|    }
_ZN3uWS17WebSocketProtocolILb1E4ImplE16unmaskImprecise8ILi14EEEvPcmj:
  290|  1.58k|    static inline void unmaskImprecise8(char *src, uint64_t mask, unsigned int length) {
  291|  33.8k|        for (unsigned int n = (length >> 3) + 1; n; n--) {
  ------------------
  |  Branch (291:50): [True: 32.2k, False: 1.58k]
  ------------------
  292|  32.2k|            uint64_t loaded;
  293|  32.2k|            memcpy(&loaded, src, 8);
  294|  32.2k|            loaded ^= mask;
  295|  32.2k|            memcpy(src - DESTINATION, &loaded, 8);
  296|  32.2k|            src += 8;
  297|  32.2k|        }
  298|  1.58k|    }
_ZN3uWS8protocol14cond_byte_swapImEET_S2_:
   97|  3.36k|T cond_byte_swap(T value) {
   98|  3.36k|    static_assert(std::is_trivially_copyable<T>::value, "T must be trivially copyable");
   99|  3.36k|    uint32_t endian_test = 1;
  100|  3.36k|    if (*reinterpret_cast<char*>(&endian_test)) {
  ------------------
  |  Branch (100:9): [True: 3.36k, False: 0]
  ------------------
  101|  3.36k|        uint8_t src[sizeof(T)];
  102|  3.36k|        uint8_t dst[sizeof(T)];
  103|       |
  104|  3.36k|        std::memcpy(src, &value, sizeof(T));
  105|  30.2k|        for (size_t i = 0; i < sizeof(T); ++i) {
  ------------------
  |  Branch (105:28): [True: 26.8k, False: 3.36k]
  ------------------
  106|  26.8k|            dst[i] = src[sizeof(T) - 1 - i];
  107|  26.8k|        }
  108|       |
  109|  3.36k|        T result;
  110|  3.36k|        std::memcpy(&result, dst, sizeof(T));
  111|  3.36k|        return result;
  112|  3.36k|    }
  113|      0|    return value;
  114|  3.36k|}
_ZN3uWS8protocol8bit_castImEET_Pc:
   89|  3.36k|T bit_cast(char *c) {
   90|  3.36k|    T val;
   91|  3.36k|    memcpy(&val, c, sizeof(T));
   92|  3.36k|    return val;
   93|  3.36k|}
_ZN3uWS17WebSocketProtocolILb1E4ImplE19consumeContinuationERPcRjPNS_14WebSocketStateILb1EEEPv:
  410|  10.1k|    static inline bool consumeContinuation(char *&src, unsigned int &length, WebSocketState<isServer> *wState, void *user) {
  411|  10.1k|        if (wState->remainingBytes <= length) {
  ------------------
  |  Branch (411:13): [True: 8.15k, False: 2.03k]
  ------------------
  412|  8.15k|            if (isServer) {
  ------------------
  |  Branch (412:17): [Folded - Ignored]
  ------------------
  413|  8.15k|                unsigned int n = wState->remainingBytes >> 2;
  414|  8.15k|                unmaskInplace(src, src + n * 4, wState->mask);
  415|  16.2k|                for (unsigned int i = 0, s = wState->remainingBytes % 4; i < s; i++) {
  ------------------
  |  Branch (415:74): [True: 8.06k, False: 8.15k]
  ------------------
  416|  8.06k|                    src[n * 4 + i] ^= wState->mask[i];
  417|  8.06k|                }
  418|  8.15k|            }
  419|       |
  420|  8.15k|            if (Impl::handleFragment(src, wState->remainingBytes, 0, wState->state.opCode[wState->state.opStack], wState->state.lastFin, wState, user)) {
  ------------------
  |  Branch (420:17): [True: 3.41k, False: 4.74k]
  ------------------
  421|  3.41k|                return false;
  422|  3.41k|            }
  423|       |
  424|  4.74k|            if (wState->state.lastFin) {
  ------------------
  |  Branch (424:17): [True: 3.29k, False: 1.45k]
  ------------------
  425|  3.29k|                wState->state.opStack--;
  426|  3.29k|            }
  427|       |
  428|  4.74k|            src += wState->remainingBytes;
  429|  4.74k|            length -= wState->remainingBytes;
  430|  4.74k|            wState->state.wantsHead = true;
  431|  4.74k|            return true;
  432|  8.15k|        } else {
  433|  2.03k|            if (isServer) {
  ------------------
  |  Branch (433:17): [Folded - Ignored]
  ------------------
  434|       |                /* No need to unmask if mask is 0 */
  435|  2.03k|                uint32_t nullmask = 0;
  436|  2.03k|                if (memcmp(wState->mask, &nullmask, sizeof(uint32_t))) {
  ------------------
  |  Branch (436:21): [True: 1.10k, False: 931]
  ------------------
  437|  1.10k|                    if /*constexpr*/ (LIBUS_RECV_BUFFER_LENGTH == length) {
  ------------------
  |  |   22|  1.10k|#define LIBUS_RECV_BUFFER_LENGTH 524288
  ------------------
  |  Branch (437:39): [True: 0, False: 1.10k]
  ------------------
  438|      0|                        unmaskAll(src, wState->mask);
  439|  1.10k|                    } else {
  440|       |                        // Slow path
  441|  1.10k|                        unmaskInplace(src, src + ((length >> 2) + 1) * 4, wState->mask);
  442|  1.10k|                    }
  443|  1.10k|                }
  444|  2.03k|            }
  445|       |
  446|  2.03k|            wState->remainingBytes -= length;
  447|  2.03k|            if (Impl::handleFragment(src, length, wState->remainingBytes, wState->state.opCode[wState->state.opStack], wState->state.lastFin, wState, user)) {
  ------------------
  |  Branch (447:17): [True: 484, False: 1.55k]
  ------------------
  448|    484|                return false;
  449|    484|            }
  450|       |
  451|  1.55k|            if (isServer && length % 4) {
  ------------------
  |  Branch (451:17): [Folded - Ignored]
  |  Branch (451:29): [True: 1.10k, False: 454]
  ------------------
  452|  1.10k|                rotateMask(4 - (length % 4), wState->mask);
  453|  1.10k|            }
  454|  1.55k|            return false;
  455|  2.03k|        }
  456|  10.1k|    }
_ZN3uWS17WebSocketProtocolILb1E4ImplE13unmaskInplaceEPcS3_S3_:
  335|  9.26k|    static inline void unmaskInplace(char *data, char *stop, char *mask) {
  336|  83.3k|        while (data < stop) {
  ------------------
  |  Branch (336:16): [True: 74.1k, False: 9.26k]
  ------------------
  337|  74.1k|            *(data++) ^= mask[0];
  338|  74.1k|            *(data++) ^= mask[1];
  339|  74.1k|            *(data++) ^= mask[2];
  340|  74.1k|            *(data++) ^= mask[3];
  341|  74.1k|        }
  342|  9.26k|    }

