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

buffer_init:
   14|  3.31k|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.31k|	buffer * const b = calloc(1, sizeof(*b));
   20|  3.31k|	force_assert(b);
  ------------------
  |  |  448|  3.31k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.31k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.31k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.31k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   21|  3.31k|	return b;
   22|  3.31k|  #endif
   23|  3.31k|}
buffer_free:
   25|  3.31k|void buffer_free(buffer *b) {
   26|  3.31k|	if (NULL == b) return;
  ------------------
  |  Branch (26:6): [True: 0, False: 3.31k]
  ------------------
   27|  3.31k|	free(b->ptr);
   28|  3.31k|	free(b);
   29|  3.31k|}
buffer_string_prepare_copy:
   82|  1.25k|char* buffer_string_prepare_copy(buffer * const b, const size_t size) {
   83|  1.25k|    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.25k|    return (size < b->size)
  ------------------
  |  Branch (87:12): [True: 0, False: 1.25k]
  ------------------
   88|  1.25k|      ? b->ptr
   89|  1.25k|      : buffer_alloc_replace(b, size);
   90|  1.25k|}
buffer_extend:
  127|    152|{
  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|    152|    const uint32_t len = b->used ? b->used-1 : 0;
  ------------------
  |  Branch (136:26): [True: 152, False: 0]
  ------------------
  137|    152|    char * const s = (b->size - len >= x + 1)
  ------------------
  |  Branch (137:22): [True: 152, False: 0]
  ------------------
  138|    152|      ? b->ptr + len
  139|    152|      : buffer_string_prepare_append_resize(b, x);
  140|    152|    b->used = len+x+1;
  141|    152|  #endif
  142|    152|    s[x] = '\0';
  143|    152|    return s;
  144|    152|}
buffer_copy_string_len:
  172|  3.06k|void buffer_copy_string_len(buffer * const restrict b, const char * const restrict s, const size_t len) {
  173|  3.06k|    b->used = len + 1;
  174|  3.06k|    char * const restrict d = (len < b->size)
  ------------------
  |  Branch (174:31): [True: 935, False: 2.12k]
  ------------------
  175|  3.06k|      ? b->ptr
  176|  3.06k|      : buffer_alloc_replace(b, len);
  177|  3.06k|    d[len] = '\0';
  178|  3.06k|    memcpy(d, s, len);
  179|  3.06k|}
buffer_append_string_len:
  198|    152|void buffer_append_string_len(buffer * const restrict b, const char * const restrict s, const size_t len) {
  199|    152|    memcpy(buffer_extend(b, len), s, len);
  200|    152|}
hex2int:
  386|  97.5M|char hex2int(unsigned char hex) {
  387|  97.5M|	unsigned char n;
  388|  97.5M|	return li_cton(hex,n) ? (char)n : 0xFF;
  ------------------
  |  |  381|  97.5M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (381:4): [True: 86.6M, False: 10.8M]
  |  |  |  Branch (381:30): [True: 10.8M, False: 0]
  |  |  |  Branch (381:31): [True: 10.8M, False: 0]
  |  |  ------------------
  ------------------
  389|  97.5M|}
buffer_urldecode_path:
  792|  1.65k|void buffer_urldecode_path(buffer * const b) {
  793|  1.65k|    const size_t len = buffer_clen(b);
  794|  1.65k|    char *src = len ? memchr(b->ptr, '%', len) : NULL;
  ------------------
  |  Branch (794:17): [True: 1.65k, False: 6]
  ------------------
  795|  1.65k|    if (NULL == src) return;
  ------------------
  |  Branch (795:9): [True: 359, False: 1.29k]
  ------------------
  796|       |
  797|  1.29k|    char *dst = src;
  798|  48.7M|    do {
  799|       |        /* *src == '%' */
  800|  48.7M|        unsigned char high = ((unsigned char *)src)[1];
  801|  48.7M|        unsigned char low = high ? hex2int(((unsigned char *)src)[2]) : 0xFF;
  ------------------
  |  Branch (801:29): [True: 48.7M, False: 0]
  ------------------
  802|  48.7M|        if (0xFF != (high = hex2int(high)) && 0xFF != low) {
  ------------------
  |  Branch (802:13): [True: 48.7M, False: 0]
  |  Branch (802:47): [True: 48.7M, False: 0]
  ------------------
  803|  48.7M|            high = (high << 4) | low;   /* map ctrls to '_' */
  804|  48.7M|            *dst = (high >= 32 && high != 127) ? high : '_';
  ------------------
  |  Branch (804:21): [True: 8.97M, False: 39.7M]
  |  Branch (804:35): [True: 7.94M, False: 1.02M]
  ------------------
  805|  48.7M|            src += 2;
  806|  48.7M|        } /* else ignore this '%'; leave as-is and move on */
  807|       |
  808|  51.8M|        while ((*++dst = *++src) != '%' && *src) ;
  ------------------
  |  Branch (808:16): [True: 3.08M, False: 48.7M]
  |  Branch (808:44): [True: 3.08M, False: 1.29k]
  ------------------
  809|  48.7M|    } while (*src);
  ------------------
  |  Branch (809:14): [True: 48.7M, False: 1.29k]
  ------------------
  810|  1.29k|    b->used = (dst - b->ptr) + 1;
  811|  1.29k|}
