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, False: 3.47k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   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.34k|char* buffer_string_prepare_copy(buffer * const b, const size_t size) {
   83|  1.34k|    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.34k|    return (size < b->size)
  ------------------
  |  Branch (87:12): [True: 0, False: 1.34k]
  ------------------
   88|  1.34k|      ? b->ptr
   89|  1.34k|      : buffer_alloc_replace(b, size);
   90|  1.34k|}
buffer_extend:
  127|    145|{
  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|    145|    const uint32_t len = b->used ? b->used-1 : 0;
  ------------------
  |  Branch (136:26): [True: 145, False: 0]
  ------------------
  137|    145|    char * const s = (b->size - len >= x + 1)
  ------------------
  |  Branch (137:22): [True: 145, False: 0]
  ------------------
  138|    145|      ? b->ptr + len
  139|    145|      : buffer_string_prepare_append_resize(b, x);
  140|    145|    b->used = len+x+1;
  141|    145|  #endif
  142|    145|    s[x] = '\0';
  143|    145|    return s;
  144|    145|}
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: 977, False: 2.25k]
  ------------------
  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|    145|void buffer_append_string_len(buffer * const restrict b, const char * const restrict s, const size_t len) {
  199|    145|    memcpy(buffer_extend(b, len), s, len);
  200|    145|}
hex2int:
  386|   116M|char hex2int(unsigned char hex) {
  387|   116M|	unsigned char n;
  388|   116M|	return li_cton(hex,n) ? (char)n : 0xFF;
  ------------------
  |  |  381|   116M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (381:4): [True: 103M, False: 12.4M]
  |  |  |  Branch (381:30): [True: 12.4M, False: 0]
  |  |  |  Branch (381:31): [True: 12.4M, False: 0]
  |  |  ------------------
  ------------------
  389|   116M|}
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: 6]
  ------------------
  795|  1.73k|    if (NULL == src) return;
  ------------------
  |  Branch (795:9): [True: 363, False: 1.37k]
  ------------------
  796|       |
  797|  1.37k|    char *dst = src;
  798|  58.0M|    do {
  799|       |        /* *src == '%' */
  800|  58.0M|        unsigned char high = ((unsigned char *)src)[1];
  801|  58.0M|        unsigned char low = high ? hex2int(((unsigned char *)src)[2]) : 0xFF;
  ------------------
  |  Branch (801:29): [True: 58.0M, False: 0]
  ------------------
  802|  58.0M|        if (0xFF != (high = hex2int(high)) && 0xFF != low) {
  ------------------
  |  Branch (802:13): [True: 58.0M, False: 0]
  |  Branch (802:47): [True: 58.0M, False: 0]
  ------------------
  803|  58.0M|            high = (high << 4) | low;   /* map ctrls to '_' */
  804|  58.0M|            *dst = (high >= 32 && high != 127) ? high : '_';
  ------------------
  |  Branch (804:21): [True: 10.1M, False: 47.8M]
  |  Branch (804:35): [True: 8.79M, False: 1.33M]
  ------------------
  805|  58.0M|            src += 2;
  806|  58.0M|        } /* else ignore this '%'; leave as-is and move on */
  807|       |
  808|  61.4M|        while ((*++dst = *++src) != '%' && *src) ;
  ------------------
  |  Branch (808:16): [True: 3.45M, False: 58.0M]
  |  Branch (808:44): [True: 3.45M, False: 1.37k]
  ------------------
  809|  58.0M|    } while (*src);
  ------------------
  |  Branch (809:14): [True: 58.0M, False: 1.37k]
  ------------------
  810|  1.37k|    b->used = (dst - b->ptr) + 1;
  811|  1.37k|}
