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

buffer_init:
   14|  3.46k|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.46k|	buffer * const b = calloc(1, sizeof(*b));
   20|  3.46k|	force_assert(b);
  ------------------
  |  |  448|  3.46k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.46k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.46k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.46k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   21|  3.46k|	return b;
   22|  3.46k|  #endif
   23|  3.46k|}
buffer_free:
   25|  3.46k|void buffer_free(buffer *b) {
   26|  3.46k|	if (NULL == b) return;
  ------------------
  |  Branch (26:6): [True: 0, False: 3.46k]
  ------------------
   27|  3.46k|	free(b->ptr);
   28|  3.46k|	free(b);
   29|  3.46k|}
buffer_string_prepare_copy:
   82|  1.33k|char* buffer_string_prepare_copy(buffer * const b, const size_t size) {
   83|  1.33k|    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.33k|    return (size < b->size)
  ------------------
  |  Branch (87:12): [True: 0, False: 1.33k]
  ------------------
   88|  1.33k|      ? b->ptr
   89|  1.33k|      : buffer_alloc_replace(b, size);
   90|  1.33k|}
buffer_extend:
  127|    135|{
  128|       |    /* extend buffer to append x (reallocate by power-2 (or larger), if needed)
  129|       |     * (combine buffer_string_prepare_append() and buffer_commit())
  130|       |     * (future: might make buffer.h static inline func for HTTP/1.1 performance)
  131|       |     * pre-sets '\0' byte and b->used (unlike buffer_string_prepare_append())*/
  132|       |  #if 0
  133|       |    char * const s = buffer_string_prepare_append(b, x);
  134|       |    b->used += x + (0 == b->used);
  135|       |  #else
  136|    135|    const uint32_t len = b->used ? b->used-1 : 0;
  ------------------
  |  Branch (136:26): [True: 135, False: 0]
  ------------------
  137|    135|    char * const s = (b->size - len >= x + 1)
  ------------------
  |  Branch (137:22): [True: 135, False: 0]
  ------------------
  138|    135|      ? b->ptr + len
  139|    135|      : buffer_string_prepare_append_resize(b, x);
  140|    135|    b->used = len+x+1;
  141|    135|  #endif
  142|    135|    s[x] = '\0';
  143|    135|    return s;
  144|    135|}
buffer_copy_string_len:
  172|  3.20k|void buffer_copy_string_len(buffer * const restrict b, const char * const restrict s, const size_t len) {
  173|  3.20k|    b->used = len + 1;
  174|  3.20k|    char * const restrict d = (len < b->size)
  ------------------
  |  Branch (174:31): [True: 956, False: 2.24k]
  ------------------
  175|  3.20k|      ? b->ptr
  176|  3.20k|      : buffer_alloc_replace(b, len);
  177|  3.20k|    d[len] = '\0';
  178|  3.20k|    memcpy(d, s, len);
  179|  3.20k|}
buffer_append_string_len:
  198|    135|void buffer_append_string_len(buffer * const restrict b, const char * const restrict s, const size_t len) {
  199|    135|    memcpy(buffer_extend(b, len), s, len);
  200|    135|}
hex2int:
  386|   106M|char hex2int(unsigned char hex) {
  387|   106M|	unsigned char n;
  388|   106M|	return li_cton(hex,n) ? (char)n : 0xFF;
  ------------------
  |  |  381|   106M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (381:4): [True: 92.2M, False: 13.8M]
  |  |  |  Branch (381:30): [True: 13.8M, False: 0]
  |  |  |  Branch (381:31): [True: 13.8M, False: 0]
  |  |  ------------------
  ------------------
  389|   106M|}
buffer_urldecode_path:
  792|  1.73k|void buffer_urldecode_path(buffer * const b) {
  793|  1.73k|    const size_t len = buffer_clen(b);
  794|  1.73k|    char *src = len ? memchr(b->ptr, '%', len) : NULL;
  ------------------
  |  Branch (794:17): [True: 1.72k, False: 5]
  ------------------
  795|  1.73k|    if (NULL == src) return;
  ------------------
  |  Branch (795:9): [True: 363, False: 1.36k]
  ------------------
  796|       |
  797|  1.36k|    char *dst = src;
  798|  53.0M|    do {
  799|       |        /* *src == '%' */
  800|  53.0M|        unsigned char high = ((unsigned char *)src)[1];
  801|  53.0M|        unsigned char low = high ? hex2int(((unsigned char *)src)[2]) : 0xFF;
  ------------------
  |  Branch (801:29): [True: 53.0M, False: 0]
  ------------------
  802|  53.0M|        if (0xFF != (high = hex2int(high)) && 0xFF != low) {
  ------------------
  |  Branch (802:13): [True: 53.0M, False: 0]
  |  Branch (802:47): [True: 53.0M, False: 0]
  ------------------
  803|  53.0M|            high = (high << 4) | low;   /* map ctrls to '_' */
  804|  53.0M|            *dst = (high >= 32 && high != 127) ? high : '_';
  ------------------
  |  Branch (804:21): [True: 10.9M, False: 42.1M]
  |  Branch (804:35): [True: 9.95M, False: 990k]
  ------------------
  805|  53.0M|            src += 2;
  806|  53.0M|        } /* else ignore this '%'; leave as-is and move on */
  807|       |
  808|  58.1M|        while ((*++dst = *++src) != '%' && *src) ;
  ------------------
  |  Branch (808:16): [True: 5.13M, False: 53.0M]
  |  Branch (808:44): [True: 5.12M, False: 1.36k]
  ------------------
  809|  53.0M|    } while (*src);
  ------------------
  |  Branch (809:14): [True: 53.0M, False: 1.36k]
  ------------------
  810|  1.36k|    b->used = (dst - b->ptr) + 1;
  811|  1.36k|}