buffer_path_simplify:
  864|    388|{
  865|    388|    char *out = b->ptr;
  866|    388|    char * const end = b->ptr + b->used - 1;
  867|       |
  868|    388|    if (__builtin_expect( (buffer_is_blank(b)), 0)) {
  ------------------
  |  Branch (868:9): [True: 0, False: 388]
  ------------------
  869|      0|        buffer_blank(b);
  870|      0|        return;
  871|      0|    }
  872|       |
  873|       |  #if defined(_WIN32) || defined(__CYGWIN__)
  874|       |    /* cygwin is treating \ and / the same, so we have to that too */
  875|       |    for (char *p = b->ptr; *p; p++) {
  876|       |        if (*p == '\\') *p = '/';
  877|       |    }
  878|       |  #endif
  879|       |
  880|    388|    *end = '/'; /*(end of path modified to avoid need to check '\0')*/
  881|       |
  882|    388|    char *walk = out;
  883|    388|    if (__builtin_expect( (*walk == '/'), 1)) {
  ------------------
  |  Branch (883:9): [True: 135, False: 253]
  ------------------
  884|       |        /* scan to detect (potential) need for path simplification
  885|       |         * (repeated '/' or "/.") */
  886|    494|        do {
  887|    494|            if (*++walk == '.' || *walk == '/')
  ------------------
  |  Branch (887:17): [True: 77, False: 417]
  |  Branch (887:35): [True: 58, False: 359]
  ------------------
  888|    135|                break;
  889|  1.05M|            do { ++walk; } while (*walk != '/');
  ------------------
  |  Branch (889:35): [True: 1.05M, False: 359]
  ------------------
  890|    359|        } while (walk != end);
  ------------------
  |  Branch (890:18): [True: 359, False: 0]
  ------------------
  891|    135|        if (__builtin_expect( (walk == end), 1)) {
  ------------------
  |  Branch (891:13): [True: 0, False: 135]
  ------------------
  892|       |            /* common case: no repeated '/' or "/." */
  893|      0|            *end = '\0'; /* overwrite extra '/' added to end of path */
  894|      0|            return;
  895|      0|        }
  896|    135|        out = walk-1;
  897|    135|    }
  898|    253|    else {
  899|    253|        if (walk[0] == '.' && walk[1] == '/')
  ------------------
  |  Branch (899:13): [True: 140, False: 113]
  |  Branch (899:31): [True: 74, False: 66]
  ------------------
  900|     74|            *out = *++walk;
  901|    179|        else if (walk[0] == '.' && walk[1] == '.' && walk[2] == '/')
  ------------------
  |  Branch (901:18): [True: 66, False: 113]
  |  Branch (901:36): [True: 19, False: 47]
  |  Branch (901:54): [True: 3, False: 16]
  ------------------
  902|      3|            *out = *(walk += 2);
  903|    176|        else {
  904|  12.8M|            while (*++walk != '/') ;
  ------------------
  |  Branch (904:20): [True: 12.8M, False: 176]
  ------------------
  905|    176|            out = walk;
  906|    176|        }
  907|    253|        ++walk;
  908|    253|    }
  909|       |
  910|  5.59k|    while (walk <= end) {
  ------------------
  |  Branch (910:12): [True: 5.36k, False: 227]
  ------------------
  911|       |        /* previous char is '/' at this point (or start of string w/o '/') */
  912|  5.36k|        if (__builtin_expect( (walk[0] == '/'), 0)) {
  ------------------
  |  Branch (912:13): [True: 1.12k, False: 4.24k]
  ------------------
  913|       |            /* skip repeated '/' (e.g. "///" -> "/") */
  914|  1.12k|            if (++walk < end)
  ------------------
  |  Branch (914:17): [True: 1.06k, False: 60]
  ------------------
  915|  1.06k|                continue;
  916|     60|            else {
  917|     60|                ++out;
  918|     60|                break;
  919|     60|            }
  920|  1.12k|        }
  921|  4.24k|        else if (__builtin_expect( (walk[0] == '.'), 0)) {
  ------------------
  |  Branch (921:18): [True: 3.27k, False: 969]
  ------------------
  922|       |            /* handle "./" and "../" */
  923|  3.27k|            if (walk[1] == '.' && walk[2] == '/') {
  ------------------
  |  Branch (923:17): [True: 2.11k, False: 1.15k]
  |  Branch (923:35): [True: 659, False: 1.46k]
  ------------------
  924|       |                /* handle "../" */
  925|  6.72M|                while (out > b->ptr && *--out != '/') ;
  ------------------
  |  Branch (925:24): [True: 6.72M, False: 543]
  |  Branch (925:40): [True: 6.72M, False: 116]
  ------------------
  926|    659|                *out = '/'; /*(in case path had not started with '/')*/
  927|    659|                if ((walk += 3) >= end) {
  ------------------
  |  Branch (927:21): [True: 47, False: 612]
  ------------------
  928|     47|                    ++out;
  929|     47|                    break;
  930|     47|                }
  931|    612|                else
  932|    612|                continue;
  933|    659|            }
  934|  2.61k|            else if (walk[1] == '/') {
  ------------------
  |  Branch (934:22): [True: 619, False: 1.99k]
  ------------------
  935|       |                /* handle "./" */
  936|    619|                if ((walk += 2) >= end) {
  ------------------
  |  Branch (936:21): [True: 54, False: 565]
  ------------------
  937|     54|                    ++out;
  938|     54|                    break;
  939|     54|                }
  940|    565|                continue;
  941|    619|            }
  942|  1.99k|            else {
  943|       |                /* accept "." if not part of "../" or "./" */
  944|  1.99k|                *++out = '.';
  945|  1.99k|                ++walk;
  946|  1.99k|            }
  947|  3.27k|        }
  948|       |
  949|  23.8M|        while ((*++out = *walk++) != '/') ;
  ------------------
  |  Branch (949:16): [True: 23.8M, False: 2.96k]
  ------------------
  950|  2.96k|    }
  951|    388|    *out = *end = '\0'; /* overwrite extra '/' added to end of path */
  952|    388|    b->used = (out - b->ptr) + 1;
  953|       |    /*buffer_truncate(b, out - b->ptr);*/
  954|    388|}
