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

buffer_init:
   14|  3.33k|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.33k|	buffer * const b = calloc(1, sizeof(*b));
   20|  3.33k|	force_assert(b);
  ------------------
  |  |  448|  3.33k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.33k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.33k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.33k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   21|  3.33k|	return b;
   22|  3.33k|  #endif
   23|  3.33k|}
buffer_free:
   25|  3.33k|void buffer_free(buffer *b) {
   26|  3.33k|	if (NULL == b) return;
  ------------------
  |  Branch (26:6): [True: 0, False: 3.33k]
  ------------------
   27|  3.33k|	free(b->ptr);
   28|  3.33k|	free(b);
   29|  3.33k|}
buffer_string_prepare_copy:
   82|  1.28k|char* buffer_string_prepare_copy(buffer * const b, const size_t size) {
   83|  1.28k|    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.28k|    return (size < b->size)
  ------------------
  |  Branch (87:12): [True: 0, False: 1.28k]
  ------------------
   88|  1.28k|      ? b->ptr
   89|  1.28k|      : buffer_alloc_replace(b, size);
   90|  1.28k|}
buffer_extend:
  127|    148|{
  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|    148|    const uint32_t len = b->used ? b->used-1 : 0;
  ------------------
  |  Branch (136:26): [True: 148, False: 0]
  ------------------
  137|    148|    char * const s = (b->size - len >= x + 1)
  ------------------
  |  Branch (137:22): [True: 148, False: 0]
  ------------------
  138|    148|      ? b->ptr + len
  139|    148|      : buffer_string_prepare_append_resize(b, x);
  140|    148|    b->used = len+x+1;
  141|    148|  #endif
  142|    148|    s[x] = '\0';
  143|    148|    return s;
  144|    148|}
buffer_copy_string_len:
  172|  3.10k|void buffer_copy_string_len(buffer * const restrict b, const char * const restrict s, const size_t len) {
  173|  3.10k|    b->used = len + 1;
  174|  3.10k|    char * const restrict d = (len < b->size)
  ------------------
  |  Branch (174:31): [True: 935, False: 2.16k]
  ------------------
  175|  3.10k|      ? b->ptr
  176|  3.10k|      : buffer_alloc_replace(b, len);
  177|  3.10k|    d[len] = '\0';
  178|  3.10k|    memcpy(d, s, len);
  179|  3.10k|}
buffer_append_string_len:
  198|    148|void buffer_append_string_len(buffer * const restrict b, const char * const restrict s, const size_t len) {
  199|    148|    memcpy(buffer_extend(b, len), s, len);
  200|    148|}
hex2int:
  386|  95.8M|char hex2int(unsigned char hex) {
  387|  95.8M|	unsigned char n;
  388|  95.8M|	return li_cton(hex,n) ? (char)n : 0xFF;
  ------------------
  |  |  381|  95.8M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (381:4): [True: 85.0M, False: 10.8M]
  |  |  |  Branch (381:30): [True: 10.8M, False: 0]
  |  |  |  Branch (381:31): [True: 10.8M, False: 0]
  |  |  ------------------
  ------------------
  389|  95.8M|}
buffer_urldecode_path:
  792|  1.66k|void buffer_urldecode_path(buffer * const b) {
  793|  1.66k|    const size_t len = buffer_clen(b);
  794|  1.66k|    char *src = len ? memchr(b->ptr, '%', len) : NULL;
  ------------------
  |  Branch (794:17): [True: 1.66k, False: 7]
  ------------------
  795|  1.66k|    if (NULL == src) return;
  ------------------
  |  Branch (795:9): [True: 355, False: 1.31k]
  ------------------
  796|       |
  797|  1.31k|    char *dst = src;
  798|  47.9M|    do {
  799|       |        /* *src == '%' */
  800|  47.9M|        unsigned char high = ((unsigned char *)src)[1];
  801|  47.9M|        unsigned char low = high ? hex2int(((unsigned char *)src)[2]) : 0xFF;
  ------------------
  |  Branch (801:29): [True: 47.9M, False: 0]
  ------------------
  802|  47.9M|        if (0xFF != (high = hex2int(high)) && 0xFF != low) {
  ------------------
  |  Branch (802:13): [True: 47.9M, False: 0]
  |  Branch (802:47): [True: 47.9M, False: 0]
  ------------------
  803|  47.9M|            high = (high << 4) | low;   /* map ctrls to '_' */
  804|  47.9M|            *dst = (high >= 32 && high != 127) ? high : '_';
  ------------------
  |  Branch (804:21): [True: 8.79M, False: 39.1M]
  |  Branch (804:35): [True: 8.23M, False: 561k]
  ------------------
  805|  47.9M|            src += 2;
  806|  47.9M|        } /* else ignore this '%'; leave as-is and move on */
  807|       |
  808|  51.3M|        while ((*++dst = *++src) != '%' && *src) ;
  ------------------
  |  Branch (808:16): [True: 3.38M, False: 47.9M]
  |  Branch (808:44): [True: 3.38M, False: 1.31k]
  ------------------
  809|  47.9M|    } while (*src);
  ------------------
  |  Branch (809:14): [True: 47.9M, False: 1.31k]
  ------------------
  810|  1.31k|    b->used = (dst - b->ptr) + 1;
  811|  1.31k|}