buffer_path_simplify:
  859|    390|{
  860|    390|    char *out = b->ptr;
  861|    390|    char * const end = b->ptr + b->used - 1;
  862|       |
  863|    390|    if (__builtin_expect( (buffer_is_blank(b)), 0)) {
  ------------------
  |  Branch (863:9): [True: 0, False: 390]
  ------------------
  864|      0|        buffer_blank(b);
  865|      0|        return;
  866|      0|    }
  867|       |
  868|       |  #if defined(_WIN32) || defined(__CYGWIN__)
  869|       |    /* cygwin is treating \ and / the same, so we have to that too */
  870|       |    for (char *p = b->ptr; *p; p++) {
  871|       |        if (*p == '\\') *p = '/';
  872|       |    }
  873|       |  #endif
  874|       |
  875|    390|    *end = '/'; /*(end of path modified to avoid need to check '\0')*/
  876|       |
  877|    390|    char *walk = out;
  878|    390|    if (__builtin_expect( (*walk == '/'), 1)) {
  ------------------
  |  Branch (878:9): [True: 156, False: 234]
  ------------------
  879|       |        /* scan to detect (potential) need for path simplification
  880|       |         * (repeated '/' or "/.") */
  881|    595|        do {
  882|    595|            if (*++walk == '.' || *walk == '/')
  ------------------
  |  Branch (882:17): [True: 84, False: 511]
  |  Branch (882:35): [True: 72, False: 439]
  ------------------
  883|    156|                break;
  884|   618k|            do { ++walk; } while (*walk != '/');
  ------------------
  |  Branch (884:35): [True: 618k, False: 439]
  ------------------
  885|    439|        } while (walk != end);
  ------------------
  |  Branch (885:18): [True: 439, False: 0]
  ------------------
  886|    156|        if (__builtin_expect( (walk == end), 1)) {
  ------------------
  |  Branch (886:13): [True: 0, False: 156]
  ------------------
  887|       |            /* common case: no repeated '/' or "/." */
  888|      0|            *end = '\0'; /* overwrite extra '/' added to end of path */
  889|      0|            return;
  890|      0|        }
  891|    156|        out = walk-1;
  892|    156|    }
  893|    234|    else {
  894|    234|        if (walk[0] == '.' && walk[1] == '/')
  ------------------
  |  Branch (894:13): [True: 103, False: 131]
  |  Branch (894:31): [True: 69, False: 34]
  ------------------
  895|     69|            *out = *++walk;
  896|    165|        else if (walk[0] == '.' && walk[1] == '.' && walk[2] == '/')
  ------------------
  |  Branch (896:18): [True: 34, False: 131]
  |  Branch (896:36): [True: 16, False: 18]
  |  Branch (896:54): [True: 1, False: 15]
  ------------------
  897|      1|            *out = *(walk += 2);
  898|    164|        else {
  899|  6.22M|            while (*++walk != '/') ;
  ------------------
  |  Branch (899:20): [True: 6.21M, False: 164]
  ------------------
  900|    164|            out = walk;
  901|    164|        }
  902|    234|        ++walk;
  903|    234|    }
  904|       |
  905|  16.5k|    while (walk <= end) {
  ------------------
  |  Branch (905:12): [True: 16.3k, False: 209]
  ------------------
  906|       |        /* previous char is '/' at this point (or start of string w/o '/') */
  907|  16.3k|        if (__builtin_expect( (walk[0] == '/'), 0)) {
  ------------------
  |  Branch (907:13): [True: 2.13k, False: 14.1k]
  ------------------
  908|       |            /* skip repeated '/' (e.g. "///" -> "/") */
  909|  2.13k|            if (++walk < end)
  ------------------
  |  Branch (909:17): [True: 2.07k, False: 61]
  ------------------
  910|  2.07k|                continue;
  911|     61|            else {
  912|     61|                ++out;
  913|     61|                break;
  914|     61|            }
  915|  2.13k|        }
  916|  14.1k|        else if (__builtin_expect( (walk[0] == '.'), 0)) {
  ------------------
  |  Branch (916:18): [True: 9.89k, False: 4.29k]
  ------------------
  917|       |            /* handle "./" and "../" */
  918|  9.89k|            if (walk[1] == '.' && walk[2] == '/') {
  ------------------
  |  Branch (918:17): [True: 6.16k, False: 3.73k]
  |  Branch (918:35): [True: 2.28k, False: 3.87k]
  ------------------
  919|       |                /* handle "../" */
  920|  1.69M|                while (out > b->ptr && *--out != '/') ;
  ------------------
  |  Branch (920:24): [True: 1.69M, False: 471]
  |  Branch (920:40): [True: 1.68M, False: 1.81k]
  ------------------
  921|  2.28k|                *out = '/'; /*(in case path had not started with '/')*/
  922|  2.28k|                if ((walk += 3) >= end) {
  ------------------
  |  Branch (922:21): [True: 51, False: 2.23k]
  ------------------
  923|     51|                    ++out;
  924|     51|                    break;
  925|     51|                }
  926|  2.23k|                else
  927|  2.23k|                    continue;
  928|  2.28k|            }
  929|  7.61k|            else if (walk[1] == '/') {
  ------------------
  |  Branch (929:22): [True: 1.32k, False: 6.29k]
  ------------------
  930|       |                /* handle "./" */
  931|  1.32k|                if ((walk += 2) >= end) {
  ------------------
  |  Branch (931:21): [True: 69, False: 1.25k]
  ------------------
  932|     69|                    ++out;
  933|     69|                    break;
  934|     69|                }
  935|  1.25k|                continue;
  936|  1.32k|            }
  937|  6.29k|            else {
  938|       |                /* accept "." if not part of "../" or "./" */
  939|  6.29k|                *++out = '.';
  940|  6.29k|                ++walk;
  941|  6.29k|            }
  942|  9.89k|        }
  943|       |
  944|  27.7M|        while ((*++out = *walk++) != '/') ;
  ------------------
  |  Branch (944:16): [True: 27.7M, False: 10.5k]
  ------------------
  945|  10.5k|    }
  946|    390|    *out = *end = '\0'; /* overwrite extra '/' added to end of path */
  947|    390|    b->used = (out - b->ptr) + 1;
  948|       |    /*buffer_truncate(b, out - b->ptr);*/
  949|    390|}
