run_burl_normalize:
   26|  1.75k|						size_t in_len) {
   27|  1.75k|    int qs;
   28|  1.75k|    buffer_copy_string_len(psrc, in, in_len);
   29|  1.75k|    qs = burl_normalize(psrc, ptmp, flags);
   30|  1.75k|}
LLVMFuzzerTestOneInput:
   32|  1.75k|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   33|  1.75k|    if (size <= 4) {
  ------------------
  |  Branch (33:9): [True: 4, False: 1.75k]
  ------------------
   34|      4|        return 0;
   35|      4|    }
   36|  1.75k|    int flags = ((int*)data)[0];
   37|  1.75k|    data += 4;
   38|  1.75k|    size -= 4;
   39|  1.75k|    char *new_str = (char *)malloc(size+1);
   40|  1.75k|    if (new_str == NULL){
  ------------------
  |  Branch (40:9): [True: 0, False: 1.75k]
  ------------------
   41|      0|        return 0;
   42|      0|    }
   43|  1.75k|    memcpy(new_str, data, size);
   44|  1.75k|    new_str[size] = '\0';
   45|       |
   46|       |    /* main fuzzer entrypoint for library */
   47|  1.75k|    buffer *psrc = buffer_init();
   48|  1.75k|    buffer *ptmp = buffer_init();
   49|  1.75k|    run_burl_normalize(psrc, ptmp, flags, __LINE__, new_str, size);
   50|  1.75k|    buffer_urldecode_path(psrc);
   51|       |
   52|  1.75k|    buffer_free(psrc);
   53|  1.75k|    buffer_free(ptmp);
   54|  1.75k|    free(new_str);
   55|  1.75k|    return 0;     
   56|  1.75k|}

buffer_init:
   14|  3.50k|buffer* buffer_init(void) {
   15|       |  #if 0 /* buffer_init() and chunk_init() can be hot,
   16|       |	 * so avoid the additional hop of indirection */
   17|       |	return ck_calloc(1, sizeof(buffer));
   18|       |  #else
   19|  3.50k|	buffer * const b = calloc(1, sizeof(*b));
   20|  3.50k|	force_assert(b);
  ------------------
  |  |  448|  3.50k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.50k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.50k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.50k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   21|  3.50k|	return b;
   22|  3.50k|  #endif
   23|  3.50k|}
buffer_free:
   25|  3.50k|void buffer_free(buffer *b) {
   26|  3.50k|	if (NULL == b) return;
  ------------------
  |  Branch (26:6): [True: 0, False: 3.50k]
  ------------------
   27|  3.50k|	free(b->ptr);
   28|  3.50k|	free(b);
   29|  3.50k|}
buffer_string_prepare_copy:
   82|  1.36k|char* buffer_string_prepare_copy(buffer * const b, const size_t size) {
   83|  1.36k|    b->used = 0;
   84|       |  #ifdef __COVERITY__ /*(b->ptr is not NULL if b->size is not 0)*/
   85|       |    force_assert(size >= b->size || b->ptr);
   86|       |  #endif
   87|  1.36k|    return (size < b->size)
  ------------------
  |  Branch (87:12): [True: 0, False: 1.36k]
  ------------------
   88|  1.36k|      ? b->ptr
   89|  1.36k|      : buffer_alloc_replace(b, size);
   90|  1.36k|}
buffer_extend:
  127|    144|{
  128|       |    /* extend buffer to append x (reallocate by power-2 (or larger), if needed)
  129|       |     * (combine buffer_string_prepare_append() and buffer_commit())
  130|       |     * (future: might make buffer.h static inline func for HTTP/1.1 performance)
  131|       |     * pre-sets '\0' byte and b->used (unlike buffer_string_prepare_append())*/
  132|       |  #if 0
  133|       |    char * const s = buffer_string_prepare_append(b, x);
  134|       |    b->used += x + (0 == b->used);
  135|       |  #else
  136|    144|    const uint32_t len = b->used ? b->used-1 : 0;
  ------------------
  |  Branch (136:26): [True: 144, False: 0]
  ------------------
  137|    144|    char * const s = (b->size - len >= x + 1)
  ------------------
  |  Branch (137:22): [True: 144, False: 0]
  ------------------
  138|    144|      ? b->ptr + len
  139|    144|      : buffer_string_prepare_append_resize(b, x);
  140|    144|    b->used = len+x+1;
  141|    144|  #endif
  142|    144|    s[x] = '\0';
  143|    144|    return s;
  144|    144|}
buffer_copy_string_len:
  172|  3.25k|void buffer_copy_string_len(buffer * const restrict b, const char * const restrict s, const size_t len) {
  173|  3.25k|    b->used = len + 1;
  174|  3.25k|    char * const restrict d = (len < b->size)
  ------------------
  |  Branch (174:31): [True: 981, False: 2.27k]
  ------------------
  175|  3.25k|      ? b->ptr
  176|  3.25k|      : buffer_alloc_replace(b, len);
  177|  3.25k|    d[len] = '\0';
  178|  3.25k|    memcpy(d, s, len);
  179|  3.25k|}
buffer_append_string_len:
  198|    144|void buffer_append_string_len(buffer * const restrict b, const char * const restrict s, const size_t len) {
  199|    144|    memcpy(buffer_extend(b, len), s, len);
  200|    144|}
hex2int:
  386|   107M|char hex2int(unsigned char hex) {
  387|   107M|	unsigned char n;
  388|   107M|	return li_cton(hex,n) ? (char)n : 0xFF;
  ------------------
  |  |  381|   107M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (381:4): [True: 92.7M, False: 14.7M]
  |  |  |  Branch (381:30): [True: 14.7M, False: 0]
  |  |  |  Branch (381:31): [True: 14.7M, False: 0]
  |  |  ------------------
  ------------------
  389|   107M|}