buffer.c:buffer_alloc_replace:
   71|  3.38k|static char* buffer_alloc_replace(buffer * const restrict b, const size_t size) {
   72|       |    /*(discard old data so realloc() does not copy)*/
   73|  3.38k|    if (NULL != b->ptr) {
  ------------------
  |  Branch (73:9): [True: 464, False: 2.92k]
  ------------------
   74|    464|        free(b->ptr);
   75|    464|        b->ptr = NULL;
   76|    464|    }
   77|       |    /*(note: if size larger than one lshift, use size instead of power-2)*/
   78|  3.38k|    const size_t bsize2x = (b->size & ~1uL) << 1;
   79|  3.38k|    return buffer_realloc(b, bsize2x > size ? bsize2x-1 : size);
  ------------------
  |  Branch (79:30): [True: 222, False: 3.16k]
  ------------------
   80|  3.38k|}
buffer.c:buffer_realloc:
   49|  3.38k|static char* buffer_realloc(buffer * const restrict b, const size_t len) {
   50|  3.38k|    #define BUFFER_PIECE_SIZE 64uL  /*(must be power-of-2)*/
   51|  3.38k|    size_t sz = (len + 1 + BUFFER_PIECE_SIZE-1) & ~(BUFFER_PIECE_SIZE-1);
  ------------------
  |  |   50|  3.38k|    #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.38k|    #define BUFFER_PIECE_SIZE 64uL  /*(must be power-of-2)*/
  ------------------
   52|  3.38k|    force_assert(sz > len);
  ------------------
  |  |  448|  3.38k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.38k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.38k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.38k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   53|  3.38k|    if ((sz & (sz-1)) && sz < INT_MAX) {/* not power-2; huge val not expected */
  ------------------
  |  Branch (53:9): [True: 1.15k, False: 2.22k]
  |  Branch (53:26): [True: 1.15k, False: 0]
  ------------------
   54|       |        /*(optimizer should recognize this and use ffs or clz or equivalent)*/
   55|  1.15k|        const size_t psz = sz;
   56|  8.02k|        for (sz = 256; sz < psz; sz <<= 1) ;
  ------------------
  |  Branch (56:24): [True: 6.86k, False: 1.15k]
  ------------------
   57|  1.15k|    }
   58|  3.38k|    sz |= 1; /*(extra +1 for '\0' when needed buffer size is exact power-2)*/
   59|       |
   60|  3.38k|    b->size = sz;
   61|  3.38k|    b->ptr = realloc(b->ptr, sz);
   62|       |
   63|  3.38k|    force_assert(NULL != b->ptr);
  ------------------
  |  |  448|  3.38k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.38k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.38k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.38k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   64|  3.38k|    return b->ptr;
   65|  3.38k|}

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