buffer.c:buffer_alloc_replace:
   71|  3.59k|static char* buffer_alloc_replace(buffer * const restrict b, const size_t size) {
   72|       |    /*(discard old data so realloc() does not copy)*/
   73|  3.59k|    if (NULL != b->ptr) {
  ------------------
  |  Branch (73:9): [True: 506, False: 3.09k]
  ------------------
   74|    506|        free(b->ptr);
   75|    506|        b->ptr = NULL;
   76|    506|    }
   77|       |    /*(note: if size larger than one lshift, use size instead of power-2)*/
   78|  3.59k|    const size_t bsize2x = (b->size & ~1uL) << 1;
   79|  3.59k|    return buffer_realloc(b, bsize2x > size ? bsize2x-1 : size);
  ------------------
  |  Branch (79:30): [True: 255, False: 3.34k]
  ------------------
   80|  3.59k|}
buffer.c:buffer_realloc:
   49|  3.59k|static char* buffer_realloc(buffer * const restrict b, const size_t len) {
   50|  3.59k|    #define BUFFER_PIECE_SIZE 64uL  /*(must be power-of-2)*/
   51|  3.59k|    size_t sz = (len + 1 + BUFFER_PIECE_SIZE-1) & ~(BUFFER_PIECE_SIZE-1);
  ------------------
  |  |   50|  3.59k|    #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.59k|    #define BUFFER_PIECE_SIZE 64uL  /*(must be power-of-2)*/
  ------------------
   52|  3.59k|    force_assert(sz > len);
  ------------------
  |  |  448|  3.59k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.59k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.59k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.59k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   53|  3.59k|    if ((sz & (sz-1)) && sz < INT_MAX) {/* not power-2; huge val not expected */
  ------------------
  |  Branch (53:9): [True: 1.22k, False: 2.37k]
  |  Branch (53:26): [True: 1.22k, False: 0]
  ------------------
   54|       |        /*(optimizer should recognize this and use ffs or clz or equivalent)*/
   55|  1.22k|        const size_t psz = sz;
   56|  8.56k|        for (sz = 256; sz < psz; sz <<= 1) ;
  ------------------
  |  Branch (56:24): [True: 7.33k, False: 1.22k]
  ------------------
   57|  1.22k|    }
   58|  3.59k|    sz |= 1; /*(extra +1 for '\0' when needed buffer size is exact power-2)*/
   59|       |
   60|  3.59k|    b->size = sz;
   61|  3.59k|    b->ptr = realloc(b->ptr, sz);
   62|       |
   63|  3.59k|    force_assert(NULL != b->ptr);
  ------------------
  |  |  448|  3.59k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.59k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.59k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.59k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   64|  3.59k|    return b->ptr;
   65|  3.59k|}

burl.c:buffer_truncate:
  349|    442|static inline void buffer_truncate(buffer *b, uint32_t len) {
  350|    442|    b->ptr[len] = '\0'; /* b->ptr must exist; use buffer_blank() for trunc 0 */
  351|    442|    b->used = len + 1;
  352|    442|}
burl.c:light_isalnum:
  232|  19.8k|static inline int light_isalnum(int c) {
  233|  19.8k|	return light_isdigit(c) || light_isalpha(c);
  ------------------
  |  Branch (233:9): [True: 351, False: 19.4k]
  |  Branch (233:29): [True: 411, False: 19.0k]
  ------------------
  234|  19.8k|}
burl.c:light_isdigit:
  214|  19.8k|static inline int light_isdigit(int c) {
  215|  19.8k|	return ((uint32_t)c-'0' <= '9'-'0');
  216|  19.8k|}
burl.c:light_isalpha:
  226|  19.4k|static inline int light_isalpha(int c) {
  227|  19.4k|	return (((uint32_t)c | 0x20)-'a' <= 'z'-'a');
  228|  19.4k|}
burl.c:buffer_clen:
  323|  6.42k|static inline uint32_t buffer_clen (const buffer *b) {
  324|  6.42k|    return b->used - (0 != b->used);
  325|  6.42k|}
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|    390|static inline int buffer_is_blank(const buffer *b) {
  316|    390|    return b->used < 2; /* buffer_is_blank() || buffer_is_unset() */
  317|    390|}