buffer_path_simplify:
  859|    395|{
  860|    395|    char *out = b->ptr;
  861|    395|    char * const end = b->ptr + b->used - 1;
  862|       |
  863|    395|    if (__builtin_expect( (buffer_is_blank(b)), 0)) {
  ------------------
  |  Branch (863:9): [True: 0, False: 395]
  ------------------
  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|    395|    *end = '/'; /*(end of path modified to avoid need to check '\0')*/
  876|       |
  877|    395|    char *walk = out;
  878|    395|    if (__builtin_expect( (*walk == '/'), 1)) {
  ------------------
  |  Branch (878:9): [True: 146, False: 249]
  ------------------
  879|       |        /* scan to detect (potential) need for path simplification
  880|       |         * (repeated '/' or "/.") */
  881|    537|        do {
  882|    537|            if (*++walk == '.' || *walk == '/')
  ------------------
  |  Branch (882:17): [True: 82, False: 455]
  |  Branch (882:35): [True: 64, False: 391]
  ------------------
  883|    146|                break;
  884|   256k|            do { ++walk; } while (*walk != '/');
  ------------------
  |  Branch (884:35): [True: 256k, False: 391]
  ------------------
  885|    391|        } while (walk != end);
  ------------------
  |  Branch (885:18): [True: 391, False: 0]
  ------------------
  886|    146|        if (__builtin_expect( (walk == end), 1)) {
  ------------------
  |  Branch (886:13): [True: 0, False: 146]
  ------------------
  887|       |            /* common case: no repeated '/' or "/." */
  888|      0|            *end = '\0'; /* overwrite extra '/' added to end of path */
  889|      0|            return;
  890|      0|        }
  891|    146|        out = walk-1;
  892|    146|    }
  893|    249|    else {
  894|    249|        if (walk[0] == '.' && walk[1] == '/')
  ------------------
  |  Branch (894:13): [True: 95, False: 154]
  |  Branch (894:31): [True: 54, False: 41]
  ------------------
  895|     54|            *out = *++walk;
  896|    195|        else if (walk[0] == '.' && walk[1] == '.' && walk[2] == '/')
  ------------------
  |  Branch (896:18): [True: 41, False: 154]
  |  Branch (896:36): [True: 19, False: 22]
  |  Branch (896:54): [True: 3, False: 16]
  ------------------
  897|      3|            *out = *(walk += 2);
  898|    192|        else {
  899|  6.62M|            while (*++walk != '/') ;
  ------------------
  |  Branch (899:20): [True: 6.62M, False: 192]
  ------------------
  900|    192|            out = walk;
  901|    192|        }
  902|    249|        ++walk;
  903|    249|    }
  904|       |
  905|  11.0k|    while (walk <= end) {
  ------------------
  |  Branch (905:12): [True: 10.8k, False: 202]
  ------------------
  906|       |        /* previous char is '/' at this point (or start of string w/o '/') */
  907|  10.8k|        if (__builtin_expect( (walk[0] == '/'), 0)) {
  ------------------
  |  Branch (907:13): [True: 2.44k, False: 8.37k]
  ------------------
  908|       |            /* skip repeated '/' (e.g. "///" -> "/") */
  909|  2.44k|            if (++walk < end)
  ------------------
  |  Branch (909:17): [True: 2.38k, False: 59]
  ------------------
  910|  2.38k|                continue;
  911|     59|            else {
  912|     59|                ++out;
  913|     59|                break;
  914|     59|            }
  915|  2.44k|        }
  916|  8.37k|        else if (__builtin_expect( (walk[0] == '.'), 0)) {
  ------------------
  |  Branch (916:18): [True: 6.14k, False: 2.23k]
  ------------------
  917|       |            /* handle "./" and "../" */
  918|  6.14k|            if (walk[1] == '.' && walk[2] == '/') {
  ------------------
  |  Branch (918:17): [True: 2.75k, False: 3.38k]
  |  Branch (918:35): [True: 1.07k, False: 1.68k]
  ------------------
  919|       |                /* handle "../" */
  920|  8.28M|                while (out > b->ptr && *--out != '/') ;
  ------------------
  |  Branch (920:24): [True: 8.28M, False: 557]
  |  Branch (920:40): [True: 8.28M, False: 520]
  ------------------
  921|  1.07k|                *out = '/'; /*(in case path had not started with '/')*/
  922|  1.07k|                if ((walk += 3) >= end) {
  ------------------
  |  Branch (922:21): [True: 59, False: 1.01k]
  ------------------
  923|     59|                    ++out;
  924|     59|                    break;
  925|     59|                }
  926|  1.01k|                else
  927|  1.01k|                    continue;
  928|  1.07k|            }
  929|  5.06k|            else if (walk[1] == '/') {
  ------------------
  |  Branch (929:22): [True: 2.20k, False: 2.85k]
  ------------------
  930|       |                /* handle "./" */
  931|  2.20k|                if ((walk += 2) >= end) {
  ------------------
  |  Branch (931:21): [True: 75, False: 2.13k]
  ------------------
  932|     75|                    ++out;
  933|     75|                    break;
  934|     75|                }
  935|  2.13k|                continue;
  936|  2.20k|            }
  937|  2.85k|            else {
  938|       |                /* accept "." if not part of "../" or "./" */
  939|  2.85k|                *++out = '.';
  940|  2.85k|                ++walk;
  941|  2.85k|            }
  942|  6.14k|        }
  943|       |
  944|  35.4M|        while ((*++out = *walk++) != '/') ;
  ------------------
  |  Branch (944:16): [True: 35.4M, False: 5.08k]
  ------------------
  945|  5.08k|    }
  946|    395|    *out = *end = '\0'; /* overwrite extra '/' added to end of path */
  947|    395|    b->used = (out - b->ptr) + 1;
  948|       |    /*buffer_truncate(b, out - b->ptr);*/
  949|    395|}
buffer.c:buffer_alloc_replace:
   71|  3.45k|static char* buffer_alloc_replace(buffer * const restrict b, const size_t size) {
   72|       |    /*(discard old data so realloc() does not copy)*/
   73|  3.45k|    if (NULL != b->ptr) {
  ------------------
  |  Branch (73:9): [True: 486, False: 2.96k]
  ------------------
   74|    486|        free(b->ptr);
   75|    486|        b->ptr = NULL;
   76|    486|    }
   77|       |    /*(note: if size larger than one lshift, use size instead of power-2)*/
   78|  3.45k|    const size_t bsize2x = (b->size & ~1uL) << 1;
   79|  3.45k|    return buffer_realloc(b, bsize2x > size ? bsize2x-1 : size);
  ------------------
  |  Branch (79:30): [True: 253, False: 3.20k]
  ------------------
   80|  3.45k|}
buffer.c:buffer_realloc:
   49|  3.45k|static char* buffer_realloc(buffer * const restrict b, const size_t len) {
   50|  3.45k|    #define BUFFER_PIECE_SIZE 64uL  /*(must be power-of-2)*/
   51|  3.45k|    size_t sz = (len + 1 + BUFFER_PIECE_SIZE-1) & ~(BUFFER_PIECE_SIZE-1);
  ------------------
  |  |   50|  3.45k|    #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.45k|    #define BUFFER_PIECE_SIZE 64uL  /*(must be power-of-2)*/
  ------------------
   52|  3.45k|    force_assert(sz > len);
  ------------------
  |  |  448|  3.45k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.45k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.45k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.45k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   53|  3.45k|    if ((sz & (sz-1)) && sz < INT_MAX) {/* not power-2; huge val not expected */
  ------------------
  |  Branch (53:9): [True: 1.18k, False: 2.26k]
  |  Branch (53:26): [True: 1.18k, False: 0]
  ------------------
   54|       |        /*(optimizer should recognize this and use ffs or clz or equivalent)*/
   55|  1.18k|        const size_t psz = sz;
   56|  8.14k|        for (sz = 256; sz < psz; sz <<= 1) ;
  ------------------
  |  Branch (56:24): [True: 6.96k, False: 1.18k]
  ------------------
   57|  1.18k|    }
   58|  3.45k|    sz |= 1; /*(extra +1 for '\0' when needed buffer size is exact power-2)*/
   59|       |
   60|  3.45k|    b->size = sz;
   61|  3.45k|    b->ptr = realloc(b->ptr, sz);
   62|       |
   63|  3.45k|    force_assert(NULL != b->ptr);
  ------------------
  |  |  448|  3.45k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.45k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.45k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.45k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   64|  3.45k|    return b->ptr;
   65|  3.45k|}

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

burl_normalize:
  344|  1.66k|{
  345|  1.66k|    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.66k|    qs = (flags & HTTP_PARSEOPT_URL_NORMALIZE_REQUIRED)
  ------------------
  |  Branch (364:10): [True: 934, False: 734]
  ------------------
  365|  1.66k|      ? burl_normalize_basic_required(b, t)
  366|  1.66k|      : burl_normalize_basic_unreserved(b, t);
  367|  1.66k|    if (-2 == qs) {
  ------------------
  |  Branch (367:9): [True: 476, False: 1.19k]
  ------------------
  368|    476|        if (flags & HTTP_PARSEOPT_URL_NORMALIZE_INVALID_UTF8_REJECT) return -2;
  ------------------
  |  Branch (368:13): [True: 103, False: 373]
  ------------------
  369|    373|        qs = burl_scan_qmark(b);
  370|    373|    }
  371|       |
  372|  1.56k|    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_CTRLS_REJECT) {
  ------------------
  |  Branch (372:9): [True: 385, False: 1.18k]
  ------------------
  373|    385|        if (burl_contains_ctrls(b)) return -2;
  ------------------
  |  Branch (373:13): [True: 95, False: 290]
  ------------------
  374|    385|    }
  375|       |
  376|  1.47k|    if (flags & (HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_DECODE
  ------------------
  |  Branch (376:9): [True: 1.21k, False: 259]
  ------------------
  377|  1.47k|                |HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)) {
  378|  1.21k|        qs = burl_normalize_2F_to_slash(b, qs, flags);
  379|  1.21k|        if (-2 == qs) return -2;
  ------------------
  |  Branch (379:13): [True: 18, False: 1.19k]
  ------------------
  380|  1.21k|    }
  381|       |
  382|  1.45k|    if (flags & (HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REMOVE
  ------------------
  |  Branch (382:9): [True: 1.17k, False: 282]
  ------------------
  383|  1.45k|                |HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT)) {
  384|  1.17k|        qs = burl_normalize_path(b, t, qs, flags);
  385|  1.17k|        if (-2 == qs) return -2;
  ------------------
  |  Branch (385:13): [True: 11, False: 1.15k]
  ------------------
  386|  1.17k|    }
  387|       |
  388|  1.44k|    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_QUERY_20_PLUS) {
  ------------------
  |  Branch (388:9): [True: 850, False: 591]
  ------------------
  389|    850|        if (qs >= 0) burl_normalize_qs20_to_plus(b, qs);
  ------------------
  |  Branch (389:13): [True: 445, False: 405]
  ------------------
  390|    850|    }
  391|       |
  392|  1.44k|    return qs;
  393|  1.45k|}
