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.70k|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   33|  1.70k|    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.40k|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.40k|	buffer * const b = calloc(1, sizeof(*b));
   20|  3.40k|	force_assert(b);
  ------------------
  |  |  448|  3.40k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.40k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.40k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.40k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   21|  3.40k|	return b;
   22|  3.40k|  #endif
   23|  3.40k|}
buffer_free:
   25|  3.40k|void buffer_free(buffer *b) {
   26|  3.40k|	if (NULL == b) return;
  ------------------
  |  Branch (26:6): [True: 0, False: 3.40k]
  ------------------
   27|  3.40k|	free(b->ptr);
   28|  3.40k|	free(b);
   29|  3.40k|}
buffer_string_prepare_copy:
   82|  1.30k|char* buffer_string_prepare_copy(buffer * const b, const size_t size) {
   83|  1.30k|    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.30k|    return (size < b->size)
  ------------------
  |  Branch (87:12): [True: 0, False: 1.30k]
  ------------------
   88|  1.30k|      ? b->ptr
   89|  1.30k|      : buffer_alloc_replace(b, size);
   90|  1.30k|}
buffer_extend:
  127|    142|{
  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|    142|    const uint32_t len = b->used ? b->used-1 : 0;
  ------------------
  |  Branch (136:26): [True: 142, False: 0]
  ------------------
  137|    142|    char * const s = (b->size - len >= x + 1)
  ------------------
  |  Branch (137:22): [True: 142, False: 0]
  ------------------
  138|    142|      ? b->ptr + len
  139|    142|      : buffer_string_prepare_append_resize(b, x);
  140|    142|    b->used = len+x+1;
  141|    142|  #endif
  142|    142|    s[x] = '\0';
  143|    142|    return s;
  144|    142|}
buffer_copy_string_len:
  172|  3.14k|void buffer_copy_string_len(buffer * const restrict b, const char * const restrict s, const size_t len) {
  173|  3.14k|    b->used = len + 1;
  174|  3.14k|    char * const restrict d = (len < b->size)
  ------------------
  |  Branch (174:31): [True: 960, False: 2.18k]
  ------------------
  175|  3.14k|      ? b->ptr
  176|  3.14k|      : buffer_alloc_replace(b, len);
  177|  3.14k|    d[len] = '\0';
  178|  3.14k|    memcpy(d, s, len);
  179|  3.14k|}
buffer_append_string_len:
  198|    142|void buffer_append_string_len(buffer * const restrict b, const char * const restrict s, const size_t len) {
  199|    142|    memcpy(buffer_extend(b, len), s, len);
  200|    142|}
hex2int:
  386|   100M|char hex2int(unsigned char hex) {
  387|   100M|	unsigned char n;
  388|   100M|	return li_cton(hex,n) ? (char)n : 0xFF;
  ------------------
  |  |  381|   100M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (381:4): [True: 89.6M, False: 11.1M]
  |  |  |  Branch (381:30): [True: 11.1M, False: 0]
  |  |  |  Branch (381:31): [True: 11.1M, False: 0]
  |  |  ------------------
  ------------------
  389|   100M|}
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.69k, False: 4]
  ------------------
  795|  1.70k|    if (NULL == src) return;
  ------------------
  |  Branch (795:9): [True: 377, False: 1.32k]
  ------------------
  796|       |
  797|  1.32k|    char *dst = src;
  798|  50.4M|    do {
  799|       |        /* *src == '%' */
  800|  50.4M|        unsigned char high = ((unsigned char *)src)[1];
  801|  50.4M|        unsigned char low = high ? hex2int(((unsigned char *)src)[2]) : 0xFF;
  ------------------
  |  Branch (801:29): [True: 50.4M, False: 0]
  ------------------
  802|  50.4M|        if (0xFF != (high = hex2int(high)) && 0xFF != low) {
  ------------------
  |  Branch (802:13): [True: 50.4M, False: 0]
  |  Branch (802:47): [True: 50.4M, False: 0]
  ------------------
  803|  50.4M|            high = (high << 4) | low;   /* map ctrls to '_' */
  804|  50.4M|            *dst = (high >= 32 && high != 127) ? high : '_';
  ------------------
  |  Branch (804:21): [True: 8.81M, False: 41.5M]
  |  Branch (804:35): [True: 7.44M, False: 1.37M]
  ------------------
  805|  50.4M|            src += 2;
  806|  50.4M|        } /* else ignore this '%'; leave as-is and move on */
  807|       |
  808|  52.9M|        while ((*++dst = *++src) != '%' && *src) ;
  ------------------
  |  Branch (808:16): [True: 2.49M, False: 50.4M]
  |  Branch (808:44): [True: 2.49M, False: 1.32k]
  ------------------
  809|  50.4M|    } while (*src);
  ------------------
  |  Branch (809:14): [True: 50.4M, False: 1.32k]
  ------------------
  810|  1.32k|    b->used = (dst - b->ptr) + 1;
  811|  1.32k|}