buffer_path_simplify:
  859|    375|{
  860|    375|    char *out = b->ptr;
  861|    375|    char * const end = b->ptr + b->used - 1;
  862|       |
  863|    375|    if (__builtin_expect( (buffer_is_blank(b)), 0)) {
  ------------------
  |  Branch (863:9): [True: 0, False: 375]
  ------------------
  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|    375|    *end = '/'; /*(end of path modified to avoid need to check '\0')*/
  876|       |
  877|    375|    char *walk = out;
  878|    375|    if (__builtin_expect( (*walk == '/'), 1)) {
  ------------------
  |  Branch (878:9): [True: 133, False: 242]
  ------------------
  879|       |        /* scan to detect (potential) need for path simplification
  880|       |         * (repeated '/' or "/.") */
  881|    521|        do {
  882|    521|            if (*++walk == '.' || *walk == '/')
  ------------------
  |  Branch (882:17): [True: 75, False: 446]
  |  Branch (882:35): [True: 58, False: 388]
  ------------------
  883|    133|                break;
  884|   713k|            do { ++walk; } while (*walk != '/');
  ------------------
  |  Branch (884:35): [True: 712k, False: 388]
  ------------------
  885|    388|        } while (walk != end);
  ------------------
  |  Branch (885:18): [True: 388, False: 0]
  ------------------
  886|    133|        if (__builtin_expect( (walk == end), 1)) {
  ------------------
  |  Branch (886:13): [True: 0, False: 133]
  ------------------
  887|       |            /* common case: no repeated '/' or "/." */
  888|      0|            *end = '\0'; /* overwrite extra '/' added to end of path */
  889|      0|            return;
  890|      0|        }
  891|    133|        out = walk-1;
  892|    133|    }
  893|    242|    else {
  894|    242|        if (walk[0] == '.' && walk[1] == '/')
  ------------------
  |  Branch (894:13): [True: 109, False: 133]
  |  Branch (894:31): [True: 70, False: 39]
  ------------------
  895|     70|            *out = *++walk;
  896|    172|        else if (walk[0] == '.' && walk[1] == '.' && walk[2] == '/')
  ------------------
  |  Branch (896:18): [True: 39, False: 133]
  |  Branch (896:36): [True: 20, False: 19]
  |  Branch (896:54): [True: 2, False: 18]
  ------------------
  897|      2|            *out = *(walk += 2);
  898|    170|        else {
  899|  10.0M|            while (*++walk != '/') ;
  ------------------
  |  Branch (899:20): [True: 10.0M, False: 170]
  ------------------
  900|    170|            out = walk;
  901|    170|        }
  902|    242|        ++walk;
  903|    242|    }
  904|       |
  905|  11.0k|    while (walk <= end) {
  ------------------
  |  Branch (905:12): [True: 10.8k, False: 204]
  ------------------
  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.62k, False: 8.17k]
  ------------------
  908|       |            /* skip repeated '/' (e.g. "///" -> "/") */
  909|  2.62k|            if (++walk < end)
  ------------------
  |  Branch (909:17): [True: 2.57k, False: 50]
  ------------------
  910|  2.57k|                continue;
  911|     50|            else {
  912|     50|                ++out;
  913|     50|                break;
  914|     50|            }
  915|  2.62k|        }
  916|  8.17k|        else if (__builtin_expect( (walk[0] == '.'), 0)) {
  ------------------
  |  Branch (916:18): [True: 5.48k, False: 2.69k]
  ------------------
  917|       |            /* handle "./" and "../" */
  918|  5.48k|            if (walk[1] == '.' && walk[2] == '/') {
  ------------------
  |  Branch (918:17): [True: 3.49k, False: 1.98k]
  |  Branch (918:35): [True: 965, False: 2.53k]
  ------------------
  919|       |                /* handle "../" */
  920|  4.18M|                while (out > b->ptr && *--out != '/') ;
  ------------------
  |  Branch (920:24): [True: 4.18M, False: 540]
  |  Branch (920:40): [True: 4.18M, False: 425]
  ------------------
  921|    965|                *out = '/'; /*(in case path had not started with '/')*/
  922|    965|                if ((walk += 3) >= end) {
  ------------------
  |  Branch (922:21): [True: 58, False: 907]
  ------------------
  923|     58|                    ++out;
  924|     58|                    break;
  925|     58|                }
  926|    907|                else
  927|    907|                    continue;
  928|    965|            }
  929|  4.52k|            else if (walk[1] == '/') {
  ------------------
  |  Branch (929:22): [True: 1.30k, False: 3.21k]
  ------------------
  930|       |                /* handle "./" */
  931|  1.30k|                if ((walk += 2) >= end) {
  ------------------
  |  Branch (931:21): [True: 63, False: 1.24k]
  ------------------
  932|     63|                    ++out;
  933|     63|                    break;
  934|     63|                }
  935|  1.24k|                continue;
  936|  1.30k|            }
  937|  3.21k|            else {
  938|       |                /* accept "." if not part of "../" or "./" */
  939|  3.21k|                *++out = '.';
  940|  3.21k|                ++walk;
  941|  3.21k|            }
  942|  5.48k|        }
  943|       |
  944|  24.0M|        while ((*++out = *walk++) != '/') ;
  ------------------
  |  Branch (944:16): [True: 24.0M, False: 5.90k]
  ------------------
  945|  5.90k|    }
  946|    375|    *out = *end = '\0'; /* overwrite extra '/' added to end of path */
  947|    375|    b->used = (out - b->ptr) + 1;
  948|       |    /*buffer_truncate(b, out - b->ptr);*/
  949|    375|}