buffer_urldecode_path:
  792|  1.75k|void buffer_urldecode_path(buffer * const b) {
  793|  1.75k|    const size_t len = buffer_clen(b);
  794|  1.75k|    char *src = len ? memchr(b->ptr, '%', len) : NULL;
  ------------------
  |  Branch (794:17): [True: 1.74k, False: 5]
  ------------------
  795|  1.75k|    if (NULL == src) return;
  ------------------
  |  Branch (795:9): [True: 369, False: 1.38k]
  ------------------
  796|       |
  797|  1.38k|    char *dst = src;
  798|  53.7M|    do {
  799|       |        /* *src == '%' */
  800|  53.7M|        unsigned char high = ((unsigned char *)src)[1];
  801|  53.7M|        unsigned char low = high ? hex2int(((unsigned char *)src)[2]) : 0xFF;
  ------------------
  |  Branch (801:29): [True: 53.7M, False: 0]
  ------------------
  802|  53.7M|        if (0xFF != (high = hex2int(high)) && 0xFF != low) {
  ------------------
  |  Branch (802:13): [True: 53.7M, False: 0]
  |  Branch (802:47): [True: 53.7M, False: 0]
  ------------------
  803|  53.7M|            high = (high << 4) | low;   /* map ctrls to '_' */
  804|  53.7M|            *dst = (high >= 32 && high != 127) ? high : '_';
  ------------------
  |  Branch (804:21): [True: 11.6M, False: 42.1M]
  |  Branch (804:35): [True: 10.3M, False: 1.33M]
  ------------------
  805|  53.7M|            src += 2;
  806|  53.7M|        } /* else ignore this '%'; leave as-is and move on */
  807|       |
  808|  57.5M|        while ((*++dst = *++src) != '%' && *src) ;
  ------------------
  |  Branch (808:16): [True: 3.80M, False: 53.7M]
  |  Branch (808:44): [True: 3.80M, False: 1.38k]
  ------------------
  809|  53.7M|    } while (*src);
  ------------------
  |  Branch (809:14): [True: 53.7M, False: 1.38k]
  ------------------
  810|  1.38k|    b->used = (dst - b->ptr) + 1;
  811|  1.38k|}
buffer_path_simplify:
  859|    382|{
  860|    382|    char *out = b->ptr;
  861|    382|    char * const end = b->ptr + b->used - 1;
  862|       |
  863|    382|    if (__builtin_expect( (buffer_is_blank(b)), 0)) {
  ------------------
  |  Branch (863:9): [True: 0, False: 382]
  ------------------
  864|      0|        buffer_blank(b);
  865|      0|        return;
  866|      0|    }
  867|       |
  868|       |  #if defined(_WIN32) || defined(__CYGWIN__)
  869|       |    /* cygwin is treating \ and / the same, so we have to that too */
  870|       |    for (char *p = b->ptr; *p; p++) {
  871|       |        if (*p == '\\') *p = '/';
  872|       |    }
  873|       |  #endif
  874|       |
  875|    382|    *end = '/'; /*(end of path modified to avoid need to check '\0')*/
  876|       |
  877|    382|    char *walk = out;
  878|    382|    if (__builtin_expect( (*walk == '/'), 1)) {
  ------------------
  |  Branch (878:9): [True: 139, False: 243]
  ------------------
  879|       |        /* scan to detect (potential) need for path simplification
  880|       |         * (repeated '/' or "/.") */
  881|    504|        do {
  882|    504|            if (*++walk == '.' || *walk == '/')
  ------------------
  |  Branch (882:17): [True: 75, False: 429]
  |  Branch (882:35): [True: 64, False: 365]
  ------------------
  883|    139|                break;
  884|   226k|            do { ++walk; } while (*walk != '/');
  ------------------
  |  Branch (884:35): [True: 225k, False: 365]
  ------------------
  885|    365|        } while (walk != end);
  ------------------
  |  Branch (885:18): [True: 365, False: 0]
  ------------------
  886|    139|        if (__builtin_expect( (walk == end), 1)) {
  ------------------
  |  Branch (886:13): [True: 0, False: 139]
  ------------------
  887|       |            /* common case: no repeated '/' or "/." */
  888|      0|            *end = '\0'; /* overwrite extra '/' added to end of path */
  889|      0|            return;
  890|      0|        }
  891|    139|        out = walk-1;
  892|    139|    }
  893|    243|    else {
  894|    243|        if (walk[0] == '.' && walk[1] == '/')
  ------------------
  |  Branch (894:13): [True: 99, False: 144]
  |  Branch (894:31): [True: 62, False: 37]
  ------------------
  895|     62|            *out = *++walk;
  896|    181|        else if (walk[0] == '.' && walk[1] == '.' && walk[2] == '/')
  ------------------
  |  Branch (896:18): [True: 37, False: 144]
  |  Branch (896:36): [True: 15, False: 22]
  |  Branch (896:54): [True: 1, False: 14]
  ------------------
  897|      1|            *out = *(walk += 2);
  898|    180|        else {
  899|  8.24M|            while (*++walk != '/') ;
  ------------------
  |  Branch (899:20): [True: 8.24M, False: 180]
  ------------------
  900|    180|            out = walk;
  901|    180|        }
  902|    243|        ++walk;
  903|    243|    }
  904|       |
  905|  12.4k|    while (walk <= end) {
  ------------------
  |  Branch (905:12): [True: 12.2k, False: 200]
  ------------------
  906|       |        /* previous char is '/' at this point (or start of string w/o '/') */
  907|  12.2k|        if (__builtin_expect( (walk[0] == '/'), 0)) {
  ------------------
  |  Branch (907:13): [True: 3.50k, False: 8.73k]
  ------------------
  908|       |            /* skip repeated '/' (e.g. "///" -> "/") */
  909|  3.50k|            if (++walk < end)
  ------------------
  |  Branch (909:17): [True: 3.45k, False: 57]
  ------------------
  910|  3.45k|                continue;
  911|     57|            else {
  912|     57|                ++out;
  913|     57|                break;
  914|     57|            }
  915|  3.50k|        }
  916|  8.73k|        else if (__builtin_expect( (walk[0] == '.'), 0)) {
  ------------------
  |  Branch (916:18): [True: 5.84k, False: 2.88k]
  ------------------
  917|       |            /* handle "./" and "../" */
  918|  5.84k|            if (walk[1] == '.' && walk[2] == '/') {
  ------------------
  |  Branch (918:17): [True: 3.70k, False: 2.14k]
  |  Branch (918:35): [True: 2.09k, False: 1.60k]
  ------------------
  919|       |                /* handle "../" */
  920|  6.11M|                while (out > b->ptr && *--out != '/') ;
  ------------------
  |  Branch (920:24): [True: 6.11M, False: 604]
  |  Branch (920:40): [True: 6.11M, False: 1.48k]
  ------------------
  921|  2.09k|                *out = '/'; /*(in case path had not started with '/')*/
  922|  2.09k|                if ((walk += 3) >= end) {
  ------------------
  |  Branch (922:21): [True: 60, False: 2.03k]
  ------------------
  923|     60|                    ++out;
  924|     60|                    break;
  925|     60|                }
  926|  2.03k|                else
  927|  2.03k|                    continue;
  928|  2.09k|            }
  929|  3.75k|            else if (walk[1] == '/') {
  ------------------
  |  Branch (929:22): [True: 888, False: 2.86k]
  ------------------
  930|       |                /* handle "./" */
  931|    888|                if ((walk += 2) >= end) {
  ------------------
  |  Branch (931:21): [True: 65, False: 823]
  ------------------
  932|     65|                    ++out;
  933|     65|                    break;
  934|     65|                }
  935|    823|                continue;
  936|    888|            }
  937|  2.86k|            else {
  938|       |                /* accept "." if not part of "../" or "./" */
  939|  2.86k|                *++out = '.';
  940|  2.86k|                ++walk;
  941|  2.86k|            }
  942|  5.84k|        }
  943|       |
  944|  30.9M|        while ((*++out = *walk++) != '/') ;
  ------------------
  |  Branch (944:16): [True: 30.9M, False: 5.75k]
  ------------------
  945|  5.75k|    }
  946|    382|    *out = *end = '\0'; /* overwrite extra '/' added to end of path */
  947|    382|    b->used = (out - b->ptr) + 1;
  948|       |    /*buffer_truncate(b, out - b->ptr);*/
  949|    382|}
