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

buffer_init:
   14|  3.47k|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.47k|	buffer * const b = calloc(1, sizeof(*b));
   20|  3.47k|	force_assert(b);
  ------------------
  |  |  448|  3.47k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.47k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.47k]
  |  |  |  |  |  Branch (115:75): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   21|  3.47k|	return b;
   22|  3.47k|  #endif
   23|  3.47k|}
buffer_free:
   25|  3.47k|void buffer_free(buffer *b) {
   26|  3.47k|	if (NULL == b) return;
  ------------------
  |  Branch (26:6): [True: 0, False: 3.47k]
  ------------------
   27|  3.47k|	free(b->ptr);
   28|  3.47k|	free(b);
   29|  3.47k|}
buffer_string_prepare_copy:
   82|  1.36k|char* buffer_string_prepare_copy(buffer * const b, const size_t size) {
   83|  1.36k|    b->used = 0;
   84|       |  #ifdef __COVERITY__ /*(b->ptr is not NULL if b->size is not 0)*/
   85|       |    force_assert(size >= b->size || b->ptr);
   86|       |  #endif
   87|  1.36k|    return (size < b->size)
  ------------------
  |  Branch (87:12): [True: 0, False: 1.36k]
  ------------------
   88|  1.36k|      ? b->ptr
   89|  1.36k|      : buffer_alloc_replace(b, size);
   90|  1.36k|}
buffer_extend:
  127|    135|{
  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|    135|    const uint32_t len = b->used ? b->used-1 : 0;
  ------------------
  |  Branch (136:26): [True: 135, False: 0]
  ------------------
  137|    135|    char * const s = (b->size - len >= x + 1)
  ------------------
  |  Branch (137:22): [True: 135, False: 0]
  ------------------
  138|    135|      ? b->ptr + len
  139|    135|      : buffer_string_prepare_append_resize(b, x);
  140|    135|    b->used = len+x+1;
  141|    135|  #endif
  142|    135|    s[x] = '\0';
  143|    135|    return s;
  144|    135|}
buffer_copy_string_len:
  172|  3.23k|void buffer_copy_string_len(buffer * const restrict b, const char * const restrict s, const size_t len) {
  173|  3.23k|    b->used = len + 1;
  174|  3.23k|    char * const restrict d = (len < b->size)
  ------------------
  |  Branch (174:31): [True: 974, False: 2.26k]
  ------------------
  175|  3.23k|      ? b->ptr
  176|  3.23k|      : buffer_alloc_replace(b, len);
  177|  3.23k|    d[len] = '\0';
  178|  3.23k|    memcpy(d, s, len);
  179|  3.23k|}
buffer_append_string_len:
  198|    135|void buffer_append_string_len(buffer * const restrict b, const char * const restrict s, const size_t len) {
  199|    135|    memcpy(buffer_extend(b, len), s, len);
  200|    135|}
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: 77.3M, False: 22.1M]
  |  |  |  Branch (381:30): [True: 22.1M, False: 0]
  |  |  |  Branch (381:31): [True: 22.1M, False: 0]
  |  |  ------------------
  ------------------
  389|  99.4M|}
buffer_urldecode_path:
  792|  1.73k|void buffer_urldecode_path(buffer * const b) {
  793|  1.73k|    const size_t len = buffer_clen(b);
  794|  1.73k|    char *src = len ? memchr(b->ptr, '%', len) : NULL;
  ------------------
  |  Branch (794:17): [True: 1.73k, False: 4]
  ------------------
  795|  1.73k|    if (NULL == src) return;
  ------------------
  |  Branch (795:9): [True: 343, False: 1.39k]
  ------------------
  796|       |
  797|  1.39k|    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: 18.6M, False: 31.1M]
  |  Branch (804:35): [True: 16.2M, False: 2.37M]
  ------------------
  805|  49.7M|            src += 2;
  806|  49.7M|        } /* else ignore this '%'; leave as-is and move on */
  807|       |
  808|  55.0M|        while ((*++dst = *++src) != '%' && *src) ;
  ------------------
  |  Branch (808:16): [True: 5.34M, False: 49.7M]
  |  Branch (808:44): [True: 5.34M, False: 1.39k]
  ------------------
  809|  49.7M|    } while (*src);
  ------------------
  |  Branch (809:14): [True: 49.7M, False: 1.39k]
  ------------------
  810|  1.39k|    b->used = (dst - b->ptr) + 1;
  811|  1.39k|}