buffer_path_simplify:
  859|    372|{
  860|    372|    char *out = b->ptr;
  861|    372|    char * const end = b->ptr + b->used - 1;
  862|       |
  863|    372|    if (__builtin_expect( (buffer_is_blank(b)), 0)) {
  ------------------
  |  Branch (863:9): [True: 0, False: 372]
  ------------------
  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|    372|    *end = '/'; /*(end of path modified to avoid need to check '\0')*/
  876|       |
  877|    372|    char *walk = out;
  878|    372|    if (__builtin_expect( (*walk == '/'), 1)) {
  ------------------
  |  Branch (878:9): [True: 141, False: 231]
  ------------------
  879|       |        /* scan to detect (potential) need for path simplification
  880|       |         * (repeated '/' or "/.") */
  881|    504|        do {
  882|    504|            if (*++walk == '.' || *walk == '/')
  ------------------
  |  Branch (882:17): [True: 75, False: 429]
  |  Branch (882:35): [True: 66, False: 363]
  ------------------
  883|    141|                break;
  884|  29.0k|            do { ++walk; } while (*walk != '/');
  ------------------
  |  Branch (884:35): [True: 28.6k, False: 363]
  ------------------
  885|    363|        } while (walk != end);
  ------------------
  |  Branch (885:18): [True: 363, False: 0]
  ------------------
  886|    141|        if (__builtin_expect( (walk == end), 1)) {
  ------------------
  |  Branch (886:13): [True: 0, False: 141]
  ------------------
  887|       |            /* common case: no repeated '/' or "/." */
  888|      0|            *end = '\0'; /* overwrite extra '/' added to end of path */
  889|      0|            return;
  890|      0|        }
  891|    141|        out = walk-1;
  892|    141|    }
  893|    231|    else {
  894|    231|        if (walk[0] == '.' && walk[1] == '/')
  ------------------
  |  Branch (894:13): [True: 111, False: 120]
  |  Branch (894:31): [True: 73, False: 38]
  ------------------
  895|     73|            *out = *++walk;
  896|    158|        else if (walk[0] == '.' && walk[1] == '.' && walk[2] == '/')
  ------------------
  |  Branch (896:18): [True: 38, False: 120]
  |  Branch (896:36): [True: 16, False: 22]
  |  Branch (896:54): [True: 2, False: 14]
  ------------------
  897|      2|            *out = *(walk += 2);
  898|    156|        else {
  899|  6.19M|            while (*++walk != '/') ;
  ------------------
  |  Branch (899:20): [True: 6.19M, False: 156]
  ------------------
  900|    156|            out = walk;
  901|    156|        }
  902|    231|        ++walk;
  903|    231|    }
  904|       |
  905|  10.2k|    while (walk <= end) {
  ------------------
  |  Branch (905:12): [True: 10.0k, False: 194]
  ------------------
  906|       |        /* previous char is '/' at this point (or start of string w/o '/') */
  907|  10.0k|        if (__builtin_expect( (walk[0] == '/'), 0)) {
  ------------------
  |  Branch (907:13): [True: 1.25k, False: 8.83k]
  ------------------
  908|       |            /* skip repeated '/' (e.g. "///" -> "/") */
  909|  1.25k|            if (++walk < end)
  ------------------
  |  Branch (909:17): [True: 1.19k, False: 63]
  ------------------
  910|  1.19k|                continue;
  911|     63|            else {
  912|     63|                ++out;
  913|     63|                break;
  914|     63|            }
  915|  1.25k|        }
  916|  8.83k|        else if (__builtin_expect( (walk[0] == '.'), 0)) {
  ------------------
  |  Branch (916:18): [True: 6.13k, False: 2.70k]
  ------------------
  917|       |            /* handle "./" and "../" */
  918|  6.13k|            if (walk[1] == '.' && walk[2] == '/') {
  ------------------
  |  Branch (918:17): [True: 2.21k, False: 3.92k]
  |  Branch (918:35): [True: 722, False: 1.49k]
  ------------------
  919|       |                /* handle "../" */
  920|  2.12M|                while (out > b->ptr && *--out != '/') ;
  ------------------
  |  Branch (920:24): [True: 2.12M, False: 500]
  |  Branch (920:40): [True: 2.12M, False: 222]
  ------------------
  921|    722|                *out = '/'; /*(in case path had not started with '/')*/
  922|    722|                if ((walk += 3) >= end) {
  ------------------
  |  Branch (922:21): [True: 54, False: 668]
  ------------------
  923|     54|                    ++out;
  924|     54|                    break;
  925|     54|                }
  926|    668|                else
  927|    668|                    continue;
  928|    722|            }
  929|  5.41k|            else if (walk[1] == '/') {
  ------------------
  |  Branch (929:22): [True: 565, False: 4.85k]
  ------------------
  930|       |                /* handle "./" */
  931|    565|                if ((walk += 2) >= end) {
  ------------------
  |  Branch (931:21): [True: 61, False: 504]
  ------------------
  932|     61|                    ++out;
  933|     61|                    break;
  934|     61|                }
  935|    504|                continue;
  936|    565|            }
  937|  4.85k|            else {
  938|       |                /* accept "." if not part of "../" or "./" */
  939|  4.85k|                *++out = '.';
  940|  4.85k|                ++walk;
  941|  4.85k|            }
  942|  6.13k|        }
  943|       |
  944|  15.1M|        while ((*++out = *walk++) != '/') ;
  ------------------
  |  Branch (944:16): [True: 15.1M, False: 7.55k]
  ------------------
  945|  7.55k|    }
  946|    372|    *out = *end = '\0'; /* overwrite extra '/' added to end of path */
  947|    372|    b->used = (out - b->ptr) + 1;
  948|       |    /*buffer_truncate(b, out - b->ptr);*/
  949|    372|}
buffer.c:buffer_alloc_replace:
   71|  3.48k|static char* buffer_alloc_replace(buffer * const restrict b, const size_t size) {
   72|       |    /*(discard old data so realloc() does not copy)*/
   73|  3.48k|    if (NULL != b->ptr) {
  ------------------
  |  Branch (73:9): [True: 474, False: 3.01k]
  ------------------
   74|    474|        free(b->ptr);
   75|    474|        b->ptr = NULL;
   76|    474|    }
   77|       |    /*(note: if size larger than one lshift, use size instead of power-2)*/
   78|  3.48k|    const size_t bsize2x = (b->size & ~1uL) << 1;
   79|  3.48k|    return buffer_realloc(b, bsize2x > size ? bsize2x-1 : size);
  ------------------
  |  Branch (79:30): [True: 243, False: 3.24k]
  ------------------
   80|  3.48k|}
buffer.c:buffer_realloc:
   49|  3.48k|static char* buffer_realloc(buffer * const restrict b, const size_t len) {
   50|  3.48k|    #define BUFFER_PIECE_SIZE 64uL  /*(must be power-of-2)*/
   51|  3.48k|    size_t sz = (len + 1 + BUFFER_PIECE_SIZE-1) & ~(BUFFER_PIECE_SIZE-1);
  ------------------
  |  |   50|  3.48k|    #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.48k|    #define BUFFER_PIECE_SIZE 64uL  /*(must be power-of-2)*/
  ------------------
   52|  3.48k|    force_assert(sz > len);
  ------------------
  |  |  448|  3.48k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.48k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.48k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.48k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   53|  3.48k|    if ((sz & (sz-1)) && sz < INT_MAX) {/* not power-2; huge val not expected */
  ------------------
  |  Branch (53:9): [True: 1.14k, False: 2.34k]
  |  Branch (53:26): [True: 1.14k, False: 0]
  ------------------
   54|       |        /*(optimizer should recognize this and use ffs or clz or equivalent)*/
   55|  1.14k|        const size_t psz = sz;
   56|  7.77k|        for (sz = 256; sz < psz; sz <<= 1) ;
  ------------------
  |  Branch (56:24): [True: 6.63k, False: 1.14k]
  ------------------
   57|  1.14k|    }
   58|  3.48k|    sz |= 1; /*(extra +1 for '\0' when needed buffer size is exact power-2)*/
   59|       |
   60|  3.48k|    b->size = sz;
   61|  3.48k|    b->ptr = realloc(b->ptr, sz);
   62|       |
   63|  3.48k|    force_assert(NULL != b->ptr);
  ------------------
  |  |  448|  3.48k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.48k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.48k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.48k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   64|  3.48k|    return b->ptr;
   65|  3.48k|}

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

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: 884, False: 819]
  ------------------
  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: 488, False: 1.21k]
  ------------------
  368|    488|        if (flags & HTTP_PARSEOPT_URL_NORMALIZE_INVALID_UTF8_REJECT) return -2;
  ------------------
  |  Branch (368:13): [True: 119, False: 369]
  ------------------
  369|    369|        qs = burl_scan_qmark(b);
  370|    369|    }
  371|       |
  372|  1.58k|    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_CTRLS_REJECT) {
  ------------------
  |  Branch (372:9): [True: 336, False: 1.24k]
  ------------------
  373|    336|        if (burl_contains_ctrls(b)) return -2;
  ------------------
  |  Branch (373:13): [True: 91, False: 245]
  ------------------
  374|    336|    }
  375|       |
  376|  1.49k|    if (flags & (HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_DECODE
  ------------------
  |  Branch (376:9): [True: 1.24k, False: 247]
  ------------------
  377|  1.49k|                |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: 29, False: 1.21k]
  ------------------
  380|  1.24k|    }
  381|       |
  382|  1.46k|    if (flags & (HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REMOVE
  ------------------
  |  Branch (382:9): [True: 1.17k, False: 287]
  ------------------
  383|  1.46k|                |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.16k]
  ------------------
  386|  1.17k|    }
  387|       |
  388|  1.45k|    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_QUERY_20_PLUS) {
  ------------------
  |  Branch (388:9): [True: 845, False: 608]
  ------------------
  389|    845|        if (qs >= 0) burl_normalize_qs20_to_plus(b, qs);
  ------------------
  |  Branch (389:13): [True: 411, False: 434]
  ------------------
  390|    845|    }
  391|       |
  392|  1.45k|    return qs;
  393|  1.46k|}