buffer.c:buffer_alloc_replace:
   71|  3.63k|static char* buffer_alloc_replace(buffer * const restrict b, const size_t size) {
   72|       |    /*(discard old data so realloc() does not copy)*/
   73|  3.63k|    if (NULL != b->ptr) {
  ------------------
  |  Branch (73:9): [True: 513, False: 3.12k]
  ------------------
   74|    513|        free(b->ptr);
   75|    513|        b->ptr = NULL;
   76|    513|    }
   77|       |    /*(note: if size larger than one lshift, use size instead of power-2)*/
   78|  3.63k|    const size_t bsize2x = (b->size & ~1uL) << 1;
   79|  3.63k|    return buffer_realloc(b, bsize2x > size ? bsize2x-1 : size);
  ------------------
  |  Branch (79:30): [True: 262, False: 3.37k]
  ------------------
   80|  3.63k|}
buffer.c:buffer_realloc:
   49|  3.63k|static char* buffer_realloc(buffer * const restrict b, const size_t len) {
   50|  3.63k|    #define BUFFER_PIECE_SIZE 64uL  /*(must be power-of-2)*/
   51|  3.63k|    size_t sz = (len + 1 + BUFFER_PIECE_SIZE-1) & ~(BUFFER_PIECE_SIZE-1);
  ------------------
  |  |   50|  3.63k|    #define BUFFER_PIECE_SIZE 64uL  /*(must be power-of-2)*/
  ------------------
                  size_t sz = (len + 1 + BUFFER_PIECE_SIZE-1) & ~(BUFFER_PIECE_SIZE-1);
  ------------------
  |  |   50|  3.63k|    #define BUFFER_PIECE_SIZE 64uL  /*(must be power-of-2)*/
  ------------------
   52|  3.63k|    force_assert(sz > len);
  ------------------
  |  |  448|  3.63k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.63k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.63k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.63k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   53|  3.63k|    if ((sz & (sz-1)) && sz < INT_MAX) {/* not power-2; huge val not expected */
  ------------------
  |  Branch (53:9): [True: 1.26k, False: 2.37k]
  |  Branch (53:26): [True: 1.26k, False: 0]
  ------------------
   54|       |        /*(optimizer should recognize this and use ffs or clz or equivalent)*/
   55|  1.26k|        const size_t psz = sz;
   56|  8.81k|        for (sz = 256; sz < psz; sz <<= 1) ;
  ------------------
  |  Branch (56:24): [True: 7.55k, False: 1.26k]
  ------------------
   57|  1.26k|    }
   58|  3.63k|    sz |= 1; /*(extra +1 for '\0' when needed buffer size is exact power-2)*/
   59|       |
   60|  3.63k|    b->size = sz;
   61|  3.63k|    b->ptr = realloc(b->ptr, sz);
   62|       |
   63|  3.63k|    force_assert(NULL != b->ptr);
  ------------------
  |  |  448|  3.63k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.63k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.63k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.63k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   64|  3.63k|    return b->ptr;
   65|  3.63k|}