burl.c:burl_normalize_basic_required:
  179|    934|{
  180|    934|    const unsigned char * const s = (unsigned char *)b->ptr;
  181|    934|    const int used = (int)buffer_clen(b);
  182|    934|    unsigned int n1, n2, x;
  183|    934|    int qs = -1;
  184|    934|    int invalid_utf8 = 0;
  185|       |
  186|   195k|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (186:21): [True: 194k, False: 211]
  ------------------
  187|   194k|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (187:13): [True: 185k, False: 9.54k]
  ------------------
  188|   185k|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = i;
  ------------------
  |  Branch (188:17): [True: 1.73k, False: 183k]
  |  Branch (188:56): [True: 202, False: 1.52k]
  ------------------
  189|   185k|        }
  190|  9.54k|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  18.5k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 4.12k, False: 4.90k]
  |  |  |  Branch (43:30): [True: 4.81k, False: 81]
  |  |  |  Branch (43:31): [True: 4.81k, False: 81]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  18.4k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 3.39k, False: 5.55k]
  |  |  |  Branch (43:30): [True: 5.48k, False: 61]
  |  |  |  Branch (43:31): [True: 5.48k, False: 61]
  |  |  ------------------
  ------------------
  |  Branch (190:18): [True: 9.02k, False: 514]
  ------------------
  191|  8.88k|                 && (encoded_chars_http_uri_reqd[(x = (n1 << 4) | n2)]
  ------------------
  |  Branch (191:22): [True: 6.27k, False: 2.61k]
  ------------------
  192|  2.61k|                     || (qs < 0
  ------------------
  |  Branch (192:25): [True: 2.54k, False: 67]
  |  Branch (192:26): [True: 603, False: 2.01k]
  ------------------
  193|  2.61k|                         ? (x == '/' || x == '?')
  ------------------
  |  Branch (193:29): [True: 343, False: 260]
  |  Branch (193:41): [True: 230, False: 30]
  ------------------
  194|  8.81k|                         : (x == '&' || x == '=' || x == ';' || x == '+')))) {
  ------------------
  |  Branch (194:29): [True: 706, False: 1.30k]
  |  Branch (194:41): [True: 407, False: 900]
  |  Branch (194:53): [True: 231, False: 669]
  |  Branch (194:65): [True: 632, False: 37]
  ------------------
  195|  8.81k|            invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  8.81k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  8.81k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 372, False: 8.44k]
  |  |  |  |  ------------------
  |  |  |  |  261|  8.81k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 97, False: 8.35k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|  8.81k|            if (s[i+1] >= 'a') b->ptr[i+1] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (196:17): [True: 3.79k, False: 5.02k]
  ------------------
  197|  8.81k|            if (s[i+2] >= 'a') b->ptr[i+2] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (197:17): [True: 3.32k, False: 5.49k]
  ------------------
  198|  8.81k|            i+=2;
  199|  8.81k|        }
  200|    723|        else if (s[i] == '#') { /* ignore fragment */
  ------------------
  |  Branch (200:18): [True: 1, False: 722]
  ------------------
  201|      1|            buffer_truncate(b, (size_t)i);
  202|      1|            break;
  203|      1|        }
  204|    722|        else {
  205|    722|            qs = burl_normalize_basic_required_fix(b, t, i, qs);
  206|    722|            break;
  207|    722|        }
  208|   194k|    }
  209|       |
  210|    934|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (210:12): [True: 911, False: 23]
  ------------------
  211|    934|}
