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

buffer_init:
   14|  3.41k|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.41k|	buffer * const b = calloc(1, sizeof(*b));
   20|  3.41k|	force_assert(b);
  ------------------
  |  |  448|  3.41k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.41k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.41k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.41k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   21|  3.41k|	return b;
   22|  3.41k|  #endif
   23|  3.41k|}
buffer_free:
   25|  3.41k|void buffer_free(buffer *b) {
   26|  3.41k|	if (NULL == b) return;
  ------------------
  |  Branch (26:6): [True: 0, False: 3.41k]
  ------------------
   27|  3.41k|	free(b->ptr);
   28|  3.41k|	free(b);
   29|  3.41k|}
buffer_string_prepare_copy:
   82|  1.32k|char* buffer_string_prepare_copy(buffer * const b, const size_t size) {
   83|  1.32k|    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.32k|    return (size < b->size)
  ------------------
  |  Branch (87:12): [True: 0, False: 1.32k]
  ------------------
   88|  1.32k|      ? b->ptr
   89|  1.32k|      : buffer_alloc_replace(b, size);
   90|  1.32k|}
buffer_extend:
  127|    150|{
  128|       |    /* extend buffer to append x (reallocate by power-2 (or larger), if needed)
  129|       |     * (combine buffer_string_prepare_append() and buffer_commit())
  130|       |     * (future: might make buffer.h static inline func for HTTP/1.1 performance)
  131|       |     * pre-sets '\0' byte and b->used (unlike buffer_string_prepare_append())*/
  132|       |  #if 0
  133|       |    char * const s = buffer_string_prepare_append(b, x);
  134|       |    b->used += x + (0 == b->used);
  135|       |  #else
  136|    150|    const uint32_t len = b->used ? b->used-1 : 0;
  ------------------
  |  Branch (136:26): [True: 150, False: 0]
  ------------------
  137|    150|    char * const s = (b->size - len >= x + 1)
  ------------------
  |  Branch (137:22): [True: 150, False: 0]
  ------------------
  138|    150|      ? b->ptr + len
  139|    150|      : buffer_string_prepare_append_resize(b, x);
  140|    150|    b->used = len+x+1;
  141|    150|  #endif
  142|    150|    s[x] = '\0';
  143|    150|    return s;
  144|    150|}
buffer_copy_string_len:
  172|  3.17k|void buffer_copy_string_len(buffer * const restrict b, const char * const restrict s, const size_t len) {
  173|  3.17k|    b->used = len + 1;
  174|  3.17k|    char * const restrict d = (len < b->size)
  ------------------
  |  Branch (174:31): [True: 966, False: 2.21k]
  ------------------
  175|  3.17k|      ? b->ptr
  176|  3.17k|      : buffer_alloc_replace(b, len);
  177|  3.17k|    d[len] = '\0';
  178|  3.17k|    memcpy(d, s, len);
  179|  3.17k|}
buffer_append_string_len:
  198|    150|void buffer_append_string_len(buffer * const restrict b, const char * const restrict s, const size_t len) {
  199|    150|    memcpy(buffer_extend(b, len), s, len);
  200|    150|}
hex2int:
  386|  98.5M|char hex2int(unsigned char hex) {
  387|  98.5M|	unsigned char n;
  388|  98.5M|	return li_cton(hex,n) ? (char)n : 0xFF;
  ------------------
  |  |  381|  98.5M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (381:4): [True: 86.4M, False: 12.0M]
  |  |  |  Branch (381:30): [True: 12.0M, False: 0]
  |  |  |  Branch (381:31): [True: 12.0M, False: 0]
  |  |  ------------------
  ------------------
  389|  98.5M|}
buffer_urldecode_path:
  792|  1.70k|void buffer_urldecode_path(buffer * const b) {
  793|  1.70k|    const size_t len = buffer_clen(b);
  794|  1.70k|    char *src = len ? memchr(b->ptr, '%', len) : NULL;
  ------------------
  |  Branch (794:17): [True: 1.70k, False: 7]
  ------------------
  795|  1.70k|    if (NULL == src) return;
  ------------------
  |  Branch (795:9): [True: 357, False: 1.35k]
  ------------------
  796|       |
  797|  1.35k|    char *dst = src;
  798|  49.2M|    do {
  799|       |        /* *src == '%' */
  800|  49.2M|        unsigned char high = ((unsigned char *)src)[1];
  801|  49.2M|        unsigned char low = high ? hex2int(((unsigned char *)src)[2]) : 0xFF;
  ------------------
  |  Branch (801:29): [True: 49.2M, False: 0]
  ------------------
  802|  49.2M|        if (0xFF != (high = hex2int(high)) && 0xFF != low) {
  ------------------
  |  Branch (802:13): [True: 49.2M, False: 0]
  |  Branch (802:47): [True: 49.2M, False: 0]
  ------------------
  803|  49.2M|            high = (high << 4) | low;   /* map ctrls to '_' */
  804|  49.2M|            *dst = (high >= 32 && high != 127) ? high : '_';
  ------------------
  |  Branch (804:21): [True: 9.91M, False: 39.3M]
  |  Branch (804:35): [True: 9.16M, False: 748k]
  ------------------
  805|  49.2M|            src += 2;
  806|  49.2M|        } /* else ignore this '%'; leave as-is and move on */
  807|       |
  808|  52.7M|        while ((*++dst = *++src) != '%' && *src) ;
  ------------------
  |  Branch (808:16): [True: 3.41M, False: 49.2M]
  |  Branch (808:44): [True: 3.41M, False: 1.35k]
  ------------------
  809|  49.2M|    } while (*src);
  ------------------
  |  Branch (809:14): [True: 49.2M, False: 1.35k]
  ------------------
  810|  1.35k|    b->used = (dst - b->ptr) + 1;
  811|  1.35k|}
