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

buffer_init:
   14|  3.28k|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.28k|	buffer * const b = calloc(1, sizeof(*b));
   20|  3.28k|	force_assert(b);
  ------------------
  |  |  448|  3.28k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.28k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.28k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.28k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   21|  3.28k|	return b;
   22|  3.28k|  #endif
   23|  3.28k|}
buffer_free:
   25|  3.28k|void buffer_free(buffer *b) {
   26|  3.28k|	if (NULL == b) return;
  ------------------
  |  Branch (26:6): [True: 0, False: 3.28k]
  ------------------
   27|  3.28k|	free(b->ptr);
   28|  3.28k|	free(b);
   29|  3.28k|}
buffer_string_prepare_copy:
   82|  1.27k|char* buffer_string_prepare_copy(buffer * const b, const size_t size) {
   83|  1.27k|    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.27k|    return (size < b->size)
  ------------------
  |  Branch (87:12): [True: 0, False: 1.27k]
  ------------------
   88|  1.27k|      ? b->ptr
   89|  1.27k|      : buffer_alloc_replace(b, size);
   90|  1.27k|}
buffer_extend:
  127|    150|{
  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|    150|    const uint32_t len = b->used ? b->used-1 : 0;
  ------------------
  |  Branch (136:26): [True: 150, False: 0]
  ------------------
  137|    150|    char * const s = (b->size - len >= x + 1)
  ------------------
  |  Branch (137:22): [True: 150, False: 0]
  ------------------
  138|    150|      ? b->ptr + len
  139|    150|      : buffer_string_prepare_append_resize(b, x);
  140|    150|    b->used = len+x+1;
  141|    150|  #endif
  142|    150|    s[x] = '\0';
  143|    150|    return s;
  144|    150|}
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: 944, 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|    150|void buffer_append_string_len(buffer * const restrict b, const char * const restrict s, const size_t len) {
  199|    150|    memcpy(buffer_extend(b, len), s, len);
  200|    150|}
hex2int:
  386|  99.4M|char hex2int(unsigned char hex) {
  387|  99.4M|	unsigned char n;
  388|  99.4M|	return li_cton(hex,n) ? (char)n : 0xFF;
  ------------------
  |  |  381|  99.4M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (381:4): [True: 89.8M, False: 9.63M]
  |  |  |  Branch (381:30): [True: 9.63M, False: 0]
  |  |  |  Branch (381:31): [True: 9.63M, False: 0]
  |  |  ------------------
  ------------------
  389|  99.4M|}
buffer_urldecode_path:
  792|  1.64k|void buffer_urldecode_path(buffer * const b) {
  793|  1.64k|    const size_t len = buffer_clen(b);
  794|  1.64k|    char *src = len ? memchr(b->ptr, '%', len) : NULL;
  ------------------
  |  Branch (794:17): [True: 1.63k, False: 6]
  ------------------
  795|  1.64k|    if (NULL == src) return;
  ------------------
  |  Branch (795:9): [True: 350, False: 1.29k]
  ------------------
  796|       |
  797|  1.29k|    char *dst = src;
  798|  49.7M|    do {
  799|       |        /* *src == '%' */
  800|  49.7M|        unsigned char high = ((unsigned char *)src)[1];
  801|  49.7M|        unsigned char low = high ? hex2int(((unsigned char *)src)[2]) : 0xFF;
  ------------------
  |  Branch (801:29): [True: 49.7M, False: 0]
  ------------------
  802|  49.7M|        if (0xFF != (high = hex2int(high)) && 0xFF != low) {
  ------------------
  |  Branch (802:13): [True: 49.7M, False: 0]
  |  Branch (802:47): [True: 49.7M, False: 0]
  ------------------
  803|  49.7M|            high = (high << 4) | low;   /* map ctrls to '_' */
  804|  49.7M|            *dst = (high >= 32 && high != 127) ? high : '_';
  ------------------
  |  Branch (804:21): [True: 6.95M, False: 42.7M]
  |  Branch (804:35): [True: 5.93M, False: 1.02M]
  ------------------
  805|  49.7M|            src += 2;
  806|  49.7M|        } /* else ignore this '%'; leave as-is and move on */
  807|       |
  808|  53.3M|        while ((*++dst = *++src) != '%' && *src) ;
  ------------------
  |  Branch (808:16): [True: 3.60M, False: 49.7M]
  |  Branch (808:44): [True: 3.60M, False: 1.29k]
  ------------------
  809|  49.7M|    } while (*src);
  ------------------
  |  Branch (809:14): [True: 49.7M, False: 1.29k]
  ------------------
  810|  1.29k|    b->used = (dst - b->ptr) + 1;
  811|  1.29k|}