burl_normalize:
  344|  1.73k|{
  345|  1.73k|    int qs;
  346|       |
  347|       |  #if defined(_WIN32) || defined(__CYGWIN__)
  348|       |    /* Windows and Cygwin treat '\\' as '/' if '\\' is present in path;
  349|       |     * convert to '/' for consistency before percent-encoding
  350|       |     * normalization which will convert '\\' to "%5C" in the URL.
  351|       |     * (Clients still should not be sending '\\' unencoded in requests.) */
  352|       |    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_BACKSLASH_TRANS) {
  353|       |        for (char *p = b->ptr; *p != '?' && *p != '\0'; ++p) {
  354|       |            if (*p == '\\') *p = '/';
  355|       |            if (p[0] == '%' && p[1] == '5' && (p[2] | 0x20) == 'c') {
  356|       |                p[1] = '2';
  357|       |                p[2] = 'F';
  358|       |                p += 2;
  359|       |            }
  360|       |        }
  361|       |    }
  362|       |  #endif
  363|       |
  364|  1.73k|    qs = (flags & HTTP_PARSEOPT_URL_NORMALIZE_REQUIRED)
  ------------------
  |  Branch (364:10): [True: 959, False: 780]
  ------------------
  365|  1.73k|      ? burl_normalize_basic_required(b, t)
  366|  1.73k|      : burl_normalize_basic_unreserved(b, t);
  367|  1.73k|    if (-2 == qs) {
  ------------------
  |  Branch (367:9): [True: 551, False: 1.18k]
  ------------------
  368|    551|        if (flags & HTTP_PARSEOPT_URL_NORMALIZE_INVALID_UTF8_REJECT) return -2;
  ------------------
  |  Branch (368:13): [True: 130, False: 421]
  ------------------
  369|    421|        qs = burl_scan_qmark(b);
  370|    421|    }
  371|       |
  372|  1.60k|    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_CTRLS_REJECT) {
  ------------------
  |  Branch (372:9): [True: 341, False: 1.26k]
  ------------------
  373|    341|        if (burl_contains_ctrls(b)) return -2;
  ------------------
  |  Branch (373:13): [True: 97, False: 244]
  ------------------
  374|    341|    }
  375|       |
  376|  1.51k|    if (flags & (HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_DECODE
  ------------------
  |  Branch (376:9): [True: 1.27k, False: 240]
  ------------------
  377|  1.51k|                |HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)) {
  378|  1.27k|        qs = burl_normalize_2F_to_slash(b, qs, flags);
  379|  1.27k|        if (-2 == qs) return -2;
  ------------------
  |  Branch (379:13): [True: 20, False: 1.25k]
  ------------------
  380|  1.27k|    }
  381|       |
  382|  1.49k|    if (flags & (HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REMOVE
  ------------------
  |  Branch (382:9): [True: 1.20k, False: 286]
  ------------------
  383|  1.49k|                |HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT)) {
  384|  1.20k|        qs = burl_normalize_path(b, t, qs, flags);
  385|  1.20k|        if (-2 == qs) return -2;
  ------------------
  |  Branch (385:13): [True: 11, False: 1.19k]
  ------------------
  386|  1.20k|    }
  387|       |
  388|  1.48k|    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_QUERY_20_PLUS) {
  ------------------
  |  Branch (388:9): [True: 924, False: 557]
  ------------------
  389|    924|        if (qs >= 0) burl_normalize_qs20_to_plus(b, qs);
  ------------------
  |  Branch (389:13): [True: 447, False: 477]
  ------------------
  390|    924|    }
  391|       |
  392|  1.48k|    return qs;
  393|  1.49k|}
burl.c:burl_normalize_basic_required:
  179|    959|{
  180|    959|    const unsigned char * const s = (unsigned char *)b->ptr;
  181|    959|    const int used = (int)buffer_clen(b);
  182|    959|    unsigned int n1, n2, x;
  183|    959|    int qs = -1;
  184|    959|    int invalid_utf8 = 0;
  185|       |
  186|   358k|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (186:21): [True: 357k, False: 208]
  ------------------
  187|   357k|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (187:13): [True: 347k, False: 10.1k]
  ------------------
  188|   347k|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = i;
  ------------------
  |  Branch (188:17): [True: 1.04k, False: 346k]
  |  Branch (188:56): [True: 238, False: 806]
  ------------------
  189|   347k|        }
  190|  10.1k|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  19.6k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 7.10k, False: 2.47k]
  |  |  |  Branch (43:30): [True: 2.38k, False: 90]
  |  |  |  Branch (43:31): [True: 2.38k, False: 90]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  19.5k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 3.38k, False: 6.09k]
  |  |  |  Branch (43:30): [True: 6.04k, False: 57]
  |  |  |  Branch (43:31): [True: 6.04k, False: 57]
  |  |  ------------------
  ------------------
  |  Branch (190:18): [True: 9.57k, False: 528]
  ------------------
  191|  9.43k|                 && (encoded_chars_http_uri_reqd[(x = (n1 << 4) | n2)]
  ------------------
  |  Branch (191:22): [True: 4.78k, False: 4.64k]
  ------------------
  192|  4.64k|                     || (qs < 0
  ------------------
  |  Branch (192:25): [True: 4.57k, False: 76]
  |  Branch (192:26): [True: 3.21k, False: 1.43k]
  ------------------
  193|  4.64k|                         ? (x == '/' || x == '?')
  ------------------
  |  Branch (193:29): [True: 2.44k, False: 768]
  |  Branch (193:41): [True: 733, False: 35]
  ------------------
  194|  9.35k|                         : (x == '&' || x == '=' || x == ';' || x == '+')))) {
  ------------------
  |  Branch (194:29): [True: 498, False: 935]
  |  Branch (194:41): [True: 340, False: 595]
  |  Branch (194:53): [True: 294, False: 301]
  |  Branch (194:65): [True: 260, False: 41]
  ------------------
  195|  9.35k|            invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  9.35k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  9.35k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 1.26k, False: 8.09k]
  |  |  |  |  ------------------
  |  |  |  |  261|  9.35k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 139, False: 7.95k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|  9.35k|            if (s[i+1] >= 'a') b->ptr[i+1] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (196:17): [True: 1.05k, False: 8.30k]
  ------------------
  197|  9.35k|            if (s[i+2] >= 'a') b->ptr[i+2] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (197:17): [True: 4.90k, False: 4.45k]
  ------------------
  198|  9.35k|            i+=2;
  199|  9.35k|        }
  200|    751|        else if (s[i] == '#') { /* ignore fragment */
  ------------------
  |  Branch (200:18): [True: 1, False: 750]
  ------------------
  201|      1|            buffer_truncate(b, (size_t)i);
  202|      1|            break;
  203|      1|        }
  204|    750|        else {
  205|    750|            qs = burl_normalize_basic_required_fix(b, t, i, qs);
  206|    750|            break;
  207|    750|        }
  208|   357k|    }
  209|       |
  210|    959|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (210:12): [True: 926, False: 33]
  ------------------
  211|    959|}