burl.c:burl_normalize_basic_required_fix:
  135|    722|{
  136|    722|    int j = i;
  137|    722|    const int used = (int)buffer_clen(b);
  138|    722|    const unsigned char * const s = (unsigned char *)b->ptr;
  139|    722|    unsigned char * const p =
  140|    722|      (unsigned char *)buffer_string_prepare_copy(t,i+(used-i)*3+1);
  141|    722|    unsigned int n1, n2;
  142|    722|    int invalid_utf8 = 0;
  143|    722|    memcpy(p, s, (size_t)i);
  144|  31.8M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (144:12): [True: 31.8M, False: 708]
  ------------------
  145|  31.8M|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (145:13): [True: 1.60M, False: 30.2M]
  ------------------
  146|  1.60M|            p[j] = s[i];
  147|  1.60M|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = j;
  ------------------
  |  Branch (147:17): [True: 9.85k, False: 1.59M]
  |  Branch (147:56): [True: 202, False: 9.65k]
  ------------------
  148|  1.60M|        }
  149|  30.2M|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  30.2M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 30.0k, False: 28.8k]
  |  |  |  Branch (43:30): [True: 23.4k, False: 5.42k]
  |  |  |  Branch (43:31): [True: 23.4k, False: 5.42k]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  53.4k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 19.4k, False: 34.0k]
  |  |  |  Branch (43:30): [True: 31.4k, False: 2.55k]
  |  |  |  Branch (43:31): [True: 31.4k, False: 2.55k]
  |  |  ------------------
  ------------------
  |  Branch (149:18): [True: 58.8k, False: 30.1M]
  ------------------
  150|  50.8k|            const unsigned int x = (n1 << 4) | n2;
  151|  50.8k|            if (!encoded_chars_http_uri_reqd[x]
  ------------------
  |  Branch (151:17): [True: 20.4k, False: 30.4k]
  ------------------
  152|  20.4k|                && (qs < 0
  ------------------
  |  Branch (152:20): [True: 9.16k, False: 11.3k]
  |  Branch (152:21): [True: 3.42k, False: 17.0k]
  ------------------
  153|  20.4k|                    ? (x != '/' && x != '?')
  ------------------
  |  Branch (153:24): [True: 2.07k, False: 1.35k]
  |  Branch (153:36): [True: 1.52k, False: 547]
  ------------------
  154|  20.4k|                    : (x != '&' && x != '=' && x != ';' && x != '+'))) {
  ------------------
  |  Branch (154:24): [True: 11.8k, False: 5.15k]
  |  Branch (154:36): [True: 9.41k, False: 2.47k]
  |  Branch (154:48): [True: 8.86k, False: 551]
  |  Branch (154:60): [True: 7.63k, False: 1.22k]
  ------------------
  155|  9.16k|                p[j] = x;
  156|  9.16k|            }
  157|  41.7k|            else {
  158|  41.7k|                p[j]   = '%';
  159|  41.7k|                p[++j] = hex_chars_uc[n1]; /*(s[i+1] & 0xdf)*/
  160|  41.7k|                p[++j] = hex_chars_uc[n2]; /*(s[i+2] & 0xdf)*/
  161|  41.7k|                invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  41.7k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  41.7k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 555, False: 41.1k]
  |  |  |  |  ------------------
  |  |  |  |  261|  41.7k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 412, False: 40.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  162|  41.7k|            }
  163|  50.8k|            i+=2;
  164|  50.8k|        }
  165|  30.1M|        else if (s[i] == '#') break; /* ignore fragment */
  ------------------
  |  Branch (165:18): [True: 14, False: 30.1M]
  ------------------
  166|  30.1M|        else {
  167|  30.1M|            p[j]   = '%';
  168|  30.1M|            p[++j] = hex_chars_uc[(s[i] >> 4) & 0xF];
  169|  30.1M|            p[++j] = hex_chars_uc[s[i] & 0xF];
  170|  30.1M|            invalid_utf8 |= li_utf8_invalid_byte(s[i]);
  ------------------
  |  |   49|  30.1M|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  30.1M|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 860k, False: 29.2M]
  |  |  |  |  ------------------
  |  |  |  |  261|  30.1M|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 260, False: 29.2M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  171|  30.1M|        }
  172|  31.8M|    }
  173|    722|    buffer_copy_string_len(b, (char *)p, (size_t)j);
  174|    722|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (174:12): [True: 457, False: 265]
  ------------------
  175|    722|}