buffer_path_simplify:
  864|    360|{
  865|    360|    char *out = b->ptr;
  866|    360|    char * const end = b->ptr + b->used - 1;
  867|       |
  868|    360|    if (__builtin_expect( (buffer_is_blank(b)), 0)) {
  ------------------
  |  Branch (868:9): [True: 0, False: 360]
  ------------------
  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|    360|    *end = '/'; /*(end of path modified to avoid need to check '\0')*/
  881|       |
  882|    360|    char *walk = out;
  883|    360|    if (__builtin_expect( (*walk == '/'), 1)) {
  ------------------
  |  Branch (883:9): [True: 135, False: 225]
  ------------------
  884|       |        /* scan to detect (potential) need for path simplification
  885|       |         * (repeated '/' or "/.") */
  886|    508|        do {
  887|    508|            if (*++walk == '.' || *walk == '/')
  ------------------
  |  Branch (887:17): [True: 72, False: 436]
  |  Branch (887:35): [True: 63, False: 373]
  ------------------
  888|    135|                break;
  889|  1.22M|            do { ++walk; } while (*walk != '/');
  ------------------
  |  Branch (889:35): [True: 1.22M, False: 373]
  ------------------
  890|    373|        } while (walk != end);
  ------------------
  |  Branch (890:18): [True: 373, 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|    225|    else {
  899|    225|        if (walk[0] == '.' && walk[1] == '/')
  ------------------
  |  Branch (899:13): [True: 121, False: 104]
  |  Branch (899:31): [True: 71, False: 50]
  ------------------
  900|     71|            *out = *++walk;
  901|    154|        else if (walk[0] == '.' && walk[1] == '.' && walk[2] == '/')
  ------------------
  |  Branch (901:18): [True: 50, False: 104]
  |  Branch (901:36): [True: 8, False: 42]
  |  Branch (901:54): [True: 2, False: 6]
  ------------------
  902|      2|            *out = *(walk += 2);
  903|    152|        else {
  904|  10.5M|            while (*++walk != '/') ;
  ------------------
  |  Branch (904:20): [True: 10.5M, False: 152]
  ------------------
  905|    152|            out = walk;
  906|    152|        }
  907|    225|        ++walk;
  908|    225|    }
  909|       |
  910|  9.05k|    while (walk <= end) {
  ------------------
  |  Branch (910:12): [True: 8.84k, False: 215]
  ------------------
  911|       |        /* previous char is '/' at this point (or start of string w/o '/') */
  912|  8.84k|        if (__builtin_expect( (walk[0] == '/'), 0)) {
  ------------------
  |  Branch (912:13): [True: 2.20k, False: 6.64k]
  ------------------
  913|       |            /* skip repeated '/' (e.g. "///" -> "/") */
  914|  2.20k|            if (++walk < end)
  ------------------
  |  Branch (914:17): [True: 2.14k, False: 54]
  ------------------
  915|  2.14k|                continue;
  916|     54|            else {
  917|     54|                ++out;
  918|     54|                break;
  919|     54|            }
  920|  2.20k|        }
  921|  6.64k|        else if (__builtin_expect( (walk[0] == '.'), 0)) {
  ------------------
  |  Branch (921:18): [True: 4.81k, False: 1.82k]
  ------------------
  922|       |            /* handle "./" and "../" */
  923|  4.81k|            if (walk[1] == '.' && walk[2] == '/') {
  ------------------
  |  Branch (923:17): [True: 2.27k, False: 2.54k]
  |  Branch (923:35): [True: 884, False: 1.38k]
  ------------------
  924|       |                /* handle "../" */
  925|  5.62M|                while (out > b->ptr && *--out != '/') ;
  ------------------
  |  Branch (925:24): [True: 5.62M, False: 493]
  |  Branch (925:40): [True: 5.62M, False: 391]
  ------------------
  926|    884|                *out = '/'; /*(in case path had not started with '/')*/
  927|    884|                if ((walk += 3) >= end) {
  ------------------
  |  Branch (927:21): [True: 48, False: 836]
  ------------------
  928|     48|                    ++out;
  929|     48|                    break;
  930|     48|                }
  931|    836|                else
  932|    836|                continue;
  933|    884|            }
  934|  3.93k|            else if (walk[1] == '/') {
  ------------------
  |  Branch (934:22): [True: 978, False: 2.95k]
  ------------------
  935|       |                /* handle "./" */
  936|    978|                if ((walk += 2) >= end) {
  ------------------
  |  Branch (936:21): [True: 43, False: 935]
  ------------------
  937|     43|                    ++out;
  938|     43|                    break;
  939|     43|                }
  940|    935|                continue;
  941|    978|            }
  942|  2.95k|            else {
  943|       |                /* accept "." if not part of "../" or "./" */
  944|  2.95k|                *++out = '.';
  945|  2.95k|                ++walk;
  946|  2.95k|            }
  947|  4.81k|        }
  948|       |
  949|  28.6M|        while ((*++out = *walk++) != '/') ;
  ------------------
  |  Branch (949:16): [True: 28.6M, False: 4.77k]
  ------------------
  950|  4.77k|    }
  951|    360|    *out = *end = '\0'; /* overwrite extra '/' added to end of path */
  952|    360|    b->used = (out - b->ptr) + 1;
  953|       |    /*buffer_truncate(b, out - b->ptr);*/
  954|    360|}
buffer.c:buffer_alloc_replace:
   71|  3.39k|static char* buffer_alloc_replace(buffer * const restrict b, const size_t size) {
   72|       |    /*(discard old data so realloc() does not copy)*/
   73|  3.39k|    if (NULL != b->ptr) {
  ------------------
  |  Branch (73:9): [True: 468, False: 2.92k]
  ------------------
   74|    468|        free(b->ptr);
   75|    468|        b->ptr = NULL;
   76|    468|    }
   77|       |    /*(note: if size larger than one lshift, use size instead of power-2)*/
   78|  3.39k|    const size_t bsize2x = (b->size & ~1uL) << 1;
   79|  3.39k|    return buffer_realloc(b, bsize2x > size ? bsize2x-1 : size);
  ------------------
  |  Branch (79:30): [True: 234, False: 3.15k]
  ------------------
   80|  3.39k|}
buffer.c:buffer_realloc:
   49|  3.39k|static char* buffer_realloc(buffer * const restrict b, const size_t len) {
   50|  3.39k|    #define BUFFER_PIECE_SIZE 64uL  /*(must be power-of-2)*/
   51|  3.39k|    size_t sz = (len + 1 + BUFFER_PIECE_SIZE-1) & ~(BUFFER_PIECE_SIZE-1);
  ------------------
  |  |   50|  3.39k|    #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.39k|    #define BUFFER_PIECE_SIZE 64uL  /*(must be power-of-2)*/
  ------------------
   52|  3.39k|    force_assert(sz > len);
  ------------------
  |  |  448|  3.39k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.39k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.39k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.39k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   53|  3.39k|    if ((sz & (sz-1)) && sz < INT_MAX) {/* not power-2; huge val not expected */
  ------------------
  |  Branch (53:9): [True: 1.17k, False: 2.22k]
  |  Branch (53:26): [True: 1.17k, False: 0]
  ------------------
   54|       |        /*(optimizer should recognize this and use ffs or clz or equivalent)*/
   55|  1.17k|        const size_t psz = sz;
   56|  8.06k|        for (sz = 256; sz < psz; sz <<= 1) ;
  ------------------
  |  Branch (56:24): [True: 6.89k, False: 1.17k]
  ------------------
   57|  1.17k|    }
   58|  3.39k|    sz |= 1; /*(extra +1 for '\0' when needed buffer size is exact power-2)*/
   59|       |
   60|  3.39k|    b->size = sz;
   61|  3.39k|    b->ptr = realloc(b->ptr, sz);
   62|       |
   63|  3.39k|    force_assert(NULL != b->ptr);
  ------------------
  |  |  448|  3.39k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.39k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.39k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.39k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   64|  3.39k|    return b->ptr;
   65|  3.39k|}

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

burl_normalize:
  338|  1.64k|{
  339|  1.64k|    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.64k|    qs = (flags & HTTP_PARSEOPT_URL_NORMALIZE_REQUIRED)
  ------------------
  |  Branch (353:10): [True: 895, False: 749]
  ------------------
  354|  1.64k|      ? burl_normalize_basic_required(b, t)
  355|  1.64k|      : burl_normalize_basic_unreserved(b, t);
  356|  1.64k|    if (-2 == qs) {
  ------------------
  |  Branch (356:9): [True: 489, False: 1.15k]
  ------------------
  357|    489|        if (flags & HTTP_PARSEOPT_URL_NORMALIZE_INVALID_UTF8_REJECT) return -2;
  ------------------
  |  Branch (357:13): [True: 102, False: 387]
  ------------------
  358|    387|        qs = burl_scan_qmark(b);
  359|    387|    }
  360|       |
  361|  1.54k|    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_CTRLS_REJECT) {
  ------------------
  |  Branch (361:9): [True: 325, False: 1.21k]
  ------------------
  362|    325|        if (burl_contains_ctrls(b)) return -2;
  ------------------
  |  Branch (362:13): [True: 90, False: 235]
  ------------------
  363|    325|    }
  364|       |
  365|  1.45k|    if (flags & (HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_DECODE
  ------------------
  |  Branch (365:9): [True: 1.18k, False: 268]
  ------------------
  366|  1.45k|                |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: 12, False: 1.17k]
  ------------------
  369|  1.18k|    }
  370|       |
  371|  1.44k|    if (flags & (HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REMOVE
  ------------------
  |  Branch (371:9): [True: 1.14k, False: 292]
  ------------------
  372|  1.44k|                |HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT)) {
  373|  1.14k|        qs = burl_normalize_path(b, t, qs, flags);
  374|  1.14k|        if (-2 == qs) return -2;
  ------------------
  |  Branch (374:13): [True: 24, False: 1.12k]
  ------------------
  375|  1.14k|    }
  376|       |
  377|  1.41k|    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_QUERY_20_PLUS) {
  ------------------
  |  Branch (377:9): [True: 831, False: 585]
  ------------------
  378|    831|        if (qs >= 0) burl_normalize_qs20_to_plus(b, qs);
  ------------------
  |  Branch (378:13): [True: 407, False: 424]
  ------------------
  379|    831|    }
  380|       |
  381|  1.41k|    return qs;
  382|  1.44k|}
burl.c:burl_normalize_basic_required:
  175|    895|{
  176|    895|    const unsigned char * const s = (unsigned char *)b->ptr;
  177|    895|    const int used = (int)buffer_clen(b);
  178|    895|    unsigned int n1, n2, x;
  179|    895|    int qs = -1;
  180|    895|    int invalid_utf8 = 0;
  181|       |
  182|  1.16M|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (182:21): [True: 1.16M, False: 188]
  ------------------
  183|  1.16M|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (183:13): [True: 1.09M, False: 75.3k]
  ------------------
  184|  1.09M|            if (s[i] == '?') qs = i;
  ------------------
  |  Branch (184:17): [True: 59.9k, False: 1.03M]
  ------------------
  185|  1.09M|        }
  186|  75.3k|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|   150k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 70.2k, False: 4.60k]
  |  |  |  Branch (43:30): [True: 4.52k, False: 82]
  |  |  |  Branch (43:31): [True: 4.52k, False: 82]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|   150k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 44.4k, False: 30.3k]
  |  |  |  Branch (43:30): [True: 30.2k, False: 57]
  |  |  |  Branch (43:31): [True: 30.2k, False: 57]
  |  |  ------------------
  ------------------
  |  Branch (186:18): [True: 74.8k, False: 498]
  ------------------
  187|  74.6k|                 && (encoded_chars_http_uri_reqd[(x = (n1 << 4) | n2)]
  ------------------
  |  Branch (187:22): [True: 13.2k, False: 61.4k]
  ------------------
  188|  61.4k|                     || (qs < 0
  ------------------
  |  Branch (188:25): [True: 61.3k, False: 70]
  |  Branch (188:26): [True: 710, False: 60.6k]
  ------------------
  189|  61.4k|                         ? (x == '/' || x == '?')
  ------------------
  |  Branch (189:29): [True: 431, False: 279]
  |  Branch (189:41): [True: 248, False: 31]
  ------------------
  190|  74.6k|                         : (x == '&' || x == '=' || x == ';' || x == '+')))) {
  ------------------
  |  Branch (190:29): [True: 33.3k, False: 27.2k]
  |  Branch (190:41): [True: 16.3k, False: 10.9k]
  |  Branch (190:53): [True: 3.04k, False: 7.89k]
  |  Branch (190:65): [True: 7.85k, False: 39]
  ------------------
  191|  74.6k|            invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  74.6k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  74.6k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 600, False: 74.0k]
  |  |  |  |  ------------------
  |  |  |  |  261|  74.6k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 194, False: 73.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  192|  74.6k|            if (s[i+1] >= 'a') b->ptr[i+1] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (192:17): [True: 825, False: 73.7k]
  ------------------
  193|  74.6k|            if (s[i+2] >= 'a') b->ptr[i+2] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (193:17): [True: 11.8k, False: 62.7k]
  ------------------
  194|  74.6k|            i+=2;
  195|  74.6k|        }
  196|    707|        else if (s[i] == '#') { /* ignore fragment */
  ------------------
  |  Branch (196:18): [True: 1, False: 706]
  ------------------
  197|      1|            buffer_truncate(b, (size_t)i);
  198|      1|            break;
  199|      1|        }
  200|    706|        else {
  201|    706|            qs = burl_normalize_basic_required_fix(b, t, i, qs);
  202|    706|            break;
  203|    706|        }
  204|  1.16M|    }
  205|       |
  206|    895|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (206:12): [True: 866, False: 29]
  ------------------
  207|    895|}