buffer_path_simplify:
  864|    378|{
  865|    378|    char *out = b->ptr;
  866|    378|    char * const end = b->ptr + b->used - 1;
  867|       |
  868|    378|    if (__builtin_expect( (buffer_is_blank(b)), 0)) {
  ------------------
  |  Branch (868:9): [True: 0, False: 378]
  ------------------
  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|    378|    *end = '/'; /*(end of path modified to avoid need to check '\0')*/
  881|       |
  882|    378|    char *walk = out;
  883|    378|    if (__builtin_expect( (*walk == '/'), 1)) {
  ------------------
  |  Branch (883:9): [True: 130, False: 248]
  ------------------
  884|       |        /* scan to detect (potential) need for path simplification
  885|       |         * (repeated '/' or "/.") */
  886|    352|        do {
  887|    352|            if (*++walk == '.' || *walk == '/')
  ------------------
  |  Branch (887:17): [True: 62, False: 290]
  |  Branch (887:35): [True: 68, False: 222]
  ------------------
  888|    130|                break;
  889|   187k|            do { ++walk; } while (*walk != '/');
  ------------------
  |  Branch (889:35): [True: 187k, False: 222]
  ------------------
  890|    222|        } while (walk != end);
  ------------------
  |  Branch (890:18): [True: 222, False: 0]
  ------------------
  891|    130|        if (__builtin_expect( (walk == end), 1)) {
  ------------------
  |  Branch (891:13): [True: 0, False: 130]
  ------------------
  892|       |            /* common case: no repeated '/' or "/." */
  893|      0|            *end = '\0'; /* overwrite extra '/' added to end of path */
  894|      0|            return;
  895|      0|        }
  896|    130|        out = walk-1;
  897|    130|    }
  898|    248|    else {
  899|    248|        if (walk[0] == '.' && walk[1] == '/')
  ------------------
  |  Branch (899:13): [True: 142, False: 106]
  |  Branch (899:31): [True: 75, False: 67]
  ------------------
  900|     75|            *out = *++walk;
  901|    173|        else if (walk[0] == '.' && walk[1] == '.' && walk[2] == '/')
  ------------------
  |  Branch (901:18): [True: 67, False: 106]
  |  Branch (901:36): [True: 16, False: 51]
  |  Branch (901:54): [True: 1, False: 15]
  ------------------
  902|      1|            *out = *(walk += 2);
  903|    172|        else {
  904|  9.02M|            while (*++walk != '/') ;
  ------------------
  |  Branch (904:20): [True: 9.02M, False: 172]
  ------------------
  905|    172|            out = walk;
  906|    172|        }
  907|    248|        ++walk;
  908|    248|    }
  909|       |
  910|  9.67k|    while (walk <= end) {
  ------------------
  |  Branch (910:12): [True: 9.44k, False: 227]
  ------------------
  911|       |        /* previous char is '/' at this point (or start of string w/o '/') */
  912|  9.44k|        if (__builtin_expect( (walk[0] == '/'), 0)) {
  ------------------
  |  Branch (912:13): [True: 1.58k, False: 7.86k]
  ------------------
  913|       |            /* skip repeated '/' (e.g. "///" -> "/") */
  914|  1.58k|            if (++walk < end)
  ------------------
  |  Branch (914:17): [True: 1.53k, False: 56]
  ------------------
  915|  1.53k|                continue;
  916|     56|            else {
  917|     56|                ++out;
  918|     56|                break;
  919|     56|            }
  920|  1.58k|        }
  921|  7.86k|        else if (__builtin_expect( (walk[0] == '.'), 0)) {
  ------------------
  |  Branch (921:18): [True: 3.26k, False: 4.59k]
  ------------------
  922|       |            /* handle "./" and "../" */
  923|  3.26k|            if (walk[1] == '.' && walk[2] == '/') {
  ------------------
  |  Branch (923:17): [True: 1.33k, False: 1.93k]
  |  Branch (923:35): [True: 622, False: 716]
  ------------------
  924|       |                /* handle "../" */
  925|  1.68M|                while (out > b->ptr && *--out != '/') ;
  ------------------
  |  Branch (925:24): [True: 1.68M, False: 421]
  |  Branch (925:40): [True: 1.68M, False: 201]
  ------------------
  926|    622|                *out = '/'; /*(in case path had not started with '/')*/
  927|    622|                if ((walk += 3) >= end) {
  ------------------
  |  Branch (927:21): [True: 35, False: 587]
  ------------------
  928|     35|                    ++out;
  929|     35|                    break;
  930|     35|                }
  931|    587|                else
  932|    587|                continue;
  933|    622|            }
  934|  2.64k|            else if (walk[1] == '/') {
  ------------------
  |  Branch (934:22): [True: 725, False: 1.92k]
  ------------------
  935|       |                /* handle "./" */
  936|    725|                if ((walk += 2) >= end) {
  ------------------
  |  Branch (936:21): [True: 60, False: 665]
  ------------------
  937|     60|                    ++out;
  938|     60|                    break;
  939|     60|                }
  940|    665|                continue;
  941|    725|            }
  942|  1.92k|            else {
  943|       |                /* accept "." if not part of "../" or "./" */
  944|  1.92k|                *++out = '.';
  945|  1.92k|                ++walk;
  946|  1.92k|            }
  947|  3.26k|        }
  948|       |
  949|  16.5M|        while ((*++out = *walk++) != '/') ;
  ------------------
  |  Branch (949:16): [True: 16.5M, False: 6.51k]
  ------------------
  950|  6.51k|    }
  951|    378|    *out = *end = '\0'; /* overwrite extra '/' added to end of path */
  952|    378|    b->used = (out - b->ptr) + 1;
  953|       |    /*buffer_truncate(b, out - b->ptr);*/
  954|    378|}
buffer.c:buffer_alloc_replace:
   71|  3.63k|static char* buffer_alloc_replace(buffer * const restrict b, const size_t size) {
   72|       |    /*(discard old data so realloc() does not copy)*/
   73|  3.63k|    if (NULL != b->ptr) {
  ------------------
  |  Branch (73:9): [True: 523, False: 3.10k]
  ------------------
   74|    523|        free(b->ptr);
   75|    523|        b->ptr = NULL;
   76|    523|    }
   77|       |    /*(note: if size larger than one lshift, use size instead of power-2)*/
   78|  3.63k|    const size_t bsize2x = (b->size & ~1uL) << 1;
   79|  3.63k|    return buffer_realloc(b, bsize2x > size ? bsize2x-1 : size);
  ------------------
  |  Branch (79:30): [True: 285, False: 3.34k]
  ------------------
   80|  3.63k|}
buffer.c:buffer_realloc:
   49|  3.63k|static char* buffer_realloc(buffer * const restrict b, const size_t len) {
   50|  3.63k|    #define BUFFER_PIECE_SIZE 64uL  /*(must be power-of-2)*/
   51|  3.63k|    size_t sz = (len + 1 + BUFFER_PIECE_SIZE-1) & ~(BUFFER_PIECE_SIZE-1);
  ------------------
  |  |   50|  3.63k|    #define BUFFER_PIECE_SIZE 64uL  /*(must be power-of-2)*/
  ------------------
                  size_t sz = (len + 1 + BUFFER_PIECE_SIZE-1) & ~(BUFFER_PIECE_SIZE-1);
  ------------------
  |  |   50|  3.63k|    #define BUFFER_PIECE_SIZE 64uL  /*(must be power-of-2)*/
  ------------------
   52|  3.63k|    force_assert(sz > len);
  ------------------
  |  |  448|  3.63k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.63k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.63k]
  |  |  |  |  |  Branch (115:75): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   53|  3.63k|    if ((sz & (sz-1)) && sz < INT_MAX) {/* not power-2; huge val not expected */
  ------------------
  |  Branch (53:9): [True: 1.26k, False: 2.36k]
  |  Branch (53:26): [True: 1.26k, False: 0]
  ------------------
   54|       |        /*(optimizer should recognize this and use ffs or clz or equivalent)*/
   55|  1.26k|        const size_t psz = sz;
   56|  8.64k|        for (sz = 256; sz < psz; sz <<= 1) ;
  ------------------
  |  Branch (56:24): [True: 7.37k, False: 1.26k]
  ------------------
   57|  1.26k|    }
   58|  3.63k|    sz |= 1; /*(extra +1 for '\0' when needed buffer size is exact power-2)*/
   59|       |
   60|  3.63k|    b->size = sz;
   61|  3.63k|    b->ptr = realloc(b->ptr, sz);
   62|       |
   63|  3.63k|    force_assert(NULL != b->ptr);
  ------------------
  |  |  448|  3.63k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.63k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.63k]
  |  |  |  |  |  Branch (115:75): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   64|  3.63k|    return b->ptr;
   65|  3.63k|}

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