burl.c:buffer_truncate:
  349|    431|static inline void buffer_truncate(buffer *b, uint32_t len) {
  350|    431|    b->ptr[len] = '\0'; /* b->ptr must exist; use buffer_blank() for trunc 0 */
  351|    431|    b->used = len + 1;
  352|    431|}
burl.c:light_isalnum:
  232|  18.1k|static inline int light_isalnum(int c) {
  233|  18.1k|	return light_isdigit(c) || light_isalpha(c);
  ------------------
  |  Branch (233:9): [True: 368, False: 17.8k]
  |  Branch (233:29): [True: 719, False: 17.1k]
  ------------------
  234|  18.1k|}
burl.c:light_isdigit:
  214|  18.1k|static inline int light_isdigit(int c) {
  215|  18.1k|	return ((uint32_t)c-'0' <= '9'-'0');
  216|  18.1k|}
burl.c:light_isalpha:
  226|  17.8k|static inline int light_isalpha(int c) {
  227|  17.8k|	return (((uint32_t)c | 0x20)-'a' <= 'z'-'a');
  228|  17.8k|}
burl.c:buffer_clen:
  323|  6.46k|static inline uint32_t buffer_clen (const buffer *b) {
  324|  6.46k|    return b->used - (0 != b->used);
  325|  6.46k|}
buffer.c:buffer_clen:
  323|  1.75k|static inline uint32_t buffer_clen (const buffer *b) {
  324|  1.75k|    return b->used - (0 != b->used);
  325|  1.75k|}
buffer.c:buffer_is_blank:
  315|    382|static inline int buffer_is_blank(const buffer *b) {
  316|    382|    return b->used < 2; /* buffer_is_blank() || buffer_is_unset() */
  317|    382|}

burl_normalize:
  344|  1.75k|{
  345|  1.75k|    int qs;
  346|       |
  347|       |  #if defined(_WIN32) || defined(__CYGWIN__)
  348|       |    /* Windows and Cygwin treat '\\' as '/' if '\\' is present in path;
  349|       |     * convert to '/' for consistency before percent-encoding
  350|       |     * normalization which will convert '\\' to "%5C" in the URL.
  351|       |     * (Clients still should not be sending '\\' unencoded in requests.) */
  352|       |    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_BACKSLASH_TRANS) {
  353|       |        for (char *p = b->ptr; *p != '?' && *p != '\0'; ++p) {
  354|       |            if (*p == '\\') *p = '/';
  355|       |            if (p[0] == '%' && p[1] == '5' && (p[2] | 0x20) == 'c') {
  356|       |                p[1] = '2';
  357|       |                p[2] = 'F';
  358|       |                p += 2;
  359|       |            }
  360|       |        }
  361|       |    }
  362|       |  #endif
  363|       |
  364|  1.75k|    qs = (flags & HTTP_PARSEOPT_URL_NORMALIZE_REQUIRED)
  ------------------
  |  Branch (364:10): [True: 975, False: 775]
  ------------------
  365|  1.75k|      ? burl_normalize_basic_required(b, t)
  366|  1.75k|      : burl_normalize_basic_unreserved(b, t);
  367|  1.75k|    if (-2 == qs) {
  ------------------
  |  Branch (367:9): [True: 556, False: 1.19k]
  ------------------
  368|    556|        if (flags & HTTP_PARSEOPT_URL_NORMALIZE_INVALID_UTF8_REJECT) return -2;
  ------------------
  |  Branch (368:13): [True: 116, False: 440]
  ------------------
  369|    440|        qs = burl_scan_qmark(b);
  370|    440|    }
  371|       |
  372|  1.63k|    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_CTRLS_REJECT) {
  ------------------
  |  Branch (372:9): [True: 367, False: 1.26k]
  ------------------
  373|    367|        if (burl_contains_ctrls(b)) return -2;
  ------------------
  |  Branch (373:13): [True: 99, False: 268]
  ------------------
  374|    367|    }
  375|       |
  376|  1.53k|    if (flags & (HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_DECODE
  ------------------
  |  Branch (376:9): [True: 1.25k, False: 282]
  ------------------
  377|  1.53k|                |HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)) {
  378|  1.25k|        qs = burl_normalize_2F_to_slash(b, qs, flags);
  379|  1.25k|        if (-2 == qs) return -2;
  ------------------
  |  Branch (379:13): [True: 12, False: 1.24k]
  ------------------
  380|  1.25k|    }
  381|       |
  382|  1.52k|    if (flags & (HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REMOVE
  ------------------
  |  Branch (382:9): [True: 1.21k, False: 313]
  ------------------
  383|  1.52k|                |HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT)) {
  384|  1.21k|        qs = burl_normalize_path(b, t, qs, flags);
  385|  1.21k|        if (-2 == qs) return -2;
  ------------------
  |  Branch (385:13): [True: 12, False: 1.19k]
  ------------------
  386|  1.21k|    }
  387|       |
  388|  1.51k|    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_QUERY_20_PLUS) {
  ------------------
  |  Branch (388:9): [True: 954, False: 557]
  ------------------
  389|    954|        if (qs >= 0) burl_normalize_qs20_to_plus(b, qs);
  ------------------
  |  Branch (389:13): [True: 460, False: 494]
  ------------------
  390|    954|    }
  391|       |
  392|  1.51k|    return qs;
  393|  1.52k|}