burl.c:burl_normalize_basic_required_fix:
  135|    750|{
  136|    750|    int j = i;
  137|    750|    const int used = (int)buffer_clen(b);
  138|    750|    const unsigned char * const s = (unsigned char *)b->ptr;
  139|    750|    unsigned char * const p =
  140|    750|      (unsigned char *)buffer_string_prepare_copy(t,i+(used-i)*3+1);
  141|    750|    unsigned int n1, n2;
  142|    750|    int invalid_utf8 = 0;
  143|    750|    memcpy(p, s, (size_t)i);
  144|  34.7M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (144:12): [True: 34.7M, False: 737]
  ------------------
  145|  34.7M|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (145:13): [True: 1.63M, False: 33.0M]
  ------------------
  146|  1.63M|            p[j] = s[i];
  147|  1.63M|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = j;
  ------------------
  |  Branch (147:17): [True: 15.2k, False: 1.62M]
  |  Branch (147:56): [True: 195, False: 15.0k]
  ------------------
  148|  1.63M|        }
  149|  33.0M|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  33.1M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 69.9k, False: 17.4k]
  |  |  |  Branch (43:30): [True: 7.24k, False: 10.1k]
  |  |  |  Branch (43:31): [True: 7.24k, False: 10.1k]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  77.1k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 14.0k, False: 63.1k]
  |  |  |  Branch (43:30): [True: 54.6k, False: 8.47k]
  |  |  |  Branch (43:31): [True: 54.6k, False: 8.47k]
  |  |  ------------------
  ------------------
  |  Branch (149:18): [True: 87.3k, False: 32.9M]
  ------------------
  150|  68.6k|            const unsigned int x = (n1 << 4) | n2;
  151|  68.6k|            if (!encoded_chars_http_uri_reqd[x]
  ------------------
  |  Branch (151:17): [True: 59.6k, False: 9.08k]
  ------------------
  152|  59.6k|                && (qs < 0
  ------------------
  |  Branch (152:20): [True: 39.7k, False: 19.8k]
  |  Branch (152:21): [True: 2.54k, False: 57.0k]
  ------------------
  153|  59.6k|                    ? (x != '/' && x != '?')
  ------------------
  |  Branch (153:24): [True: 1.79k, False: 747]
  |  Branch (153:36): [True: 1.42k, False: 373]
  ------------------
  154|  59.6k|                    : (x != '&' && x != '=' && x != ';' && x != '+'))) {
  ------------------
  |  Branch (154:24): [True: 49.7k, False: 7.35k]
  |  Branch (154:36): [True: 46.1k, False: 3.55k]
  |  Branch (154:48): [True: 45.1k, False: 1.04k]
  |  Branch (154:60): [True: 38.3k, False: 6.80k]
  ------------------
  155|  39.7k|                p[j] = x;
  156|  39.7k|            }
  157|  28.9k|            else {
  158|  28.9k|                p[j]   = '%';
  159|  28.9k|                p[++j] = hex_chars_uc[n1]; /*(s[i+1] & 0xdf)*/
  160|  28.9k|                p[++j] = hex_chars_uc[n2]; /*(s[i+2] & 0xdf)*/
  161|  28.9k|                invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  28.9k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  28.9k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 3.23k, False: 25.7k]
  |  |  |  |  ------------------
  |  |  |  |  261|  28.9k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 85, False: 25.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  162|  28.9k|            }
  163|  68.6k|            i+=2;
  164|  68.6k|        }
  165|  33.0M|        else if (s[i] == '#') break; /* ignore fragment */
  ------------------
  |  Branch (165:18): [True: 13, False: 33.0M]
  ------------------
  166|  33.0M|        else {
  167|  33.0M|            p[j]   = '%';
  168|  33.0M|            p[++j] = hex_chars_uc[(s[i] >> 4) & 0xF];
  169|  33.0M|            p[++j] = hex_chars_uc[s[i] & 0xF];
  170|  33.0M|            invalid_utf8 |= li_utf8_invalid_byte(s[i]);
  ------------------
  |  |   49|  33.0M|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  33.0M|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 1.62M, False: 31.3M]
  |  |  |  |  ------------------
  |  |  |  |  261|  33.0M|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 6.52k, False: 31.3M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  171|  33.0M|        }
  172|  34.7M|    }
  173|    750|    buffer_copy_string_len(b, (char *)p, (size_t)j);
  174|    750|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (174:12): [True: 453, False: 297]
  ------------------
  175|    750|}