buffer_path_simplify:
  859|    401|{
  860|    401|    char *out = b->ptr;
  861|    401|    char * const end = b->ptr + b->used - 1;
  862|       |
  863|    401|    if (__builtin_expect( (buffer_is_blank(b)), 0)) {
  ------------------
  |  Branch (863:9): [True: 0, False: 401]
  ------------------
  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|    401|    *end = '/'; /*(end of path modified to avoid need to check '\0')*/
  876|       |
  877|    401|    char *walk = out;
  878|    401|    if (__builtin_expect( (*walk == '/'), 1)) {
  ------------------
  |  Branch (878:9): [True: 133, False: 268]
  ------------------
  879|       |        /* scan to detect (potential) need for path simplification
  880|       |         * (repeated '/' or "/.") */
  881|    395|        do {
  882|    395|            if (*++walk == '.' || *walk == '/')
  ------------------
  |  Branch (882:17): [True: 78, False: 317]
  |  Branch (882:35): [True: 55, False: 262]
  ------------------
  883|    133|                break;
  884|   146k|            do { ++walk; } while (*walk != '/');
  ------------------
  |  Branch (884:35): [True: 146k, False: 262]
  ------------------
  885|    262|        } while (walk != end);
  ------------------
  |  Branch (885:18): [True: 262, False: 0]
  ------------------
  886|    133|        if (__builtin_expect( (walk == end), 1)) {
  ------------------
  |  Branch (886:13): [True: 0, False: 133]
  ------------------
  887|       |            /* common case: no repeated '/' or "/." */
  888|      0|            *end = '\0'; /* overwrite extra '/' added to end of path */
  889|      0|            return;
  890|      0|        }
  891|    133|        out = walk-1;
  892|    133|    }
  893|    268|    else {
  894|    268|        if (walk[0] == '.' && walk[1] == '/')
  ------------------
  |  Branch (894:13): [True: 117, False: 151]
  |  Branch (894:31): [True: 68, False: 49]
  ------------------
  895|     68|            *out = *++walk;
  896|    200|        else if (walk[0] == '.' && walk[1] == '.' && walk[2] == '/')
  ------------------
  |  Branch (896:18): [True: 49, False: 151]
  |  Branch (896:36): [True: 22, False: 27]
  |  Branch (896:54): [True: 4, False: 18]
  ------------------
  897|      4|            *out = *(walk += 2);
  898|    196|        else {
  899|  5.69M|            while (*++walk != '/') ;
  ------------------
  |  Branch (899:20): [True: 5.69M, False: 196]
  ------------------
  900|    196|            out = walk;
  901|    196|        }
  902|    268|        ++walk;
  903|    268|    }
  904|       |
  905|  7.77k|    while (walk <= end) {
  ------------------
  |  Branch (905:12): [True: 7.56k, False: 211]
  ------------------
  906|       |        /* previous char is '/' at this point (or start of string w/o '/') */
  907|  7.56k|        if (__builtin_expect( (walk[0] == '/'), 0)) {
  ------------------
  |  Branch (907:13): [True: 1.50k, False: 6.06k]
  ------------------
  908|       |            /* skip repeated '/' (e.g. "///" -> "/") */
  909|  1.50k|            if (++walk < end)
  ------------------
  |  Branch (909:17): [True: 1.44k, False: 60]
  ------------------
  910|  1.44k|                continue;
  911|     60|            else {
  912|     60|                ++out;
  913|     60|                break;
  914|     60|            }
  915|  1.50k|        }
  916|  6.06k|        else if (__builtin_expect( (walk[0] == '.'), 0)) {
  ------------------
  |  Branch (916:18): [True: 4.24k, False: 1.81k]
  ------------------
  917|       |            /* handle "./" and "../" */
  918|  4.24k|            if (walk[1] == '.' && walk[2] == '/') {
  ------------------
  |  Branch (918:17): [True: 1.76k, False: 2.48k]
  |  Branch (918:35): [True: 760, False: 1.00k]
  ------------------
  919|       |                /* handle "../" */
  920|  8.10M|                while (out > b->ptr && *--out != '/') ;
  ------------------
  |  Branch (920:24): [True: 8.10M, False: 544]
  |  Branch (920:40): [True: 8.10M, False: 216]
  ------------------
  921|    760|                *out = '/'; /*(in case path had not started with '/')*/
  922|    760|                if ((walk += 3) >= end) {
  ------------------
  |  Branch (922:21): [True: 63, False: 697]
  ------------------
  923|     63|                    ++out;
  924|     63|                    break;
  925|     63|                }
  926|    697|                else
  927|    697|                    continue;
  928|    760|            }
  929|  3.48k|            else if (walk[1] == '/') {
  ------------------
  |  Branch (929:22): [True: 1.76k, False: 1.72k]
  ------------------
  930|       |                /* handle "./" */
  931|  1.76k|                if ((walk += 2) >= end) {
  ------------------
  |  Branch (931:21): [True: 67, False: 1.69k]
  ------------------
  932|     67|                    ++out;
  933|     67|                    break;
  934|     67|                }
  935|  1.69k|                continue;
  936|  1.76k|            }
  937|  1.72k|            else {
  938|       |                /* accept "." if not part of "../" or "./" */
  939|  1.72k|                *++out = '.';
  940|  1.72k|                ++walk;
  941|  1.72k|            }
  942|  4.24k|        }
  943|       |
  944|  31.6M|        while ((*++out = *walk++) != '/') ;
  ------------------
  |  Branch (944:16): [True: 31.6M, False: 3.53k]
  ------------------
  945|  3.53k|    }
  946|    401|    *out = *end = '\0'; /* overwrite extra '/' added to end of path */
  947|    401|    b->used = (out - b->ptr) + 1;
  948|       |    /*buffer_truncate(b, out - b->ptr);*/
  949|    401|}
buffer.c:buffer_alloc_replace:
   71|  3.53k|static char* buffer_alloc_replace(buffer * const restrict b, const size_t size) {
   72|       |    /*(discard old data so realloc() does not copy)*/
   73|  3.53k|    if (NULL != b->ptr) {
  ------------------
  |  Branch (73:9): [True: 490, False: 3.04k]
  ------------------
   74|    490|        free(b->ptr);
   75|    490|        b->ptr = NULL;
   76|    490|    }
   77|       |    /*(note: if size larger than one lshift, use size instead of power-2)*/
   78|  3.53k|    const size_t bsize2x = (b->size & ~1uL) << 1;
   79|  3.53k|    return buffer_realloc(b, bsize2x > size ? bsize2x-1 : size);
  ------------------
  |  Branch (79:30): [True: 245, False: 3.29k]
  ------------------
   80|  3.53k|}
buffer.c:buffer_realloc:
   49|  3.53k|static char* buffer_realloc(buffer * const restrict b, const size_t len) {
   50|  3.53k|    #define BUFFER_PIECE_SIZE 64uL  /*(must be power-of-2)*/
   51|  3.53k|    size_t sz = (len + 1 + BUFFER_PIECE_SIZE-1) & ~(BUFFER_PIECE_SIZE-1);
  ------------------
  |  |   50|  3.53k|    #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.53k|    #define BUFFER_PIECE_SIZE 64uL  /*(must be power-of-2)*/
  ------------------
   52|  3.53k|    force_assert(sz > len);
  ------------------
  |  |  448|  3.53k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.53k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.53k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.53k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   53|  3.53k|    if ((sz & (sz-1)) && sz < INT_MAX) {/* not power-2; huge val not expected */
  ------------------
  |  Branch (53:9): [True: 1.20k, False: 2.33k]
  |  Branch (53:26): [True: 1.20k, False: 0]
  ------------------
   54|       |        /*(optimizer should recognize this and use ffs or clz or equivalent)*/
   55|  1.20k|        const size_t psz = sz;
   56|  8.31k|        for (sz = 256; sz < psz; sz <<= 1) ;
  ------------------
  |  Branch (56:24): [True: 7.11k, False: 1.20k]
  ------------------
   57|  1.20k|    }
   58|  3.53k|    sz |= 1; /*(extra +1 for '\0' when needed buffer size is exact power-2)*/
   59|       |
   60|  3.53k|    b->size = sz;
   61|  3.53k|    b->ptr = realloc(b->ptr, sz);
   62|       |
   63|  3.53k|    force_assert(NULL != b->ptr);
  ------------------
  |  |  448|  3.53k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.53k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.53k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.53k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   64|  3.53k|    return b->ptr;
   65|  3.53k|}

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

burl_normalize:
  344|  1.70k|{
  345|  1.70k|    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.70k|    qs = (flags & HTTP_PARSEOPT_URL_NORMALIZE_REQUIRED)
  ------------------
  |  Branch (364:10): [True: 939, False: 768]
  ------------------
  365|  1.70k|      ? burl_normalize_basic_required(b, t)
  366|  1.70k|      : burl_normalize_basic_unreserved(b, t);
  367|  1.70k|    if (-2 == qs) {
  ------------------
  |  Branch (367:9): [True: 507, False: 1.20k]
  ------------------
  368|    507|        if (flags & HTTP_PARSEOPT_URL_NORMALIZE_INVALID_UTF8_REJECT) return -2;
  ------------------
  |  Branch (368:13): [True: 105, False: 402]
  ------------------
  369|    402|        qs = burl_scan_qmark(b);
  370|    402|    }
  371|       |
  372|  1.60k|    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_CTRLS_REJECT) {
  ------------------
  |  Branch (372:9): [True: 358, False: 1.24k]
  ------------------
  373|    358|        if (burl_contains_ctrls(b)) return -2;
  ------------------
  |  Branch (373:13): [True: 92, False: 266]
  ------------------
  374|    358|    }
  375|       |
  376|  1.51k|    if (flags & (HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_DECODE
  ------------------
  |  Branch (376:9): [True: 1.24k, False: 267]
  ------------------
  377|  1.51k|                |HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)) {
  378|  1.24k|        qs = burl_normalize_2F_to_slash(b, qs, flags);
  379|  1.24k|        if (-2 == qs) return -2;
  ------------------
  |  Branch (379:13): [True: 14, False: 1.22k]
  ------------------
  380|  1.24k|    }
  381|       |
  382|  1.49k|    if (flags & (HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REMOVE
  ------------------
  |  Branch (382:9): [True: 1.21k, False: 278]
  ------------------
  383|  1.49k|                |HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT)) {
  384|  1.21k|        qs = burl_normalize_path(b, t, qs, flags);
  385|  1.21k|        if (-2 == qs) return -2;
  ------------------
  |  Branch (385:13): [True: 4, False: 1.21k]
  ------------------
  386|  1.21k|    }
  387|       |
  388|  1.49k|    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_QUERY_20_PLUS) {
  ------------------
  |  Branch (388:9): [True: 886, False: 606]
  ------------------
  389|    886|        if (qs >= 0) burl_normalize_qs20_to_plus(b, qs);
  ------------------
  |  Branch (389:13): [True: 453, False: 433]
  ------------------
  390|    886|    }
  391|       |
  392|  1.49k|    return qs;
  393|  1.49k|}