burl_normalize:
  338|  1.73k|{
  339|  1.73k|    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.73k|    qs = (flags & HTTP_PARSEOPT_URL_NORMALIZE_REQUIRED)
  ------------------
  |  Branch (353:10): [True: 906, False: 831]
  ------------------
  354|  1.73k|      ? burl_normalize_basic_required(b, t)
  355|  1.73k|      : burl_normalize_basic_unreserved(b, t);
  356|  1.73k|    if (-2 == qs) {
  ------------------
  |  Branch (356:9): [True: 551, False: 1.18k]
  ------------------
  357|    551|        if (flags & HTTP_PARSEOPT_URL_NORMALIZE_INVALID_UTF8_REJECT) return -2;
  ------------------
  |  Branch (357:13): [True: 108, False: 443]
  ------------------
  358|    443|        qs = burl_scan_qmark(b);
  359|    443|    }
  360|       |
  361|  1.62k|    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_CTRLS_REJECT) {
  ------------------
  |  Branch (361:9): [True: 400, False: 1.22k]
  ------------------
  362|    400|        if (burl_contains_ctrls(b)) return -2;
  ------------------
  |  Branch (362:13): [True: 97, False: 303]
  ------------------
  363|    400|    }
  364|       |
  365|  1.53k|    if (flags & (HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_DECODE
  ------------------
  |  Branch (365:9): [True: 1.25k, False: 279]
  ------------------
  366|  1.53k|                |HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)) {
  367|  1.25k|        qs = burl_normalize_2F_to_slash(b, qs, flags);
  368|  1.25k|        if (-2 == qs) return -2;
  ------------------
  |  Branch (368:13): [True: 5, False: 1.24k]
  ------------------
  369|  1.25k|    }
  370|       |
  371|  1.52k|    if (flags & (HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REMOVE
  ------------------
  |  Branch (371:9): [True: 1.22k, False: 307]
  ------------------
  372|  1.52k|                |HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT)) {
  373|  1.22k|        qs = burl_normalize_path(b, t, qs, flags);
  374|  1.22k|        if (-2 == qs) return -2;
  ------------------
  |  Branch (374:13): [True: 22, False: 1.19k]
  ------------------
  375|  1.22k|    }
  376|       |
  377|  1.50k|    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_QUERY_20_PLUS) {
  ------------------
  |  Branch (377:9): [True: 897, False: 608]
  ------------------
  378|    897|        if (qs >= 0) burl_normalize_qs20_to_plus(b, qs);
  ------------------
  |  Branch (378:13): [True: 397, False: 500]
  ------------------
  379|    897|    }
  380|       |
  381|  1.50k|    return qs;
  382|  1.52k|}