burl.c:burl_normalize_basic_unreserved:
  101|    780|{
  102|    780|    const unsigned char * const s = (unsigned char *)b->ptr;
  103|    780|    const int used = (int)buffer_clen(b);
  104|    780|    unsigned int n1, n2, x;
  105|    780|    int qs = -1;
  106|    780|    int invalid_utf8 = 0;
  107|       |
  108|   613k|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (108:21): [True: 613k, False: 183]
  ------------------
  109|   613k|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (109:13): [True: 610k, False: 2.73k]
  ------------------
  110|   610k|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = i;
  ------------------
  |  Branch (110:17): [True: 454, False: 610k]
  |  Branch (110:56): [True: 80, False: 374]
  ------------------
  111|   610k|        }
  112|  2.73k|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  5.05k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 961, False: 1.35k]
  |  |  |  Branch (43:30): [True: 1.29k, False: 67]
  |  |  |  Branch (43:31): [True: 1.29k, False: 67]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  4.98k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 934, False: 1.31k]
  |  |  |  Branch (43:30): [True: 1.25k, False: 61]
  |  |  |  Branch (43:31): [True: 1.25k, False: 61]
  |  |  ------------------
  ------------------
  |  Branch (112:18): [True: 2.31k, False: 417]
  ------------------
  113|  2.19k|                 && !burl_is_unreserved((x = (n1 << 4) | n2))) {
  ------------------
  |  Branch (113:21): [True: 2.13k, False: 52]
  ------------------
  114|  2.13k|            invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  2.13k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  2.13k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 1.09k, False: 1.04k]
  |  |  |  |  ------------------
  |  |  |  |  261|  2.13k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 8, False: 1.03k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  115|  2.13k|            if (s[i+1] >= 'a') b->ptr[i+1] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (115:17): [True: 1.09k, False: 1.04k]
  ------------------
  116|  2.13k|            if (s[i+2] >= 'a') b->ptr[i+2] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (116:17): [True: 944, False: 1.19k]
  ------------------
  117|  2.13k|            i+=2;
  118|  2.13k|        }
  119|    597|        else if (s[i] == '#') { /* ignore fragment */
  ------------------
  |  Branch (119:18): [True: 1, False: 596]
  ------------------
  120|      1|            buffer_truncate(b, (size_t)i);
  121|      1|            break;
  122|      1|        }
  123|    596|        else {
  124|    596|            qs = burl_normalize_basic_unreserved_fix(b, t, i, qs);
  125|    596|            break;
  126|    596|        }
  127|   613k|    }
  128|       |
  129|    780|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (129:12): [True: 743, False: 37]
  ------------------
  130|    780|}
burl.c:burl_is_unreserved:
   53|  19.8k|{
   54|  19.8k|    return (light_isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~');
  ------------------
  |  Branch (54:13): [True: 762, False: 19.0k]
  |  Branch (54:33): [True: 345, False: 18.7k]
  |  Branch (54:45): [True: 258, False: 18.4k]
  |  Branch (54:57): [True: 217, False: 18.2k]
  |  Branch (54:69): [True: 53, False: 18.1k]
  ------------------
   55|  19.8k|}
burl.c:burl_normalize_basic_unreserved_fix:
   60|    596|{
   61|    596|    int j = i;
   62|    596|    const int used = (int)buffer_clen(b);
   63|    596|    const unsigned char * const s = (unsigned char *)b->ptr;
   64|    596|    unsigned char * const p =
   65|    596|      (unsigned char *)buffer_string_prepare_copy(t,i+(used-i)*3+1);
   66|    596|    unsigned int n1, n2;
   67|    596|    int invalid_utf8 = 0;
   68|    596|    memcpy(p, s, (size_t)i);
   69|  26.5M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (69:12): [True: 26.5M, False: 591]
  ------------------
   70|  26.5M|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (70:13): [True: 967k, False: 25.5M]
  ------------------
   71|   967k|            p[j] = s[i];
   72|   967k|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = j;
  ------------------
  |  Branch (72:17): [True: 6.27k, False: 961k]
  |  Branch (72:56): [True: 137, False: 6.13k]
  ------------------
   73|   967k|        }
   74|  25.5M|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  25.5M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 12.9k, False: 13.9k]
  |  |  |  Branch (43:30): [True: 8.11k, False: 5.79k]
  |  |  |  Branch (43:31): [True: 8.11k, False: 5.79k]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  21.0k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 6.13k, False: 14.9k]
  |  |  |  Branch (43:30): [True: 11.5k, False: 3.43k]
  |  |  |  Branch (43:31): [True: 11.5k, False: 3.43k]
  |  |  ------------------
  ------------------
  |  Branch (74:18): [True: 26.8k, False: 25.5M]
  ------------------
   75|  17.6k|            const unsigned int x = (n1 << 4) | n2;
   76|  17.6k|            if (burl_is_unreserved(x)) {
  ------------------
  |  Branch (76:17): [True: 1.58k, False: 16.0k]
  ------------------
   77|  1.58k|                p[j] = x;
   78|  1.58k|            }
   79|  16.0k|            else {
   80|  16.0k|                p[j]   = '%';
   81|  16.0k|                p[++j] = hex_chars_uc[n1]; /*(s[i+1] & 0xdf)*/
   82|  16.0k|                p[++j] = hex_chars_uc[n2]; /*(s[i+2] & 0xdf)*/
   83|  16.0k|                invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  16.0k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  16.0k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 4.81k, False: 11.2k]
  |  |  |  |  ------------------
  |  |  |  |  261|  16.0k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 975, False: 10.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   84|  16.0k|            }
   85|  17.6k|            i+=2;
   86|  17.6k|        }
   87|  25.5M|        else if (s[i] == '#') break; /* ignore fragment */
  ------------------
  |  Branch (87:18): [True: 5, False: 25.5M]
  ------------------
   88|  25.5M|        else {
   89|  25.5M|            p[j]   = '%';
   90|  25.5M|            p[++j] = hex_chars_uc[(s[i] >> 4) & 0xF];
   91|  25.5M|            p[++j] = hex_chars_uc[s[i] & 0xF];
   92|  25.5M|            invalid_utf8 |= li_utf8_invalid_byte(s[i]);
  ------------------
  |  |   49|  25.5M|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  25.5M|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 137k, False: 25.3M]
  |  |  |  |  ------------------
  |  |  |  |  261|  25.5M|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 8.31k, False: 25.3M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   93|  25.5M|        }
   94|  26.5M|    }
   95|    596|    buffer_copy_string_len(b, (char *)p, (size_t)j);
   96|    596|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (96:12): [True: 404, False: 192]
  ------------------
   97|    596|}