buffer.c:buffer_alloc_replace:
   71|  3.58k|static char* buffer_alloc_replace(buffer * const restrict b, const size_t size) {
   72|       |    /*(discard old data so realloc() does not copy)*/
   73|  3.58k|    if (NULL != b->ptr) {
  ------------------
  |  Branch (73:9): [True: 509, False: 3.07k]
  ------------------
   74|    509|        free(b->ptr);
   75|    509|        b->ptr = NULL;
   76|    509|    }
   77|       |    /*(note: if size larger than one lshift, use size instead of power-2)*/
   78|  3.58k|    const size_t bsize2x = (b->size & ~1uL) << 1;
   79|  3.58k|    return buffer_realloc(b, bsize2x > size ? bsize2x-1 : size);
  ------------------
  |  Branch (79:30): [True: 264, False: 3.32k]
  ------------------
   80|  3.58k|}
buffer.c:buffer_realloc:
   49|  3.58k|static char* buffer_realloc(buffer * const restrict b, const size_t len) {
   50|  3.58k|    #define BUFFER_PIECE_SIZE 64uL  /*(must be power-of-2)*/
   51|  3.58k|    size_t sz = (len + 1 + BUFFER_PIECE_SIZE-1) & ~(BUFFER_PIECE_SIZE-1);
  ------------------
  |  |   50|  3.58k|    #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.58k|    #define BUFFER_PIECE_SIZE 64uL  /*(must be power-of-2)*/
  ------------------
   52|  3.58k|    force_assert(sz > len);
  ------------------
  |  |  448|  3.58k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.58k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.58k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.58k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   53|  3.58k|    if ((sz & (sz-1)) && sz < INT_MAX) {/* not power-2; huge val not expected */
  ------------------
  |  Branch (53:9): [True: 1.24k, False: 2.34k]
  |  Branch (53:26): [True: 1.24k, False: 0]
  ------------------
   54|       |        /*(optimizer should recognize this and use ffs or clz or equivalent)*/
   55|  1.24k|        const size_t psz = sz;
   56|  8.60k|        for (sz = 256; sz < psz; sz <<= 1) ;
  ------------------
  |  Branch (56:24): [True: 7.35k, False: 1.24k]
  ------------------
   57|  1.24k|    }
   58|  3.58k|    sz |= 1; /*(extra +1 for '\0' when needed buffer size is exact power-2)*/
   59|       |
   60|  3.58k|    b->size = sz;
   61|  3.58k|    b->ptr = realloc(b->ptr, sz);
   62|       |
   63|  3.58k|    force_assert(NULL != b->ptr);
  ------------------
  |  |  448|  3.58k|#define force_assert(x) ck_assert(x)
  |  |  ------------------
  |  |  |  |  115|  3.58k|        do { if (!(x)) ck_assert_failed(__FILE__, __LINE__, #x); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (115:18): [True: 0, False: 3.58k]
  |  |  |  |  |  Branch (115:75): [Folded, False: 3.58k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   64|  3.58k|    return b->ptr;
   65|  3.58k|}

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

burl_normalize:
  344|  1.73k|{
  345|  1.73k|    int qs;
  346|       |
  347|       |  #if defined(_WIN32) || defined(__CYGWIN__)
  348|       |    /* Windows and Cygwin treat '\\' as '/' if '\\' is present in path;
  349|       |     * convert to '/' for consistency before percent-encoding
  350|       |     * normalization which will convert '\\' to "%5C" in the URL.
  351|       |     * (Clients still should not be sending '\\' unencoded in requests.) */
  352|       |    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_BACKSLASH_TRANS) {
  353|       |        for (char *p = b->ptr; *p != '?' && *p != '\0'; ++p) {
  354|       |            if (*p == '\\') *p = '/';
  355|       |            if (p[0] == '%' && p[1] == '5' && (p[2] | 0x20) == 'c') {
  356|       |                p[1] = '2';
  357|       |                p[2] = 'F';
  358|       |                p += 2;
  359|       |            }
  360|       |        }
  361|       |    }
  362|       |  #endif
  363|       |
  364|  1.73k|    qs = (flags & HTTP_PARSEOPT_URL_NORMALIZE_REQUIRED)
  ------------------
  |  Branch (364:10): [True: 959, False: 771]
  ------------------
  365|  1.73k|      ? burl_normalize_basic_required(b, t)
  366|  1.73k|      : burl_normalize_basic_unreserved(b, t);
  367|  1.73k|    if (-2 == qs) {
  ------------------
  |  Branch (367:9): [True: 541, False: 1.18k]
  ------------------
  368|    541|        if (flags & HTTP_PARSEOPT_URL_NORMALIZE_INVALID_UTF8_REJECT) return -2;
  ------------------
  |  Branch (368:13): [True: 122, False: 419]
  ------------------
  369|    419|        qs = burl_scan_qmark(b);
  370|    419|    }
  371|       |
  372|  1.60k|    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_CTRLS_REJECT) {
  ------------------
  |  Branch (372:9): [True: 372, False: 1.23k]
  ------------------
  373|    372|        if (burl_contains_ctrls(b)) return -2;
  ------------------
  |  Branch (373:13): [True: 98, False: 274]
  ------------------
  374|    372|    }
  375|       |
  376|  1.51k|    if (flags & (HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_DECODE
  ------------------
  |  Branch (376:9): [True: 1.20k, False: 301]
  ------------------
  377|  1.51k|                |HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)) {
  378|  1.20k|        qs = burl_normalize_2F_to_slash(b, qs, flags);
  379|  1.20k|        if (-2 == qs) return -2;
  ------------------
  |  Branch (379:13): [True: 18, False: 1.19k]
  ------------------
  380|  1.20k|    }
  381|       |
  382|  1.49k|    if (flags & (HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REMOVE
  ------------------
  |  Branch (382:9): [True: 1.19k, False: 297]
  ------------------
  383|  1.49k|                |HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT)) {
  384|  1.19k|        qs = burl_normalize_path(b, t, qs, flags);
  385|  1.19k|        if (-2 == qs) return -2;
  ------------------
  |  Branch (385:13): [True: 21, False: 1.17k]
  ------------------
  386|  1.19k|    }
  387|       |
  388|  1.47k|    if (flags & HTTP_PARSEOPT_URL_NORMALIZE_QUERY_20_PLUS) {
  ------------------
  |  Branch (388:9): [True: 861, False: 610]
  ------------------
  389|    861|        if (qs >= 0) burl_normalize_qs20_to_plus(b, qs);
  ------------------
  |  Branch (389:13): [True: 428, False: 433]
  ------------------
  390|    861|    }
  391|       |
  392|  1.47k|    return qs;
  393|  1.49k|}
burl.c:burl_normalize_basic_required:
  179|    959|{
  180|    959|    const unsigned char * const s = (unsigned char *)b->ptr;
  181|    959|    const int used = (int)buffer_clen(b);
  182|    959|    unsigned int n1, n2, x;
  183|    959|    int qs = -1;
  184|    959|    int invalid_utf8 = 0;
  185|       |
  186|   366k|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (186:21): [True: 366k, False: 218]
  ------------------
  187|   366k|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (187:13): [True: 359k, False: 7.28k]
  ------------------
  188|   359k|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = i;
  ------------------
  |  Branch (188:17): [True: 1.70k, False: 357k]
  |  Branch (188:56): [True: 227, False: 1.48k]
  ------------------
  189|   359k|        }
  190|  7.28k|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  14.0k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 3.00k, False: 3.74k]
  |  |  |  Branch (43:30): [True: 3.67k, False: 78]
  |  |  |  Branch (43:31): [True: 3.67k, False: 78]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  13.9k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 2.58k, False: 4.09k]
  |  |  |  Branch (43:30): [True: 4.03k, False: 56]
  |  |  |  Branch (43:31): [True: 4.03k, False: 56]
  |  |  ------------------
  ------------------
  |  Branch (190:18): [True: 6.75k, False: 532]
  ------------------
  191|  6.62k|                 && (encoded_chars_http_uri_reqd[(x = (n1 << 4) | n2)]
  ------------------
  |  Branch (191:22): [True: 3.96k, False: 2.66k]
  ------------------
  192|  2.66k|                     || (qs < 0
  ------------------
  |  Branch (192:25): [True: 2.58k, False: 75]
  |  Branch (192:26): [True: 759, False: 1.90k]
  ------------------
  193|  2.66k|                         ? (x == '/' || x == '?')
  ------------------
  |  Branch (193:29): [True: 395, False: 364]
  |  Branch (193:41): [True: 331, False: 33]
  ------------------
  194|  6.54k|                         : (x == '&' || x == '=' || x == ';' || x == '+')))) {
  ------------------
  |  Branch (194:29): [True: 810, False: 1.09k]
  |  Branch (194:41): [True: 489, False: 602]
  |  Branch (194:53): [True: 225, False: 377]
  |  Branch (194:65): [True: 335, False: 42]
  ------------------
  195|  6.54k|            invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  6.54k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  6.54k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 631, False: 5.91k]
  |  |  |  |  ------------------
  |  |  |  |  261|  6.54k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 55, False: 5.85k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|  6.54k|            if (s[i+1] >= 'a') b->ptr[i+1] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (196:17): [True: 3.54k, False: 3.00k]
  ------------------
  197|  6.54k|            if (s[i+2] >= 'a') b->ptr[i+2] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (197:17): [True: 2.40k, False: 4.14k]
  ------------------
  198|  6.54k|            i+=2;
  199|  6.54k|        }
  200|    741|        else if (s[i] == '#') { /* ignore fragment */
  ------------------
  |  Branch (200:18): [True: 1, False: 740]
  ------------------
  201|      1|            buffer_truncate(b, (size_t)i);
  202|      1|            break;
  203|      1|        }
  204|    740|        else {
  205|    740|            qs = burl_normalize_basic_required_fix(b, t, i, qs);
  206|    740|            break;
  207|    740|        }
  208|   366k|    }
  209|       |
  210|    959|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (210:12): [True: 935, False: 24]
  ------------------
  211|    959|}