burl.c:burl_normalize_basic_required:
  179|    975|{
  180|    975|    const unsigned char * const s = (unsigned char *)b->ptr;
  181|    975|    const int used = (int)buffer_clen(b);
  182|    975|    unsigned int n1, n2, x;
  183|    975|    int qs = -1;
  184|    975|    int invalid_utf8 = 0;
  185|       |
  186|   353k|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (186:21): [True: 352k, False: 207]
  ------------------
  187|   352k|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (187:13): [True: 345k, False: 7.43k]
  ------------------
  188|   345k|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = i;
  ------------------
  |  Branch (188:17): [True: 1.82k, False: 343k]
  |  Branch (188:56): [True: 230, False: 1.59k]
  ------------------
  189|   345k|        }
  190|  7.43k|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  14.3k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 3.21k, False: 3.66k]
  |  |  |  Branch (43:30): [True: 3.58k, False: 77]
  |  |  |  Branch (43:31): [True: 3.58k, False: 77]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  14.2k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 2.41k, False: 4.37k]
  |  |  |  Branch (43:30): [True: 4.32k, False: 57]
  |  |  |  Branch (43:31): [True: 4.32k, False: 57]
  |  |  ------------------
  ------------------
  |  Branch (190:18): [True: 6.87k, False: 560]
  ------------------
  191|  6.73k|                 && (encoded_chars_http_uri_reqd[(x = (n1 << 4) | n2)]
  ------------------
  |  Branch (191:22): [True: 3.87k, False: 2.86k]
  ------------------
  192|  2.86k|                     || (qs < 0
  ------------------
  |  Branch (192:25): [True: 2.79k, False: 74]
  |  Branch (192:26): [True: 700, False: 2.16k]
  ------------------
  193|  2.86k|                         ? (x == '/' || x == '?')
  ------------------
  |  Branch (193:29): [True: 421, False: 279]
  |  Branch (193:41): [True: 246, False: 33]
  ------------------
  194|  6.66k|                         : (x == '&' || x == '=' || x == ';' || x == '+')))) {
  ------------------
  |  Branch (194:29): [True: 958, False: 1.20k]
  |  Branch (194:41): [True: 566, False: 640]
  |  Branch (194:53): [True: 234, False: 406]
  |  Branch (194:65): [True: 365, False: 41]
  ------------------
  195|  6.66k|            invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  6.66k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  6.66k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 699, False: 5.96k]
  |  |  |  |  ------------------
  |  |  |  |  261|  6.66k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 130, False: 5.83k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|  6.66k|            if (s[i+1] >= 'a') b->ptr[i+1] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (196:17): [True: 3.39k, False: 3.27k]
  ------------------
  197|  6.66k|            if (s[i+2] >= 'a') b->ptr[i+2] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (197:17): [True: 2.50k, False: 4.16k]
  ------------------
  198|  6.66k|            i+=2;
  199|  6.66k|        }
  200|    768|        else if (s[i] == '#') { /* ignore fragment */
  ------------------
  |  Branch (200:18): [True: 1, False: 767]
  ------------------
  201|      1|            buffer_truncate(b, (size_t)i);
  202|      1|            break;
  203|      1|        }
  204|    767|        else {
  205|    767|            qs = burl_normalize_basic_required_fix(b, t, i, qs);
  206|    767|            break;
  207|    767|        }
  208|   352k|    }
  209|       |
  210|    975|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (210:12): [True: 946, False: 29]
  ------------------
  211|    975|}
burl.c:burl_normalize_basic_required_fix:
  135|    767|{
  136|    767|    int j = i;
  137|    767|    const int used = (int)buffer_clen(b);
  138|    767|    const unsigned char * const s = (unsigned char *)b->ptr;
  139|    767|    unsigned char * const p =
  140|    767|      (unsigned char *)buffer_string_prepare_copy(t,i+(used-i)*3+1);
  141|    767|    unsigned int n1, n2;
  142|    767|    int invalid_utf8 = 0;
  143|    767|    memcpy(p, s, (size_t)i);
  144|  35.7M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (144:12): [True: 35.7M, False: 751]
  ------------------
  145|  35.7M|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (145:13): [True: 1.92M, False: 33.8M]
  ------------------
  146|  1.92M|            p[j] = s[i];
  147|  1.92M|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = j;
  ------------------
  |  Branch (147:17): [True: 10.8k, False: 1.91M]
  |  Branch (147:56): [True: 202, False: 10.6k]
  ------------------
  148|  1.92M|        }
  149|  33.8M|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  33.8M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 18.5k, False: 9.04k]
  |  |  |  Branch (43:30): [True: 4.10k, False: 4.93k]
  |  |  |  Branch (43:31): [True: 4.10k, False: 4.93k]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  22.6k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 9.73k, False: 12.9k]
  |  |  |  Branch (43:30): [True: 11.2k, False: 1.69k]
  |  |  |  Branch (43:31): [True: 11.2k, False: 1.69k]
  |  |  ------------------
  ------------------
  |  Branch (149:18): [True: 27.5k, False: 33.8M]
  ------------------
  150|  20.9k|            const unsigned int x = (n1 << 4) | n2;
  151|  20.9k|            if (!encoded_chars_http_uri_reqd[x]
  ------------------
  |  Branch (151:17): [True: 14.3k, False: 6.63k]
  ------------------
  152|  14.3k|                && (qs < 0
  ------------------
  |  Branch (152:20): [True: 3.06k, False: 11.2k]
  |  Branch (152:21): [True: 2.25k, False: 12.0k]
  ------------------
  153|  14.3k|                    ? (x != '/' && x != '?')
  ------------------
  |  Branch (153:24): [True: 1.30k, False: 947]
  |  Branch (153:36): [True: 1.01k, False: 289]
  ------------------
  154|  14.3k|                    : (x != '&' && x != '=' && x != ';' && x != '+'))) {
  ------------------
  |  Branch (154:24): [True: 6.75k, False: 5.30k]
  |  Branch (154:36): [True: 4.10k, False: 2.64k]
  |  Branch (154:48): [True: 3.25k, False: 850]
  |  Branch (154:60): [True: 2.04k, False: 1.20k]
  ------------------
  155|  3.06k|                p[j] = x;
  156|  3.06k|            }
  157|  17.8k|            else {
  158|  17.8k|                p[j]   = '%';
  159|  17.8k|                p[++j] = hex_chars_uc[n1]; /*(s[i+1] & 0xdf)*/
  160|  17.8k|                p[++j] = hex_chars_uc[n2]; /*(s[i+2] & 0xdf)*/
  161|  17.8k|                invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  17.8k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  17.8k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 1.64k, False: 16.2k]
  |  |  |  |  ------------------
  |  |  |  |  261|  17.8k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 224, False: 16.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  162|  17.8k|            }
  163|  20.9k|            i+=2;
  164|  20.9k|        }
  165|  33.8M|        else if (s[i] == '#') break; /* ignore fragment */
  ------------------
  |  Branch (165:18): [True: 16, False: 33.8M]
  ------------------
  166|  33.8M|        else {
  167|  33.8M|            p[j]   = '%';
  168|  33.8M|            p[++j] = hex_chars_uc[(s[i] >> 4) & 0xF];
  169|  33.8M|            p[++j] = hex_chars_uc[s[i] & 0xF];
  170|  33.8M|            invalid_utf8 |= li_utf8_invalid_byte(s[i]);
  ------------------
  |  |   49|  33.8M|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  33.8M|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 1.85M, False: 31.9M]
  |  |  |  |  ------------------
  |  |  |  |  261|  33.8M|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 1.37k, False: 31.9M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  171|  33.8M|        }
  172|  35.7M|    }
  173|    767|    buffer_copy_string_len(b, (char *)p, (size_t)j);
  174|    767|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (174:12): [True: 452, False: 315]
  ------------------
  175|    767|}