burl.c:burl_scan_qmark:
  337|    421|static int burl_scan_qmark (const buffer * const b) {
  338|    421|    const char * const qmark = strchr(b->ptr, '?');
  339|    421|    return qmark ? (int)(qmark - b->ptr) : -1;
  ------------------
  |  Branch (339:12): [True: 220, False: 201]
  ------------------
  340|    421|}
burl.c:burl_contains_ctrls:
  215|    341|{
  216|    341|    const char * const s = b->ptr;
  217|    341|    const int used = (int)buffer_clen(b);
  218|  11.3M|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (218:21): [True: 11.3M, False: 244]
  ------------------
  219|  11.3M|        if (s[i] == '%' && (s[i+1] < '2' || (s[i+1] == '7' && s[i+2] == 'F')))
  ------------------
  |  Branch (219:13): [True: 3.60M, False: 7.79M]
  |  Branch (219:29): [True: 94, False: 3.60M]
  |  Branch (219:46): [True: 326, False: 3.60M]
  |  Branch (219:63): [True: 3, False: 323]
  ------------------
  220|     97|            return 1;
  221|  11.3M|    }
  222|    244|    return 0;
  223|    341|}
burl.c:burl_normalize_2F_to_slash:
  282|  1.27k|{
  283|       |    /*("%2F" must already have been uppercased during normalization)*/
  284|  1.27k|    const char * const s = b->ptr;
  285|  1.27k|    const int used = qs < 0 ? (int)buffer_clen(b) : qs;
  ------------------
  |  Branch (285:22): [True: 759, False: 513]
  ------------------
  286|  77.2M|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (286:21): [True: 77.2M, False: 1.09k]
  ------------------
  287|  77.2M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == 'F') {
  ------------------
  |  Branch (287:13): [True: 25.6M, False: 51.6M]
  |  Branch (287:28): [True: 5.21k, False: 25.6M]
  |  Branch (287:45): [True: 178, False: 5.04k]
  ------------------
  288|    178|            return !(flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)
  ------------------
  |  Branch (288:20): [True: 158, False: 20]
  ------------------
  289|    178|              ? burl_normalize_2F_to_slash_fix(b, qs, i)     /* _DECODE */
  290|    178|              : -2; /*(flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)*/
  291|    178|        }
  292|  77.2M|    }
  293|  1.09k|    return qs;
  294|  1.27k|}
burl.c:burl_normalize_2F_to_slash_fix:
  258|    158|{
  259|    158|    char * const s = b->ptr;
  260|    158|    const int blen = (int)buffer_clen(b);
  261|    158|    const int used = qs < 0 ? blen : qs;
  ------------------
  |  Branch (261:22): [True: 89, False: 69]
  ------------------
  262|    158|    int j = i;
  263|  8.77M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (263:12): [True: 8.77M, False: 158]
  ------------------
  264|  8.77M|        s[j] = s[i];
  265|  8.77M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == 'F') {
  ------------------
  |  Branch (265:13): [True: 2.91M, False: 5.86M]
  |  Branch (265:28): [True: 6.72k, False: 2.90M]
  |  Branch (265:45): [True: 1.22k, False: 5.49k]
  ------------------
  266|  1.22k|            s[j] = '/';
  267|  1.22k|            i+=2;
  268|  1.22k|        }
  269|  8.77M|    }
  270|    158|    if (qs >= 0) {
  ------------------
  |  Branch (270:9): [True: 69, False: 89]
  ------------------
  271|     69|        const int qslen = blen - qs;
  272|     69|        memmove(s+j, s+qs, (size_t)qslen);
  273|     69|        qs = j;
  274|     69|        j += qslen;
  275|     69|    }
  276|    158|    buffer_truncate(b, j);
  277|    158|    return qs;
  278|    158|}