burl.c:burl_normalize_basic_required:
  175|    906|{
  176|    906|    const unsigned char * const s = (unsigned char *)b->ptr;
  177|    906|    const int used = (int)buffer_clen(b);
  178|    906|    unsigned int n1, n2, x;
  179|    906|    int qs = -1;
  180|    906|    int invalid_utf8 = 0;
  181|       |
  182|  1.86M|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (182:21): [True: 1.86M, False: 181]
  ------------------
  183|  1.86M|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (183:13): [True: 1.85M, False: 9.90k]
  ------------------
  184|  1.85M|            if (s[i] == '?') qs = i;
  ------------------
  |  Branch (184:17): [True: 1.79k, False: 1.85M]
  ------------------
  185|  1.85M|        }
  186|  9.90k|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  19.2k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 6.56k, False: 2.81k]
  |  |  |  Branch (43:30): [True: 2.74k, False: 65]
  |  |  |  Branch (43:31): [True: 2.74k, False: 65]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  19.2k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 3.56k, False: 5.74k]
  |  |  |  Branch (43:30): [True: 5.68k, False: 62]
  |  |  |  Branch (43:31): [True: 5.68k, False: 62]
  |  |  ------------------
  ------------------
  |  Branch (186:18): [True: 9.37k, False: 527]
  ------------------
  187|  9.90k|                 && (encoded_chars_http_uri_reqd[(x = (n1 << 4) | n2)]
  ------------------
  |  Branch (187:22): [True: 5.47k, False: 3.77k]
  ------------------
  188|  9.25k|                     || (qs < 0
  ------------------
  |  Branch (188:25): [True: 3.70k, False: 71]
  |  Branch (188:26): [True: 1.43k, False: 2.33k]
  ------------------
  189|  3.77k|                         ? (x == '/' || x == '?')
  ------------------
  |  Branch (189:29): [True: 1.00k, False: 436]
  |  Branch (189:41): [True: 400, False: 36]
  ------------------
  190|  9.18k|                         : (x == '&' || x == '=' || x == ';' || x == '+')))) {
  ------------------
  |  Branch (190:29): [True: 696, False: 1.64k]
  |  Branch (190:41): [True: 196, False: 1.44k]
  |  Branch (190:53): [True: 369, False: 1.07k]
  |  Branch (190:65): [True: 1.04k, False: 35]
  ------------------
  191|  9.18k|            invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  9.18k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  9.18k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 1.02k, False: 8.16k]
  |  |  |  |  ------------------
  |  |  |  |  261|  9.18k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 229, False: 7.93k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  192|  9.18k|            if (s[i+1] >= 'a') b->ptr[i+1] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (192:17): [True: 1.86k, False: 7.31k]
  ------------------
  193|  9.18k|            if (s[i+2] >= 'a') b->ptr[i+2] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (193:17): [True: 3.59k, False: 5.58k]
  ------------------
  194|  9.18k|            i+=2;
  195|  9.18k|        }
  196|    725|        else if (s[i] == '#') { /* ignore fragment */
  ------------------
  |  Branch (196:18): [True: 1, False: 724]
  ------------------
  197|      1|            buffer_truncate(b, (size_t)i);
  198|      1|            break;
  199|      1|        }
  200|    724|        else {
  201|    724|            qs = burl_normalize_basic_required_fix(b, t, i, qs);
  202|    724|            break;
  203|    724|        }
  204|  1.86M|    }
  205|       |
  206|    906|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (206:12): [True: 882, False: 24]
  ------------------
  207|    906|}