burl.c:burl_normalize_basic_required_fix:
  135|    740|{
  136|    740|    int j = i;
  137|    740|    const int used = (int)buffer_clen(b);
  138|    740|    const unsigned char * const s = (unsigned char *)b->ptr;
  139|    740|    unsigned char * const p =
  140|    740|      (unsigned char *)buffer_string_prepare_copy(t,i+(used-i)*3+1);
  141|    740|    unsigned int n1, n2;
  142|    740|    int invalid_utf8 = 0;
  143|    740|    memcpy(p, s, (size_t)i);
  144|  32.0M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (144:12): [True: 32.0M, False: 729]
  ------------------
  145|  32.0M|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (145:13): [True: 2.08M, False: 30.0M]
  ------------------
  146|  2.08M|            p[j] = s[i];
  147|  2.08M|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = j;
  ------------------
  |  Branch (147:17): [True: 10.4k, False: 2.07M]
  |  Branch (147:56): [True: 198, False: 10.2k]
  ------------------
  148|  2.08M|        }
  149|  30.0M|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  30.0M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 23.2k, False: 20.9k]
  |  |  |  Branch (43:30): [True: 12.4k, False: 8.46k]
  |  |  |  Branch (43:31): [True: 12.4k, False: 8.46k]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  35.7k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 10.8k, False: 24.9k]
  |  |  |  Branch (43:30): [True: 20.5k, False: 4.37k]
  |  |  |  Branch (43:31): [True: 20.5k, False: 4.37k]
  |  |  ------------------
  ------------------
  |  Branch (149:18): [True: 44.2k, False: 29.9M]
  ------------------
  150|  31.3k|            const unsigned int x = (n1 << 4) | n2;
  151|  31.3k|            if (!encoded_chars_http_uri_reqd[x]
  ------------------
  |  Branch (151:17): [True: 18.4k, False: 12.9k]
  ------------------
  152|  18.4k|                && (qs < 0
  ------------------
  |  Branch (152:20): [True: 4.25k, False: 14.2k]
  |  Branch (152:21): [True: 3.28k, False: 15.2k]
  ------------------
  153|  18.4k|                    ? (x != '/' && x != '?')
  ------------------
  |  Branch (153:24): [True: 2.32k, False: 962]
  |  Branch (153:36): [True: 1.90k, False: 421]
  ------------------
  154|  18.4k|                    : (x != '&' && x != '=' && x != ';' && x != '+'))) {
  ------------------
  |  Branch (154:24): [True: 9.85k, False: 5.35k]
  |  Branch (154:36): [True: 7.17k, False: 2.67k]
  |  Branch (154:48): [True: 3.77k, False: 3.39k]
  |  Branch (154:60): [True: 2.35k, False: 1.42k]
  ------------------
  155|  4.25k|                p[j] = x;
  156|  4.25k|            }
  157|  27.1k|            else {
  158|  27.1k|                p[j]   = '%';
  159|  27.1k|                p[++j] = hex_chars_uc[n1]; /*(s[i+1] & 0xdf)*/
  160|  27.1k|                p[++j] = hex_chars_uc[n2]; /*(s[i+2] & 0xdf)*/
  161|  27.1k|                invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  27.1k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  27.1k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 7.79k, False: 19.3k]
  |  |  |  |  ------------------
  |  |  |  |  261|  27.1k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 93, False: 19.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  162|  27.1k|            }
  163|  31.3k|            i+=2;
  164|  31.3k|        }
  165|  29.9M|        else if (s[i] == '#') break; /* ignore fragment */
  ------------------
  |  Branch (165:18): [True: 11, False: 29.9M]
  ------------------
  166|  29.9M|        else {
  167|  29.9M|            p[j]   = '%';
  168|  29.9M|            p[++j] = hex_chars_uc[(s[i] >> 4) & 0xF];
  169|  29.9M|            p[++j] = hex_chars_uc[s[i] & 0xF];
  170|  29.9M|            invalid_utf8 |= li_utf8_invalid_byte(s[i]);
  ------------------
  |  |   49|  29.9M|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  29.9M|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 1.77M, False: 28.1M]
  |  |  |  |  ------------------
  |  |  |  |  261|  29.9M|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 15.1k, False: 28.1M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  171|  29.9M|        }
  172|  32.0M|    }
  173|    740|    buffer_copy_string_len(b, (char *)p, (size_t)j);
  174|    740|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (174:12): [True: 450, False: 290]
  ------------------
  175|    740|}