burl.c:burl_normalize_path:
  298|  1.20k|{
  299|  1.20k|    const unsigned char * const s = (unsigned char *)b->ptr;
  300|  1.20k|    const int used = (int)buffer_clen(b);
  301|  1.20k|    int path_simplify = 0;
  302|  6.19k|    for (int i = 0, len = qs < 0 ? used : qs; i < len; ++i) {
  ------------------
  |  Branch (302:27): [True: 733, False: 473]
  |  Branch (302:47): [True: 5.38k, False: 805]
  ------------------
  303|  5.38k|        if (s[i] == '.' && (s[i+1] != '.' || ++i)
  ------------------
  |  Branch (303:13): [True: 3.00k, False: 2.38k]
  |  Branch (303:29): [True: 946, False: 2.05k]
  |  Branch (303:46): [True: 2.05k, False: 0]
  ------------------
  304|  3.00k|            && (s[i+1] == '/' || s[i+1] == '?' || s[i+1] == '\0')) {
  ------------------
  |  Branch (304:17): [True: 94, False: 2.90k]
  |  Branch (304:34): [True: 56, False: 2.85k]
  |  Branch (304:51): [True: 82, False: 2.76k]
  ------------------
  305|    232|            path_simplify = 1;
  306|    232|            break;
  307|    232|        }
  308|  68.2M|        while (i < len && s[i] != '/') ++i;
  ------------------
  |  Branch (308:16): [True: 68.2M, False: 631]
  |  Branch (308:27): [True: 68.2M, False: 4.52k]
  ------------------
  309|  5.15k|        if (s[i] == '/' && s[i+1] == '/') { /*(s[len] != '/')*/
  ------------------
  |  Branch (309:13): [True: 4.52k, False: 631]
  |  Branch (309:28): [True: 169, False: 4.35k]
  ------------------
  310|    169|            path_simplify = 1;
  311|    169|            break;
  312|    169|        }
  313|  5.15k|    }
  314|       |
  315|  1.20k|    if (path_simplify) {
  ------------------
  |  Branch (315:9): [True: 401, False: 805]
  ------------------
  316|    401|        if (flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT) return -2;
  ------------------
  |  Branch (316:13): [True: 11, False: 390]
  ------------------
  317|    390|        if (qs >= 0) {
  ------------------
  |  Branch (317:13): [True: 145, False: 245]
  ------------------
  318|    145|            buffer_copy_string_len(t, b->ptr+qs, used - qs);
  319|    145|            buffer_truncate(b, qs);
  320|    145|        }
  321|       |
  322|    390|        buffer_path_simplify(b);
  323|       |
  324|    390|        if (qs >= 0) {
  ------------------
  |  Branch (324:13): [True: 145, False: 245]
  ------------------
  325|    145|            qs = (int)buffer_clen(b);
  326|    145|            buffer_append_string_len(b, BUF_PTR_LEN(t));
  ------------------
  |  |  297|    145|#define BUF_PTR_LEN(x)       (x)->ptr, buffer_clen(x)
  ------------------
  327|    145|        }
  328|    390|    }
  329|       |
  330|  1.19k|    return qs;
  331|  1.20k|}
burl.c:burl_normalize_qs20_to_plus:
  244|    447|{
  245|    447|    const char * const s = b->ptr;
  246|    447|    const int used = qs < 0 ? 0 : (int)buffer_clen(b);
  ------------------
  |  Branch (246:22): [True: 0, False: 447]
  ------------------
  247|    447|    int i;
  248|    447|    if (qs < 0) return;
  ------------------
  |  Branch (248:9): [True: 0, False: 447]
  ------------------
  249|  8.09M|    for (i = qs+1; i < used; ++i) {
  ------------------
  |  Branch (249:20): [True: 8.09M, False: 310]
  ------------------
  250|  8.09M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == '0') break;
  ------------------
  |  Branch (250:13): [True: 2.67M, False: 5.41M]
  |  Branch (250:28): [True: 14.1k, False: 2.65M]
  |  Branch (250:45): [True: 137, False: 14.0k]
  ------------------
  251|  8.09M|    }
  252|    447|    if (i != used) burl_normalize_qs20_to_plus_fix(b, i);
  ------------------
  |  Branch (252:9): [True: 137, False: 310]
  ------------------
  253|    447|}
burl.c:burl_normalize_qs20_to_plus_fix:
  228|    137|{
  229|    137|    char * const s = b->ptr;
  230|    137|    const int used = (int)buffer_clen(b);
  231|    137|    int j = i;
  232|  14.4M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (232:12): [True: 14.4M, False: 137]
  ------------------
  233|  14.4M|        s[j] = s[i];
  234|  14.4M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == '0') {
  ------------------
  |  Branch (234:13): [True: 4.78M, False: 9.68M]
  |  Branch (234:28): [True: 14.6k, False: 4.76M]
  |  Branch (234:45): [True: 2.41k, False: 12.2k]
  ------------------
  235|  2.41k|            s[j] = '+';
  236|  2.41k|            i+=2;
  237|  2.41k|        }
  238|  14.4M|    }
  239|    137|    buffer_truncate(b, j);
  240|    137|}