burl_normalize:
  338|  1.65k|{
  339|  1.65k|    int qs;
  340|       |
  341|       |  #if defined(_WIN32) || defined(__CYGWIN__)
  342|       |    /* Windows and Cygwin treat '\\' as '/' if '\\' is present in path;
  343|       |     * convert to '/' for consistency before percent-encoding
  344|       |     * normalization which will convert '\\' to "%5C" in the URL.
  345|       |     * (Clients still should not be sending '\\' unencoded in requests.) */
  346|       |    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_BACKSLASH_TRANS) {
  347|       |        for (char *p = b->ptr; *p != '?' && *p != '\0'; ++p) {
  348|       |            if (*p == '\\') *p = '/';
  349|       |        }
  350|       |    }
  351|       |  #endif
  352|       |
  353|  1.65k|    qs = (flags & HTTP_PARSEOPT_URL_NORMALIZE_REQUIRED)
  ------------------
  |  Branch (353:10): [True: 889, False: 767]
  ------------------
  354|  1.65k|      ? burl_normalize_basic_required(b, t)
  355|  1.65k|      : burl_normalize_basic_unreserved(b, t);
  356|  1.65k|    if (-2 == qs) {
  ------------------
  |  Branch (356:9): [True: 458, False: 1.19k]
  ------------------
  357|    458|        if (flags & HTTP_PARSEOPT_URL_NORMALIZE_INVALID_UTF8_REJECT) return -2;
  ------------------
  |  Branch (357:13): [True: 112, False: 346]
  ------------------
  358|    346|        qs = burl_scan_qmark(b);
  359|    346|    }
  360|       |
  361|  1.54k|    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_CTRLS_REJECT) {
  ------------------
  |  Branch (361:9): [True: 342, False: 1.20k]
  ------------------
  362|    342|        if (burl_contains_ctrls(b)) return -2;
  ------------------
  |  Branch (362:13): [True: 101, False: 241]
  ------------------
  363|    342|    }
  364|       |
  365|  1.44k|    if (flags & (HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_DECODE
  ------------------
  |  Branch (365:9): [True: 1.18k, False: 259]
  ------------------
  366|  1.44k|                |HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)) {
  367|  1.18k|        qs = burl_normalize_2F_to_slash(b, qs, flags);
  368|  1.18k|        if (-2 == qs) return -2;
  ------------------
  |  Branch (368:13): [True: 11, False: 1.17k]
  ------------------
  369|  1.18k|    }
  370|       |
  371|  1.43k|    if (flags & (HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REMOVE
  ------------------
  |  Branch (371:9): [True: 1.15k, False: 274]
  ------------------
  372|  1.43k|                |HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT)) {
  373|  1.15k|        qs = burl_normalize_path(b, t, qs, flags);
  374|  1.15k|        if (-2 == qs) return -2;
  ------------------
  |  Branch (374:13): [True: 16, False: 1.14k]
  ------------------
  375|  1.15k|    }
  376|       |
  377|  1.41k|    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_QUERY_20_PLUS) {
  ------------------
  |  Branch (377:9): [True: 845, False: 571]
  ------------------
  378|    845|        if (qs >= 0) burl_normalize_qs20_to_plus(b, qs);
  ------------------
  |  Branch (378:13): [True: 405, False: 440]
  ------------------
  379|    845|    }
  380|       |
  381|  1.41k|    return qs;
  382|  1.43k|}
burl.c:burl_normalize_basic_required:
  175|    889|{
  176|    889|    const unsigned char * const s = (unsigned char *)b->ptr;
  177|    889|    const int used = (int)buffer_clen(b);
  178|    889|    unsigned int n1, n2, x;
  179|    889|    int qs = -1;
  180|    889|    int invalid_utf8 = 0;
  181|       |
  182|   847k|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (182:21): [True: 847k, False: 211]
  ------------------
  183|   847k|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (183:13): [True: 780k, False: 66.6k]
  ------------------
  184|   780k|            if (s[i] == '?') qs = i;
  ------------------
  |  Branch (184:17): [True: 54.2k, False: 726k]
  ------------------
  185|   780k|        }
  186|  66.6k|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|   132k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 62.6k, False: 3.54k]
  |  |  |  Branch (43:30): [True: 3.46k, False: 78]
  |  |  |  Branch (43:31): [True: 3.46k, False: 78]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|   132k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 39.2k, False: 26.9k]
  |  |  |  Branch (43:30): [True: 26.8k, False: 56]
  |  |  |  Branch (43:31): [True: 26.8k, False: 56]
  |  |  ------------------
  ------------------
  |  Branch (186:18): [True: 66.2k, False: 479]
  ------------------
  187|  66.0k|                 && (encoded_chars_http_uri_reqd[(x = (n1 << 4) | n2)]
  ------------------
  |  Branch (187:22): [True: 11.0k, False: 54.9k]
  ------------------
  188|  54.9k|                     || (qs < 0
  ------------------
  |  Branch (188:25): [True: 54.9k, False: 65]
  |  Branch (188:26): [True: 862, False: 54.1k]
  ------------------
  189|  54.9k|                         ? (x == '/' || x == '?')
  ------------------
  |  Branch (189:29): [True: 620, False: 242]
  |  Branch (189:41): [True: 212, False: 30]
  ------------------
  190|  66.0k|                         : (x == '&' || x == '=' || x == ';' || x == '+')))) {
  ------------------
  |  Branch (190:29): [True: 30.0k, False: 24.0k]
  |  Branch (190:41): [True: 14.6k, False: 9.41k]
  |  Branch (190:53): [True: 3.07k, False: 6.34k]
  |  Branch (190:65): [True: 6.30k, False: 35]
  ------------------
  191|  66.0k|            invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  66.0k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  66.0k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 324, False: 65.6k]
  |  |  |  |  ------------------
  |  |  |  |  261|  66.0k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 290, False: 65.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  192|  66.0k|            if (s[i+1] >= 'a') b->ptr[i+1] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (192:17): [True: 715, False: 65.2k]
  ------------------
  193|  66.0k|            if (s[i+2] >= 'a') b->ptr[i+2] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (193:17): [True: 9.96k, False: 56.0k]
  ------------------
  194|  66.0k|            i+=2;
  195|  66.0k|        }
  196|    678|        else if (s[i] == '#') { /* ignore fragment */
  ------------------
  |  Branch (196:18): [True: 1, False: 677]
  ------------------
  197|      1|            buffer_truncate(b, (size_t)i);
  198|      1|            break;
  199|      1|        }
  200|    677|        else {
  201|    677|            qs = burl_normalize_basic_required_fix(b, t, i, qs);
  202|    677|            break;
  203|    677|        }
  204|   847k|    }
  205|       |
  206|    889|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (206:12): [True: 865, False: 24]
  ------------------
  207|    889|}