burl.c:burl_normalize_basic_unreserved:
  101|    771|{
  102|    771|    const unsigned char * const s = (unsigned char *)b->ptr;
  103|    771|    const int used = (int)buffer_clen(b);
  104|    771|    unsigned int n1, n2, x;
  105|    771|    int qs = -1;
  106|    771|    int invalid_utf8 = 0;
  107|       |
  108|   726k|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (108:21): [True: 726k, False: 171]
  ------------------
  109|   726k|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (109:13): [True: 722k, False: 3.42k]
  ------------------
  110|   722k|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = i;
  ------------------
  |  Branch (110:17): [True: 483, False: 722k]
  |  Branch (110:56): [True: 83, False: 400]
  ------------------
  111|   722k|        }
  112|  3.42k|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  6.41k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 1.34k, False: 1.64k]
  |  |  |  Branch (43:30): [True: 1.58k, False: 58]
  |  |  |  Branch (43:31): [True: 1.58k, False: 58]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)
  ------------------
  |  |   43|  6.36k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 903, False: 2.03k]
  |  |  |  Branch (43:30): [True: 1.97k, False: 56]
  |  |  |  Branch (43:31): [True: 1.97k, False: 56]
  |  |  ------------------
  ------------------
  |  Branch (112:18): [True: 2.99k, False: 433]
  ------------------
  113|  2.87k|                 && !burl_is_unreserved((x = (n1 << 4) | n2))) {
  ------------------
  |  Branch (113:21): [True: 2.82k, False: 53]
  ------------------
  114|  2.82k|            invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  2.82k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  2.82k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 618, False: 2.20k]
  |  |  |  |  ------------------
  |  |  |  |  261|  2.82k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 153, False: 2.05k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  115|  2.82k|            if (s[i+1] >= 'a') b->ptr[i+1] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (115:17): [True: 1.38k, False: 1.44k]
  ------------------
  116|  2.82k|            if (s[i+2] >= 'a') b->ptr[i+2] &= 0xdf; /* uppercase hex */
  ------------------
  |  Branch (116:17): [True: 1.41k, False: 1.41k]
  ------------------
  117|  2.82k|            i+=2;
  118|  2.82k|        }
  119|    600|        else if (s[i] == '#') { /* ignore fragment */
  ------------------
  |  Branch (119:18): [True: 1, False: 599]
  ------------------
  120|      1|            buffer_truncate(b, (size_t)i);
  121|      1|            break;
  122|      1|        }
  123|    599|        else {
  124|    599|            qs = burl_normalize_basic_unreserved_fix(b, t, i, qs);
  125|    599|            break;
  126|    599|        }
  127|   726k|    }
  128|       |
  129|    771|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (129:12): [True: 741, False: 30]
  ------------------
  130|    771|}