burl.c:burl_normalize_basic_required:
  179|    939|{
  180|    939|    const unsigned char * const s = (unsigned char *)b->ptr;
  181|    939|    const int used = (int)buffer_clen(b);
  182|    939|    unsigned int n1, n2, x;
  183|    939|    int qs = -1;
  184|    939|    int invalid_utf8 = 0;
  185|       |
  186|   195k|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (186:21): [True: 194k, False: 207]
  ------------------
  187|   194k|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (187:13): [True: 185k, False: 9.79k]
  ------------------
  188|   185k|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = i;
  ------------------
  |  Branch (188:17): [True: 1.75k, False: 183k]
  |  Branch (188:56): [True: 207, False: 1.54k]
  ------------------
  189|   185k|        }
  190|  9.79k|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  19.0k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 4.27k, False: 4.99k]
  |  |  |  Branch (43:30): [True: 4.91k, False: 82]
  |  |  |  Branch (43:31): [True: 4.91k, False: 82]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  18.9k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 3.30k, False: 5.88k]
  |  |  |  Branch (43:30): [True: 5.82k, False: 56]
  |  |  |  Branch (43:31): [True: 5.82k, False: 56]
  |  |  ------------------
  ------------------
  |  Branch (190:18): [True: 9.26k, False: 532]
  ------------------
  191|  9.12k|                 && (encoded_chars_http_uri_reqd[(x = (n1 << 4) | n2)]
  ------------------
  |  Branch (191:22): [True: 6.57k, False: 2.55k]
  ------------------
  192|  2.55k|                     || (qs < 0
  ------------------
  |  Branch (192:25): [True: 2.49k, False: 62]
  |  Branch (192:26): [True: 545, False: 2.00k]
  ------------------
  193|  2.55k|                         ? (x == '/' || x == '?')
  ------------------
  |  Branch (193:29): [True: 285, False: 260]
  |  Branch (193:41): [True: 231, False: 29]
  ------------------
  194|  9.06k|                         : (x == '&' || x == '=' || x == ';' || x == '+')))) {
  ------------------
  |  Branch (194:29): [True: 706, False: 1.30k]
  |  Branch (194:41): [True: 409, False: 893]
  |  Branch (194:53): [True: 224, False: 669]
  |  Branch (194:65): [True: 636, False: 33]
  ------------------
  195|  9.06k|            invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  9.06k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  9.06k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 469, False: 8.59k]
  |  |  |  |  ------------------
  |  |  |  |  261|  9.06k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 105, False: 8.49k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|  9.06k|            if (s[i+1] >= 'a') b->ptr[i+1] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (196:17): [True: 3.88k, False: 5.17k]
  ------------------
  197|  9.06k|            if (s[i+2] >= 'a') b->ptr[i+2] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (197:17): [True: 3.60k, False: 5.46k]
  ------------------
  198|  9.06k|            i+=2;
  199|  9.06k|        }
  200|    732|        else if (s[i] == '#') { /* ignore fragment */
  ------------------
  |  Branch (200:18): [True: 2, False: 730]
  ------------------
  201|      2|            buffer_truncate(b, (size_t)i);
  202|      2|            break;
  203|      2|        }
  204|    730|        else {
  205|    730|            qs = burl_normalize_basic_required_fix(b, t, i, qs);
  206|    730|            break;
  207|    730|        }
  208|   194k|    }
  209|       |
  210|    939|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (210:12): [True: 917, False: 22]
  ------------------
  211|    939|}