burl.c:burl_normalize_basic_unreserved:
  101|    734|{
  102|    734|    const unsigned char * const s = (unsigned char *)b->ptr;
  103|    734|    const int used = (int)buffer_clen(b);
  104|    734|    unsigned int n1, n2, x;
  105|    734|    int qs = -1;
  106|    734|    int invalid_utf8 = 0;
  107|       |
  108|   707k|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (108:21): [True: 707k, False: 169]
  ------------------
  109|   707k|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (109:13): [True: 704k, False: 3.03k]
  ------------------
  110|   704k|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = i;
  ------------------
  |  Branch (110:17): [True: 538, False: 703k]
  |  Branch (110:56): [True: 86, False: 452]
  ------------------
  111|   704k|        }
  112|  3.03k|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  5.69k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 1.43k, False: 1.22k]
  |  |  |  Branch (43:30): [True: 1.16k, False: 65]
  |  |  |  Branch (43:31): [True: 1.16k, False: 65]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  5.62k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 1.05k, False: 1.53k]
  |  |  |  Branch (43:30): [True: 1.47k, False: 66]
  |  |  |  Branch (43:31): [True: 1.47k, False: 66]
  |  |  ------------------
  ------------------
  |  Branch (112:18): [True: 2.65k, False: 380]
  ------------------
  113|  2.52k|                 && !burl_is_unreserved((x = (n1 << 4) | n2))) {
  ------------------
  |  Branch (113:21): [True: 2.47k, False: 54]
  ------------------
  114|  2.47k|            invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  2.47k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  2.47k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 493, False: 1.97k]
  |  |  |  |  ------------------
  |  |  |  |  261|  2.47k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 26, False: 1.95k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  115|  2.47k|            if (s[i+1] >= 'a') b->ptr[i+1] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (115:17): [True: 994, False: 1.47k]
  ------------------
  116|  2.47k|            if (s[i+2] >= 'a') b->ptr[i+2] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (116:17): [True: 916, False: 1.55k]
  ------------------
  117|  2.47k|            i+=2;
  118|  2.47k|        }
  119|    565|        else if (s[i] == '#') { /* ignore fragment */
  ------------------
  |  Branch (119:18): [True: 1, False: 564]
  ------------------
  120|      1|            buffer_truncate(b, (size_t)i);
  121|      1|            break;
  122|      1|        }
  123|    564|        else {
  124|    564|            qs = burl_normalize_basic_unreserved_fix(b, t, i, qs);
  125|    564|            break;
  126|    564|        }
  127|   707k|    }
  128|       |
  129|    734|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (129:12): [True: 706, False: 28]
  ------------------
  130|    734|}