burl.c:burl_is_unreserved:
   53|  16.3k|{
   54|  16.3k|    return (light_isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~');
  ------------------
  |  Branch (54:13): [True: 789, False: 15.5k]
  |  Branch (54:33): [True: 393, False: 15.1k]
  |  Branch (54:45): [True: 307, False: 14.8k]
  |  Branch (54:57): [True: 326, False: 14.5k]
  |  Branch (54:69): [True: 118, False: 14.4k]
  ------------------
   55|  16.3k|}
burl.c:burl_normalize_basic_unreserved_fix:
   60|    599|{
   61|    599|    int j = i;
   62|    599|    const int used = (int)buffer_clen(b);
   63|    599|    const unsigned char * const s = (unsigned char *)b->ptr;
   64|    599|    unsigned char * const p =
   65|    599|      (unsigned char *)buffer_string_prepare_copy(t,i+(used-i)*3+1);
   66|    599|    unsigned int n1, n2;
   67|    599|    int invalid_utf8 = 0;
   68|    599|    memcpy(p, s, (size_t)i);
   69|  26.6M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (69:12): [True: 26.6M, False: 591]
  ------------------
   70|  26.6M|        if (!encoded_chars_http_uri_reqd[s[i]]) {
  ------------------
  |  Branch (70:13): [True: 2.20M, False: 24.4M]
  ------------------
   71|  2.20M|            p[j] = s[i];
   72|  2.20M|            if (__builtin_expect( (s[i] == '?'), 0) && -1 == qs) qs = j;
  ------------------
  |  Branch (72:17): [True: 1.23k, False: 2.20M]
  |  Branch (72:56): [True: 143, False: 1.09k]
  ------------------
   73|  2.20M|        }
   74|  24.4M|        else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  24.4M|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 9.71k, False: 16.4k]
  |  |  |  Branch (43:30): [True: 6.06k, False: 10.3k]
  |  |  |  Branch (43:31): [True: 6.06k, False: 10.3k]
  |  |  ------------------
  ------------------
                      else if (s[i]=='%' && li_cton(s[i+1], n1) && li_cton(s[i+2], n2)) {
  ------------------
  |  |   43|  15.7k|  (((n) = (c) - '0') <= 9 || (((n) = ((c)&0xdf) - 'A') <= 5 ? ((n) += 10) : 0))
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 3.83k, False: 11.9k]
  |  |  |  Branch (43:30): [True: 9.65k, False: 2.28k]
  |  |  |  Branch (43:31): [True: 9.65k, False: 2.28k]
  |  |  ------------------
  ------------------
  |  Branch (74:18): [True: 26.1k, False: 24.4M]
  ------------------
   75|  13.4k|            const unsigned int x = (n1 << 4) | n2;
   76|  13.4k|            if (burl_is_unreserved(x)) {
  ------------------
  |  Branch (76:17): [True: 1.88k, False: 11.6k]
  ------------------
   77|  1.88k|                p[j] = x;
   78|  1.88k|            }
   79|  11.6k|            else {
   80|  11.6k|                p[j]   = '%';
   81|  11.6k|                p[++j] = hex_chars_uc[n1]; /*(s[i+1] & 0xdf)*/
   82|  11.6k|                p[++j] = hex_chars_uc[n2]; /*(s[i+2] & 0xdf)*/
   83|  11.6k|                invalid_utf8 |= li_utf8_invalid_byte(x);
  ------------------
  |  |   49|  11.6k|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  11.6k|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 3.03k, False: 8.58k]
  |  |  |  |  ------------------
  |  |  |  |  261|  11.6k|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 1.00k, False: 7.58k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   84|  11.6k|            }
   85|  13.4k|            i+=2;
   86|  13.4k|        }
   87|  24.4M|        else if (s[i] == '#') break; /* ignore fragment */
  ------------------
  |  Branch (87:18): [True: 8, False: 24.4M]
  ------------------
   88|  24.4M|        else {
   89|  24.4M|            p[j]   = '%';
   90|  24.4M|            p[++j] = hex_chars_uc[(s[i] >> 4) & 0xF];
   91|  24.4M|            p[++j] = hex_chars_uc[s[i] & 0xF];
   92|  24.4M|            invalid_utf8 |= li_utf8_invalid_byte(s[i]);
  ------------------
  |  |   49|  24.4M|#define li_utf8_invalid_byte(b) light_utf8_invalid_byte(b)
  |  |  ------------------
  |  |  |  |  260|  24.4M|  (   __builtin_expect( ((c) >= 0xF5),       0) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (260:7): [True: 74.1k, False: 24.3M]
  |  |  |  |  ------------------
  |  |  |  |  261|  24.4M|   || __builtin_expect( (((c)|0x1) == 0xC1), 0) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (261:7): [True: 2.44k, False: 24.3M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   93|  24.4M|        }
   94|  26.6M|    }
   95|    599|    buffer_copy_string_len(b, (char *)p, (size_t)j);
   96|    599|    return !invalid_utf8 ? qs : -2;
  ------------------
  |  Branch (96:12): [True: 399, False: 200]
  ------------------
   97|    599|}