burl.c:burl_normalize_basic_required_fix:
  131|    706|{
  132|    706|    int j = i;
  133|    706|    const int used = (int)buffer_clen(b);
  134|    706|    const unsigned char * const s = (unsigned char *)b->ptr;
  135|    706|    unsigned char * const p =
  136|    706|      (unsigned char *)buffer_string_prepare_copy(t,i+(used-i)*3+1);
  137|    706|    unsigned int n1, n2;
  138|    706|    int invalid_utf8 = 0;
  139|    706|    memcpy(p, s, (size_t)i);
  140|  29.5M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (140:12): [True: 29.5M, False: 693]
  ------------------
  141|  29.5M|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (141:13): [True: 746k, False: 28.7M]
  ------------------
  142|   746k|            p[j] = s[i];
  143|   746k|            if (__builtin_expect( (s[i] == '?'), 0)) qs = j;
  ------------------
  |  Branch (143:17): [True: 13.5k, False: 733k]
  ------------------
  144|   746k|        }
  145|  28.7M|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  28.8M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 26.7k, False: 37.7k]
  |  |  |  Branch (43:30): [True: 8.35k, False: 29.4k]
  |  |  |  Branch (43:31): [True: 8.35k, False: 29.4k]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  35.0k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 16.4k, False: 18.6k]
  |  |  |  Branch (43:30): [True: 15.0k, False: 3.55k]
  |  |  |  Branch (43:31): [True: 15.0k, False: 3.55k]
  |  |  ------------------
  ------------------
  |  Branch (145:18): [True: 64.4k, False: 28.6M]
  ------------------
  146|  31.5k|            const unsigned int x = (n1 << 4) | n2;
  147|  31.5k|            if (!encoded_chars_http_uri_reqd[x]
  ------------------
  |  Branch (147:17): [True: 20.6k, False: 10.8k]
  ------------------
  148|  20.6k|                && (qs < 0
  ------------------
  |  Branch (148:20): [True: 5.61k, False: 15.0k]
  |  Branch (148:21): [True: 1.97k, False: 18.7k]
  ------------------
  149|  20.6k|                    ? (x != '/' && x != '?')
  ------------------
  |  Branch (149:24): [True: 1.39k, False: 577]
  |  Branch (149:36): [True: 1.03k, False: 364]
  ------------------
  150|  20.6k|                    : (x != '&' && x != '=' && x != ';' && x != '+'))) {
  ------------------
  |  Branch (150:24): [True: 12.1k, False: 6.61k]
  |  Branch (150:36): [True: 8.66k, False: 3.43k]
  |  Branch (150:48): [True: 6.99k, False: 1.67k]
  |  Branch (150:60): [True: 4.58k, False: 2.41k]
  ------------------
  151|  5.61k|                p[j] = x;
  152|  5.61k|            }
  153|  25.9k|            else {
  154|  25.9k|                p[j]   = '%';
  155|  25.9k|                p[++j] = hex_chars_uc[n1]; /*(s[i+1] & 0xdf)*/
  156|  25.9k|                p[++j] = hex_chars_uc[n2]; /*(s[i+2] & 0xdf)*/
  157|  25.9k|                invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  25.9k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  25.9k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 1.92k, False: 23.9k]
  |  |  |  |  ------------------
  |  |  |  |  261|  25.9k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 78, False: 23.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  158|  25.9k|            }
  159|  31.5k|            i+=2;
  160|  31.5k|        }
  161|  28.7M|        else if (s[i] == '#') break; /* ignore fragment */
  ------------------
  |  Branch (161:18): [True: 13, False: 28.7M]
  ------------------
  162|  28.7M|        else {
  163|  28.7M|            p[j]   = '%';
  164|  28.7M|            p[++j] = hex_chars_uc[(s[i] >> 4) & 0xF];
  165|  28.7M|            p[++j] = hex_chars_uc[s[i] & 0xF];
  166|  28.7M|            invalid_utf8 |= li_utf8_invalid_byte(s[i]);
  ------------------
  |  |   49|  28.7M|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  28.7M|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 1.88M, False: 26.8M]
  |  |  |  |  ------------------
  |  |  |  |  261|  28.7M|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 726, False: 26.8M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  167|  28.7M|        }
  168|  29.5M|    }
  169|    706|    buffer_copy_string_len(b, (char *)p, (size_t)j);
  170|    706|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (170:12): [True: 447, False: 259]
  ------------------
  171|    706|}