burl.c:burl_normalize_basic_required_fix:
  131|    677|{
  132|    677|    int j = i;
  133|    677|    const int used = (int)buffer_clen(b);
  134|    677|    const unsigned char * const s = (unsigned char *)b->ptr;
  135|    677|    unsigned char * const p =
  136|    677|      (unsigned char *)buffer_string_prepare_copy(t,i+(used-i)*3+1);
  137|    677|    unsigned int n1, n2;
  138|    677|    int invalid_utf8 = 0;
  139|    677|    memcpy(p, s, (size_t)i);
  140|  26.6M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (140:12): [True: 26.6M, False: 665]
  ------------------
  141|  26.6M|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (141:13): [True: 573k, False: 26.0M]
  ------------------
  142|   573k|            p[j] = s[i];
  143|   573k|            if (__builtin_expect( (s[i] == '?'), 0)) qs = j;
  ------------------
  |  Branch (143:17): [True: 9.06k, False: 564k]
  ------------------
  144|   573k|        }
  145|  26.0M|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  26.0M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 15.6k, False: 19.5k]
  |  |  |  Branch (43:30): [True: 3.83k, False: 15.7k]
  |  |  |  Branch (43:31): [True: 3.83k, False: 15.7k]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  19.5k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 9.46k, False: 10.0k]
  |  |  |  Branch (43:30): [True: 8.20k, False: 1.83k]
  |  |  |  Branch (43:31): [True: 8.20k, False: 1.83k]
  |  |  ------------------
  ------------------
  |  Branch (145:18): [True: 35.2k, False: 26.0M]
  ------------------
  146|  17.6k|            const unsigned int x = (n1 << 4) | n2;
  147|  17.6k|            if (!encoded_chars_http_uri_reqd[x]
  ------------------
  |  Branch (147:17): [True: 12.2k, False: 5.44k]
  ------------------
  148|  12.2k|                && (qs < 0
  ------------------
  |  Branch (148:20): [True: 2.04k, False: 10.1k]
  |  Branch (148:21): [True: 1.36k, False: 10.8k]
  ------------------
  149|  12.2k|                    ? (x != '/' && x != '?')
  ------------------
  |  Branch (149:24): [True: 909, False: 457]
  |  Branch (149:36): [True: 663, False: 246]
  ------------------
  150|  12.2k|                    : (x != '&' && x != '=' && x != ';' && x != '+'))) {
  ------------------
  |  Branch (150:24): [True: 5.93k, False: 4.92k]
  |  Branch (150:36): [True: 3.49k, False: 2.44k]
  |  Branch (150:48): [True: 2.72k, False: 769]
  |  Branch (150:60): [True: 1.38k, False: 1.33k]
  ------------------
  151|  2.04k|                p[j] = x;
  152|  2.04k|            }
  153|  15.6k|            else {
  154|  15.6k|                p[j]   = '%';
  155|  15.6k|                p[++j] = hex_chars_uc[n1]; /*(s[i+1] & 0xdf)*/
  156|  15.6k|                p[++j] = hex_chars_uc[n2]; /*(s[i+2] & 0xdf)*/
  157|  15.6k|                invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  15.6k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  15.6k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 1.21k, False: 14.4k]
  |  |  |  |  ------------------
  |  |  |  |  261|  15.6k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 247, False: 14.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  158|  15.6k|            }
  159|  17.6k|            i+=2;
  160|  17.6k|        }
  161|  26.0M|        else if (s[i] == '#') break; /* ignore fragment */
  ------------------
  |  Branch (161:18): [True: 12, False: 26.0M]
  ------------------
  162|  26.0M|        else {
  163|  26.0M|            p[j]   = '%';
  164|  26.0M|            p[++j] = hex_chars_uc[(s[i] >> 4) & 0xF];
  165|  26.0M|            p[++j] = hex_chars_uc[s[i] & 0xF];
  166|  26.0M|            invalid_utf8 |= li_utf8_invalid_byte(s[i]);
  ------------------
  |  |   49|  26.0M|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  26.0M|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 1.87M, False: 24.1M]
  |  |  |  |  ------------------
  |  |  |  |  261|  26.0M|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 790, False: 24.1M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  167|  26.0M|        }
  168|  26.6M|    }
  169|    677|    buffer_copy_string_len(b, (char *)p, (size_t)j);
  170|    677|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (170:12): [True: 448, False: 229]
  ------------------
  171|    677|}