burl.c:burl_scan_qmark:
  337|    419|static int burl_scan_qmark (const buffer * const b) {
  338|    419|    const char * const qmark = strchr(b->ptr, '?');
  339|    419|    return qmark ? (int)(qmark - b->ptr) : -1;
  ------------------
  |  Branch (339:12): [True: 233, False: 186]
  ------------------
  340|    419|}
burl.c:burl_contains_ctrls:
  215|    372|{
  216|    372|    const char * const s = b->ptr;
  217|    372|    const int used = (int)buffer_clen(b);
  218|  11.6M|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (218:21): [True: 11.6M, False: 274]
  ------------------
  219|  11.6M|        if (s[i] == '%' && (s[i+1] < '2' || (s[i+1] == '7' && s[i+2] == 'F')))
  ------------------
  |  Branch (219:13): [True: 3.65M, False: 8.00M]
  |  Branch (219:29): [True: 90, False: 3.65M]
  |  Branch (219:46): [True: 454, False: 3.65M]
  |  Branch (219:63): [True: 8, False: 446]
  ------------------
  220|     98|            return 1;
  221|  11.6M|    }
  222|    274|    return 0;
  223|    372|}
burl.c:burl_normalize_2F_to_slash:
  282|  1.20k|{
  283|       |    /*("%2F" must already have been uppercased during normalization)*/
  284|  1.20k|    const char * const s = b->ptr;
  285|  1.20k|    const int used = qs < 0 ? (int)buffer_clen(b) : qs;
  ------------------
  |  Branch (285:22): [True: 727, False: 482]
  ------------------
  286|  75.7M|    for (int i = 0; i < used; ++i) {
  ------------------
  |  Branch (286:21): [True: 75.7M, False: 1.03k]
  ------------------
  287|  75.7M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == 'F') {
  ------------------
  |  Branch (287:13): [True: 25.1M, False: 50.5M]
  |  Branch (287:28): [True: 4.09k, False: 25.1M]
  |  Branch (287:45): [True: 177, False: 3.92k]
  ------------------
  288|    177|            return !(flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)
  ------------------
  |  Branch (288:20): [True: 159, False: 18]
  ------------------
  289|    177|              ? burl_normalize_2F_to_slash_fix(b, qs, i)     /* _DECODE */
  290|    177|              : -2; /*(flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT)*/
  291|    177|        }
  292|  75.7M|    }
  293|  1.03k|    return qs;
  294|  1.20k|}
burl.c:burl_normalize_2F_to_slash_fix:
  258|    159|{
  259|    159|    char * const s = b->ptr;
  260|    159|    const int blen = (int)buffer_clen(b);
  261|    159|    const int used = qs < 0 ? blen : qs;
  ------------------
  |  Branch (261:22): [True: 93, False: 66]
  ------------------
  262|    159|    int j = i;
  263|  9.56M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (263:12): [True: 9.56M, False: 159]
  ------------------
  264|  9.56M|        s[j] = s[i];
  265|  9.56M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == 'F') {
  ------------------
  |  Branch (265:13): [True: 3.18M, False: 6.38M]
  |  Branch (265:28): [True: 5.50k, False: 3.17M]
  |  Branch (265:45): [True: 1.83k, False: 3.67k]
  ------------------
  266|  1.83k|            s[j] = '/';
  267|  1.83k|            i+=2;
  268|  1.83k|        }
  269|  9.56M|    }
  270|    159|    if (qs >= 0) {
  ------------------
  |  Branch (270:9): [True: 66, False: 93]
  ------------------
  271|     66|        const int qslen = blen - qs;
  272|     66|        memmove(s+j, s+qs, (size_t)qslen);
  273|     66|        qs = j;
  274|     66|        j += qslen;
  275|     66|    }
  276|    159|    buffer_truncate(b, j);
  277|    159|    return qs;
  278|    159|}