burl.c:burl_is_unreserved:
   53|  38.6k|{
   54|  38.6k|    return (light_isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~');
  ------------------
  |  Branch (54:13): [True: 705, False: 37.9k]
  |  Branch (54:33): [True: 225, False: 37.7k]
  |  Branch (54:45): [True: 229, False: 37.5k]
  |  Branch (54:57): [True: 1.21k, False: 36.3k]
  |  Branch (54:69): [True: 322, False: 35.9k]
  ------------------
   55|  38.6k|}
burl.c:burl_normalize_basic_unreserved_fix:
   60|    564|{
   61|    564|    int j = i;
   62|    564|    const int used = (int)buffer_clen(b);
   63|    564|    const unsigned char * const s = (unsigned char *)b->ptr;
   64|    564|    unsigned char * const p =
   65|    564|      (unsigned char *)buffer_string_prepare_copy(t,i+(used-i)*3+1);
   66|    564|    unsigned int n1, n2;
   67|    564|    int invalid_utf8 = 0;
   68|    564|    memcpy(p, s, (size_t)i);
   69|  21.6M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (69:12): [True: 21.6M, False: 561]
  ------------------
   70|  21.6M|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (70:13): [True: 1.10M, False: 20.5M]
  ------------------
   71|  1.10M|            p[j] = s[i];
   72|  1.10M|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = j;
  ------------------
  |  Branch (72:17): [True: 1.76k, False: 1.09M]
  |  Branch (72:56): [True: 151, False: 1.61k]
  ------------------
   73|  1.10M|        }
   74|  20.5M|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  20.5M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 8.46k, False: 31.7k]
  |  |  |  Branch (43:30): [True: 29.0k, False: 2.64k]
  |  |  |  Branch (43:31): [True: 29.0k, False: 2.64k]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  37.5k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 11.6k, False: 25.9k]
  |  |  |  Branch (43:30): [True: 24.5k, False: 1.38k]
  |  |  |  Branch (43:31): [True: 24.5k, False: 1.38k]
  |  |  ------------------
  ------------------
  |  Branch (74:18): [True: 40.1k, False: 20.4M]
  ------------------
   75|  36.1k|            const unsigned int x = (n1 << 4) | n2;
   76|  36.1k|            if (burl_is_unreserved(x)) {
  ------------------
  |  Branch (76:17): [True: 2.64k, False: 33.5k]
  ------------------
   77|  2.64k|                p[j] = x;
   78|  2.64k|            }
   79|  33.5k|            else {
   80|  33.5k|                p[j]   = '%';
   81|  33.5k|                p[++j] = hex_chars_uc[n1]; /*(s[i+1] & 0xdf)*/
   82|  33.5k|                p[++j] = hex_chars_uc[n2]; /*(s[i+2] & 0xdf)*/
   83|  33.5k|                invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  33.5k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  33.5k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 1.31k, False: 32.2k]
  |  |  |  |  ------------------
  |  |  |  |  261|  33.5k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 51, False: 32.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   84|  33.5k|            }
   85|  36.1k|            i+=2;
   86|  36.1k|        }
   87|  20.4M|        else if (s[i] == '#') break; /* ignore fragment */
  ------------------
  |  Branch (87:18): [True: 3, False: 20.4M]
  ------------------
   88|  20.4M|        else {
   89|  20.4M|            p[j]   = '%';
   90|  20.4M|            p[++j] = hex_chars_uc[(s[i] >> 4) & 0xF];
   91|  20.4M|            p[++j] = hex_chars_uc[s[i] & 0xF];
   92|  20.4M|            invalid_utf8 |= li_utf8_invalid_byte(s[i]);
  ------------------
  |  |   49|  20.4M|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  20.4M|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 31.5k, False: 20.4M]
  |  |  |  |  ------------------
  |  |  |  |  261|  20.4M|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 99, False: 20.4M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   93|  20.4M|        }
   94|  21.6M|    }
   95|    564|    buffer_copy_string_len(b, (char *)p, (size_t)j);
   96|    564|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (96:12): [True: 402, False: 162]
  ------------------
   97|    564|}