burl.c:burl_normalize_basic_unreserved:
  101|    775|{
  102|    775|    const unsigned char * const s = (unsigned char *)b->ptr;
  103|    775|    const int used = (int)buffer_clen(b);
  104|    775|    unsigned int n1, n2, x;
  105|    775|    int qs = -1;
  106|    775|    int invalid_utf8 = 0;
  107|       |
  108|   661k|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (108:21): [True: 660k, False: 181]
  ------------------
  109|   660k|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (109:13): [True: 656k, False: 4.22k]
  ------------------
  110|   656k|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = i;
  ------------------
  |  Branch (110:17): [True: 534, False: 656k]
  |  Branch (110:56): [True: 90, False: 444]
  ------------------
  111|   656k|        }
  112|  4.22k|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  8.01k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 1.75k, False: 2.04k]
  |  |  |  Branch (43:30): [True: 1.98k, False: 59]
  |  |  |  Branch (43:31): [True: 1.98k, False: 59]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  7.95k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 1.23k, False: 2.50k]
  |  |  |  Branch (43:30): [True: 2.44k, False: 53]
  |  |  |  Branch (43:31): [True: 2.44k, False: 53]
  |  |  ------------------
  ------------------
  |  Branch (112:18): [True: 3.79k, False: 422]
  ------------------
  113|  3.68k|                 && !burl_is_unreserved((x = (n1 << 4) | n2))) {
  ------------------
  |  Branch (113:21): [True: 3.62k, False: 60]
  ------------------
  114|  3.62k|            invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  3.62k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  3.62k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 1.15k, False: 2.47k]
  |  |  |  |  ------------------
  |  |  |  |  261|  3.62k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 155, False: 2.32k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  115|  3.62k|            if (s[i+1] >= 'a') b->ptr[i+1] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (115:17): [True: 1.74k, False: 1.88k]
  ------------------
  116|  3.62k|            if (s[i+2] >= 'a') b->ptr[i+2] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (116:17): [True: 1.69k, False: 1.93k]
  ------------------
  117|  3.62k|            i+=2;
  118|  3.62k|        }
  119|    594|        else if (s[i] == '#') { /* ignore fragment */
  ------------------
  |  Branch (119:18): [True: 1, False: 593]
  ------------------
  120|      1|            buffer_truncate(b, (size_t)i);
  121|      1|            break;
  122|      1|        }
  123|    593|        else {
  124|    593|            qs = burl_normalize_basic_unreserved_fix(b, t, i, qs);
  125|    593|            break;
  126|    593|        }
  127|   660k|    }
  128|       |
  129|    775|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (129:12): [True: 743, False: 32]
  ------------------
  130|    775|}