burl.c:burl_normalize_basic_unreserved:
   99|    749|{
  100|    749|    const unsigned char * const s = (unsigned char *)b->ptr;
  101|    749|    const int used = (int)buffer_clen(b);
  102|    749|    unsigned int n1, n2, x;
  103|    749|    int qs = -1;
  104|       |
  105|   765k|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (105:21): [True: 765k, False: 184]
  ------------------
  106|   765k|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (106:13): [True: 761k, False: 4.06k]
  ------------------
  107|   761k|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = i;
  ------------------
  |  Branch (107:17): [True: 1.81k, False: 759k]
  |  Branch (107:56): [True: 66, False: 1.74k]
  ------------------
  108|   761k|        }
  109|  4.06k|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  7.74k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 2.54k, False: 1.12k]
  |  |  |  Branch (43:30): [True: 1.06k, False: 59]
  |  |  |  Branch (43:31): [True: 1.06k, False: 59]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  7.68k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 2.00k, False: 1.61k]
  |  |  |  Branch (43:30): [True: 1.55k, False: 58]
  |  |  |  Branch (43:31): [True: 1.55k, False: 58]
  |  |  ------------------
  ------------------
  |  Branch (109:18): [True: 3.67k, False: 395]
  ------------------
  110|  3.55k|                 && !burl_is_unreserved((x = (n1 << 4) | n2))) {
  ------------------
  |  Branch (110:21): [True: 3.50k, False: 53]
  ------------------
  111|  3.50k|            if (li_utf8_invalid_byte(x)) qs = -2;
  ------------------
  |  |   49|  3.50k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  3.50k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 438, False: 3.06k]
  |  |  |  |  ------------------
  |  |  |  |  261|  3.50k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 376, False: 2.68k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  112|  3.50k|            if (s[i+1] >= 'a') b->ptr[i+1] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (112:17): [True: 928, False: 2.57k]
  ------------------
  113|  3.50k|            if (s[i+2] >= 'a') b->ptr[i+2] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (113:17): [True: 764, False: 2.73k]
  ------------------
  114|  3.50k|            i+=2;
  115|  3.50k|        }
  116|    565|        else if (s[i] == '#') { /* ignore fragment */
  ------------------
  |  Branch (116:18): [True: 1, False: 564]
  ------------------
  117|      1|            buffer_truncate(b, (size_t)i);
  118|      1|            break;
  119|      1|        }
  120|    564|        else {
  121|    564|            qs = burl_normalize_basic_unreserved_fix(b, t, i, qs);
  122|    564|            break;
  123|    564|        }
  124|   765k|    }
  125|       |
  126|    749|    return qs;
  127|    749|}