burl.c:burl_normalize_basic_required_fix:
  135|    730|{
  136|    730|    int j = i;
  137|    730|    const int used = (int)buffer_clen(b);
  138|    730|    const unsigned char * const s = (unsigned char *)b->ptr;
  139|    730|    unsigned char * const p =
  140|    730|      (unsigned char *)buffer_string_prepare_copy(t,i+(used-i)*3+1);
  141|    730|    unsigned int n1, n2;
  142|    730|    int invalid_utf8 = 0;
  143|    730|    memcpy(p, s, (size_t)i);
  144|  32.8M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (144:12): [True: 32.8M, False: 717]
  ------------------
  145|  32.8M|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (145:13): [True: 1.82M, False: 30.9M]
  ------------------
  146|  1.82M|            p[j] = s[i];
  147|  1.82M|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = j;
  ------------------
  |  Branch (147:17): [True: 27.0k, False: 1.79M]
  |  Branch (147:56): [True: 203, False: 26.8k]
  ------------------
  148|  1.82M|        }
  149|  30.9M|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  31.1M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 71.5k, False: 30.8k]
  |  |  |  Branch (43:30): [True: 25.3k, False: 5.45k]
  |  |  |  Branch (43:31): [True: 25.3k, False: 5.45k]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  96.8k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 33.3k, False: 63.5k]
  |  |  |  Branch (43:30): [True: 59.3k, False: 4.22k]
  |  |  |  Branch (43:31): [True: 59.3k, False: 4.22k]
  |  |  ------------------
  ------------------
  |  Branch (149:18): [True: 102k, False: 30.8M]
  ------------------
  150|  92.6k|            const unsigned int x = (n1 << 4) | n2;
  151|  92.6k|            if (!encoded_chars_http_uri_reqd[x]
  ------------------
  |  Branch (151:17): [True: 56.7k, False: 35.9k]
  ------------------
  152|  56.7k|                && (qs < 0
  ------------------
  |  Branch (152:20): [True: 26.4k, False: 30.2k]
  |  Branch (152:21): [True: 2.39k, False: 54.3k]
  ------------------
  153|  56.7k|                    ? (x != '/' && x != '?')
  ------------------
  |  Branch (153:24): [True: 1.35k, False: 1.04k]
  |  Branch (153:36): [True: 625, False: 728]
  ------------------
  154|  56.7k|                    : (x != '&' && x != '=' && x != ';' && x != '+'))) {
  ------------------
  |  Branch (154:24): [True: 39.4k, False: 14.8k]
  |  Branch (154:36): [True: 32.3k, False: 7.15k]
  |  Branch (154:48): [True: 31.2k, False: 1.04k]
  |  Branch (154:60): [True: 25.8k, False: 5.45k]
  ------------------
  155|  26.4k|                p[j] = x;
  156|  26.4k|            }
  157|  66.2k|            else {
  158|  66.2k|                p[j]   = '%';
  159|  66.2k|                p[++j] = hex_chars_uc[n1]; /*(s[i+1] & 0xdf)*/
  160|  66.2k|                p[++j] = hex_chars_uc[n2]; /*(s[i+2] & 0xdf)*/
  161|  66.2k|                invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  66.2k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  66.2k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 822, False: 65.3k]
  |  |  |  |  ------------------
  |  |  |  |  261|  66.2k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 470, False: 64.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  162|  66.2k|            }
  163|  92.6k|            i+=2;
  164|  92.6k|        }
  165|  30.9M|        else if (s[i] == '#') break; /* ignore fragment */
  ------------------
  |  Branch (165:18): [True: 13, False: 30.9M]
  ------------------
  166|  30.9M|        else {
  167|  30.9M|            p[j]   = '%';
  168|  30.9M|            p[++j] = hex_chars_uc[(s[i] >> 4) & 0xF];
  169|  30.9M|            p[++j] = hex_chars_uc[s[i] & 0xF];
  170|  30.9M|            invalid_utf8 |= li_utf8_invalid_byte(s[i]);
  ------------------
  |  |   49|  30.9M|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  30.9M|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 1.04M, False: 29.8M]
  |  |  |  |  ------------------
  |  |  |  |  261|  30.9M|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 386, False: 29.8M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  171|  30.9M|        }
  172|  32.8M|    }
  173|    730|    buffer_copy_string_len(b, (char *)p, (size_t)j);
  174|    730|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (174:12): [True: 460, False: 270]
  ------------------
  175|    730|}