burl.c:burl_normalize_basic_required:
  179|    884|{
  180|    884|    const unsigned char * const s = (unsigned char *)b->ptr;
  181|    884|    const int used = (int)buffer_clen(b);
  182|    884|    unsigned int n1, n2, x;
  183|    884|    int qs = -1;
  184|    884|    int invalid_utf8 = 0;
  185|       |
  186|   334k|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (186:21): [True: 334k, False: 223]
  ------------------
  187|   334k|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (187:13): [True: 324k, False: 10.3k]
  ------------------
  188|   324k|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = i;
  ------------------
  |  Branch (188:17): [True: 5.42k, False: 318k]
  |  Branch (188:56): [True: 227, False: 5.19k]
  ------------------
  189|   324k|        }
  190|  10.3k|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  20.1k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 8.48k, False: 1.37k]
  |  |  |  Branch (43:30): [True: 1.29k, False: 73]
  |  |  |  Branch (43:31): [True: 1.29k, False: 73]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  20.1k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 4.07k, False: 5.71k]
  |  |  |  Branch (43:30): [True: 5.66k, False: 53]
  |  |  |  Branch (43:31): [True: 5.66k, False: 53]
  |  |  ------------------
  ------------------
  |  Branch (190:18): [True: 9.85k, False: 459]
  ------------------
  191|  9.73k|                 && (encoded_chars_http_uri_reqd[(x = (n1 << 4) | n2)]
  ------------------
  |  Branch (191:22): [True: 2.19k, False: 7.54k]
  ------------------
  192|  7.54k|                     || (qs < 0
  ------------------
  |  Branch (192:25): [True: 7.46k, False: 76]
  |  Branch (192:26): [True: 578, False: 6.96k]
  ------------------
  193|  7.54k|                         ? (x == '/' || x == '?')
  ------------------
  |  Branch (193:29): [True: 296, False: 282]
  |  Branch (193:41): [True: 250, False: 32]
  ------------------
  194|  9.65k|                         : (x == '&' || x == '=' || x == ';' || x == '+')))) {
  ------------------
  |  Branch (194:29): [True: 2.75k, False: 4.21k]
  |  Branch (194:41): [True: 1.51k, False: 2.69k]
  |  Branch (194:53): [True: 1.82k, False: 872]
  |  Branch (194:65): [True: 828, False: 44]
  ------------------
  195|  9.65k|            invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  9.65k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  9.65k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 237, False: 9.42k]
  |  |  |  |  ------------------
  |  |  |  |  261|  9.65k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 263, False: 9.15k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|  9.65k|            if (s[i+1] >= 'a') b->ptr[i+1] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (196:17): [True: 637, False: 9.02k]
  ------------------
  197|  9.65k|            if (s[i+2] >= 'a') b->ptr[i+2] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (197:17): [True: 3.08k, False: 6.57k]
  ------------------
  198|  9.65k|            i+=2;
  199|  9.65k|        }
  200|    661|        else if (s[i] == '#') { /* ignore fragment */
  ------------------
  |  Branch (200:18): [True: 1, False: 660]
  ------------------
  201|      1|            buffer_truncate(b, (size_t)i);
  202|      1|            break;
  203|      1|        }
  204|    660|        else {
  205|    660|            qs = burl_normalize_basic_required_fix(b, t, i, qs);
  206|    660|            break;
  207|    660|        }
  208|   334k|    }
  209|       |
  210|    884|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (210:12): [True: 856, False: 28]
  ------------------
  211|    884|}