burl.c:burl_normalize_basic_required_fix:
  131|    724|{
  132|    724|    int j = i;
  133|    724|    const int used = (int)buffer_clen(b);
  134|    724|    const unsigned char * const s = (unsigned char *)b->ptr;
  135|    724|    unsigned char * const p =
  136|    724|      (unsigned char *)buffer_string_prepare_copy(t,i+(used-i)*3+1);
  137|    724|    unsigned int n1, n2;
  138|    724|    int invalid_utf8 = 0;
  139|    724|    memcpy(p, s, (size_t)i);
  140|  26.8M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (140:12): [True: 26.8M, False: 715]
  ------------------
  141|  26.8M|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (141:13): [True: 1.81M, False: 24.9M]
  ------------------
  142|  1.81M|            p[j] = s[i];
  143|  1.81M|            if (__builtin_expect( (s[i] == '?'), 0)) qs = j;
  ------------------
  |  Branch (143:17): [True: 2.38k, False: 1.81M]
  ------------------
  144|  1.81M|        }
  145|  24.9M|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  25.0M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 49.6k, False: 14.9k]
  |  |  |  Branch (43:30): [True: 4.41k, False: 10.4k]
  |  |  |  Branch (43:31): [True: 4.41k, False: 10.4k]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  54.0k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 15.9k, False: 38.1k]
  |  |  |  Branch (43:30): [True: 24.2k, False: 13.8k]
  |  |  |  Branch (43:31): [True: 24.2k, False: 13.8k]
  |  |  ------------------
  ------------------
  |  Branch (145:18): [True: 64.5k, False: 24.9M]
  ------------------
  146|  40.2k|            const unsigned int x = (n1 << 4) | n2;
  147|  40.2k|            if (!encoded_chars_http_uri_reqd[x]
  ------------------
  |  Branch (147:17): [True: 29.6k, False: 10.5k]
  ------------------
  148|  40.2k|                && (qs < 0
  ------------------
  |  Branch (148:20): [True: 24.0k, False: 5.64k]
  |  Branch (148:21): [True: 2.09k, False: 27.5k]
  ------------------
  149|  29.6k|                    ? (x != '/' && x != '?')
  ------------------
  |  Branch (149:24): [True: 1.59k, False: 499]
  |  Branch (149:36): [True: 1.10k, False: 490]
  ------------------
  150|  29.6k|                    : (x != '&' && x != '=' && x != ';' && x != '+'))) {
  ------------------
  |  Branch (150:24): [True: 25.7k, False: 1.87k]
  |  Branch (150:36): [True: 25.1k, False: 557]
  |  Branch (150:48): [True: 24.4k, False: 734]
  |  Branch (150:60): [True: 22.9k, False: 1.48k]
  ------------------
  151|  24.0k|                p[j] = x;
  152|  24.0k|            }
  153|  16.1k|            else {
  154|  16.1k|                p[j]   = '%';
  155|  16.1k|                p[++j] = hex_chars_uc[n1]; /*(s[i+1] & 0xdf)*/
  156|  16.1k|                p[++j] = hex_chars_uc[n2]; /*(s[i+2] & 0xdf)*/
  157|  16.1k|                invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  16.1k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  16.1k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 517, False: 15.6k]
  |  |  |  |  ------------------
  |  |  |  |  261|  16.1k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 729, False: 14.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  158|  16.1k|            }
  159|  40.2k|            i+=2;
  160|  40.2k|        }
  161|  24.9M|        else if (s[i] == '#') break; /* ignore fragment */
  ------------------
  |  Branch (161:18): [True: 9, False: 24.9M]
  ------------------
  162|  24.9M|        else {
  163|  24.9M|            p[j]   = '%';
  164|  24.9M|            p[++j] = hex_chars_uc[(s[i] >> 4) & 0xF];
  165|  24.9M|            p[++j] = hex_chars_uc[s[i] & 0xF];
  166|  24.9M|            invalid_utf8 |= li_utf8_invalid_byte(s[i]);
  ------------------
  |  |   49|  24.9M|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  24.9M|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 1.46M, False: 23.4M]
  |  |  |  |  ------------------
  |  |  |  |  261|  24.9M|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 322, False: 23.4M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  167|  24.9M|        }
  168|  26.8M|    }
  169|    724|    buffer_copy_string_len(b, (char *)p, (size_t)j);
  170|    724|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (170:12): [True: 458, False: 266]
  ------------------
  171|    724|}