burl.c:burl_normalize_basic_unreserved:
  101|    768|{
  102|    768|    const unsigned char * const s = (unsigned char *)b->ptr;
  103|    768|    const int used = (int)buffer_clen(b);
  104|    768|    unsigned int n1, n2, x;
  105|    768|    int qs = -1;
  106|    768|    int invalid_utf8 = 0;
  107|       |
  108|   679k|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (108:21): [True: 679k, False: 175]
  ------------------
  109|   679k|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (109:13): [True: 674k, False: 5.03k]
  ------------------
  110|   674k|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = i;
  ------------------
  |  Branch (110:17): [True: 953, False: 673k]
  |  Branch (110:56): [True: 83, False: 870]
  ------------------
  111|   674k|        }
  112|  5.03k|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  9.65k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 1.88k, False: 2.73k]
  |  |  |  Branch (43:30): [True: 2.67k, False: 64]
  |  |  |  Branch (43:31): [True: 2.67k, False: 64]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  9.59k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 2.00k, False: 2.54k]
  |  |  |  Branch (43:30): [True: 2.48k, False: 61]
  |  |  |  Branch (43:31): [True: 2.48k, False: 61]
  |  |  ------------------
  ------------------
  |  Branch (112:18): [True: 4.62k, False: 415]
  ------------------
  113|  4.49k|                 && !burl_is_unreserved((x = (n1 << 4) | n2))) {
  ------------------
  |  Branch (113:21): [True: 4.44k, False: 53]
  ------------------
  114|  4.44k|            invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  4.44k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  4.44k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 671, False: 3.77k]
  |  |  |  |  ------------------
  |  |  |  |  261|  4.44k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 23, False: 3.74k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  115|  4.44k|            if (s[i+1] >= 'a') b->ptr[i+1] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (115:17): [True: 1.61k, False: 2.83k]
  ------------------
  116|  4.44k|            if (s[i+2] >= 'a') b->ptr[i+2] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (116:17): [True: 1.60k, False: 2.84k]
  ------------------
  117|  4.44k|            i+=2;
  118|  4.44k|        }
  119|    593|        else if (s[i] == '#') { /* ignore fragment */
  ------------------
  |  Branch (119:18): [True: 1, False: 592]
  ------------------
  120|      1|            buffer_truncate(b, (size_t)i);
  121|      1|            break;
  122|      1|        }
  123|    592|        else {
  124|    592|            qs = burl_normalize_basic_unreserved_fix(b, t, i, qs);
  125|    592|            break;
  126|    592|        }
  127|   679k|    }
  128|       |
  129|    768|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (129:12): [True: 734, False: 34]
  ------------------
  130|    768|}