burl.c:burl_normalize_basic_unreserved:
   99|    767|{
  100|    767|    const unsigned char * const s = (unsigned char *)b->ptr;
  101|    767|    const int used = (int)buffer_clen(b);
  102|    767|    unsigned int n1, n2, x;
  103|    767|    int qs = -1;
  104|       |
  105|   590k|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (105:21): [True: 590k, False: 187]
  ------------------
  106|   590k|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (106:13): [True: 587k, False: 3.05k]
  ------------------
  107|   587k|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = i;
  ------------------
  |  Branch (107:17): [True: 1.12k, False: 586k]
  |  Branch (107:56): [True: 78, False: 1.05k]
  ------------------
  108|   587k|        }
  109|  3.05k|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  5.69k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 1.71k, False: 928]
  |  |  |  Branch (43:30): [True: 865, False: 63]
  |  |  |  Branch (43:31): [True: 865, False: 63]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  5.63k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 1.34k, False: 1.23k]
  |  |  |  Branch (43:30): [True: 1.18k, False: 50]
  |  |  |  Branch (43:31): [True: 1.18k, False: 50]
  |  |  ------------------
  ------------------
  |  Branch (109:18): [True: 2.64k, False: 414]
  ------------------
  110|  2.52k|                 && !burl_is_unreserved((x = (n1 << 4) | n2))) {
  ------------------
  |  Branch (110:21): [True: 2.47k, False: 53]
  ------------------
  111|  2.47k|            if (li_utf8_invalid_byte(x)) qs = -2;
  ------------------
  |  |   49|  2.47k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  2.47k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 262, False: 2.21k]
  |  |  |  |  ------------------
  |  |  |  |  261|  2.47k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 447, False: 1.76k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  112|  2.47k|            if (s[i+1] >= 'a') b->ptr[i+1] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (112:17): [True: 739, False: 1.73k]
  ------------------
  113|  2.47k|            if (s[i+2] >= 'a') b->ptr[i+2] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (113:17): [True: 717, False: 1.75k]
  ------------------
  114|  2.47k|            i+=2;
  115|  2.47k|        }
  116|    580|        else if (s[i] == '#') { /* ignore fragment */
  ------------------
  |  Branch (116:18): [True: 1, False: 579]
  ------------------
  117|      1|            buffer_truncate(b, (size_t)i);
  118|      1|            break;
  119|      1|        }
  120|    579|        else {
  121|    579|            qs = burl_normalize_basic_unreserved_fix(b, t, i, qs);
  122|    579|            break;
  123|    579|        }
  124|   590k|    }
  125|       |
  126|    767|    return qs;
  127|    767|}
burl.c:burl_is_unreserved:
   53|  13.0k|{
   54|  13.0k|    return (light_isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~');
  ------------------
  |  Branch (54:13): [True: 810, False: 12.2k]
  |  Branch (54:33): [True: 302, False: 11.9k]
  |  Branch (54:45): [True: 657, False: 11.3k]
  |  Branch (54:57): [True: 249, False: 11.0k]
  |  Branch (54:69): [True: 211, False: 10.8k]
  ------------------
   55|  13.0k|}
burl.c:burl_normalize_basic_unreserved_fix:
   59|    579|{
   60|    579|    int j = i;
   61|    579|    const int used = (int)buffer_clen(b);
   62|    579|    const unsigned char * const s = (unsigned char *)b->ptr;
   63|    579|    unsigned char * const p =
   64|    579|      (unsigned char *)buffer_string_prepare_copy(t,i+(used-i)*3+1);
   65|    579|    unsigned int n1, n2;
   66|    579|    memcpy(p, s, (size_t)i);
   67|  26.2M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (67:12): [True: 26.2M, False: 573]
  ------------------
   68|  26.2M|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (68:13): [True: 1.33M, False: 24.8M]
  ------------------
   69|  1.33M|            p[j] = s[i];
   70|  1.33M|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = j;
  ------------------
  |  Branch (70:17): [True: 1.98k, False: 1.33M]
  |  Branch (70:56): [True: 75, False: 1.91k]
  ------------------
   71|  1.33M|        }
   72|  24.8M|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  24.8M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 6.65k, False: 8.62k]
  |  |  |  Branch (43:30): [True: 5.70k, False: 2.92k]
  |  |  |  Branch (43:31): [True: 5.70k, False: 2.92k]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  12.3k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 5.14k, False: 7.20k]
  |  |  |  Branch (43:30): [True: 5.40k, False: 1.80k]
  |  |  |  Branch (43:31): [True: 5.40k, False: 1.80k]
  |  |  ------------------
  ------------------
  |  Branch (72:18): [True: 15.2k, False: 24.8M]
  ------------------
   73|  10.5k|            const unsigned int x = (n1 << 4) | n2;
   74|  10.5k|            if (burl_is_unreserved(x)) {
  ------------------
  |  Branch (74:17): [True: 2.17k, False: 8.37k]
  ------------------
   75|  2.17k|                p[j] = x;
   76|  2.17k|            }
   77|  8.37k|            else {
   78|  8.37k|                p[j]   = '%';
   79|  8.37k|                p[++j] = hex_chars_uc[n1]; /*(s[i+1] & 0xdf)*/
   80|  8.37k|                p[++j] = hex_chars_uc[n2]; /*(s[i+2] & 0xdf)*/
   81|  8.37k|                if (li_utf8_invalid_byte(x)) qs = -2;
  ------------------
  |  |   49|  8.37k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  8.37k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 3.08k, False: 5.29k]
  |  |  |  |  ------------------
  |  |  |  |  261|  8.37k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 231, False: 5.06k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   82|  8.37k|            }
   83|  10.5k|            i+=2;
   84|  10.5k|        }
   85|  24.8M|        else if (s[i] == '#') break; /* ignore fragment */
  ------------------
  |  Branch (85:18): [True: 6, False: 24.8M]
  ------------------
   86|  24.8M|        else {
   87|  24.8M|            p[j]   = '%';
   88|  24.8M|            p[++j] = hex_chars_uc[(s[i] >> 4) & 0xF];
   89|  24.8M|            p[++j] = hex_chars_uc[s[i] & 0xF];
   90|  24.8M|            if (li_utf8_invalid_byte(s[i])) qs = -2;
  ------------------
  |  |   49|  24.8M|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  24.8M|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 59.9k, False: 24.8M]
  |  |  |  |  ------------------
  |  |  |  |  261|  24.8M|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 1.34k, False: 24.8M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   91|  24.8M|        }
   92|  26.2M|    }
   93|    579|    buffer_copy_string_len(b, (char *)p, (size_t)j);
   94|    579|    return qs;
   95|    579|}