burl.c:burl_is_unreserved:
   53|  11.0k|{
   54|  11.0k|    return (light_isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~');
  ------------------
  |  Branch (54:13): [True: 456, False: 10.5k]
  |  Branch (54:33): [True: 310, False: 10.2k]
  |  Branch (54:45): [True: 204, False: 10.0k]
  |  Branch (54:57): [True: 207, False: 9.82k]
  |  Branch (54:69): [True: 56, False: 9.76k]
  ------------------
   55|  11.0k|}
burl.c:burl_normalize_basic_unreserved_fix:
   59|    564|{
   60|    564|    int j = i;
   61|    564|    const int used = (int)buffer_clen(b);
   62|    564|    const unsigned char * const s = (unsigned char *)b->ptr;
   63|    564|    unsigned char * const p =
   64|    564|      (unsigned char *)buffer_string_prepare_copy(t,i+(used-i)*3+1);
   65|    564|    unsigned int n1, n2;
   66|    564|    memcpy(p, s, (size_t)i);
   67|  24.0M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (67:12): [True: 24.0M, False: 559]
  ------------------
   68|  24.0M|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (68:13): [True: 1.23M, False: 22.7M]
  ------------------
   69|  1.23M|            p[j] = s[i];
   70|  1.23M|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = j;
  ------------------
  |  Branch (70:17): [True: 1.47k, False: 1.23M]
  |  Branch (70:56): [True: 87, False: 1.38k]
  ------------------
   71|  1.23M|        }
   72|  22.7M|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  22.8M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 3.83k, False: 6.76k]
  |  |  |  Branch (43:30): [True: 4.84k, False: 1.92k]
  |  |  |  Branch (43:31): [True: 4.84k, False: 1.92k]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  8.67k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 3.12k, False: 5.55k]
  |  |  |  Branch (43:30): [True: 4.32k, False: 1.23k]
  |  |  |  Branch (43:31): [True: 4.32k, False: 1.23k]
  |  |  ------------------
  ------------------
  |  Branch (72:18): [True: 10.5k, False: 22.7M]
  ------------------
   73|  7.44k|            const unsigned int x = (n1 << 4) | n2;
   74|  7.44k|            if (burl_is_unreserved(x)) {
  ------------------
  |  Branch (74:17): [True: 1.18k, False: 6.26k]
  ------------------
   75|  1.18k|                p[j] = x;
   76|  1.18k|            }
   77|  6.26k|            else {
   78|  6.26k|                p[j]   = '%';
   79|  6.26k|                p[++j] = hex_chars_uc[n1]; /*(s[i+1] & 0xdf)*/
   80|  6.26k|                p[++j] = hex_chars_uc[n2]; /*(s[i+2] & 0xdf)*/
   81|  6.26k|                if (li_utf8_invalid_byte(x)) qs = -2;
  ------------------
  |  |   49|  6.26k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  6.26k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 2.47k, False: 3.78k]
  |  |  |  |  ------------------
  |  |  |  |  261|  6.26k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 1.03k, False: 2.75k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   82|  6.26k|            }
   83|  7.44k|            i+=2;
   84|  7.44k|        }
   85|  22.7M|        else if (s[i] == '#') break; /* ignore fragment */
  ------------------
  |  Branch (85:18): [True: 5, False: 22.7M]
  ------------------
   86|  22.7M|        else {
   87|  22.7M|            p[j]   = '%';
   88|  22.7M|            p[++j] = hex_chars_uc[(s[i] >> 4) & 0xF];
   89|  22.7M|            p[++j] = hex_chars_uc[s[i] & 0xF];
   90|  22.7M|            if (li_utf8_invalid_byte(s[i])) qs = -2;
  ------------------
  |  |   49|  22.7M|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  22.7M|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 22.6k, False: 22.7M]
  |  |  |  |  ------------------
  |  |  |  |  261|  22.7M|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 2.61k, False: 22.7M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   91|  22.7M|        }
   92|  24.0M|    }
   93|    564|    buffer_copy_string_len(b, (char *)p, (size_t)j);
   94|    564|    return qs;
   95|    564|}