burl.c:burl_is_unreserved:
   53|  15.8k|{
   54|  15.8k|    return (light_isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~');
  ------------------
  |  Branch (54:13): [True: 714, False: 15.1k]
  |  Branch (54:33): [True: 360, False: 14.8k]
  |  Branch (54:45): [True: 203, False: 14.6k]
  |  Branch (54:57): [True: 460, False: 14.1k]
  |  Branch (54:69): [True: 93, False: 14.0k]
  ------------------
   55|  15.8k|}
burl.c:burl_normalize_basic_unreserved_fix:
   60|    592|{
   61|    592|    int j = i;
   62|    592|    const int used = (int)buffer_clen(b);
   63|    592|    const unsigned char * const s = (unsigned char *)b->ptr;
   64|    592|    unsigned char * const p =
   65|    592|      (unsigned char *)buffer_string_prepare_copy(t,i+(used-i)*3+1);
   66|    592|    unsigned int n1, n2;
   67|    592|    int invalid_utf8 = 0;
   68|    592|    memcpy(p, s, (size_t)i);
   69|  21.9M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (69:12): [True: 21.9M, False: 583]
  ------------------
   70|  21.9M|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (70:13): [True: 912k, False: 21.0M]
  ------------------
   71|   912k|            p[j] = s[i];
   72|   912k|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = j;
  ------------------
  |  Branch (72:17): [True: 2.17k, False: 909k]
  |  Branch (72:56): [True: 154, False: 2.02k]
  ------------------
   73|   912k|        }
   74|  21.0M|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  21.0M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 7.20k, False: 9.09k]
  |  |  |  Branch (43:30): [True: 6.08k, False: 3.00k]
  |  |  |  Branch (43:31): [True: 6.08k, False: 3.00k]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  13.2k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 3.96k, False: 9.33k]
  |  |  |  Branch (43:30): [True: 7.42k, False: 1.90k]
  |  |  |  Branch (43:31): [True: 7.42k, False: 1.90k]
  |  |  ------------------
  ------------------
  |  Branch (74:18): [True: 16.2k, False: 20.9M]
  ------------------
   75|  11.3k|            const unsigned int x = (n1 << 4) | n2;
   76|  11.3k|            if (burl_is_unreserved(x)) {
  ------------------
  |  Branch (76:17): [True: 1.77k, False: 9.60k]
  ------------------
   77|  1.77k|                p[j] = x;
   78|  1.77k|            }
   79|  9.60k|            else {
   80|  9.60k|                p[j]   = '%';
   81|  9.60k|                p[++j] = hex_chars_uc[n1]; /*(s[i+1] & 0xdf)*/
   82|  9.60k|                p[++j] = hex_chars_uc[n2]; /*(s[i+2] & 0xdf)*/
   83|  9.60k|                invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  9.60k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  9.60k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 2.86k, False: 6.74k]
  |  |  |  |  ------------------
  |  |  |  |  261|  9.60k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 592, False: 6.14k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   84|  9.60k|            }
   85|  11.3k|            i+=2;
   86|  11.3k|        }
   87|  20.9M|        else if (s[i] == '#') break; /* ignore fragment */
  ------------------
  |  Branch (87:18): [True: 9, False: 20.9M]
  ------------------
   88|  20.9M|        else {
   89|  20.9M|            p[j]   = '%';
   90|  20.9M|            p[++j] = hex_chars_uc[(s[i] >> 4) & 0xF];
   91|  20.9M|            p[++j] = hex_chars_uc[s[i] & 0xF];
   92|  20.9M|            invalid_utf8 |= li_utf8_invalid_byte(s[i]);
  ------------------
  |  |   49|  20.9M|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  20.9M|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 39.3k, False: 20.9M]
  |  |  |  |  ------------------
  |  |  |  |  261|  20.9M|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 622, False: 20.9M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   93|  20.9M|        }
   94|  21.9M|    }
   95|    592|    buffer_copy_string_len(b, (char *)p, (size_t)j);
   96|    592|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (96:12): [True: 408, False: 184]
  ------------------
   97|    592|}