burl.c:burl_normalize_basic_required_fix:
  135|    660|{
  136|    660|    int j = i;
  137|    660|    const int used = (int)buffer_clen(b);
  138|    660|    const unsigned char * const s = (unsigned char *)b->ptr;
  139|    660|    unsigned char * const p =
  140|    660|      (unsigned char *)buffer_string_prepare_copy(t,i+(used-i)*3+1);
  141|    660|    unsigned int n1, n2;
  142|    660|    int invalid_utf8 = 0;
  143|    660|    memcpy(p, s, (size_t)i);
  144|  23.7M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (144:12): [True: 23.7M, False: 652]
  ------------------
  145|  23.7M|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (145:13): [True: 630k, False: 23.1M]
  ------------------
  146|   630k|            p[j] = s[i];
  147|   630k|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = j;
  ------------------
  |  Branch (147:17): [True: 17.1k, False: 613k]
  |  Branch (147:56): [True: 150, False: 16.9k]
  ------------------
  148|   630k|        }
  149|  23.1M|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  23.1M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 28.2k, False: 10.8k]
  |  |  |  Branch (43:30): [True: 3.86k, False: 7.02k]
  |  |  |  Branch (43:31): [True: 3.86k, False: 7.02k]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  32.1k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 15.6k, False: 16.4k]
  |  |  |  Branch (43:30): [True: 13.2k, False: 3.20k]
  |  |  |  Branch (43:31): [True: 13.2k, False: 3.20k]
  |  |  ------------------
  ------------------
  |  Branch (149:18): [True: 39.1k, False: 23.1M]
  ------------------
  150|  28.9k|            const unsigned int x = (n1 << 4) | n2;
  151|  28.9k|            if (!encoded_chars_http_uri_reqd[x]
  ------------------
  |  Branch (151:17): [True: 23.0k, False: 5.94k]
  ------------------
  152|  23.0k|                && (qs < 0
  ------------------
  |  Branch (152:20): [True: 3.68k, False: 19.3k]
  |  Branch (152:21): [True: 2.35k, False: 20.6k]
  ------------------
  153|  23.0k|                    ? (x != '/' && x != '?')
  ------------------
  |  Branch (153:24): [True: 1.52k, False: 834]
  |  Branch (153:36): [True: 1.12k, False: 401]
  ------------------
  154|  23.0k|                    : (x != '&' && x != '=' && x != ';' && x != '+'))) {
  ------------------
  |  Branch (154:24): [True: 10.1k, False: 10.4k]
  |  Branch (154:36): [True: 6.45k, False: 3.71k]
  |  Branch (154:48): [True: 4.90k, False: 1.55k]
  |  Branch (154:60): [True: 2.56k, False: 2.34k]
  ------------------
  155|  3.68k|                p[j] = x;
  156|  3.68k|            }
  157|  25.2k|            else {
  158|  25.2k|                p[j]   = '%';
  159|  25.2k|                p[++j] = hex_chars_uc[n1]; /*(s[i+1] & 0xdf)*/
  160|  25.2k|                p[++j] = hex_chars_uc[n2]; /*(s[i+2] & 0xdf)*/
  161|  25.2k|                invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  25.2k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  25.2k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 1.18k, False: 24.0k]
  |  |  |  |  ------------------
  |  |  |  |  261|  25.2k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 137, False: 23.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  162|  25.2k|            }
  163|  28.9k|            i+=2;
  164|  28.9k|        }
  165|  23.1M|        else if (s[i] == '#') break; /* ignore fragment */
  ------------------
  |  Branch (165:18): [True: 8, False: 23.1M]
  ------------------
  166|  23.1M|        else {
  167|  23.1M|            p[j]   = '%';
  168|  23.1M|            p[++j] = hex_chars_uc[(s[i] >> 4) & 0xF];
  169|  23.1M|            p[++j] = hex_chars_uc[s[i] & 0xF];
  170|  23.1M|            invalid_utf8 |= li_utf8_invalid_byte(s[i]);
  ------------------
  |  |   49|  23.1M|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  23.1M|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 1.44M, False: 21.6M]
  |  |  |  |  ------------------
  |  |  |  |  261|  23.1M|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 636, False: 21.6M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  171|  23.1M|        }
  172|  23.7M|    }
  173|    660|    buffer_copy_string_len(b, (char *)p, (size_t)j);
  174|    660|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (174:12): [True: 423, False: 237]
  ------------------
  175|    660|}