burl.c:burl_scan_qmark:
  331|    346|static int burl_scan_qmark (const buffer * const b) {
  332|    346|    const char * const qmark = strchr(b->ptr, '?');
  333|    346|    return qmark ? (int)(qmark - b->ptr) : -1;
  ------------------
  |  Branch (333:12): [True: 170, False: 176]
  ------------------
  334|    346|}
burl.c:burl_contains_ctrls:
  211|    342|{
  212|    342|    const char * const s = b->ptr;
  213|    342|    const int used = (int)buffer_clen(b);
  214|  7.48M|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (214:21): [True: 7.48M, False: 241]
  ------------------
  215|  7.48M|        if (s[i] == '%' && (s[i+1] < '2' || (s[i+1] == '7' && s[i+2] == 'F')))
  ------------------
  |  Branch (215:13): [True: 2.16M, False: 5.32M]
  |  Branch (215:29): [True: 95, False: 2.16M]
  |  Branch (215:46): [True: 707, False: 2.16M]
  |  Branch (215:63): [True: 6, False: 701]
  ------------------
  216|    101|            return 1;
  217|  7.48M|    }
  218|    241|    return 0;
  219|    342|}
burl.c:burl_normalize_2F_to_slash:
  276|  1.18k|{
  277|       |    /*("%2F" must already have been uppercased during normalization)*/
  278|  1.18k|    const char * const s = b->ptr;
  279|  1.18k|    const int used = qs < 0 ? (int)buffer_clen(b) : qs;
  ------------------
  |  Branch (279:22): [True: 737, False: 447]
  ------------------
  280|  78.4M|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (280:21): [True: 78.4M, False: 1.00k]
  ------------------
  281|  78.4M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == 'F') {
  ------------------
  |  Branch (281:13): [True: 25.8M, False: 52.5M]
  |  Branch (281:28): [True: 41.4k, False: 25.8M]
  |  Branch (281:45): [True: 181, False: 41.2k]
  ------------------
  282|    181|            return (flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_DECODE)
  ------------------
  |  Branch (282:20): [True: 170, False: 11]
  ------------------
  283|    181|              ? burl_normalize_2F_to_slash_fix(b, qs, i)
  284|    181|              : -2; /*(flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)*/
  285|    181|        }
  286|  78.4M|    }
  287|  1.00k|    return qs;
  288|  1.18k|}
burl.c:burl_normalize_2F_to_slash_fix:
  252|    170|{
  253|    170|    char * const s = b->ptr;
  254|    170|    const int blen = (int)buffer_clen(b);
  255|    170|    const int used = qs < 0 ? blen : qs;
  ------------------
  |  Branch (255:22): [True: 108, False: 62]
  ------------------
  256|    170|    int j = i;
  257|  11.9M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (257:12): [True: 11.9M, False: 170]
  ------------------
  258|  11.9M|        s[j] = s[i];
  259|  11.9M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == 'F') {
  ------------------
  |  Branch (259:13): [True: 3.96M, False: 7.94M]
  |  Branch (259:28): [True: 18.0k, False: 3.94M]
  |  Branch (259:45): [True: 1.02k, False: 17.0k]
  ------------------
  260|  1.02k|            s[j] = '/';
  261|  1.02k|            i+=2;
  262|  1.02k|        }
  263|  11.9M|    }
  264|    170|    if (qs >= 0) {
  ------------------
  |  Branch (264:9): [True: 62, False: 108]
  ------------------
  265|     62|        const int qslen = blen - qs;
  266|     62|        memmove(s+j, s+qs, (size_t)qslen);
  267|     62|        qs = j;
  268|     62|        j += qslen;
  269|     62|    }
  270|    170|    buffer_truncate(b, j);
  271|    170|    return qs;
  272|    170|}