burl.c:burl_is_unreserved:
   53|  18.1k|{
   54|  18.1k|    return (light_isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~');
  ------------------
  |  Branch (54:13): [True: 1.08k, False: 17.1k]
  |  Branch (54:33): [True: 360, False: 16.7k]
  |  Branch (54:45): [True: 248, False: 16.4k]
  |  Branch (54:57): [True: 830, False: 15.6k]
  |  Branch (54:69): [True: 447, False: 15.2k]
  ------------------
   55|  18.1k|}
burl.c:burl_normalize_basic_unreserved_fix:
   60|    593|{
   61|    593|    int j = i;
   62|    593|    const int used = (int)buffer_clen(b);
   63|    593|    const unsigned char * const s = (unsigned char *)b->ptr;
   64|    593|    unsigned char * const p =
   65|    593|      (unsigned char *)buffer_string_prepare_copy(t,i+(used-i)*3+1);
   66|    593|    unsigned int n1, n2;
   67|    593|    int invalid_utf8 = 0;
   68|    593|    memcpy(p, s, (size_t)i);
   69|  23.1M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (69:12): [True: 23.1M, False: 585]
  ------------------
   70|  23.1M|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (70:13): [True: 1.17M, False: 21.9M]
  ------------------
   71|  1.17M|            p[j] = s[i];
   72|  1.17M|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = j;
  ------------------
  |  Branch (72:17): [True: 1.37k, False: 1.17M]
  |  Branch (72:56): [True: 132, False: 1.24k]
  ------------------
   73|  1.17M|        }
   74|  21.9M|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  21.9M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 8.96k, False: 12.8k]
  |  |  |  Branch (43:30): [True: 7.54k, False: 5.30k]
  |  |  |  Branch (43:31): [True: 7.54k, False: 5.30k]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  16.5k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 5.44k, False: 11.0k]
  |  |  |  Branch (43:30): [True: 9.06k, False: 1.99k]
  |  |  |  Branch (43:31): [True: 9.06k, False: 1.99k]
  |  |  ------------------
  ------------------
  |  Branch (74:18): [True: 21.8k, False: 21.9M]
  ------------------
   75|  14.5k|            const unsigned int x = (n1 << 4) | n2;
   76|  14.5k|            if (burl_is_unreserved(x)) {
  ------------------
  |  Branch (76:17): [True: 2.91k, False: 11.5k]
  ------------------
   77|  2.91k|                p[j] = x;
   78|  2.91k|            }
   79|  11.5k|            else {
   80|  11.5k|                p[j]   = '%';
   81|  11.5k|                p[++j] = hex_chars_uc[n1]; /*(s[i+1] & 0xdf)*/
   82|  11.5k|                p[++j] = hex_chars_uc[n2]; /*(s[i+2] & 0xdf)*/
   83|  11.5k|                invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  11.5k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  11.5k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 5.09k, False: 6.50k]
  |  |  |  |  ------------------
  |  |  |  |  261|  11.5k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 341, False: 6.15k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   84|  11.5k|            }
   85|  14.5k|            i+=2;
   86|  14.5k|        }
   87|  21.9M|        else if (s[i] == '#') break; /* ignore fragment */
  ------------------
  |  Branch (87:18): [True: 8, False: 21.9M]
  ------------------
   88|  21.9M|        else {
   89|  21.9M|            p[j]   = '%';
   90|  21.9M|            p[++j] = hex_chars_uc[(s[i] >> 4) & 0xF];
   91|  21.9M|            p[++j] = hex_chars_uc[s[i] & 0xF];
   92|  21.9M|            invalid_utf8 |= li_utf8_invalid_byte(s[i]);
  ------------------
  |  |   49|  21.9M|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  21.9M|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 316k, False: 21.6M]
  |  |  |  |  ------------------
  |  |  |  |  261|  21.9M|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 1.91k, False: 21.6M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   93|  21.9M|        }
   94|  23.1M|    }
   95|    593|    buffer_copy_string_len(b, (char *)p, (size_t)j);
   96|    593|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (96:12): [True: 408, False: 185]
  ------------------
   97|    593|}
burl.c:burl_scan_qmark:
  337|    440|static int burl_scan_qmark (const buffer * const b) {
  338|    440|    const char * const qmark = strchr(b->ptr, '?');
  339|    440|    return qmark ? (int)(qmark - b->ptr) : -1;
  ------------------
  |  Branch (339:12): [True: 237, False: 203]
  ------------------
  340|    440|}
burl.c:burl_contains_ctrls:
  215|    367|{
  216|    367|    const char * const s = b->ptr;
  217|    367|    const int used = (int)buffer_clen(b);
  218|  11.6M|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (218:21): [True: 11.6M, False: 268]
  ------------------
  219|  11.6M|        if (s[i] == '%' && (s[i+1] < '2' || (s[i+1] == '7' && s[i+2] == 'F')))
  ------------------
  |  Branch (219:13): [True: 3.67M, False: 7.92M]
  |  Branch (219:29): [True: 91, False: 3.67M]
  |  Branch (219:46): [True: 564, False: 3.67M]
  |  Branch (219:63): [True: 8, False: 556]
  ------------------
  220|     99|            return 1;
  221|  11.6M|    }
  222|    268|    return 0;
  223|    367|}
burl.c:burl_normalize_2F_to_slash:
  282|  1.25k|{
  283|       |    /*("%2F" must already have been uppercased during normalization)*/
  284|  1.25k|    const char * const s = b->ptr;
  285|  1.25k|    const int used = qs < 0 ? (int)buffer_clen(b) : qs;
  ------------------
  |  Branch (285:22): [True: 744, False: 509]
  ------------------
  286|  79.0M|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (286:21): [True: 79.0M, False: 1.09k]
  ------------------
  287|  79.0M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == 'F') {
  ------------------
  |  Branch (287:13): [True: 26.2M, False: 52.7M]
  |  Branch (287:28): [True: 6.04k, False: 26.2M]
  |  Branch (287:45): [True: 158, False: 5.89k]
  ------------------
  288|    158|            return !(flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)
  ------------------
  |  Branch (288:20): [True: 146, False: 12]
  ------------------
  289|    158|              ? burl_normalize_2F_to_slash_fix(b, qs, i)     /* _DECODE */
  290|    158|              : -2; /*(flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)*/
  291|    158|        }
  292|  79.0M|    }
  293|  1.09k|    return qs;
  294|  1.25k|}
burl.c:burl_normalize_2F_to_slash_fix:
  258|    146|{
  259|    146|    char * const s = b->ptr;
  260|    146|    const int blen = (int)buffer_clen(b);
  261|    146|    const int used = qs < 0 ? blen : qs;
  ------------------
  |  Branch (261:22): [True: 84, False: 62]
  ------------------
  262|    146|    int j = i;
  263|  9.48M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (263:12): [True: 9.48M, False: 146]
  ------------------
  264|  9.48M|        s[j] = s[i];
  265|  9.48M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == 'F') {
  ------------------
  |  Branch (265:13): [True: 3.15M, False: 6.33M]
  |  Branch (265:28): [True: 4.92k, False: 3.14M]
  |  Branch (265:45): [True: 1.48k, False: 3.44k]
  ------------------
  266|  1.48k|            s[j] = '/';
  267|  1.48k|            i+=2;
  268|  1.48k|        }
  269|  9.48M|    }
  270|    146|    if (qs >= 0) {
  ------------------
  |  Branch (270:9): [True: 62, False: 84]
  ------------------
  271|     62|        const int qslen = blen - qs;
  272|     62|        memmove(s+j, s+qs, (size_t)qslen);
  273|     62|        qs = j;
  274|     62|        j += qslen;
  275|     62|    }
  276|    146|    buffer_truncate(b, j);
  277|    146|    return qs;
  278|    146|}