burl.c:burl_scan_qmark:
  331|    387|static int burl_scan_qmark (const buffer * const b) {
  332|    387|    const char * const qmark = strchr(b->ptr, '?');
  333|    387|    return qmark ? (int)(qmark - b->ptr) : -1;
  ------------------
  |  Branch (333:12): [True: 185, False: 202]
  ------------------
  334|    387|}
burl.c:burl_contains_ctrls:
  211|    325|{
  212|    325|    const char * const s = b->ptr;
  213|    325|    const int used = (int)buffer_clen(b);
  214|  7.76M|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (214:21): [True: 7.76M, False: 235]
  ------------------
  215|  7.76M|        if (s[i] == '%' && (s[i+1] < '2' || (s[i+1] == '7' && s[i+2] == 'F')))
  ------------------
  |  Branch (215:13): [True: 2.16M, False: 5.59M]
  |  Branch (215:29): [True: 82, False: 2.16M]
  |  Branch (215:46): [True: 347, False: 2.16M]
  |  Branch (215:63): [True: 8, False: 339]
  ------------------
  216|     90|            return 1;
  217|  7.76M|    }
  218|    235|    return 0;
  219|    325|}
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: 728, False: 456]
  ------------------
  280|  78.1M|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (280:21): [True: 78.1M, False: 1.00k]
  ------------------
  281|  78.1M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == 'F') {
  ------------------
  |  Branch (281:13): [True: 25.6M, False: 52.4M]
  |  Branch (281:28): [True: 48.2k, False: 25.6M]
  |  Branch (281:45): [True: 184, False: 48.0k]
  ------------------
  282|    184|            return (flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_DECODE)
  ------------------
  |  Branch (282:20): [True: 172, False: 12]
  ------------------
  283|    184|              ? burl_normalize_2F_to_slash_fix(b, qs, i)
  284|    184|              : -2; /*(flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)*/
  285|    184|        }
  286|  78.1M|    }
  287|  1.00k|    return qs;
  288|  1.18k|}