burl.c:burl_normalize_basic_unreserved:
  101|    819|{
  102|    819|    const unsigned char * const s = (unsigned char *)b->ptr;
  103|    819|    const int used = (int)buffer_clen(b);
  104|    819|    unsigned int n1, n2, x;
  105|    819|    int qs = -1;
  106|    819|    int invalid_utf8 = 0;
  107|       |
  108|   741k|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (108:21): [True: 741k, False: 177]
  ------------------
  109|   741k|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (109:13): [True: 736k, False: 5.06k]
  ------------------
  110|   736k|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = i;
  ------------------
  |  Branch (110:17): [True: 1.17k, False: 735k]
  |  Branch (110:56): [True: 85, False: 1.08k]
  ------------------
  111|   736k|        }
  112|  5.06k|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  9.67k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 3.29k, False: 1.31k]
  |  |  |  Branch (43:30): [True: 1.24k, False: 71]
  |  |  |  Branch (43:31): [True: 1.24k, False: 71]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  9.60k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 1.13k, False: 3.40k]
  |  |  |  Branch (43:30): [True: 3.34k, False: 61]
  |  |  |  Branch (43:31): [True: 3.34k, False: 61]
  |  |  ------------------
  ------------------
  |  Branch (112:18): [True: 4.60k, False: 458]
  ------------------
  113|  4.47k|                 && !burl_is_unreserved((x = (n1 << 4) | n2))) {
  ------------------
  |  Branch (113:21): [True: 4.42k, False: 52]
  ------------------
  114|  4.42k|            invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  4.42k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  4.42k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 519, False: 3.90k]
  |  |  |  |  ------------------
  |  |  |  |  261|  4.42k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 388, False: 3.51k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  115|  4.42k|            if (s[i+1] >= 'a') b->ptr[i+1] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (115:17): [True: 954, False: 3.47k]
  ------------------
  116|  4.42k|            if (s[i+2] >= 'a') b->ptr[i+2] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (116:17): [True: 2.39k, False: 2.03k]
  ------------------
  117|  4.42k|            i+=2;
  118|  4.42k|        }
  119|    642|        else if (s[i] == '#') { /* ignore fragment */
  ------------------
  |  Branch (119:18): [True: 1, False: 641]
  ------------------
  120|      1|            buffer_truncate(b, (size_t)i);
  121|      1|            break;
  122|      1|        }
  123|    641|        else {
  124|    641|            qs = burl_normalize_basic_unreserved_fix(b, t, i, qs);
  125|    641|            break;
  126|    641|        }
  127|   741k|    }
  128|       |
  129|    819|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (129:12): [True: 788, False: 31]
  ------------------
  130|    819|}