burl.c:burl_normalize_basic_unreserved:
   99|    831|{
  100|    831|    const unsigned char * const s = (unsigned char *)b->ptr;
  101|    831|    const int used = (int)buffer_clen(b);
  102|    831|    unsigned int n1, n2, x;
  103|    831|    int qs = -1;
  104|       |
  105|   196k|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (105:21): [True: 196k, False: 188]
  ------------------
  106|   196k|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (106:13): [True: 192k, False: 4.17k]
  ------------------
  107|   192k|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = i;
  ------------------
  |  Branch (107:17): [True: 372, False: 191k]
  |  Branch (107:56): [True: 81, False: 291]
  ------------------
  108|   192k|        }
  109|  4.17k|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  7.89k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 1.49k, False: 2.22k]
  |  |  |  Branch (43:30): [True: 2.14k, False: 79]
  |  |  |  Branch (43:31): [True: 2.14k, False: 79]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  7.81k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 1.24k, False: 2.40k]
  |  |  |  Branch (43:30): [True: 2.34k, False: 55]
  |  |  |  Branch (43:31): [True: 2.34k, False: 55]
  |  |  ------------------
  ------------------
  |  Branch (109:18): [True: 3.71k, False: 457]
  ------------------
  110|  4.17k|                 && !burl_is_unreserved((x = (n1 << 4) | n2))) {
  ------------------
  |  Branch (110:21): [True: 3.53k, False: 52]
  ------------------
  111|  3.53k|            if (li_utf8_invalid_byte(x)) qs = -2;
  ------------------
  |  |   49|  3.53k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  3.53k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 861, False: 2.67k]
  |  |  |  |  ------------------
  |  |  |  |  261|  3.53k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 341, False: 2.33k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  112|  3.53k|            if (s[i+1] >= 'a') b->ptr[i+1] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (112:17): [True: 1.50k, False: 2.02k]
  ------------------
  113|  3.53k|            if (s[i+2] >= 'a') b->ptr[i+2] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (113:17): [True: 1.53k, False: 2.00k]
  ------------------
  114|  3.53k|            i+=2;
  115|  3.53k|        }
  116|    643|        else if (s[i] == '#') { /* ignore fragment */
  ------------------
  |  Branch (116:18): [True: 1, False: 642]
  ------------------
  117|      1|            buffer_truncate(b, (size_t)i);
  118|      1|            break;
  119|      1|        }
  120|    642|        else {
  121|    642|            qs = burl_normalize_basic_unreserved_fix(b, t, i, qs);
  122|    642|            break;
  123|    642|        }
  124|   196k|    }
  125|       |
  126|    831|    return qs;
  127|    831|}
burl.c:burl_is_unreserved:
   53|  9.68k|{
   54|  9.68k|    return (light_isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~');
  ------------------
  |  Branch (54:13): [True: 604, False: 9.08k]
  |  Branch (54:33): [True: 384, False: 8.69k]
  |  Branch (54:45): [True: 219, False: 8.47k]
  |  Branch (54:57): [True: 222, False: 8.25k]
  |  Branch (54:69): [True: 9, False: 8.24k]
  ------------------
   55|  9.68k|}
burl.c:burl_normalize_basic_unreserved_fix:
   59|    642|{
   60|    642|    int j = i;
   61|    642|    const int used = (int)buffer_clen(b);
   62|    642|    const unsigned char * const s = (unsigned char *)b->ptr;
   63|    642|    unsigned char * const p =
   64|    642|      (unsigned char *)buffer_string_prepare_copy(t,i+(used-i)*3+1);
   65|    642|    unsigned int n1, n2;
   66|    642|    memcpy(p, s, (size_t)i);
   67|  27.3M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (67:12): [True: 27.3M, False: 632]
  ------------------
   68|  27.3M|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (68:13): [True: 2.01M, False: 25.3M]
  ------------------
   69|  2.01M|            p[j] = s[i];
   70|  2.01M|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = j;
  ------------------
  |  Branch (70:17): [True: 862, False: 2.01M]
  |  Branch (70:56): [True: 70, False: 792]
  ------------------
   71|  2.01M|        }
   72|  25.3M|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  25.3M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 4.65k, False: 9.07k]
  |  |  |  Branch (43:30): [True: 2.58k, False: 6.49k]
  |  |  |  Branch (43:31): [True: 2.58k, False: 6.49k]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  7.23k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 2.15k, False: 5.08k]
  |  |  |  Branch (43:30): [True: 3.94k, False: 1.13k]
  |  |  |  Branch (43:31): [True: 3.94k, False: 1.13k]
  |  |  ------------------
  ------------------
  |  Branch (72:18): [True: 13.7k, False: 25.3M]
  ------------------
   73|  6.10k|            const unsigned int x = (n1 << 4) | n2;
   74|  6.10k|            if (burl_is_unreserved(x)) {
  ------------------
  |  Branch (74:17): [True: 1.38k, False: 4.71k]
  ------------------
   75|  1.38k|                p[j] = x;
   76|  1.38k|            }
   77|  4.71k|            else {
   78|  4.71k|                p[j]   = '%';
   79|  4.71k|                p[++j] = hex_chars_uc[n1]; /*(s[i+1] & 0xdf)*/
   80|  4.71k|                p[++j] = hex_chars_uc[n2]; /*(s[i+2] & 0xdf)*/
   81|  4.71k|                if (li_utf8_invalid_byte(x)) qs = -2;
  ------------------
  |  |   49|  4.71k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  4.71k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 738, False: 3.97k]
  |  |  |  |  ------------------
  |  |  |  |  261|  4.71k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 351, False: 3.62k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   82|  4.71k|            }
   83|  6.10k|            i+=2;
   84|  6.10k|        }
   85|  25.3M|        else if (s[i] == '#') break; /* ignore fragment */
  ------------------
  |  Branch (85:18): [True: 10, False: 25.3M]
  ------------------
   86|  25.3M|        else {
   87|  25.3M|            p[j]   = '%';
   88|  25.3M|            p[++j] = hex_chars_uc[(s[i] >> 4) & 0xF];
   89|  25.3M|            p[++j] = hex_chars_uc[s[i] & 0xF];
   90|  25.3M|            if (li_utf8_invalid_byte(s[i])) qs = -2;
  ------------------
  |  |   49|  25.3M|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  25.3M|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 2.54M, False: 22.8M]
  |  |  |  |  ------------------
  |  |  |  |  261|  25.3M|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 1.52k, False: 22.8M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   91|  25.3M|        }
   92|  27.3M|    }
   93|    642|    buffer_copy_string_len(b, (char *)p, (size_t)j);
   94|    642|    return qs;
   95|    642|}