burl.c:burl_scan_qmark:
  337|    402|static int burl_scan_qmark (const buffer * const b) {
  338|    402|    const char * const qmark = strchr(b->ptr, '?');
  339|    402|    return qmark ? (int)(qmark - b->ptr) : -1;
  ------------------
  |  Branch (339:12): [True: 215, False: 187]
  ------------------
  340|    402|}
burl.c:burl_contains_ctrls:
  215|    358|{
  216|    358|    const char * const s = b->ptr;
  217|    358|    const int used = (int)buffer_clen(b);
  218|  11.3M|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (218:21): [True: 11.3M, False: 266]
  ------------------
  219|  11.3M|        if (s[i] == '%' && (s[i+1] < '2' || (s[i+1] == '7' && s[i+2] == 'F')))
  ------------------
  |  Branch (219:13): [True: 3.53M, False: 7.81M]
  |  Branch (219:29): [True: 86, False: 3.53M]
  |  Branch (219:46): [True: 1.41k, False: 3.53M]
  |  Branch (219:63): [True: 6, False: 1.40k]
  ------------------
  220|     92|            return 1;
  221|  11.3M|    }
  222|    266|    return 0;
  223|    358|}
burl.c:burl_normalize_2F_to_slash:
  282|  1.24k|{
  283|       |    /*("%2F" must already have been uppercased during normalization)*/
  284|  1.24k|    const char * const s = b->ptr;
  285|  1.24k|    const int used = qs < 0 ? (int)buffer_clen(b) : qs;
  ------------------
  |  Branch (285:22): [True: 732, False: 511]
  ------------------
  286|  81.0M|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (286:21): [True: 81.0M, False: 1.08k]
  ------------------
  287|  81.0M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == 'F') {
  ------------------
  |  Branch (287:13): [True: 26.9M, False: 54.0M]
  |  Branch (287:28): [True: 4.17k, False: 26.9M]
  |  Branch (287:45): [True: 154, False: 4.02k]
  ------------------
  288|    154|            return !(flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)
  ------------------
  |  Branch (288:20): [True: 140, False: 14]
  ------------------
  289|    154|              ? burl_normalize_2F_to_slash_fix(b, qs, i)     /* _DECODE */
  290|    154|              : -2; /*(flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)*/
  291|    154|        }
  292|  81.0M|    }
  293|  1.08k|    return qs;
  294|  1.24k|}
burl.c:burl_normalize_2F_to_slash_fix:
  258|    140|{
  259|    140|    char * const s = b->ptr;
  260|    140|    const int blen = (int)buffer_clen(b);
  261|    140|    const int used = qs < 0 ? blen : qs;
  ------------------
  |  Branch (261:22): [True: 90, False: 50]
  ------------------
  262|    140|    int j = i;
  263|  6.33M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (263:12): [True: 6.33M, False: 140]
  ------------------
  264|  6.33M|        s[j] = s[i];
  265|  6.33M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == 'F') {
  ------------------
  |  Branch (265:13): [True: 2.10M, False: 4.23M]
  |  Branch (265:28): [True: 12.4k, False: 2.09M]
  |  Branch (265:45): [True: 1.53k, False: 10.9k]
  ------------------
  266|  1.53k|            s[j] = '/';
  267|  1.53k|            i+=2;
  268|  1.53k|        }
  269|  6.33M|    }
  270|    140|    if (qs >= 0) {
  ------------------
  |  Branch (270:9): [True: 50, False: 90]
  ------------------
  271|     50|        const int qslen = blen - qs;
  272|     50|        memmove(s+j, s+qs, (size_t)qslen);
  273|     50|        qs = j;
  274|     50|        j += qslen;
  275|     50|    }
  276|    140|    buffer_truncate(b, j);
  277|    140|    return qs;
  278|    140|}