burl.c:burl_is_unreserved:
   53|  28.0k|{
   54|  28.0k|    return (light_isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~');
  ------------------
  |  Branch (54:13): [True: 574, False: 27.5k]
  |  Branch (54:33): [True: 700, False: 26.8k]
  |  Branch (54:45): [True: 252, False: 26.5k]
  |  Branch (54:57): [True: 534, False: 26.0k]
  |  Branch (54:69): [True: 41, False: 25.9k]
  ------------------
   55|  28.0k|}
burl.c:burl_normalize_basic_unreserved_fix:
   60|    641|{
   61|    641|    int j = i;
   62|    641|    const int used = (int)buffer_clen(b);
   63|    641|    const unsigned char * const s = (unsigned char *)b->ptr;
   64|    641|    unsigned char * const p =
   65|    641|      (unsigned char *)buffer_string_prepare_copy(t,i+(used-i)*3+1);
   66|    641|    unsigned int n1, n2;
   67|    641|    int invalid_utf8 = 0;
   68|    641|    memcpy(p, s, (size_t)i);
   69|  29.0M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (69:12): [True: 29.0M, False: 637]
  ------------------
   70|  29.0M|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (70:13): [True: 1.05M, False: 27.9M]
  ------------------
   71|  1.05M|            p[j] = s[i];
   72|  1.05M|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = j;
  ------------------
  |  Branch (72:17): [True: 12.5k, False: 1.04M]
  |  Branch (72:56): [True: 154, False: 12.3k]
  ------------------
   73|  1.05M|        }
   74|  27.9M|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  27.9M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 21.0k, False: 7.91k]
  |  |  |  Branch (43:30): [True: 4.76k, False: 3.15k]
  |  |  |  Branch (43:31): [True: 4.76k, False: 3.15k]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  25.7k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 11.0k, False: 14.6k]
  |  |  |  Branch (43:30): [True: 12.5k, False: 2.17k]
  |  |  |  Branch (43:31): [True: 12.5k, False: 2.17k]
  |  |  ------------------
  ------------------
  |  Branch (74:18): [True: 28.9k, False: 27.9M]
  ------------------
   75|  23.6k|            const unsigned int x = (n1 << 4) | n2;
   76|  23.6k|            if (burl_is_unreserved(x)) {
  ------------------
  |  Branch (76:17): [True: 2.04k, False: 21.5k]
  ------------------
   77|  2.04k|                p[j] = x;
   78|  2.04k|            }
   79|  21.5k|            else {
   80|  21.5k|                p[j]   = '%';
   81|  21.5k|                p[++j] = hex_chars_uc[n1]; /*(s[i+1] & 0xdf)*/
   82|  21.5k|                p[++j] = hex_chars_uc[n2]; /*(s[i+2] & 0xdf)*/
   83|  21.5k|                invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  21.5k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  21.5k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 2.76k, False: 18.7k]
  |  |  |  |  ------------------
  |  |  |  |  261|  21.5k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 37, False: 18.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   84|  21.5k|            }
   85|  23.6k|            i+=2;
   86|  23.6k|        }
   87|  27.9M|        else if (s[i] == '#') break; /* ignore fragment */
  ------------------
  |  Branch (87:18): [True: 4, False: 27.9M]
  ------------------
   88|  27.9M|        else {
   89|  27.9M|            p[j]   = '%';
   90|  27.9M|            p[++j] = hex_chars_uc[(s[i] >> 4) & 0xF];
   91|  27.9M|            p[++j] = hex_chars_uc[s[i] & 0xF];
   92|  27.9M|            invalid_utf8 |= li_utf8_invalid_byte(s[i]);
  ------------------
  |  |   49|  27.9M|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  27.9M|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 355k, False: 27.5M]
  |  |  |  |  ------------------
  |  |  |  |  261|  27.9M|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 2.98k, False: 27.5M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   93|  27.9M|        }
   94|  29.0M|    }
   95|    641|    buffer_copy_string_len(b, (char *)p, (size_t)j);
   96|    641|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (96:12): [True: 443, False: 198]
  ------------------
   97|    641|}