burl.c:burl_scan_qmark:
  331|    443|static int burl_scan_qmark (const buffer * const b) {
  332|    443|    const char * const qmark = strchr(b->ptr, '?');
  333|    443|    return qmark ? (int)(qmark - b->ptr) : -1;
  ------------------
  |  Branch (333:12): [True: 189, False: 254]
  ------------------
  334|    443|}
burl.c:burl_contains_ctrls:
  211|    400|{
  212|    400|    const char * const s = b->ptr;
  213|    400|    const int used = (int)buffer_clen(b);
  214|  18.2M|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (214:21): [True: 18.2M, False: 303]
  ------------------
  215|  18.2M|        if (s[i] == '%' && (s[i+1] < '2' || (s[i+1] == '7' && s[i+2] == 'F')))
  ------------------
  |  Branch (215:13): [True: 5.99M, False: 12.2M]
  |  Branch (215:29): [True: 90, False: 5.99M]
  |  Branch (215:46): [True: 1.14k, False: 5.99M]
  |  Branch (215:63): [True: 7, False: 1.14k]
  ------------------
  216|     97|            return 1;
  217|  18.2M|    }
  218|    303|    return 0;
  219|    400|}
burl.c:burl_normalize_2F_to_slash:
  276|  1.25k|{
  277|       |    /*("%2F" must already have been uppercased during normalization)*/
  278|  1.25k|    const char * const s = b->ptr;
  279|  1.25k|    const int used = qs < 0 ? (int)buffer_clen(b) : qs;
  ------------------
  |  Branch (279:22): [True: 797, False: 456]
  ------------------
  280|  68.5M|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (280:21): [True: 68.5M, False: 1.07k]
  ------------------
  281|  68.5M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == 'F') {
  ------------------
  |  Branch (281:13): [True: 22.2M, False: 46.3M]
  |  Branch (281:28): [True: 789k, False: 21.4M]
  |  Branch (281:45): [True: 180, False: 789k]
  ------------------
  282|    180|            return (flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_DECODE)
  ------------------
  |  Branch (282:20): [True: 175, False: 5]
  ------------------
  283|    180|              ? burl_normalize_2F_to_slash_fix(b, qs, i)
  284|    180|              : -2; /*(flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)*/
  285|    180|        }
  286|  68.5M|    }
  287|  1.07k|    return qs;
  288|  1.25k|}
burl.c:burl_normalize_2F_to_slash_fix:
  252|    175|{
  253|    175|    char * const s = b->ptr;
  254|    175|    const int blen = (int)buffer_clen(b);
  255|    175|    const int used = qs < 0 ? blen : qs;
  ------------------
  |  Branch (255:22): [True: 125, False: 50]
  ------------------
  256|    175|    int j = i;
  257|  20.4M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (257:12): [True: 20.4M, False: 175]
  ------------------
  258|  20.4M|        s[j] = s[i];
  259|  20.4M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == 'F') {
  ------------------
  |  Branch (259:13): [True: 6.74M, False: 13.7M]
  |  Branch (259:28): [True: 6.84k, False: 6.73M]
  |  Branch (259:45): [True: 2.11k, False: 4.72k]
  ------------------
  260|  2.11k|            s[j] = '/';
  261|  2.11k|            i+=2;
  262|  2.11k|        }
  263|  20.4M|    }
  264|    175|    if (qs >= 0) {
  ------------------
  |  Branch (264:9): [True: 50, False: 125]
  ------------------
  265|     50|        const int qslen = blen - qs;
  266|     50|        memmove(s+j, s+qs, (size_t)qslen);
  267|     50|        qs = j;
  268|     50|        j += qslen;
  269|     50|    }
  270|    175|    buffer_truncate(b, j);
  271|    175|    return qs;
  272|    175|}