burl.c:burl_normalize_path:
  292|  1.15k|{
  293|  1.15k|    const unsigned char * const s = (unsigned char *)b->ptr;
  294|  1.15k|    const int used = (int)buffer_clen(b);
  295|  1.15k|    int path_simplify = 0;
  296|  4.48k|    for (int i = 0, len = qs < 0 ? used : qs; i < len; ++i) {
  ------------------
  |  Branch (296:27): [True: 720, False: 438]
  |  Branch (296:47): [True: 3.72k, False: 754]
  ------------------
  297|  3.72k|        if (s[i] == '.' && (s[i+1] != '.' || ++i)
  ------------------
  |  Branch (297:13): [True: 1.49k, False: 2.23k]
  |  Branch (297:29): [True: 849, False: 641]
  |  Branch (297:46): [True: 641, False: 0]
  ------------------
  298|  1.49k|            && (s[i+1] == '/' || s[i+1] == '?' || s[i+1] == '\0')) {
  ------------------
  |  Branch (298:17): [True: 87, False: 1.40k]
  |  Branch (298:34): [True: 86, False: 1.31k]
  |  Branch (298:51): [True: 80, False: 1.23k]
  ------------------
  299|    253|            path_simplify = 1;
  300|    253|            break;
  301|    253|        }
  302|  73.5M|        while (i < len && s[i] != '/') ++i;
  ------------------
  |  Branch (302:16): [True: 73.5M, False: 622]
  |  Branch (302:27): [True: 73.5M, False: 2.85k]
  ------------------
  303|  3.47k|        if (s[i] == '/' && s[i+1] == '/') { /*(s[len] != '/')*/
  ------------------
  |  Branch (303:13): [True: 2.85k, False: 622]
  |  Branch (303:28): [True: 151, False: 2.70k]
  ------------------
  304|    151|            path_simplify = 1;
  305|    151|            break;
  306|    151|        }
  307|  3.47k|    }
  308|       |
  309|  1.15k|    if (path_simplify) {
  ------------------
  |  Branch (309:9): [True: 404, False: 754]
  ------------------
  310|    404|        if (flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT) return -2;
  ------------------
  |  Branch (310:13): [True: 16, False: 388]
  ------------------
  311|    388|        if (qs >= 0) {
  ------------------
  |  Branch (311:13): [True: 152, False: 236]
  ------------------
  312|    152|            buffer_copy_string_len(t, b->ptr+qs, used - qs);
  313|    152|            buffer_truncate(b, qs);
  314|    152|        }
  315|       |
  316|    388|        buffer_path_simplify(b);
  317|       |
  318|    388|        if (qs >= 0) {
  ------------------
  |  Branch (318:13): [True: 152, False: 236]
  ------------------
  319|    152|            qs = (int)buffer_clen(b);
  320|    152|            buffer_append_string_len(b, BUF_PTR_LEN(t));
  ------------------
  |  |  297|    152|#define BUF_PTR_LEN(x)       (x)->ptr, buffer_clen(x)
  ------------------
  321|    152|        }
  322|    388|    }
  323|       |
  324|  1.14k|    return qs;
  325|  1.15k|}
burl.c:burl_normalize_qs20_to_plus:
  239|    405|{
  240|    405|    const char * const s = b->ptr;
  241|    405|    const int used = qs < 0 ? 0 : (int)buffer_clen(b);
  ------------------
  |  Branch (241:22): [True: 0, False: 405]
  ------------------
  242|    405|    int i;
  243|    405|    if (qs < 0) return;
  ------------------
  |  Branch (243:9): [True: 0, False: 405]
  ------------------
  244|  5.87M|    for (i = qs+1; i < used; ++i) {
  ------------------
  |  Branch (244:20): [True: 5.87M, False: 304]
  ------------------
  245|  5.87M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == '0') break;
  ------------------
  |  Branch (245:13): [True: 1.94M, False: 3.92M]
  |  Branch (245:28): [True: 1.85k, False: 1.94M]
  |  Branch (245:45): [True: 101, False: 1.75k]
  ------------------
  246|  5.87M|    }
  247|    405|    if (i != used) burl_normalize_qs20_to_plus_fix(b, i);
  ------------------
  |  Branch (247:9): [True: 101, False: 304]
  ------------------
  248|    405|}
burl.c:burl_normalize_qs20_to_plus_fix:
  223|    101|{
  224|    101|    char * const s = b->ptr;
  225|    101|    const int used = (int)buffer_clen(b);
  226|    101|    int j = i;
  227|  4.10M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (227:12): [True: 4.10M, False: 101]
  ------------------
  228|  4.10M|        s[j] = s[i];
  229|  4.10M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == '0') {
  ------------------
  |  Branch (229:13): [True: 1.35M, False: 2.74M]
  |  Branch (229:28): [True: 1.82k, False: 1.35M]
  |  Branch (229:45): [True: 1.01k, False: 810]
  ------------------
  230|  1.01k|            s[j] = '+';
  231|  1.01k|            i+=2;
  232|  1.01k|        }
  233|  4.10M|    }
  234|    101|    buffer_truncate(b, j);
  235|    101|}