burl.c:burl_scan_qmark:
  337|    373|static int burl_scan_qmark (const buffer * const b) {
  338|    373|    const char * const qmark = strchr(b->ptr, '?');
  339|    373|    return qmark ? (int)(qmark - b->ptr) : -1;
  ------------------
  |  Branch (339:12): [True: 216, False: 157]
  ------------------
  340|    373|}
burl.c:burl_contains_ctrls:
  215|    385|{
  216|    385|    const char * const s = b->ptr;
  217|    385|    const int used = (int)buffer_clen(b);
  218|  11.3M|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (218:21): [True: 11.3M, False: 290]
  ------------------
  219|  11.3M|        if (s[i] == '%' && (s[i+1] < '2' || (s[i+1] == '7' && s[i+2] == 'F')))
  ------------------
  |  Branch (219:13): [True: 3.52M, False: 7.84M]
  |  Branch (219:29): [True: 91, False: 3.52M]
  |  Branch (219:46): [True: 973, False: 3.52M]
  |  Branch (219:63): [True: 4, False: 969]
  ------------------
  220|     95|            return 1;
  221|  11.3M|    }
  222|    290|    return 0;
  223|    385|}
burl.c:burl_normalize_2F_to_slash:
  282|  1.21k|{
  283|       |    /*("%2F" must already have been uppercased during normalization)*/
  284|  1.21k|    const char * const s = b->ptr;
  285|  1.21k|    const int used = qs < 0 ? (int)buffer_clen(b) : qs;
  ------------------
  |  Branch (285:22): [True: 718, False: 493]
  ------------------
  286|  80.6M|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (286:21): [True: 80.6M, False: 1.04k]
  ------------------
  287|  80.6M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == 'F') {
  ------------------
  |  Branch (287:13): [True: 26.8M, False: 53.8M]
  |  Branch (287:28): [True: 4.60k, False: 26.8M]
  |  Branch (287:45): [True: 167, False: 4.43k]
  ------------------
  288|    167|            return !(flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)
  ------------------
  |  Branch (288:20): [True: 149, False: 18]
  ------------------
  289|    167|              ? burl_normalize_2F_to_slash_fix(b, qs, i)     /* _DECODE */
  290|    167|              : -2; /*(flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)*/
  291|    167|        }
  292|  80.6M|    }
  293|  1.04k|    return qs;
  294|  1.21k|}
burl.c:burl_normalize_2F_to_slash_fix:
  258|    149|{
  259|    149|    char * const s = b->ptr;
  260|    149|    const int blen = (int)buffer_clen(b);
  261|    149|    const int used = qs < 0 ? blen : qs;
  ------------------
  |  Branch (261:22): [True: 98, False: 51]
  ------------------
  262|    149|    int j = i;
  263|  9.20M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (263:12): [True: 9.20M, False: 149]
  ------------------
  264|  9.20M|        s[j] = s[i];
  265|  9.20M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == 'F') {
  ------------------
  |  Branch (265:13): [True: 3.00M, False: 6.20M]
  |  Branch (265:28): [True: 4.47k, False: 3.00M]
  |  Branch (265:45): [True: 1.05k, False: 3.41k]
  ------------------
  266|  1.05k|            s[j] = '/';
  267|  1.05k|            i+=2;
  268|  1.05k|        }
  269|  9.20M|    }
  270|    149|    if (qs >= 0) {
  ------------------
  |  Branch (270:9): [True: 51, False: 98]
  ------------------
  271|     51|        const int qslen = blen - qs;
  272|     51|        memmove(s+j, s+qs, (size_t)qslen);
  273|     51|        qs = j;
  274|     51|        j += qslen;
  275|     51|    }
  276|    149|    buffer_truncate(b, j);
  277|    149|    return qs;
  278|    149|}