burl.c:burl_normalize_path:
  298|  1.21k|{
  299|  1.21k|    const unsigned char * const s = (unsigned char *)b->ptr;
  300|  1.21k|    const int used = (int)buffer_clen(b);
  301|  1.21k|    int path_simplify = 0;
  302|  5.36k|    for (int i = 0, len = qs < 0 ? used : qs; i < len; ++i) {
  ------------------
  |  Branch (302:27): [True: 727, False: 483]
  |  Branch (302:47): [True: 4.55k, False: 816]
  ------------------
  303|  4.55k|        if (s[i] == '.' && (s[i+1] != '.' || ++i)
  ------------------
  |  Branch (303:13): [True: 2.48k, False: 2.06k]
  |  Branch (303:29): [True: 1.29k, False: 1.19k]
  |  Branch (303:46): [True: 1.19k, False: 0]
  ------------------
  304|  2.48k|            && (s[i+1] == '/' || s[i+1] == '?' || s[i+1] == '\0')) {
  ------------------
  |  Branch (304:17): [True: 83, False: 2.40k]
  |  Branch (304:34): [True: 60, False: 2.34k]
  |  Branch (304:51): [True: 90, False: 2.25k]
  ------------------
  305|    233|            path_simplify = 1;
  306|    233|            break;
  307|    233|        }
  308|  68.7M|        while (i < len && s[i] != '/') ++i;
  ------------------
  |  Branch (308:16): [True: 68.7M, False: 652]
  |  Branch (308:27): [True: 68.7M, False: 3.66k]
  ------------------
  309|  4.31k|        if (s[i] == '/' && s[i+1] == '/') { /*(s[len] != '/')*/
  ------------------
  |  Branch (309:13): [True: 3.66k, False: 652]
  |  Branch (309:28): [True: 161, False: 3.50k]
  ------------------
  310|    161|            path_simplify = 1;
  311|    161|            break;
  312|    161|        }
  313|  4.31k|    }
  314|       |
  315|  1.21k|    if (path_simplify) {
  ------------------
  |  Branch (315:9): [True: 394, False: 816]
  ------------------
  316|    394|        if (flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT) return -2;
  ------------------
  |  Branch (316:13): [True: 12, False: 382]
  ------------------
  317|    382|        if (qs >= 0) {
  ------------------
  |  Branch (317:13): [True: 144, False: 238]
  ------------------
  318|    144|            buffer_copy_string_len(t, b->ptr+qs, used - qs);
  319|    144|            buffer_truncate(b, qs);
  320|    144|        }
  321|       |
  322|    382|        buffer_path_simplify(b);
  323|       |
  324|    382|        if (qs >= 0) {
  ------------------
  |  Branch (324:13): [True: 144, False: 238]
  ------------------
  325|    144|            qs = (int)buffer_clen(b);
  326|    144|            buffer_append_string_len(b, BUF_PTR_LEN(t));
  ------------------
  |  |  297|    144|#define BUF_PTR_LEN(x)       (x)->ptr, buffer_clen(x)
  ------------------
  327|    144|        }
  328|    382|    }
  329|       |
  330|  1.19k|    return qs;
  331|  1.21k|}
burl.c:burl_normalize_qs20_to_plus:
  244|    460|{
  245|    460|    const char * const s = b->ptr;
  246|    460|    const int used = qs < 0 ? 0 : (int)buffer_clen(b);
  ------------------
  |  Branch (246:22): [True: 0, False: 460]
  ------------------
  247|    460|    int i;
  248|    460|    if (qs < 0) return;
  ------------------
  |  Branch (248:9): [True: 0, False: 460]
  ------------------
  249|  9.77M|    for (i = qs+1; i < used; ++i) {
  ------------------
  |  Branch (249:20): [True: 9.77M, False: 321]
  ------------------
  250|  9.77M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == '0') break;
  ------------------
  |  Branch (250:13): [True: 3.24M, False: 6.52M]
  |  Branch (250:28): [True: 3.45k, False: 3.23M]
  |  Branch (250:45): [True: 139, False: 3.31k]
  ------------------
  251|  9.77M|    }
  252|    460|    if (i != used) burl_normalize_qs20_to_plus_fix(b, i);
  ------------------
  |  Branch (252:9): [True: 139, False: 321]
  ------------------
  253|    460|}
burl.c:burl_normalize_qs20_to_plus_fix:
  228|    139|{
  229|    139|    char * const s = b->ptr;
  230|    139|    const int used = (int)buffer_clen(b);
  231|    139|    int j = i;
  232|  10.9M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (232:12): [True: 10.9M, False: 139]
  ------------------
  233|  10.9M|        s[j] = s[i];
  234|  10.9M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == '0') {
  ------------------
  |  Branch (234:13): [True: 3.56M, False: 7.37M]
  |  Branch (234:28): [True: 5.85k, False: 3.56M]
  |  Branch (234:45): [True: 1.39k, False: 4.45k]
  ------------------
  235|  1.39k|            s[j] = '+';
  236|  1.39k|            i+=2;
  237|  1.39k|        }
  238|  10.9M|    }
  239|    139|    buffer_truncate(b, j);
  240|    139|}