burl.c:burl_normalize_path:
  298|  1.21k|{
  299|  1.21k|    const unsigned char * const s = (unsigned char *)b->ptr;
  300|  1.21k|    const int used = (int)buffer_clen(b);
  301|  1.21k|    int path_simplify = 0;
  302|  4.54k|    for (int i = 0, len = qs < 0 ? used : qs; i < len; ++i) {
  ------------------
  |  Branch (302:27): [True: 743, False: 475]
  |  Branch (302:47): [True: 3.73k, False: 813]
  ------------------
  303|  3.73k|        if (s[i] == '.' && (s[i+1] != '.' || ++i)
  ------------------
  |  Branch (303:13): [True: 1.52k, False: 2.21k]
  |  Branch (303:29): [True: 784, False: 736]
  |  Branch (303:46): [True: 736, False: 0]
  ------------------
  304|  1.52k|            && (s[i+1] == '/' || s[i+1] == '?' || s[i+1] == '\0')) {
  ------------------
  |  Branch (304:17): [True: 115, False: 1.40k]
  |  Branch (304:34): [True: 54, False: 1.35k]
  |  Branch (304:51): [True: 83, False: 1.26k]
  ------------------
  305|    252|            path_simplify = 1;
  306|    252|            break;
  307|    252|        }
  308|  69.0M|        while (i < len && s[i] != '/') ++i;
  ------------------
  |  Branch (308:16): [True: 69.0M, False: 663]
  |  Branch (308:27): [True: 69.0M, False: 2.81k]
  ------------------
  309|  3.48k|        if (s[i] == '/' && s[i+1] == '/') { /*(s[len] != '/')*/
  ------------------
  |  Branch (309:13): [True: 2.81k, False: 663]
  |  Branch (309:28): [True: 153, False: 2.66k]
  ------------------
  310|    153|            path_simplify = 1;
  311|    153|            break;
  312|    153|        }
  313|  3.48k|    }
  314|       |
  315|  1.21k|    if (path_simplify) {
  ------------------
  |  Branch (315:9): [True: 405, False: 813]
  ------------------
  316|    405|        if (flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT) return -2;
  ------------------
  |  Branch (316:13): [True: 4, False: 401]
  ------------------
  317|    401|        if (qs >= 0) {
  ------------------
  |  Branch (317:13): [True: 150, False: 251]
  ------------------
  318|    150|            buffer_copy_string_len(t, b->ptr+qs, used - qs);
  319|    150|            buffer_truncate(b, qs);
  320|    150|        }
  321|       |
  322|    401|        buffer_path_simplify(b);
  323|       |
  324|    401|        if (qs >= 0) {
  ------------------
  |  Branch (324:13): [True: 150, False: 251]
  ------------------
  325|    150|            qs = (int)buffer_clen(b);
  326|    150|            buffer_append_string_len(b, BUF_PTR_LEN(t));
  ------------------
  |  |  297|    150|#define BUF_PTR_LEN(x)       (x)->ptr, buffer_clen(x)
  ------------------
  327|    150|        }
  328|    401|    }
  329|       |
  330|  1.21k|    return qs;
  331|  1.21k|}
burl.c:burl_normalize_qs20_to_plus:
  244|    453|{
  245|    453|    const char * const s = b->ptr;
  246|    453|    const int used = qs < 0 ? 0 : (int)buffer_clen(b);
  ------------------
  |  Branch (246:22): [True: 0, False: 453]
  ------------------
  247|    453|    int i;
  248|    453|    if (qs < 0) return;
  ------------------
  |  Branch (248:9): [True: 0, False: 453]
  ------------------
  249|  9.88M|    for (i = qs+1; i < used; ++i) {
  ------------------
  |  Branch (249:20): [True: 9.88M, False: 323]
  ------------------
  250|  9.88M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == '0') break;
  ------------------
  |  Branch (250:13): [True: 3.25M, False: 6.63M]
  |  Branch (250:28): [True: 12.9k, False: 3.24M]
  |  Branch (250:45): [True: 130, False: 12.8k]
  ------------------
  251|  9.88M|    }
  252|    453|    if (i != used) burl_normalize_qs20_to_plus_fix(b, i);
  ------------------
  |  Branch (252:9): [True: 130, False: 323]
  ------------------
  253|    453|}
burl.c:burl_normalize_qs20_to_plus_fix:
  228|    130|{
  229|    130|    char * const s = b->ptr;
  230|    130|    const int used = (int)buffer_clen(b);
  231|    130|    int j = i;
  232|  8.52M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (232:12): [True: 8.52M, False: 130]
  ------------------
  233|  8.52M|        s[j] = s[i];
  234|  8.52M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == '0') {
  ------------------
  |  Branch (234:13): [True: 2.78M, False: 5.74M]
  |  Branch (234:28): [True: 14.3k, False: 2.77M]
  |  Branch (234:45): [True: 811, False: 13.5k]
  ------------------
  235|    811|            s[j] = '+';
  236|    811|            i+=2;
  237|    811|        }
  238|  8.52M|    }
  239|    130|    buffer_truncate(b, j);
  240|    130|}