burl.c:burl_normalize_2F_to_slash_fix:
  252|    172|{
  253|    172|    char * const s = b->ptr;
  254|    172|    const int blen = (int)buffer_clen(b);
  255|    172|    const int used = qs < 0 ? blen : qs;
  ------------------
  |  Branch (255:22): [True: 107, False: 65]
  ------------------
  256|    172|    int j = i;
  257|  13.3M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (257:12): [True: 13.3M, False: 172]
  ------------------
  258|  13.3M|        s[j] = s[i];
  259|  13.3M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == 'F') {
  ------------------
  |  Branch (259:13): [True: 4.45M, False: 8.90M]
  |  Branch (259:28): [True: 20.6k, False: 4.43M]
  |  Branch (259:45): [True: 895, False: 19.7k]
  ------------------
  260|    895|            s[j] = '/';
  261|    895|            i+=2;
  262|    895|        }
  263|  13.3M|    }
  264|    172|    if (qs >= 0) {
  ------------------
  |  Branch (264:9): [True: 65, False: 107]
  ------------------
  265|     65|        const int qslen = blen - qs;
  266|     65|        memmove(s+j, s+qs, (size_t)qslen);
  267|     65|        qs = j;
  268|     65|        j += qslen;
  269|     65|    }
  270|    172|    buffer_truncate(b, j);
  271|    172|    return qs;
  272|    172|}