burl.c:burl_normalize_path:
  298|  1.19k|{
  299|  1.19k|    const unsigned char * const s = (unsigned char *)b->ptr;
  300|  1.19k|    const int used = (int)buffer_clen(b);
  301|  1.19k|    int path_simplify = 0;
  302|  4.12k|    for (int i = 0, len = qs < 0 ? used : qs; i < len; ++i) {
  ------------------
  |  Branch (302:27): [True: 723, False: 472]
  |  Branch (302:47): [True: 3.32k, False: 799]
  ------------------
  303|  3.32k|        if (s[i] == '.' && (s[i+1] != '.' || ++i)
  ------------------
  |  Branch (303:13): [True: 1.39k, False: 1.93k]
  |  Branch (303:29): [True: 725, False: 667]
  |  Branch (303:46): [True: 667, False: 0]
  ------------------
  304|  1.39k|            && (s[i+1] == '/' || s[i+1] == '?' || s[i+1] == '\0')) {
  ------------------
  |  Branch (304:17): [True: 96, False: 1.29k]
  |  Branch (304:34): [True: 52, False: 1.24k]
  |  Branch (304:51): [True: 87, False: 1.15k]
  ------------------
  305|    235|            path_simplify = 1;
  306|    235|            break;
  307|    235|        }
  308|  65.7M|        while (i < len && s[i] != '/') ++i;
  ------------------
  |  Branch (308:16): [True: 65.7M, False: 628]
  |  Branch (308:27): [True: 65.7M, False: 2.45k]
  ------------------
  309|  3.08k|        if (s[i] == '/' && s[i+1] == '/') { /*(s[len] != '/')*/
  ------------------
  |  Branch (309:13): [True: 2.45k, False: 628]
  |  Branch (309:28): [True: 161, False: 2.29k]
  ------------------
  310|    161|            path_simplify = 1;
  311|    161|            break;
  312|    161|        }
  313|  3.08k|    }
  314|       |
  315|  1.19k|    if (path_simplify) {
  ------------------
  |  Branch (315:9): [True: 396, False: 799]
  ------------------
  316|    396|        if (flags & HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT) return -2;
  ------------------
  |  Branch (316:13): [True: 21, False: 375]
  ------------------
  317|    375|        if (qs >= 0) {
  ------------------
  |  Branch (317:13): [True: 135, False: 240]
  ------------------
  318|    135|            buffer_copy_string_len(t, b->ptr+qs, used - qs);
  319|    135|            buffer_truncate(b, qs);
  320|    135|        }
  321|       |
  322|    375|        buffer_path_simplify(b);
  323|       |
  324|    375|        if (qs >= 0) {
  ------------------
  |  Branch (324:13): [True: 135, False: 240]
  ------------------
  325|    135|            qs = (int)buffer_clen(b);
  326|    135|            buffer_append_string_len(b, BUF_PTR_LEN(t));
  ------------------
  |  |  297|    135|#define BUF_PTR_LEN(x)       (x)->ptr, buffer_clen(x)
  ------------------
  327|    135|        }
  328|    375|    }
  329|       |
  330|  1.17k|    return qs;
  331|  1.19k|}
burl.c:burl_normalize_qs20_to_plus:
  244|    428|{
  245|    428|    const char * const s = b->ptr;
  246|    428|    const int used = qs < 0 ? 0 : (int)buffer_clen(b);
  ------------------
  |  Branch (246:22): [True: 0, False: 428]
  ------------------
  247|    428|    int i;
  248|    428|    if (qs < 0) return;
  ------------------
  |  Branch (248:9): [True: 0, False: 428]
  ------------------
  249|  9.20M|    for (i = qs+1; i < used; ++i) {
  ------------------
  |  Branch (249:20): [True: 9.19M, False: 288]
  ------------------
  250|  9.19M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == '0') break;
  ------------------
  |  Branch (250:13): [True: 3.05M, False: 6.14M]
  |  Branch (250:28): [True: 3.49k, False: 3.05M]
  |  Branch (250:45): [True: 140, False: 3.35k]
  ------------------
  251|  9.19M|    }
  252|    428|    if (i != used) burl_normalize_qs20_to_plus_fix(b, i);
  ------------------
  |  Branch (252:9): [True: 140, False: 288]
  ------------------
  253|    428|}
burl.c:burl_normalize_qs20_to_plus_fix:
  228|    140|{
  229|    140|    char * const s = b->ptr;
  230|    140|    const int used = (int)buffer_clen(b);
  231|    140|    int j = i;
  232|  7.82M|    for (; i < used; ++i, ++j) {
  ------------------
  |  Branch (232:12): [True: 7.82M, False: 140]
  ------------------
  233|  7.82M|        s[j] = s[i];
  234|  7.82M|        if (s[i] == '%' && s[i+1] == '2' && s[i+2] == '0') {
  ------------------
  |  Branch (234:13): [True: 2.54M, False: 5.28M]
  |  Branch (234:28): [True: 16.3k, False: 2.52M]
  |  Branch (234:45): [True: 4.65k, False: 11.6k]
  ------------------
  235|  4.65k|            s[j] = '+';
  236|  4.65k|            i+=2;
  237|  4.65k|        }
  238|  7.82M|    }
  239|    140|    buffer_truncate(b, j);
  240|    140|}