burl.c:burl_scan_qmark:
  337|    369|static int burl_scan_qmark (const buffer * const b) {
  338|    369|    const char * const qmark = strchr(b->ptr, '?');
  339|    369|    return qmark ? (int)(qmark - b->ptr) : -1;
  ------------------
  |  Branch (339:12): [True: 181, False: 188]
  ------------------
  340|    369|}
burl.c:burl_contains_ctrls:
  215|    336|{
  216|    336|    const char * const s = b->ptr;
  217|    336|    const int used = (int)buffer_clen(b);
  218|  8.15M|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (218:21): [True: 8.15M, False: 245]
  ------------------
  219|  8.15M|        if (s[i] == '%' && (s[i+1] < '2' || (s[i+1] == '7' && s[i+2] == 'F')))
  ------------------
  |  Branch (219:13): [True: 2.46M, False: 5.68M]
  |  Branch (219:29): [True: 88, False: 2.46M]
  |  Branch (219:46): [True: 295, False: 2.46M]
  |  Branch (219:63): [True: 3, False: 292]
  ------------------
  220|     91|            return 1;
  221|  8.15M|    }
  222|    245|    return 0;
  223|    336|}
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: 762, False: 484]
  ------------------
  286|  71.2M|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (286:21): [True: 71.2M, False: 1.07k]
  ------------------
  287|  71.2M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == 'F') {
  ------------------
  |  Branch (287:13): [True: 23.6M, False: 47.5M]
  |  Branch (287:28): [True: 4.12k, False: 23.6M]
  |  Branch (287:45): [True: 167, False: 3.95k]
  ------------------
  288|    167|            return !(flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)
  ------------------
  |  Branch (288:20): [True: 138, False: 29]
  ------------------
  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|  71.2M|    }
  293|  1.07k|    return qs;
  294|  1.24k|}