burl.c:burl_normalize_path:
  292|  1.14k|{
  293|  1.14k|    const unsigned char * const s = (unsigned char *)b->ptr;
  294|  1.14k|    const int used = (int)buffer_clen(b);
  295|  1.14k|    int path_simplify = 0;
  296|  4.09k|    for (int i = 0, len = qs < 0 ? used : qs; i < len; ++i) {
  ------------------
  |  Branch (296:27): [True: 715, False: 433]
  |  Branch (296:47): [True: 3.33k, False: 764]
  ------------------
  297|  3.33k|        if (s[i] == '.' && (s[i+1] != '.' || ++i)
  ------------------
  |  Branch (297:13): [True: 1.45k, False: 1.87k]
  |  Branch (297:29): [True: 870, False: 583]
  |  Branch (297:46): [True: 583, False: 0]
  ------------------
  298|  1.45k|            && (s[i+1] == '/' || s[i+1] == '?' || s[i+1] == '\0')) {
  ------------------
  |  Branch (298:17): [True: 89, False: 1.36k]
  |  Branch (298:34): [True: 83, False: 1.28k]
  |  Branch (298:51): [True: 65, False: 1.21k]
  ------------------
  299|    237|            path_simplify = 1;
  300|    237|            break;
  301|    237|        }
  302|  68.8M|        while (i < len && s[i] != '/') ++i;
  ------------------
  |  Branch (302:16): [True: 68.8M, False: 635]
  |  Branch (302:27): [True: 68.8M, False: 2.45k]
  ------------------
  303|  3.09k|        if (s[i] == '/' && s[i+1] == '/') { /*(s[len] != '/')*/
  ------------------
  |  Branch (303:13): [True: 2.45k, False: 635]
  |  Branch (303:28): [True: 147, False: 2.31k]
  ------------------
  304|    147|            path_simplify = 1;
  305|    147|            break;
  306|    147|        }
  307|  3.09k|    }
  308|       |
  309|  1.14k|    if (path_simplify) {
  ------------------
  |  Branch (309:9): [True: 384, False: 764]
  ------------------
  310|    384|        if (flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT) return -2;
  ------------------
  |  Branch (310:13): [True: 24, False: 360]
  ------------------
  311|    360|        if (qs >= 0) {
  ------------------
  |  Branch (311:13): [True: 150, False: 210]
  ------------------
  312|    150|            buffer_copy_string_len(t, b->ptr+qs, used - qs);
  313|    150|            buffer_truncate(b, qs);
  314|    150|        }
  315|       |
  316|    360|        buffer_path_simplify(b);
  317|       |
  318|    360|        if (qs >= 0) {
  ------------------
  |  Branch (318:13): [True: 150, False: 210]
  ------------------
  319|    150|            qs = (int)buffer_clen(b);
  320|    150|            buffer_append_string_len(b, BUF_PTR_LEN(t));
  ------------------
  |  |  297|    150|#define BUF_PTR_LEN(x)       (x)->ptr, buffer_clen(x)
  ------------------
  321|    150|        }
  322|    360|    }
  323|       |
  324|  1.12k|    return qs;
  325|  1.14k|}
burl.c:burl_normalize_qs20_to_plus:
  239|    407|{
  240|    407|    const char * const s = b->ptr;
  241|    407|    const int used = qs < 0 ? 0 : (int)buffer_clen(b);
  ------------------
  |  Branch (241:22): [True: 0, False: 407]
  ------------------
  242|    407|    int i;
  243|    407|    if (qs < 0) return;
  ------------------
  |  Branch (243:9): [True: 0, False: 407]
  ------------------
  244|  7.68M|    for (i = qs+1; i < used; ++i) {
  ------------------
  |  Branch (244:20): [True: 7.68M, False: 302]
  ------------------
  245|  7.68M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == '0') break;
  ------------------
  |  Branch (245:13): [True: 2.51M, False: 5.17M]
  |  Branch (245:28): [True: 2.35k, False: 2.51M]
  |  Branch (245:45): [True: 105, False: 2.24k]
  ------------------
  246|  7.68M|    }
  247|    407|    if (i != used) burl_normalize_qs20_to_plus_fix(b, i);
  ------------------
  |  Branch (247:9): [True: 105, False: 302]
  ------------------
  248|    407|}
burl.c:burl_normalize_qs20_to_plus_fix:
  223|    105|{
  224|    105|    char * const s = b->ptr;
  225|    105|    const int used = (int)buffer_clen(b);
  226|    105|    int j = i;
  227|  6.83M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (227:12): [True: 6.83M, False: 105]
  ------------------
  228|  6.83M|        s[j] = s[i];
  229|  6.83M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == '0') {
  ------------------
  |  Branch (229:13): [True: 2.26M, False: 4.57M]
  |  Branch (229:28): [True: 12.3k, False: 2.24M]
  |  Branch (229:45): [True: 3.10k, False: 9.28k]
  ------------------
  230|  3.10k|            s[j] = '+';
  231|  3.10k|            i+=2;
  232|  3.10k|        }
  233|  6.83M|    }
  234|    105|    buffer_truncate(b, j);
  235|    105|}