burl.c:burl_normalize_path:
  292|  1.22k|{
  293|  1.22k|    const unsigned char * const s = (unsigned char *)b->ptr;
  294|  1.22k|    const int used = (int)buffer_clen(b);
  295|  1.22k|    int path_simplify = 0;
  296|  7.27k|    for (int i = 0, len = qs < 0 ? used : qs; i < len; ++i) {
  ------------------
  |  Branch (296:27): [True: 785, False: 435]
  |  Branch (296:47): [True: 6.45k, False: 820]
  ------------------
  297|  6.45k|        if (s[i] == '.' && (s[i+1] != '.' || ++i)
  ------------------
  |  Branch (297:13): [True: 1.69k, False: 4.75k]
  |  Branch (297:29): [True: 836, False: 858]
  |  Branch (297:46): [True: 858, False: 0]
  ------------------
  298|  6.45k|            && (s[i+1] == '/' || s[i+1] == '?' || s[i+1] == '\0')) {
  ------------------
  |  Branch (298:17): [True: 89, False: 1.60k]
  |  Branch (298:34): [True: 86, False: 1.51k]
  |  Branch (298:51): [True: 76, False: 1.44k]
  ------------------
  299|    251|            path_simplify = 1;
  300|    251|            break;
  301|    251|        }
  302|  68.3M|        while (i < len && s[i] != '/') ++i;
  ------------------
  |  Branch (302:16): [True: 68.3M, False: 669]
  |  Branch (302:27): [True: 68.3M, False: 5.53k]
  ------------------
  303|  6.20k|        if (s[i] == '/' && s[i+1] == '/') { /*(s[len] != '/')*/
  ------------------
  |  Branch (303:13): [True: 5.53k, False: 669]
  |  Branch (303:28): [True: 149, False: 5.38k]
  ------------------
  304|    149|            path_simplify = 1;
  305|    149|            break;
  306|    149|        }
  307|  6.20k|    }
  308|       |
  309|  1.22k|    if (path_simplify) {
  ------------------
  |  Branch (309:9): [True: 400, False: 820]
  ------------------
  310|    400|        if (flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT) return -2;
  ------------------
  |  Branch (310:13): [True: 22, False: 378]
  ------------------
  311|    378|        if (qs >= 0) {
  ------------------
  |  Branch (311:13): [True: 135, False: 243]
  ------------------
  312|    135|            buffer_copy_string_len(t, b->ptr+qs, used - qs);
  313|    135|            buffer_truncate(b, qs);
  314|    135|        }
  315|       |
  316|    378|        buffer_path_simplify(b);
  317|       |
  318|    378|        if (qs >= 0) {
  ------------------
  |  Branch (318:13): [True: 135, False: 243]
  ------------------
  319|    135|            qs = (int)buffer_clen(b);
  320|    135|            buffer_append_string_len(b, BUF_PTR_LEN(t));
  ------------------
  |  |  297|    135|#define BUF_PTR_LEN(x)       (x)->ptr, buffer_clen(x)
  ------------------
  321|    135|        }
  322|    378|    }
  323|       |
  324|  1.19k|    return qs;
  325|  1.22k|}
burl.c:burl_normalize_qs20_to_plus:
  239|    397|{
  240|    397|    const char * const s = b->ptr;
  241|    397|    const int used = qs < 0 ? 0 : (int)buffer_clen(b);
  ------------------
  |  Branch (241:22): [True: 0, False: 397]
  ------------------
  242|    397|    int i;
  243|    397|    if (qs < 0) return;
  ------------------
  |  Branch (243:9): [True: 0, False: 397]
  ------------------
  244|  11.7M|    for (i = qs+1; i < used; ++i) {
  ------------------
  |  Branch (244:20): [True: 11.7M, False: 296]
  ------------------
  245|  11.7M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == '0') break;
  ------------------
  |  Branch (245:13): [True: 3.91M, False: 7.82M]
  |  Branch (245:28): [True: 2.42k, False: 3.90M]
  |  Branch (245:45): [True: 101, False: 2.32k]
  ------------------
  246|  11.7M|    }
  247|    397|    if (i != used) burl_normalize_qs20_to_plus_fix(b, i);
  ------------------
  |  Branch (247:9): [True: 101, False: 296]
  ------------------
  248|    397|}
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|  10.2M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (227:12): [True: 10.2M, False: 101]
  ------------------
  228|  10.2M|        s[j] = s[i];
  229|  10.2M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == '0') {
  ------------------
  |  Branch (229:13): [True: 3.16M, False: 7.07M]
  |  Branch (229:28): [True: 63.5k, False: 3.10M]
  |  Branch (229:45): [True: 42.5k, False: 21.0k]
  ------------------
  230|  42.5k|            s[j] = '+';
  231|  42.5k|            i+=2;
  232|  42.5k|        }
  233|  10.2M|    }
  234|    101|    buffer_truncate(b, j);
  235|    101|}