burl.c:burl_normalize_2F_to_slash_fix:
  258|    138|{
  259|    138|    char * const s = b->ptr;
  260|    138|    const int blen = (int)buffer_clen(b);
  261|    138|    const int used = qs < 0 ? blen : qs;
  ------------------
  |  Branch (261:22): [True: 83, False: 55]
  ------------------
  262|    138|    int j = i;
  263|  7.47M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (263:12): [True: 7.47M, False: 138]
  ------------------
  264|  7.47M|        s[j] = s[i];
  265|  7.47M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == 'F') {
  ------------------
  |  Branch (265:13): [True: 2.48M, False: 4.98M]
  |  Branch (265:28): [True: 6.50k, False: 2.48M]
  |  Branch (265:45): [True: 786, False: 5.71k]
  ------------------
  266|    786|            s[j] = '/';
  267|    786|            i+=2;
  268|    786|        }
  269|  7.47M|    }
  270|    138|    if (qs >= 0) {
  ------------------
  |  Branch (270:9): [True: 55, False: 83]
  ------------------
  271|     55|        const int qslen = blen - qs;
  272|     55|        memmove(s+j, s+qs, (size_t)qslen);
  273|     55|        qs = j;
  274|     55|        j += qslen;
  275|     55|    }
  276|    138|    buffer_truncate(b, j);
  277|    138|    return qs;
  278|    138|}
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.28k|    for (int i = 0, len = qs < 0 ? used : qs; i < len; ++i) {
  ------------------
  |  Branch (302:27): [True: 730, False: 447]
  |  Branch (302:47): [True: 3.49k, False: 794]
  ------------------
  303|  3.49k|        if (s[i] == '.' && (s[i+1] != '.' || ++i)
  ------------------
  |  Branch (303:13): [True: 1.54k, False: 1.95k]
  |  Branch (303:29): [True: 783, False: 758]
  |  Branch (303:46): [True: 758, False: 0]
  ------------------
  304|  1.54k|            && (s[i+1] == '/' || s[i+1] == '?' || s[i+1] == '\0')) {
  ------------------
  |  Branch (304:17): [True: 80, False: 1.46k]
  |  Branch (304:34): [True: 68, False: 1.39k]
  |  Branch (304:51): [True: 76, False: 1.31k]
  ------------------
  305|    224|            path_simplify = 1;
  306|    224|            break;
  307|    224|        }
  308|  70.2M|        while (i < len && s[i] != '/') ++i;
  ------------------
  |  Branch (308:16): [True: 70.2M, False: 644]
  |  Branch (308:27): [True: 70.2M, False: 2.62k]
  ------------------
  309|  3.26k|        if (s[i] == '/' && s[i+1] == '/') { /*(s[len] != '/')*/
  ------------------
  |  Branch (309:13): [True: 2.62k, False: 644]
  |  Branch (309:28): [True: 159, False: 2.46k]
  ------------------
  310|    159|            path_simplify = 1;
  311|    159|            break;
  312|    159|        }
  313|  3.26k|    }
  314|       |
  315|  1.17k|    if (path_simplify) {
  ------------------
  |  Branch (315:9): [True: 383, False: 794]
  ------------------
  316|    383|        if (flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT) return -2;
  ------------------
  |  Branch (316:13): [True: 11, False: 372]
  ------------------
  317|    372|        if (qs >= 0) {
  ------------------
  |  Branch (317:13): [True: 142, False: 230]
  ------------------
  318|    142|            buffer_copy_string_len(t, b->ptr+qs, used - qs);
  319|    142|            buffer_truncate(b, qs);
  320|    142|        }
  321|       |
  322|    372|        buffer_path_simplify(b);
  323|       |
  324|    372|        if (qs >= 0) {
  ------------------
  |  Branch (324:13): [True: 142, False: 230]
  ------------------
  325|    142|            qs = (int)buffer_clen(b);
  326|    142|            buffer_append_string_len(b, BUF_PTR_LEN(t));
  ------------------
  |  |  297|    142|#define BUF_PTR_LEN(x)       (x)->ptr, buffer_clen(x)
  ------------------
  327|    142|        }
  328|    372|    }
  329|       |
  330|  1.16k|    return qs;
  331|  1.17k|}
burl.c:burl_normalize_qs20_to_plus:
  244|    411|{
  245|    411|    const char * const s = b->ptr;
  246|    411|    const int used = qs < 0 ? 0 : (int)buffer_clen(b);
  ------------------
  |  Branch (246:22): [True: 0, False: 411]
  ------------------
  247|    411|    int i;
  248|    411|    if (qs < 0) return;
  ------------------
  |  Branch (248:9): [True: 0, False: 411]
  ------------------
  249|  4.19M|    for (i = qs+1; i < used; ++i) {
  ------------------
  |  Branch (249:20): [True: 4.19M, False: 285]
  ------------------
  250|  4.19M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == '0') break;
  ------------------
  |  Branch (250:13): [True: 1.34M, False: 2.84M]
  |  Branch (250:28): [True: 14.2k, False: 1.33M]
  |  Branch (250:45): [True: 126, False: 14.1k]
  ------------------
  251|  4.19M|    }
  252|    411|    if (i != used) burl_normalize_qs20_to_plus_fix(b, i);
  ------------------
  |  Branch (252:9): [True: 126, False: 285]
  ------------------
  253|    411|}
burl.c:burl_normalize_qs20_to_plus_fix:
  228|    126|{
  229|    126|    char * const s = b->ptr;
  230|    126|    const int used = (int)buffer_clen(b);
  231|    126|    int j = i;
  232|  10.0M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (232:12): [True: 10.0M, False: 126]
  ------------------
  233|  10.0M|        s[j] = s[i];
  234|  10.0M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == '0') {
  ------------------
  |  Branch (234:13): [True: 3.31M, False: 6.68M]
  |  Branch (234:28): [True: 8.55k, False: 3.30M]
  |  Branch (234:45): [True: 2.26k, False: 6.29k]
  ------------------
  235|  2.26k|            s[j] = '+';
  236|  2.26k|            i+=2;
  237|  2.26k|        }
  238|  10.0M|    }
  239|    126|    buffer_truncate(b, j);
  240|    126|}