burl.c:burl_normalize_path:
  298|  1.17k|{
  299|  1.17k|    const unsigned char * const s = (unsigned char *)b->ptr;
  300|  1.17k|    const int used = (int)buffer_clen(b);
  301|  1.17k|    int path_simplify = 0;
  302|  4.72k|    for (int i = 0, len = qs < 0 ? used : qs; i < len; ++i) {
  ------------------
  |  Branch (302:27): [True: 702, False: 468]
  |  Branch (302:47): [True: 3.95k, False: 764]
  ------------------
  303|  3.95k|        if (s[i] == '.' && (s[i+1] != '.' || ++i)
  ------------------
  |  Branch (303:13): [True: 1.78k, False: 2.17k]
  |  Branch (303:29): [True: 854, False: 933]
  |  Branch (303:46): [True: 933, False: 0]
  ------------------
  304|  1.78k|            && (s[i+1] == '/' || s[i+1] == '?' || s[i+1] == '\0')) {
  ------------------
  |  Branch (304:17): [True: 104, False: 1.68k]
  |  Branch (304:34): [True: 47, False: 1.63k]
  |  Branch (304:51): [True: 90, False: 1.54k]
  ------------------
  305|    241|            path_simplify = 1;
  306|    241|            break;
  307|    241|        }
  308|  63.6M|        while (i < len && s[i] != '/') ++i;
  ------------------
  |  Branch (308:16): [True: 63.6M, False: 609]
  |  Branch (308:27): [True: 63.6M, False: 3.10k]
  ------------------
  309|  3.71k|        if (s[i] == '/' && s[i+1] == '/') { /*(s[len] != '/')*/
  ------------------
  |  Branch (309:13): [True: 3.10k, False: 609]
  |  Branch (309:28): [True: 165, False: 2.94k]
  ------------------
  310|    165|            path_simplify = 1;
  311|    165|            break;
  312|    165|        }
  313|  3.71k|    }
  314|       |
  315|  1.17k|    if (path_simplify) {
  ------------------
  |  Branch (315:9): [True: 406, False: 764]
  ------------------
  316|    406|        if (flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT) return -2;
  ------------------
  |  Branch (316:13): [True: 11, False: 395]
  ------------------
  317|    395|        if (qs >= 0) {
  ------------------
  |  Branch (317:13): [True: 148, False: 247]
  ------------------
  318|    148|            buffer_copy_string_len(t, b->ptr+qs, used - qs);
  319|    148|            buffer_truncate(b, qs);
  320|    148|        }
  321|       |
  322|    395|        buffer_path_simplify(b);
  323|       |
  324|    395|        if (qs >= 0) {
  ------------------
  |  Branch (324:13): [True: 148, False: 247]
  ------------------
  325|    148|            qs = (int)buffer_clen(b);
  326|    148|            buffer_append_string_len(b, BUF_PTR_LEN(t));
  ------------------
  |  |  297|    148|#define BUF_PTR_LEN(x)       (x)->ptr, buffer_clen(x)
  ------------------
  327|    148|        }
  328|    395|    }
  329|       |
  330|  1.15k|    return qs;
  331|  1.17k|}
burl.c:burl_normalize_qs20_to_plus:
  244|    445|{
  245|    445|    const char * const s = b->ptr;
  246|    445|    const int used = qs < 0 ? 0 : (int)buffer_clen(b);
  ------------------
  |  Branch (246:22): [True: 0, False: 445]
  ------------------
  247|    445|    int i;
  248|    445|    if (qs < 0) return;
  ------------------
  |  Branch (248:9): [True: 0, False: 445]
  ------------------
  249|  5.47M|    for (i = qs+1; i < used; ++i) {
  ------------------
  |  Branch (249:20): [True: 5.47M, False: 318]
  ------------------
  250|  5.47M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == '0') break;
  ------------------
  |  Branch (250:13): [True: 1.81M, False: 3.65M]
  |  Branch (250:28): [True: 2.87k, False: 1.80M]
  |  Branch (250:45): [True: 127, False: 2.74k]
  ------------------
  251|  5.47M|    }
  252|    445|    if (i != used) burl_normalize_qs20_to_plus_fix(b, i);
  ------------------
  |  Branch (252:9): [True: 127, False: 318]
  ------------------
  253|    445|}
burl.c:burl_normalize_qs20_to_plus_fix:
  228|    127|{
  229|    127|    char * const s = b->ptr;
  230|    127|    const int used = (int)buffer_clen(b);
  231|    127|    int j = i;
  232|  7.19M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (232:12): [True: 7.19M, False: 127]
  ------------------
  233|  7.19M|        s[j] = s[i];
  234|  7.19M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == '0') {
  ------------------
  |  Branch (234:13): [True: 2.37M, False: 4.81M]
  |  Branch (234:28): [True: 5.76k, False: 2.37M]
  |  Branch (234:45): [True: 2.13k, False: 3.63k]
  ------------------
  235|  2.13k|            s[j] = '+';
  236|  2.13k|            i+=2;
  237|  2.13k|        }
  238|  7.19M|    }
  239|    127|    buffer_truncate(b, j);
  240|    127|}

