pb_field_iter_begin:
  157|   753k|{
  158|   753k|    memset(iter, 0, sizeof(*iter));
  159|       |
  160|   753k|    iter->descriptor = desc;
  161|   753k|    iter->message = message;
  162|       |
  163|   753k|    return load_descriptor_values(iter);
  164|   753k|}
pb_field_iter_begin_extension:
  167|   115k|{
  168|   115k|    const pb_msgdesc_t *msg = (const pb_msgdesc_t*)extension->type->arg;
  169|   115k|    bool status;
  170|       |
  171|   115k|    uint32_t word0 = PB_PROGMEM_READU32(msg->field_info[0]);
  ------------------
  |  |  184|   115k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  172|   115k|    if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   115k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   115k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   115k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (172:9): [True: 0, False: 115k]
  ------------------
  173|      0|    {
  174|       |        /* For pointer extensions, the pointer is stored directly
  175|       |         * in the extension structure. This avoids having an extra
  176|       |         * indirection. */
  177|      0|        status = pb_field_iter_begin(iter, msg, &extension->dest);
  178|      0|    }
  179|   115k|    else
  180|   115k|    {
  181|   115k|        status = pb_field_iter_begin(iter, msg, extension->dest);
  182|   115k|    }
  183|       |
  184|   115k|    iter->pSize = &extension->found;
  185|   115k|    return status;
  186|   115k|}
pb_field_iter_next:
  189|  3.44M|{
  190|  3.44M|    advance_iterator(iter);
  191|  3.44M|    (void)load_descriptor_values(iter);
  192|  3.44M|    return iter->index != 0;
  193|  3.44M|}
pb_field_iter_find:
  196|  31.1M|{
  197|  31.1M|    if (iter->tag == tag)
  ------------------
  |  Branch (197:9): [True: 29.7M, False: 1.35M]
  ------------------
  198|  29.7M|    {
  199|  29.7M|        return true; /* Nothing to do, correct field already. */
  200|  29.7M|    }
  201|  1.35M|    else if (tag > iter->descriptor->largest_tag)
  ------------------
  |  Branch (201:14): [True: 248k, False: 1.10M]
  ------------------
  202|   248k|    {
  203|   248k|        return false;
  204|   248k|    }
  205|  1.10M|    else
  206|  1.10M|    {
  207|  1.10M|        pb_size_t start = iter->index;
  208|  1.10M|        uint32_t fieldinfo;
  209|       |
  210|  1.10M|        if (tag < iter->tag)
  ------------------
  |  Branch (210:13): [True: 276k, False: 833k]
  ------------------
  211|   276k|        {
  212|       |            /* Fields are in tag number order, so we know that tag is between
  213|       |             * 0 and our start position. Setting index to end forces
  214|       |             * advance_iterator() call below to restart from beginning. */
  215|   276k|            iter->index = iter->descriptor->field_count;
  216|   276k|        }
  217|       |
  218|  1.10M|        do
  219|  12.8M|        {
  220|       |            /* Advance iterator but don't load values yet */
  221|  12.8M|            advance_iterator(iter);
  222|       |
  223|       |            /* Do fast check for tag number match */
  224|  12.8M|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  184|  12.8M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  225|       |
  226|  12.8M|            if (((fieldinfo >> 2) & 0x3F) == (tag & 0x3F))
  ------------------
  |  Branch (226:17): [True: 1.14M, False: 11.6M]
  ------------------
  227|  1.14M|            {
  228|       |                /* Good candidate, check further */
  229|  1.14M|                (void)load_descriptor_values(iter);
  230|       |
  231|  1.14M|                if (iter->tag == tag &&
  ------------------
  |  Branch (231:21): [True: 1.03M, False: 113k]
  ------------------
  232|  1.03M|                    PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  1.03M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.03M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                                  PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  1.03M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (232:21): [True: 1.03M, False: 4.64k]
  ------------------
  233|  1.03M|                {
  234|       |                    /* Found it */
  235|  1.03M|                    return true;
  236|  1.03M|                }
  237|  1.14M|            }
  238|  12.8M|        } while (iter->index != start);
  ------------------
  |  Branch (238:18): [True: 11.7M, False: 79.3k]
  ------------------
  239|       |
  240|       |        /* Searched all the way back to start, and found nothing. */
  241|  79.3k|        (void)load_descriptor_values(iter);
  242|       |        return false;
  243|  1.10M|    }
  244|  31.1M|}
pb_field_iter_find_extension:
  247|  12.3k|{
  248|  12.3k|    if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  12.3k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  12.3k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  12.3k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (248:9): [True: 0, False: 12.3k]
  ------------------
  249|      0|    {
  250|      0|        return true;
  251|      0|    }
  252|  12.3k|    else
  253|  12.3k|    {
  254|  12.3k|        pb_size_t start = iter->index;
  255|  12.3k|        uint32_t fieldinfo;
  256|       |
  257|  12.3k|        do
  258|   145k|        {
  259|       |            /* Advance iterator but don't load values yet */
  260|   145k|            advance_iterator(iter);
  261|       |
  262|       |            /* Do fast check for field type */
  263|   145k|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  184|   145k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  264|       |
  265|   145k|            if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|   145k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   145k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|   145k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (265:17): [True: 4.13k, False: 140k]
  ------------------
  266|  4.13k|            {
  267|  4.13k|                return load_descriptor_values(iter);
  268|  4.13k|            }
  269|   145k|        } while (iter->index != start);
  ------------------
  |  Branch (269:18): [True: 132k, False: 8.20k]
  ------------------
  270|       |
  271|       |        /* Searched all the way back to start, and found nothing. */
  272|  8.20k|        (void)load_descriptor_values(iter);
  273|       |        return false;
  274|  12.3k|    }
  275|  12.3k|}
pb_field_iter_begin_const:
  291|   240k|{
  292|   240k|    return pb_field_iter_begin(iter, desc, pb_const_cast(message));
  293|   240k|}
pb_field_iter_begin_extension_const:
  296|  2.91k|{
  297|  2.91k|    return pb_field_iter_begin_extension(iter, (pb_extension_t*)pb_const_cast(extension));
  298|  2.91k|}
pb_default_field_callback:
  301|  9.01k|{
  302|  9.01k|    if (field->data_size == sizeof(pb_callback_t))
  ------------------
  |  Branch (302:9): [True: 9.01k, False: 0]
  ------------------
  303|  9.01k|    {
  304|  9.01k|        pb_callback_t *pCallback = (pb_callback_t*)field->pData;
  305|       |
  306|  9.01k|        if (pCallback != NULL)
  ------------------
  |  Branch (306:13): [True: 9.01k, False: 0]
  ------------------
  307|  9.01k|        {
  308|  9.01k|            if (istream != NULL && pCallback->funcs.decode != NULL)
  ------------------
  |  Branch (308:17): [True: 8.88k, False: 125]
  |  Branch (308:36): [True: 0, False: 8.88k]
  ------------------
  309|      0|            {
  310|      0|                return pCallback->funcs.decode(istream, field, &pCallback->arg);
  311|      0|            }
  312|       |
  313|  9.01k|            if (ostream != NULL && pCallback->funcs.encode != NULL)
  ------------------
  |  Branch (313:17): [True: 125, False: 8.88k]
  |  Branch (313:36): [True: 0, False: 125]
  ------------------
  314|      0|            {
  315|      0|                return pCallback->funcs.encode(ostream, field, &pCallback->arg);
  316|      0|            }
  317|  9.01k|        }
  318|  9.01k|    }
  319|       |
  320|  9.01k|    return true; /* Success, but didn't do anything */
  321|       |
  322|  9.01k|}
pb_common.c:load_descriptor_values:
    9|  5.44M|{
   10|  5.44M|    uint32_t word0;
   11|  5.44M|    uint32_t data_offset;
   12|  5.44M|    int_least8_t size_offset;
   13|       |
   14|  5.44M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (14:9): [True: 216k, False: 5.22M]
  ------------------
   15|   216k|        return false;
   16|       |
   17|  5.22M|    word0 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  184|  5.22M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   18|  5.22M|    iter->type = (pb_type_t)((word0 >> 8) & 0xFF);
   19|       |
   20|  5.22M|    switch(word0 & 3)
   21|  5.22M|    {
   22|   936k|        case 0: {
  ------------------
  |  Branch (22:9): [True: 936k, False: 4.29M]
  ------------------
   23|       |            /* 1-word format */
   24|   936k|            iter->array_size = 1;
   25|   936k|            iter->tag = (pb_size_t)((word0 >> 2) & 0x3F);
   26|   936k|            size_offset = (int_least8_t)((word0 >> 24) & 0x0F);
   27|   936k|            data_offset = (word0 >> 16) & 0xFF;
   28|   936k|            iter->data_size = (pb_size_t)((word0 >> 28) & 0x0F);
   29|   936k|            break;
   30|      0|        }
   31|       |
   32|  3.55M|        case 1: {
  ------------------
  |  Branch (32:9): [True: 3.55M, False: 1.67M]
  ------------------
   33|       |            /* 2-word format */
   34|  3.55M|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  184|  3.55M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   35|       |
   36|  3.55M|            iter->array_size = (pb_size_t)((word0 >> 16) & 0x0FFF);
   37|  3.55M|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 28) << 6));
   38|  3.55M|            size_offset = (int_least8_t)((word0 >> 28) & 0x0F);
   39|  3.55M|            data_offset = word1 & 0xFFFF;
   40|  3.55M|            iter->data_size = (pb_size_t)((word1 >> 16) & 0x0FFF);
   41|  3.55M|            break;
   42|      0|        }
   43|       |
   44|   552k|        case 2: {
  ------------------
  |  Branch (44:9): [True: 552k, False: 4.67M]
  ------------------
   45|       |            /* 4-word format */
   46|   552k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  184|   552k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   47|   552k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  184|   552k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   48|   552k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  184|   552k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   49|       |
   50|   552k|            iter->array_size = (pb_size_t)(word0 >> 16);
   51|   552k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   52|   552k|            size_offset = (int_least8_t)(word1 & 0xFF);
   53|   552k|            data_offset = word2;
   54|   552k|            iter->data_size = (pb_size_t)word3;
   55|   552k|            break;
   56|      0|        }
   57|       |
   58|   186k|        default: {
  ------------------
  |  Branch (58:9): [True: 186k, False: 5.04M]
  ------------------
   59|       |            /* 8-word format */
   60|   186k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  184|   186k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   61|   186k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  184|   186k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   62|   186k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  184|   186k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   63|   186k|            uint32_t word4 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 4]);
  ------------------
  |  |  184|   186k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   64|       |
   65|   186k|            iter->array_size = (pb_size_t)word4;
   66|   186k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   67|   186k|            size_offset = (int_least8_t)(word1 & 0xFF);
   68|   186k|            data_offset = word2;
   69|   186k|            iter->data_size = (pb_size_t)word3;
   70|   186k|            break;
   71|      0|        }
   72|  5.22M|    }
   73|       |
   74|  5.22M|    if (!iter->message)
  ------------------
  |  Branch (74:9): [True: 0, False: 5.22M]
  ------------------
   75|      0|    {
   76|       |        /* Avoid doing arithmetic on null pointers, it is undefined */
   77|      0|        iter->pField = NULL;
   78|      0|        iter->pSize = NULL;
   79|      0|    }
   80|  5.22M|    else
   81|  5.22M|    {
   82|  5.22M|        iter->pField = (char*)iter->message + data_offset;
   83|       |
   84|  5.22M|        if (size_offset)
  ------------------
  |  Branch (84:13): [True: 981k, False: 4.24M]
  ------------------
   85|   981k|        {
   86|   981k|            iter->pSize = (char*)iter->pField - size_offset;
   87|   981k|        }
   88|  4.24M|        else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  327|  4.24M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  4.24M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  314|  8.48M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (88:18): [True: 59.6k, False: 4.18M]
  ------------------
   89|  59.6k|                 (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  326|  59.6k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  59.6k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                               (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  321|   119k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (89:19): [True: 0, False: 59.6k]
  ------------------
   90|  59.6k|                  PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  326|  59.6k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  59.6k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                                PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  322|  59.6k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (90:19): [True: 59.6k, False: 0]
  ------------------
   91|  59.6k|        {
   92|       |            /* Fixed count array */
   93|  59.6k|            iter->pSize = &iter->array_size;
   94|  59.6k|        }
   95|  4.18M|        else
   96|  4.18M|        {
   97|  4.18M|            iter->pSize = NULL;
   98|  4.18M|        }
   99|       |
  100|  5.22M|        if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  326|  5.22M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  5.22M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  322|  10.4M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (100:13): [True: 4.86M, False: 356k]
  |  Branch (100:57): [True: 4.86M, False: 0]
  ------------------
  101|  4.86M|        {
  102|  4.86M|            iter->pData = *(void**)iter->pField;
  103|  4.86M|        }
  104|   356k|        else
  105|   356k|        {
  106|   356k|            iter->pData = iter->pField;
  107|   356k|        }
  108|  5.22M|    }
  109|       |
  110|  5.22M|    if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  329|  5.22M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  5.22M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  5.22M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  10.4M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 655k, False: 4.57M]
  |  |  ------------------
  |  |  330|  5.22M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  4.57M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  4.57M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  4.57M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 4.57M]
  |  |  ------------------
  ------------------
  111|   655k|    {
  112|   655k|        iter->submsg_desc = iter->descriptor->submsg_info[iter->submessage_index];
  113|   655k|    }
  114|  4.57M|    else
  115|  4.57M|    {
  116|  4.57M|        iter->submsg_desc = NULL;
  117|  4.57M|    }
  118|       |
  119|       |    return true;
  120|  5.22M|}
pb_common.c:advance_iterator:
  123|  16.4M|{
  124|  16.4M|    iter->index++;
  125|       |
  126|  16.4M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (126:9): [True: 783k, False: 15.6M]
  ------------------
  127|   783k|    {
  128|       |        /* Restart */
  129|   783k|        iter->index = 0;
  130|   783k|        iter->field_info_index = 0;
  131|   783k|        iter->submessage_index = 0;
  132|   783k|        iter->required_field_index = 0;
  133|   783k|    }
  134|  15.6M|    else
  135|  15.6M|    {
  136|       |        /* Increment indexes based on previous field type.
  137|       |         * All field info formats have the following fields:
  138|       |         * - lowest 2 bits tell the amount of words in the descriptor (2^n words)
  139|       |         * - bits 2..7 give the lowest bits of tag number.
  140|       |         * - bits 8..15 give the field type.
  141|       |         */
  142|  15.6M|        uint32_t prev_descriptor = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  184|  15.6M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  143|  15.6M|        pb_type_t prev_type = (prev_descriptor >> 8) & 0xFF;
  144|  15.6M|        pb_size_t descriptor_len = (pb_size_t)(1 << (prev_descriptor & 3));
  145|       |
  146|       |        /* Add to fields.
  147|       |         * The cast to pb_size_t is needed to avoid -Wconversion warning.
  148|       |         * Because the data is is constants from generator, there is no danger of overflow.
  149|       |         */
  150|  15.6M|        iter->field_info_index = (pb_size_t)(iter->field_info_index + descriptor_len);
  151|  15.6M|        iter->required_field_index = (pb_size_t)(iter->required_field_index + (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED));
  ------------------
  |  |  327|  15.6M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  15.6M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      iter->required_field_index = (pb_size_t)(iter->required_field_index + (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED));
  ------------------
  |  |  311|  15.6M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  152|  15.6M|        iter->submessage_index = (pb_size_t)(iter->submessage_index + PB_LTYPE_IS_SUBMSG(prev_type));
  ------------------
  |  |  329|  15.6M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  15.6M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  15.6M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  31.2M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 2.21M, False: 13.4M]
  |  |  ------------------
  |  |  330|  15.6M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  13.4M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  13.4M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  13.4M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 13.4M]
  |  |  ------------------
  ------------------
  153|  15.6M|    }
  154|  16.4M|}
pb_common.c:pb_const_cast:
  278|   243k|{
  279|       |    /* Note: this casts away const, in order to use the common field iterator
  280|       |     * logic for both encoding and decoding. The cast is done using union
  281|       |     * to avoid spurious compiler warnings. */
  282|   243k|    union {
  283|   243k|        void *p1;
  284|   243k|        const void *p2;
  285|   243k|    } t;
  286|   243k|    t.p2 = p;
  287|   243k|    return t.p1;
  288|   243k|}

pb_read:
   82|  2.65M|{
   83|  2.65M|    if (count == 0)
  ------------------
  |  Branch (83:9): [True: 953k, False: 1.70M]
  ------------------
   84|   953k|        return true;
   85|       |
   86|  1.70M|#ifndef PB_BUFFER_ONLY
   87|  1.70M|	if (buf == NULL && stream->callback != buf_read)
  ------------------
  |  Branch (87:6): [True: 113k, False: 1.59M]
  |  Branch (87:21): [True: 37.5k, False: 76.1k]
  ------------------
   88|  37.5k|	{
   89|       |		/* Skip input bytes */
   90|  37.5k|		pb_byte_t tmp[16];
   91|   199k|		while (count > 16)
  ------------------
  |  Branch (91:10): [True: 161k, False: 37.5k]
  ------------------
   92|   161k|		{
   93|   161k|			if (!pb_read(stream, tmp, 16))
  ------------------
  |  Branch (93:8): [True: 0, False: 161k]
  ------------------
   94|      0|				return false;
   95|       |			
   96|   161k|			count -= 16;
   97|   161k|		}
   98|       |		
   99|  37.5k|		return pb_read(stream, tmp, count);
  100|  37.5k|	}
  101|  1.66M|#endif
  102|       |
  103|  1.66M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (103:9): [True: 273, False: 1.66M]
  ------------------
  104|    273|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  923|    273|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|    273|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 273]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  105|       |    
  106|  1.66M|#ifndef PB_BUFFER_ONLY
  107|  1.66M|    if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (107:9): [True: 0, False: 1.66M]
  ------------------
  108|      0|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  109|       |#else
  110|       |    if (!buf_read(stream, buf, count))
  111|       |        return false;
  112|       |#endif
  113|       |    
  114|  1.66M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (114:9): [True: 0, False: 1.66M]
  ------------------
  115|      0|        stream->bytes_left = 0;
  116|  1.66M|    else
  117|  1.66M|        stream->bytes_left -= count;
  118|       |
  119|       |    return true;
  120|  1.66M|}
pb_istream_from_buffer:
  143|  13.8k|{
  144|  13.8k|    pb_istream_t stream;
  145|       |    /* Cast away the const from buf without a compiler error.  We are
  146|       |     * careful to use it only in a const manner in the callbacks.
  147|       |     */
  148|  13.8k|    union {
  149|  13.8k|        void *state;
  150|  13.8k|        const void *c_state;
  151|  13.8k|    } state;
  152|       |#ifdef PB_BUFFER_ONLY
  153|       |    stream.callback = NULL;
  154|       |#else
  155|  13.8k|    stream.callback = &buf_read;
  156|  13.8k|#endif
  157|  13.8k|    state.c_state = buf;
  158|  13.8k|    stream.state = state.state;
  159|  13.8k|    stream.bytes_left = msglen;
  160|  13.8k|#ifndef PB_NO_ERRMSG
  161|  13.8k|    stream.errmsg = NULL;
  162|  13.8k|#endif
  163|       |#ifdef PB_MESSAGE_NESTING_MAX
  164|       |    stream.depth = 0;
  165|       |#endif
  166|  13.8k|    return stream;
  167|  13.8k|}
pb_decode_varint32:
  175|  64.1M|{
  176|  64.1M|    pb_byte_t byte;
  177|  64.1M|    uint32_t result;
  178|       |    
  179|  64.1M|    if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (179:9): [True: 1.87k, False: 64.1M]
  ------------------
  180|  1.87k|    {
  181|  1.87k|        return false;
  182|  1.87k|    }
  183|       |    
  184|  64.1M|    if ((byte & 0x80) == 0)
  ------------------
  |  Branch (184:9): [True: 34.7M, False: 29.3M]
  ------------------
  185|  34.7M|    {
  186|       |        /* Quick case, 1 byte value */
  187|  34.7M|        result = byte;
  188|  34.7M|    }
  189|  29.3M|    else
  190|  29.3M|    {
  191|       |        /* Multibyte case */
  192|  29.3M|        uint_fast8_t bitpos = 7;
  193|  29.3M|        result = byte & 0x7F;
  194|       |        
  195|  29.3M|        do
  196|  29.4M|        {
  197|  29.4M|            if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (197:17): [True: 61, False: 29.4M]
  ------------------
  198|     61|                return false;
  199|       |            
  200|  29.4M|            if (bitpos >= 32)
  ------------------
  |  Branch (200:17): [True: 10.7k, False: 29.4M]
  ------------------
  201|  10.7k|            {
  202|       |                /* Note: The varint could have trailing 0x80 bytes, or 0xFF for negative. */
  203|  10.7k|                pb_byte_t sign_extension = (bitpos < 63) ? 0xFF : 0x01;
  ------------------
  |  Branch (203:44): [True: 10.6k, False: 115]
  ------------------
  204|  10.7k|                bool valid_extension = ((byte & 0x7F) == 0x00 ||
  ------------------
  |  Branch (204:41): [True: 6.00k, False: 4.78k]
  ------------------
  205|  4.78k|                         ((result >> 31) != 0 && byte == sign_extension));
  ------------------
  |  Branch (205:27): [True: 4.77k, False: 14]
  |  Branch (205:50): [True: 4.71k, False: 60]
  ------------------
  206|       |
  207|  10.7k|                if (bitpos >= 64 || !valid_extension)
  ------------------
  |  Branch (207:21): [True: 3, False: 10.7k]
  |  Branch (207:37): [True: 73, False: 10.7k]
  ------------------
  208|     76|                {
  209|     76|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  923|     76|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     76|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 76]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  210|     76|                }
  211|  10.7k|            }
  212|  29.4M|            else if (bitpos == 28)
  ------------------
  |  Branch (212:22): [True: 15.5k, False: 29.4M]
  ------------------
  213|  15.5k|            {
  214|  15.5k|                if ((byte & 0x70) != 0 && (byte & 0x78) != 0x78)
  ------------------
  |  Branch (214:21): [True: 10.9k, False: 4.60k]
  |  Branch (214:43): [True: 32, False: 10.9k]
  ------------------
  215|     32|                {
  216|     32|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  923|     32|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     32|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  217|     32|                }
  218|  15.5k|                result |= (uint32_t)(byte & 0x0F) << bitpos;
  219|  15.5k|            }
  220|  29.4M|            else
  221|  29.4M|            {
  222|  29.4M|                result |= (uint32_t)(byte & 0x7F) << bitpos;
  223|  29.4M|            }
  224|  29.4M|            bitpos = (uint_fast8_t)(bitpos + 7);
  225|  29.4M|        } while (byte & 0x80);
  ------------------
  |  Branch (225:18): [True: 150k, False: 29.3M]
  ------------------
  226|  29.3M|   }
  227|       |   
  228|  64.1M|   *dest = result;
  229|       |   return true;
  230|  64.1M|}
pb_decode_varint:
  234|  12.7M|{
  235|  12.7M|    pb_byte_t byte;
  236|  12.7M|    uint_fast8_t bitpos = 0;
  237|  12.7M|    uint64_t result = 0;
  238|       |    
  239|  12.7M|    do
  240|  22.7M|    {
  241|  22.7M|        if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (241:13): [True: 86, False: 22.7M]
  ------------------
  242|     86|            return false;
  243|       |
  244|  22.7M|        if (bitpos >= 63 && (byte & 0xFE) != 0)
  ------------------
  |  Branch (244:13): [True: 86.4k, False: 22.6M]
  |  Branch (244:29): [True: 33, False: 86.4k]
  ------------------
  245|     33|            PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  923|     33|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     33|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 33]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  246|       |
  247|  22.7M|        result |= (uint64_t)(byte & 0x7F) << bitpos;
  248|  22.7M|        bitpos = (uint_fast8_t)(bitpos + 7);
  249|  22.7M|    } while (byte & 0x80);
  ------------------
  |  Branch (249:14): [True: 9.95M, False: 12.7M]
  ------------------
  250|       |    
  251|  12.7M|    *dest = result;
  252|       |    return true;
  253|  12.7M|}
pb_decode_tag:
  282|  31.3M|{
  283|  31.3M|    uint32_t temp;
  284|  31.3M|    *eof = false;
  285|  31.3M|    *wire_type = (pb_wire_type_t) 0;
  286|  31.3M|    *tag = 0;
  287|       |
  288|  31.3M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (288:9): [True: 194k, False: 31.1M]
  ------------------
  289|   194k|    {
  290|   194k|        *eof = true;
  291|   194k|        return false;
  292|   194k|    }
  293|       |
  294|  31.1M|    if (!pb_decode_varint32(stream, &temp))
  ------------------
  |  Branch (294:9): [True: 1.75k, False: 31.1M]
  ------------------
  295|  1.75k|    {
  296|  1.75k|#ifndef PB_BUFFER_ONLY
  297|       |        /* Workaround for issue #1017
  298|       |         *
  299|       |         * Callback streams don't set bytes_left to 0 on eof until after being called by pb_decode_varint32,
  300|       |         * which results in "io error" being raised. This contrasts the behavior of buffer streams who raise
  301|       |         * no error on eof as bytes_left is already 0 on entry. This causes legitimate errors (e.g. missing
  302|       |         * required fields) to be incorrectly reported by callback streams.
  303|       |         */
  304|  1.75k|        if (stream->callback != buf_read && stream->bytes_left == 0)
  ------------------
  |  Branch (304:13): [True: 1.64k, False: 114]
  |  Branch (304:45): [True: 1.64k, False: 0]
  ------------------
  305|  1.64k|        {
  306|  1.64k|#ifndef PB_NO_ERRMSG
  307|  1.64k|            if (strcmp(stream->errmsg, "io error") == 0)
  ------------------
  |  Branch (307:17): [True: 1.64k, False: 0]
  ------------------
  308|  1.64k|                stream->errmsg = NULL;
  309|  1.64k|#endif
  310|  1.64k|            *eof = true;
  311|  1.64k|        }
  312|  1.75k|#endif
  313|  1.75k|        return false;
  314|  1.75k|    }
  315|       |    
  316|  31.1M|    *tag = temp >> 3;
  317|  31.1M|    *wire_type = (pb_wire_type_t)(temp & 7);
  318|       |    return true;
  319|  31.1M|}
pb_skip_field:
  322|   324k|{
  323|   324k|    switch (wire_type)
  324|   324k|    {
  325|   151k|        case PB_WT_VARINT: return pb_skip_varint(stream);
  ------------------
  |  Branch (325:9): [True: 151k, False: 172k]
  ------------------
  326|  11.8k|        case PB_WT_64BIT: return pb_read(stream, NULL, 8);
  ------------------
  |  Branch (326:9): [True: 11.8k, False: 312k]
  ------------------
  327|   106k|        case PB_WT_STRING: return pb_skip_string(stream);
  ------------------
  |  Branch (327:9): [True: 106k, False: 217k]
  ------------------
  328|  54.0k|        case PB_WT_32BIT: return pb_read(stream, NULL, 4);
  ------------------
  |  Branch (328:9): [True: 54.0k, False: 270k]
  ------------------
  329|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (329:2): [True: 0, False: 324k]
  ------------------
  330|       |            /* Calling pb_skip_field with a PB_WT_PACKED is an error.
  331|       |             * Explicitly handle this case and fallthrough to default to avoid
  332|       |             * compiler warnings.
  333|       |             */
  334|     79|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  923|     79|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     79|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 79]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (334:9): [True: 79, False: 324k]
  ------------------
  335|   324k|    }
  336|   324k|}
pb_make_string_substream:
  387|   314k|{
  388|   314k|    uint32_t size;
  389|   314k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (389:9): [True: 127, False: 314k]
  ------------------
  390|    127|        return false;
  391|       |    
  392|   314k|    *substream = *stream;
  393|   314k|    if (substream->bytes_left < size)
  ------------------
  |  Branch (393:9): [True: 120, False: 314k]
  ------------------
  394|    120|        PB_RETURN_ERROR(stream, "parent stream too short");
  ------------------
  |  |  923|    120|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|    120|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 120]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  395|       |    
  396|       |#ifdef PB_MESSAGE_NESTING_MAX
  397|       |    substream->depth++;
  398|       |    if (substream->depth > PB_MESSAGE_NESTING_MAX)
  399|       |        PB_RETURN_ERROR(stream, "max depth");
  400|       |#endif
  401|       |
  402|   314k|    substream->bytes_left = (size_t)size;
  403|   314k|    stream->bytes_left -= (size_t)size;
  404|       |    return true;
  405|   314k|}
pb_close_string_substream:
  408|   314k|{
  409|   314k|    if (substream->bytes_left) {
  ------------------
  |  Branch (409:9): [True: 671, False: 313k]
  ------------------
  410|    671|        if (!pb_read(substream, NULL, substream->bytes_left))
  ------------------
  |  Branch (410:13): [True: 0, False: 671]
  ------------------
  411|      0|            return false;
  412|    671|    }
  413|       |
  414|   314k|    stream->state = substream->state;
  415|       |
  416|   314k|#ifndef PB_NO_ERRMSG
  417|   314k|    stream->errmsg = substream->errmsg;
  418|   314k|#endif
  419|       |    return true;
  420|   314k|}
pb_decode_ex:
 1220|  8.65k|{
 1221|  8.65k|    bool status;
 1222|       |
 1223|  8.65k|    if ((flags & PB_DECODE_DELIMITED) == 0)
  ------------------
  |  |  123|  8.65k|#define PB_DECODE_DELIMITED       0x02U
  ------------------
  |  Branch (1223:9): [True: 8.65k, False: 0]
  ------------------
 1224|  8.65k|    {
 1225|  8.65k|      status = pb_decode_inner(stream, fields, dest_struct, flags);
 1226|  8.65k|    }
 1227|      0|    else
 1228|      0|    {
 1229|      0|      pb_istream_t substream;
 1230|      0|      if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1230:11): [True: 0, False: 0]
  ------------------
 1231|      0|        return false;
 1232|       |
 1233|      0|      status = pb_decode_inner(&substream, fields, dest_struct, flags);
 1234|       |
 1235|      0|      if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1235:11): [True: 0, False: 0]
  ------------------
 1236|      0|        status = false;
 1237|      0|    }
 1238|       |    
 1239|  8.65k|#ifdef PB_ENABLE_MALLOC
 1240|  8.65k|    if (!status)
  ------------------
  |  Branch (1240:9): [True: 2.31k, False: 6.34k]
  ------------------
 1241|  2.31k|        pb_release(fields, dest_struct);
 1242|  8.65k|#endif
 1243|       |    
 1244|  8.65k|    return status;
 1245|  8.65k|}
pb_decode:
 1248|  3.05k|{
 1249|  3.05k|    return pb_decode_ex(stream, fields, dest_struct, 0);
 1250|  3.05k|}
pb_release:
 1377|   198k|{
 1378|   198k|    pb_field_iter_t iter;
 1379|       |    
 1380|   198k|    if (!dest_struct)
  ------------------
  |  Branch (1380:9): [True: 0, False: 198k]
  ------------------
 1381|      0|        return; /* Ignore NULL pointers, similar to free() */
 1382|       |
 1383|   198k|    if (!pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1383:9): [True: 65.6k, False: 133k]
  ------------------
 1384|  65.6k|        return; /* Empty message type */
 1385|       |    
 1386|   133k|    do
 1387|  1.11M|    {
 1388|  1.11M|        pb_release_single_field(&iter);
 1389|  1.11M|    } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (1389:14): [True: 981k, False: 133k]
  ------------------
 1390|   133k|}
pb_decode_bool:
 1403|  3.87M|{
 1404|  3.87M|    uint32_t value;
 1405|  3.87M|    if (!pb_decode_varint32(stream, &value))
  ------------------
  |  Branch (1405:9): [True: 59, False: 3.87M]
  ------------------
 1406|     59|        return false;
 1407|       |
 1408|  3.87M|    *(bool*)dest = (value != 0);
 1409|       |    return true;
 1410|  3.87M|}
pb_decode_svarint:
 1413|  4.99M|{
 1414|  4.99M|    pb_uint64_t value;
  ------------------
  |  |   57|  4.99M|#define pb_uint64_t uint64_t
  ------------------
 1415|  4.99M|    if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1415:9): [True: 40, False: 4.99M]
  ------------------
 1416|     40|        return false;
 1417|       |    
 1418|  4.99M|    if (value & 1)
  ------------------
  |  Branch (1418:9): [True: 672k, False: 4.32M]
  ------------------
 1419|   672k|        *dest = (pb_int64_t)(~(value >> 1));
 1420|  4.32M|    else
 1421|  4.32M|        *dest = (pb_int64_t)(value >> 1);
 1422|       |    
 1423|       |    return true;
 1424|  4.99M|}
pb_decode_fixed32:
 1427|  88.4k|{
 1428|  88.4k|    union {
 1429|  88.4k|        uint32_t fixed32;
 1430|  88.4k|        pb_byte_t bytes[4];
 1431|  88.4k|    } u;
 1432|       |
 1433|  88.4k|    if (!pb_read(stream, u.bytes, 4))
  ------------------
  |  Branch (1433:9): [True: 19, False: 88.4k]
  ------------------
 1434|     19|        return false;
 1435|       |
 1436|  88.4k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1437|       |    /* fast path - if we know that we're on little endian, assign directly */
 1438|  88.4k|    *(uint32_t*)dest = u.fixed32;
 1439|       |#else
 1440|       |    *(uint32_t*)dest = ((uint32_t)u.bytes[0] << 0) |
 1441|       |                       ((uint32_t)u.bytes[1] << 8) |
 1442|       |                       ((uint32_t)u.bytes[2] << 16) |
 1443|       |                       ((uint32_t)u.bytes[3] << 24);
 1444|       |#endif
 1445|       |    return true;
 1446|  88.4k|}
pb_decode_fixed64:
 1450|  63.4k|{
 1451|  63.4k|    union {
 1452|  63.4k|        uint64_t fixed64;
 1453|  63.4k|        pb_byte_t bytes[8];
 1454|  63.4k|    } u;
 1455|       |
 1456|  63.4k|    if (!pb_read(stream, u.bytes, 8))
  ------------------
  |  Branch (1456:9): [True: 21, False: 63.4k]
  ------------------
 1457|     21|        return false;
 1458|       |
 1459|  63.4k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1460|       |    /* fast path - if we know that we're on little endian, assign directly */
 1461|  63.4k|    *(uint64_t*)dest = u.fixed64;
 1462|       |#else
 1463|       |    *(uint64_t*)dest = ((uint64_t)u.bytes[0] << 0) |
 1464|       |                       ((uint64_t)u.bytes[1] << 8) |
 1465|       |                       ((uint64_t)u.bytes[2] << 16) |
 1466|       |                       ((uint64_t)u.bytes[3] << 24) |
 1467|       |                       ((uint64_t)u.bytes[4] << 32) |
 1468|       |                       ((uint64_t)u.bytes[5] << 40) |
 1469|       |                       ((uint64_t)u.bytes[6] << 48) |
 1470|       |                       ((uint64_t)u.bytes[7] << 56);
 1471|       |#endif
 1472|       |    return true;
 1473|  63.4k|}
pb_decode.c:buf_read:
   69|  82.5M|{
   70|  82.5M|    const pb_byte_t *source = (const pb_byte_t*)stream->state;
   71|  82.5M|    stream->state = (pb_byte_t*)stream->state + count;
   72|       |    
   73|  82.5M|    if (buf != NULL)
  ------------------
  |  Branch (73:9): [True: 82.4M, False: 76.0k]
  ------------------
   74|  82.4M|    {
   75|  82.4M|        memcpy(buf, source, count * sizeof(pb_byte_t));
   76|  82.4M|    }
   77|       |    
   78|       |    return true;
   79|  82.5M|}
pb_decode.c:pb_readbyte:
  125|   116M|{
  126|   116M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (126:9): [True: 382, False: 116M]
  ------------------
  127|    382|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  923|    382|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|    382|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 382]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  128|       |
  129|   116M|#ifndef PB_BUFFER_ONLY
  130|   116M|    if (!stream->callback(stream, buf, 1))
  ------------------
  |  Branch (130:9): [True: 1.64k, False: 116M]
  ------------------
  131|  1.64k|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  923|  1.64k|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|  1.64k|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 1.64k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  132|       |#else
  133|       |    *buf = *(const pb_byte_t*)stream->state;
  134|       |    stream->state = (pb_byte_t*)stream->state + 1;
  135|       |#endif
  136|       |
  137|   116M|    stream->bytes_left--;
  138|       |    
  139|       |    return true;    
  140|   116M|}
pb_decode.c:pb_skip_varint:
  257|   151k|{
  258|   151k|    pb_byte_t byte;
  259|   151k|    do
  260|   173k|    {
  261|   173k|        if (!pb_read(stream, &byte, 1))
  ------------------
  |  Branch (261:13): [True: 75, False: 173k]
  ------------------
  262|     75|            return false;
  263|   173k|    } while (byte & 0x80);
  ------------------
  |  Branch (263:14): [True: 22.2k, False: 151k]
  ------------------
  264|   151k|    return true;
  265|   151k|}
pb_decode.c:pb_skip_string:
  268|   106k|{
  269|   106k|    uint32_t length;
  270|   106k|    if (!pb_decode_varint32(stream, &length))
  ------------------
  |  Branch (270:9): [True: 53, False: 106k]
  ------------------
  271|     53|        return false;
  272|       |    
  273|   106k|    if ((size_t)length != length)
  ------------------
  |  Branch (273:9): [True: 0, False: 106k]
  ------------------
  274|      0|    {
  275|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  276|      0|    }
  277|       |
  278|   106k|    return pb_read(stream, NULL, (size_t)length);
  279|   106k|}
pb_decode.c:pb_decode_inner:
 1049|   198k|{
 1050|       |    /* If the message contains extension fields, the extension handlers
 1051|       |     * are called when tag number is >= extension_range_start. This precheck
 1052|       |     * is just for speed, and the handlers will check for precise match.
 1053|       |     */
 1054|   198k|    uint32_t extension_range_start = 0;
 1055|   198k|    pb_extension_t *extensions = NULL;
 1056|       |
 1057|       |    /* 'fixed_count_field' and 'fixed_count_size' track position of a repeated fixed
 1058|       |     * count field. This can only handle _one_ repeated fixed count field that
 1059|       |     * is unpacked and unordered among other (non repeated fixed count) fields.
 1060|       |     */
 1061|   198k|    pb_size_t fixed_count_field = PB_SIZE_MAX;
  ------------------
  |  |  342|   198k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
 1062|   198k|    pb_size_t fixed_count_size = 0;
 1063|   198k|    pb_size_t fixed_count_total_size = 0;
 1064|       |
 1065|       |    /* Tag and wire type of next field from the input stream */
 1066|   198k|    uint32_t tag;
 1067|   198k|    pb_wire_type_t wire_type;
 1068|   198k|    bool eof;
 1069|       |
 1070|       |    /* Track presence of required fields */
 1071|   198k|    pb_fields_seen_t fields_seen = {{0, 0}};
 1072|   198k|    const uint32_t allbits = ~(uint32_t)0;
 1073|       |
 1074|       |    /* Descriptor for the structure field matching the tag decoded from stream */
 1075|   198k|    pb_field_iter_t iter;
 1076|       |
 1077|   198k|    if (pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1077:9): [True: 132k, False: 65.5k]
  ------------------
 1078|   132k|    {
 1079|   132k|        if ((flags & PB_DECODE_NOINIT) == 0)
  ------------------
  |  |  122|   132k|#define PB_DECODE_NOINIT          0x01U
  ------------------
  |  Branch (1079:13): [True: 123k, False: 9.14k]
  ------------------
 1080|   123k|        {
 1081|   123k|            if (!pb_message_set_to_defaults(&iter))
  ------------------
  |  Branch (1081:17): [True: 0, False: 123k]
  ------------------
 1082|      0|                PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1083|   123k|        }
 1084|   132k|    }
 1085|       |
 1086|  31.3M|    while (pb_decode_tag(stream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1086:12): [True: 31.1M, False: 196k]
  ------------------
 1087|  31.1M|    {
 1088|  31.1M|        if (tag == 0)
  ------------------
  |  Branch (1088:13): [True: 88, False: 31.1M]
  ------------------
 1089|     88|        {
 1090|     88|          if (flags & PB_DECODE_NULLTERMINATED)
  ------------------
  |  |  124|     88|#define PB_DECODE_NULLTERMINATED  0x04U
  ------------------
  |  Branch (1090:15): [True: 0, False: 88]
  ------------------
 1091|      0|          {
 1092|      0|            eof = true;
 1093|      0|            break;
 1094|      0|          }
 1095|     88|          else
 1096|     88|          {
 1097|     88|            PB_RETURN_ERROR(stream, "zero tag");
  ------------------
  |  |  923|     88|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     88|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 88]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1098|     88|          }
 1099|     88|        }
 1100|       |
 1101|  31.1M|        if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  30.7M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  30.7M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  30.7M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1101:13): [True: 328k, False: 30.7M]
  |  Branch (1101:48): [True: 896, False: 30.7M]
  ------------------
 1102|   329k|        {
 1103|       |            /* No match found, check if it matches an extension. */
 1104|   329k|            if (extension_range_start == 0)
  ------------------
  |  Branch (1104:17): [True: 12.3k, False: 316k]
  ------------------
 1105|  12.3k|            {
 1106|  12.3k|                if (pb_field_iter_find_extension(&iter))
  ------------------
  |  Branch (1106:21): [True: 4.13k, False: 8.20k]
  ------------------
 1107|  4.13k|                {
 1108|  4.13k|                    extensions = *(pb_extension_t* const *)iter.pData;
 1109|  4.13k|                    extension_range_start = iter.tag;
 1110|  4.13k|                }
 1111|       |
 1112|  12.3k|                if (!extensions)
  ------------------
  |  Branch (1112:21): [True: 8.92k, False: 3.41k]
  ------------------
 1113|  8.92k|                {
 1114|  8.92k|                    extension_range_start = (uint32_t)-1;
 1115|  8.92k|                }
 1116|  12.3k|            }
 1117|       |
 1118|   329k|            if (tag >= extension_range_start)
  ------------------
  |  Branch (1118:17): [True: 98.3k, False: 230k]
  ------------------
 1119|  98.3k|            {
 1120|  98.3k|                size_t pos = stream->bytes_left;
 1121|       |
 1122|  98.3k|                if (!decode_extension(stream, tag, wire_type, extensions))
  ------------------
  |  Branch (1122:21): [True: 116, False: 98.1k]
  ------------------
 1123|    116|                    return false;
 1124|       |
 1125|  98.1k|                if (pos != stream->bytes_left)
  ------------------
  |  Branch (1125:21): [True: 4.68k, False: 93.4k]
  ------------------
 1126|  4.68k|                {
 1127|       |                    /* The field was handled */
 1128|  4.68k|                    continue;
 1129|  4.68k|                }
 1130|  98.1k|            }
 1131|       |
 1132|       |            /* No match found, skip data */
 1133|   324k|            if (!pb_skip_field(stream, wire_type))
  ------------------
  |  Branch (1133:17): [True: 314, False: 324k]
  ------------------
 1134|    314|                return false;
 1135|   324k|            continue;
 1136|   324k|        }
 1137|       |
 1138|       |        /* If a repeated fixed count field was found, get size from
 1139|       |         * 'fixed_count_field' as there is no counter contained in the struct.
 1140|       |         */
 1141|  30.7M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  327|  30.7M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  30.7M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  314|  61.5M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1141:13): [True: 28.7M, False: 1.98M]
  |  Branch (1141:57): [True: 1.28k, False: 28.7M]
  ------------------
 1142|  1.28k|        {
 1143|  1.28k|            if (fixed_count_field != iter.index) {
  ------------------
  |  Branch (1143:17): [True: 943, False: 342]
  ------------------
 1144|       |                /* If the new fixed count field does not match the previous one,
 1145|       |                 * check that the previous one is NULL or that it finished
 1146|       |                 * receiving all the expected data.
 1147|       |                 */
 1148|    943|                if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  342|  1.88k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1148:21): [True: 391, False: 552]
  ------------------
 1149|    391|                    fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1149:21): [True: 34, False: 357]
  ------------------
 1150|     34|                {
 1151|     34|                    PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  923|     34|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     34|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 34]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1152|     34|                }
 1153|       |
 1154|    909|                fixed_count_field = iter.index;
 1155|    909|                fixed_count_size = 0;
 1156|    909|                fixed_count_total_size = iter.array_size;
 1157|    909|            }
 1158|       |
 1159|  1.25k|            iter.pSize = &fixed_count_size;
 1160|  1.25k|        }
 1161|       |
 1162|  30.7M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  327|  30.7M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  30.7M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  311|  61.5M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (1162:13): [True: 1.93M, False: 28.8M]
  ------------------
 1163|  1.93M|            && iter.required_field_index < PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  233|  1.93M|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1163:16): [True: 1.93M, False: 0]
  ------------------
 1164|  1.93M|        {
 1165|  1.93M|            uint32_t tmp = ((uint32_t)1 << (iter.required_field_index & 31));
 1166|  1.93M|            fields_seen.bitfield[iter.required_field_index >> 5] |= tmp;
 1167|  1.93M|        }
 1168|       |
 1169|  30.7M|        if (!decode_field(stream, wire_type, &iter))
  ------------------
  |  Branch (1169:13): [True: 1.46k, False: 30.7M]
  ------------------
 1170|  1.46k|            return false;
 1171|  30.7M|    }
 1172|       |
 1173|   196k|    if (!eof)
  ------------------
  |  Branch (1173:9): [True: 114, False: 196k]
  ------------------
 1174|    114|    {
 1175|       |        /* pb_decode_tag() returned error before end of stream */
 1176|    114|        return false;
 1177|    114|    }
 1178|       |
 1179|       |    /* Check that all elements of the last decoded fixed count field were present. */
 1180|   196k|    if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  342|   392k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1180:9): [True: 462, False: 195k]
  ------------------
 1181|    462|        fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1181:9): [True: 42, False: 420]
  ------------------
 1182|     42|    {
 1183|     42|        PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  923|     42|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     42|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 42]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1184|     42|    }
 1185|       |
 1186|       |    /* Check that all required fields were present. */
 1187|   196k|    {
 1188|   196k|        pb_size_t req_field_count = iter.descriptor->required_field_count;
 1189|       |
 1190|   196k|        if (req_field_count > 0)
  ------------------
  |  Branch (1190:13): [True: 124k, False: 71.3k]
  ------------------
 1191|   124k|        {
 1192|   124k|            pb_size_t i;
 1193|       |
 1194|   124k|            if (req_field_count > PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  233|   124k|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1194:17): [True: 0, False: 124k]
  ------------------
 1195|      0|                req_field_count = PB_MAX_REQUIRED_FIELDS;
  ------------------
  |  |  233|      0|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
 1196|       |
 1197|       |            /* Check the whole words */
 1198|   124k|            for (i = 0; i < (req_field_count >> 5); i++)
  ------------------
  |  Branch (1198:25): [True: 0, False: 124k]
  ------------------
 1199|      0|            {
 1200|      0|                if (fields_seen.bitfield[i] != allbits)
  ------------------
  |  Branch (1200:21): [True: 0, False: 0]
  ------------------
 1201|      0|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1202|      0|            }
 1203|       |
 1204|       |            /* Check the remaining bits (if any) */
 1205|   124k|            if ((req_field_count & 31) != 0)
  ------------------
  |  Branch (1205:17): [True: 124k, False: 0]
  ------------------
 1206|   124k|            {
 1207|   124k|                if (fields_seen.bitfield[req_field_count >> 5] !=
  ------------------
  |  Branch (1207:21): [True: 499, False: 124k]
  ------------------
 1208|   124k|                    (allbits >> (uint_least8_t)(32 - (req_field_count & 31))))
 1209|    499|                {
 1210|    499|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  923|    499|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|    499|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 499]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1211|    499|                }
 1212|   124k|            }
 1213|   124k|        }
 1214|   196k|    }
 1215|       |
 1216|   195k|    return true;
 1217|   196k|}
pb_decode.c:pb_message_set_to_defaults:
 1010|   130k|{
 1011|   130k|    pb_istream_t defstream = PB_ISTREAM_EMPTY;
  ------------------
  |  |   71|   130k|#  define PB_ISTREAM_EMPTY {0,0,0,0}
  ------------------
 1012|   130k|    uint32_t tag = 0;
 1013|   130k|    pb_wire_type_t wire_type = PB_WT_VARINT;
 1014|   130k|    bool eof;
 1015|       |
 1016|   130k|    if (iter->descriptor->default_value)
  ------------------
  |  Branch (1016:9): [True: 0, False: 130k]
  ------------------
 1017|      0|    {
 1018|      0|        defstream = pb_istream_from_buffer(iter->descriptor->default_value, (size_t)-1);
 1019|      0|        if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1019:13): [True: 0, False: 0]
  ------------------
 1020|      0|            return false;
 1021|      0|    }
 1022|       |
 1023|   130k|    do
 1024|  1.09M|    {
 1025|  1.09M|        if (!pb_field_set_to_default(iter))
  ------------------
  |  Branch (1025:13): [True: 0, False: 1.09M]
  ------------------
 1026|      0|            return false;
 1027|       |
 1028|  1.09M|        if (tag != 0 && iter->tag == tag)
  ------------------
  |  Branch (1028:13): [True: 0, False: 1.09M]
  |  Branch (1028:25): [True: 0, False: 0]
  ------------------
 1029|      0|        {
 1030|       |            /* We have a default value for this field in the defstream */
 1031|      0|            if (!decode_field(&defstream, wire_type, iter))
  ------------------
  |  Branch (1031:17): [True: 0, False: 0]
  ------------------
 1032|      0|                return false;
 1033|      0|            if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1033:17): [True: 0, False: 0]
  ------------------
 1034|      0|                return false;
 1035|       |
 1036|      0|            if (iter->pSize)
  ------------------
  |  Branch (1036:17): [True: 0, False: 0]
  ------------------
 1037|      0|                *(bool*)iter->pSize = false;
 1038|      0|        }
 1039|  1.09M|    } while (pb_field_iter_next(iter));
  ------------------
  |  Branch (1039:14): [True: 962k, False: 130k]
  ------------------
 1040|       |
 1041|   130k|    return true;
 1042|   130k|}
pb_decode.c:pb_field_set_to_default:
  928|  1.09M|{
  929|  1.09M|    pb_type_t type;
  930|  1.09M|    type = field->type;
  931|       |
  932|  1.09M|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  1.09M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.09M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  1.09M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (932:9): [True: 8.65k, False: 1.08M]
  ------------------
  933|  8.65k|    {
  934|  8.65k|        pb_extension_t *ext = *(pb_extension_t* const *)field->pData;
  935|  15.6k|        while (ext != NULL)
  ------------------
  |  Branch (935:16): [True: 7.01k, False: 8.65k]
  ------------------
  936|  7.01k|        {
  937|  7.01k|            pb_field_iter_t ext_iter;
  938|  7.01k|            if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (938:17): [True: 7.01k, False: 0]
  ------------------
  939|  7.01k|            {
  940|  7.01k|                ext->found = false;
  941|  7.01k|                if (!pb_message_set_to_defaults(&ext_iter))
  ------------------
  |  Branch (941:21): [True: 0, False: 7.01k]
  ------------------
  942|      0|                    return false;
  943|  7.01k|            }
  944|  7.01k|            ext = ext->next;
  945|  7.01k|        }
  946|  8.65k|    }
  947|  1.08M|    else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  326|  1.08M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  1.08M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  321|  1.08M|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (947:14): [True: 32.9k, False: 1.05M]
  ------------------
  948|  32.9k|    {
  949|  32.9k|        bool init_data = true;
  950|  32.9k|        if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  327|  32.9k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  32.9k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  312|  65.9k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (950:13): [True: 0, False: 32.9k]
  |  Branch (950:52): [True: 0, False: 0]
  ------------------
  951|      0|        {
  952|       |            /* Set has_field to false. Still initialize the optional field
  953|       |             * itself also. */
  954|      0|            *(bool*)field->pSize = false;
  955|      0|        }
  956|  32.9k|        else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  327|  32.9k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  32.9k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  314|  65.9k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (956:18): [True: 0, False: 32.9k]
  ------------------
  957|  32.9k|                 PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  32.9k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  32.9k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                               PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  32.9k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (957:18): [True: 25.9k, False: 7.01k]
  ------------------
  958|  25.9k|        {
  959|       |            /* REPEATED: Set array count to 0, no need to initialize contents.
  960|       |               ONEOF: Set which_field to 0. */
  961|  25.9k|            *(pb_size_t*)field->pSize = 0;
  962|  25.9k|            init_data = false;
  963|  25.9k|        }
  964|       |
  965|  32.9k|        if (init_data)
  ------------------
  |  Branch (965:13): [True: 7.01k, False: 25.9k]
  ------------------
  966|  7.01k|        {
  967|  7.01k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  329|  14.0k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  7.01k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  7.01k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  14.0k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 7.01k, False: 0]
  |  |  ------------------
  |  |  330|  14.0k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|      0|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  968|  7.01k|                (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (968:18): [True: 0, False: 7.01k]
  ------------------
  969|  7.01k|                 field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (969:18): [True: 0, False: 7.01k]
  ------------------
  970|  7.01k|                 field->submsg_desc->submsg_info[0] != NULL))
  ------------------
  |  Branch (970:18): [True: 0, False: 7.01k]
  ------------------
  971|      0|            {
  972|       |                /* Initialize submessage to defaults.
  973|       |                 * Only needed if it has default values
  974|       |                 * or callback/submessage fields. */
  975|      0|                pb_field_iter_t submsg_iter;
  976|      0|                if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (976:21): [True: 0, False: 0]
  ------------------
  977|      0|                {
  978|      0|                    if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (978:25): [True: 0, False: 0]
  ------------------
  979|      0|                        return false;
  980|      0|                }
  981|      0|            }
  982|  7.01k|            else
  983|  7.01k|            {
  984|       |                /* Initialize to zeros */
  985|  7.01k|                memset(field->pData, 0, (size_t)field->data_size);
  986|  7.01k|            }
  987|  7.01k|        }
  988|  32.9k|    }
  989|  1.05M|    else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  1.05M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  1.05M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  1.05M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (989:14): [True: 1.03M, False: 17.3k]
  ------------------
  990|  1.03M|    {
  991|       |        /* Initialize the pointer to NULL. */
  992|  1.03M|        *(void**)field->pField = NULL;
  993|       |
  994|       |        /* Initialize array count to 0. */
  995|  1.03M|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  327|  1.03M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  1.03M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  314|  2.06M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (995:13): [True: 181k, False: 852k]
  ------------------
  996|   852k|            PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|   852k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   852k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|   852k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (996:13): [True: 17.3k, False: 835k]
  ------------------
  997|   199k|        {
  998|   199k|            *(pb_size_t*)field->pSize = 0;
  999|   199k|        }
 1000|  1.03M|    }
 1001|  17.3k|    else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  326|  17.3k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  17.3k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|  17.3k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (1001:14): [True: 17.3k, False: 0]
  ------------------
 1002|  17.3k|    {
 1003|       |        /* Don't overwrite callback */
 1004|  17.3k|    }
 1005|       |
 1006|  1.09M|    return true;
 1007|  1.09M|}
pb_decode.c:decode_extension:
  906|  98.3k|{
  907|  98.3k|    size_t pos = stream->bytes_left;
  908|       |    
  909|   196k|    while (extension != NULL && pos == stream->bytes_left)
  ------------------
  |  Branch (909:12): [True: 98.3k, False: 98.1k]
  |  Branch (909:33): [True: 98.3k, False: 0]
  ------------------
  910|  98.3k|    {
  911|  98.3k|        bool status;
  912|  98.3k|        if (extension->type->decode)
  ------------------
  |  Branch (912:13): [True: 0, False: 98.3k]
  ------------------
  913|      0|            status = extension->type->decode(stream, extension, tag, wire_type);
  914|  98.3k|        else
  915|  98.3k|            status = default_extension_decoder(stream, extension, tag, wire_type);
  916|       |
  917|  98.3k|        if (!status)
  ------------------
  |  Branch (917:13): [True: 116, False: 98.1k]
  ------------------
  918|    116|            return false;
  919|       |        
  920|  98.1k|        extension = extension->next;
  921|  98.1k|    }
  922|       |    
  923|  98.1k|    return true;
  924|  98.3k|}
pb_decode.c:default_extension_decoder:
  889|  98.3k|{
  890|  98.3k|    pb_field_iter_t iter;
  891|       |
  892|  98.3k|    if (!pb_field_iter_begin_extension(&iter, extension))
  ------------------
  |  Branch (892:9): [True: 0, False: 98.3k]
  ------------------
  893|      0|        PB_RETURN_ERROR(stream, "invalid extension");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  894|       |
  895|  98.3k|    if (iter.tag != tag || !iter.message)
  ------------------
  |  Branch (895:9): [True: 93.4k, False: 4.80k]
  |  Branch (895:28): [True: 0, False: 4.80k]
  ------------------
  896|  93.4k|        return true;
  897|       |
  898|  4.80k|    extension->found = true;
  899|  4.80k|    return decode_field(stream, wire_type, &iter);
  900|  98.3k|}
pb_decode.c:decode_field:
  857|  30.7M|{
  858|  30.7M|#ifdef PB_ENABLE_MALLOC
  859|       |    /* When decoding an oneof field, check if there is old data that must be
  860|       |     * released first. */
  861|  30.7M|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  30.7M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  30.7M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  30.7M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (861:9): [True: 29.3k, False: 30.7M]
  ------------------
  862|  29.3k|    {
  863|  29.3k|        if (!pb_release_union_field(stream, field))
  ------------------
  |  Branch (863:13): [True: 0, False: 29.3k]
  ------------------
  864|      0|            return false;
  865|  29.3k|    }
  866|  30.7M|#endif
  867|       |
  868|  30.7M|    switch (PB_ATYPE(field->type))
  ------------------
  |  |  326|  30.7M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  30.7M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
  869|  30.7M|    {
  870|  12.1k|        case PB_ATYPE_STATIC:
  ------------------
  |  |  321|  12.1k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (870:9): [True: 12.1k, False: 30.7M]
  ------------------
  871|  12.1k|            return decode_static_field(stream, wire_type, field);
  872|       |        
  873|  30.7M|        case PB_ATYPE_POINTER:
  ------------------
  |  |  322|  30.7M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (873:9): [True: 30.7M, False: 21.0k]
  ------------------
  874|  30.7M|            return decode_pointer_field(stream, wire_type, field);
  875|       |        
  876|  8.98k|        case PB_ATYPE_CALLBACK:
  ------------------
  |  |  323|  8.98k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (876:9): [True: 8.98k, False: 30.7M]
  ------------------
  877|  8.98k|            return decode_callback_field(stream, wire_type, field);
  878|       |        
  879|      0|        default:
  ------------------
  |  Branch (879:9): [True: 0, False: 30.7M]
  ------------------
  880|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  881|  30.7M|    }
  882|  30.7M|}
pb_decode.c:pb_release_union_field:
 1256|  29.3k|{
 1257|  29.3k|    pb_field_iter_t old_field = *field;
 1258|  29.3k|    pb_size_t old_tag = *(pb_size_t*)field->pSize; /* Previous which_ value */
 1259|  29.3k|    pb_size_t new_tag = field->tag; /* New which_ value */
 1260|       |
 1261|  29.3k|    if (old_tag == 0)
  ------------------
  |  Branch (1261:9): [True: 1.72k, False: 27.6k]
  ------------------
 1262|  1.72k|        return true; /* Ok, no old data in union */
 1263|       |
 1264|  27.6k|    if (old_tag == new_tag)
  ------------------
  |  Branch (1264:9): [True: 18.9k, False: 8.64k]
  ------------------
 1265|  18.9k|        return true; /* Ok, old data is of same type => merge */
 1266|       |
 1267|       |    /* Release old data. The find can fail if the message struct contains
 1268|       |     * invalid data. */
 1269|  8.64k|    if (!pb_field_iter_find(&old_field, old_tag))
  ------------------
  |  Branch (1269:9): [True: 0, False: 8.64k]
  ------------------
 1270|      0|        PB_RETURN_ERROR(stream, "invalid union tag");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1271|       |
 1272|  8.64k|    pb_release_single_field(&old_field);
 1273|       |
 1274|  8.64k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  8.64k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  8.64k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  8.64k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1274:9): [True: 4.32k, False: 4.32k]
  ------------------
 1275|  4.32k|    {
 1276|       |        /* Initialize the pointer to NULL to make sure it is valid
 1277|       |         * even in case of error return. */
 1278|  4.32k|        *(void**)field->pField = NULL;
 1279|  4.32k|        field->pData = NULL;
 1280|  4.32k|    }
 1281|       |
 1282|       |    return true;
 1283|  8.64k|}
pb_decode.c:decode_static_field:
  498|  12.1k|{
  499|  12.1k|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  327|  12.1k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  12.1k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  500|  12.1k|    {
  501|  4.80k|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  311|  4.80k|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (501:9): [True: 4.80k, False: 7.30k]
  ------------------
  502|  4.80k|            return decode_basic_field(stream, wire_type, field);
  503|       |            
  504|  1.67k|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  312|  1.67k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (504:9): [True: 1.67k, False: 10.4k]
  ------------------
  505|  1.67k|            if (field->pSize != NULL)
  ------------------
  |  Branch (505:17): [True: 1.67k, False: 0]
  ------------------
  506|  1.67k|                *(bool*)field->pSize = true;
  507|  1.67k|            return decode_basic_field(stream, wire_type, field);
  508|       |    
  509|      0|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  314|      0|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (509:9): [True: 0, False: 12.1k]
  ------------------
  510|      0|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (510:17): [True: 0, False: 0]
  ------------------
  511|      0|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  328|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  276|      0|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (511:20): [True: 0, False: 0]
  ------------------
  512|      0|            {
  513|       |                /* Packed array */
  514|      0|                bool status = true;
  515|      0|                pb_istream_t substream;
  516|      0|                pb_size_t *size = (pb_size_t*)field->pSize;
  517|      0|                field->pData = (char*)field->pField + field->data_size * (*size);
  518|       |
  519|      0|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (519:21): [True: 0, False: 0]
  ------------------
  520|      0|                    return false;
  521|       |
  522|      0|                while (substream.bytes_left > 0 && *size < field->array_size)
  ------------------
  |  Branch (522:24): [True: 0, False: 0]
  |  Branch (522:52): [True: 0, False: 0]
  ------------------
  523|      0|                {
  524|      0|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (524:25): [True: 0, False: 0]
  ------------------
  525|      0|                    {
  526|      0|                        status = false;
  527|      0|                        break;
  528|      0|                    }
  529|      0|                    (*size)++;
  530|      0|                    field->pData = (char*)field->pData + field->data_size;
  531|      0|                }
  532|       |
  533|      0|                if (substream.bytes_left != 0)
  ------------------
  |  Branch (533:21): [True: 0, False: 0]
  ------------------
  534|      0|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  535|      0|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (535:21): [True: 0, False: 0]
  ------------------
  536|      0|                    return false;
  537|       |
  538|      0|                return status;
  539|      0|            }
  540|      0|            else
  541|      0|            {
  542|       |                /* Repeated field */
  543|      0|                pb_size_t *size = (pb_size_t*)field->pSize;
  544|      0|                field->pData = (char*)field->pField + field->data_size * (*size);
  545|       |
  546|      0|                if ((*size)++ >= field->array_size)
  ------------------
  |  Branch (546:21): [True: 0, False: 0]
  ------------------
  547|      0|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  548|       |
  549|      0|                return decode_basic_field(stream, wire_type, field);
  550|      0|            }
  551|       |
  552|  5.62k|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  316|  5.62k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (552:9): [True: 5.62k, False: 6.48k]
  ------------------
  553|  5.62k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  329|  11.2k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  5.62k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  5.62k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  11.2k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 4.39k, False: 1.23k]
  |  |  ------------------
  |  |  330|  11.2k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  1.23k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  1.23k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  1.23k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 1.23k]
  |  |  ------------------
  ------------------
  554|  4.39k|                *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (554:17): [True: 1.75k, False: 2.63k]
  ------------------
  555|  1.75k|            {
  556|       |                /* We memset to zero so that any callbacks are set to NULL.
  557|       |                 * This is because the callbacks might otherwise have values
  558|       |                 * from some other union field.
  559|       |                 * If callbacks are needed inside oneof field, use .proto
  560|       |                 * option submsg_callback to have a separate callback function
  561|       |                 * that can set the fields before submessage is decoded.
  562|       |                 * pb_dec_submessage() will set any default values. */
  563|  1.75k|                memset(field->pData, 0, (size_t)field->data_size);
  564|       |
  565|       |                /* Set default values for the submessage fields. */
  566|  1.75k|                if (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (566:21): [True: 0, False: 1.75k]
  ------------------
  567|  1.75k|                    field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (567:21): [True: 0, False: 1.75k]
  ------------------
  568|  1.75k|                    field->submsg_desc->submsg_info[0] != NULL)
  ------------------
  |  Branch (568:21): [True: 0, False: 1.75k]
  ------------------
  569|      0|                {
  570|      0|                    pb_field_iter_t submsg_iter;
  571|      0|                    if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (571:25): [True: 0, False: 0]
  ------------------
  572|      0|                    {
  573|      0|                        if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (573:29): [True: 0, False: 0]
  ------------------
  574|      0|                            PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  575|      0|                    }
  576|      0|                }
  577|  1.75k|            }
  578|  5.62k|            *(pb_size_t*)field->pSize = field->tag;
  579|       |
  580|  5.62k|            return decode_basic_field(stream, wire_type, field);
  581|       |
  582|      0|        default:
  ------------------
  |  Branch (582:9): [True: 0, False: 12.1k]
  ------------------
  583|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  584|  12.1k|    }
  585|  12.1k|}
pb_decode.c:decode_basic_field:
  427|  45.6M|{
  428|  45.6M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  328|  45.6M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  45.6M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  429|  45.6M|    {
  430|  3.87M|        case PB_LTYPE_BOOL:
  ------------------
  |  |  268|  3.87M|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (430:9): [True: 3.87M, False: 41.8M]
  ------------------
  431|  3.87M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (431:17): [True: 3.48M, False: 393k]
  |  Branch (431:46): [True: 11, False: 3.48M]
  ------------------
  432|     11|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     11|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     11|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  433|       |
  434|  3.87M|            return pb_dec_bool(stream, field);
  435|       |
  436|  6.65M|        case PB_LTYPE_VARINT:
  ------------------
  |  |  269|  6.65M|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (436:9): [True: 6.65M, False: 39.0M]
  ------------------
  437|  7.76M|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  270|  7.76M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (437:9): [True: 1.10M, False: 44.5M]
  ------------------
  438|  12.7M|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  271|  12.7M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (438:9): [True: 4.99M, False: 40.6M]
  ------------------
  439|  12.7M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (439:17): [True: 11.5M, False: 1.23M]
  |  Branch (439:46): [True: 82, False: 11.5M]
  ------------------
  440|     82|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     82|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     82|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 82]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  441|       |
  442|  12.7M|            return pb_dec_varint(stream, field);
  443|       |
  444|  88.4k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  272|  88.4k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (444:9): [True: 88.4k, False: 45.5M]
  ------------------
  445|  88.4k|            if (wire_type != PB_WT_32BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (445:17): [True: 8.08k, False: 80.4k]
  |  Branch (445:45): [True: 19, False: 8.06k]
  ------------------
  446|     19|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     19|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     19|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 19]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  447|       |
  448|  88.4k|            return pb_decode_fixed32(stream, field->pData);
  449|       |
  450|  63.4k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  273|  63.4k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (450:9): [True: 63.4k, False: 45.6M]
  ------------------
  451|  63.4k|            if (wire_type != PB_WT_64BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (451:17): [True: 10.3k, False: 53.0k]
  |  Branch (451:45): [True: 14, False: 10.3k]
  ------------------
  452|     14|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     14|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     14|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  453|       |
  454|       |#ifdef PB_CONVERT_DOUBLE_FLOAT
  455|       |            if (field->data_size == sizeof(float))
  456|       |            {
  457|       |                return pb_decode_double_as_float(stream, (float*)field->pData);
  458|       |            }
  459|       |#endif
  460|       |
  461|       |#ifdef PB_WITHOUT_64BIT
  462|       |            PB_RETURN_ERROR(stream, "invalid data_size");
  463|       |#else
  464|  63.4k|            return pb_decode_fixed64(stream, field->pData);
  465|      0|#endif
  466|       |
  467|   801k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  280|   801k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (467:9): [True: 801k, False: 44.8M]
  ------------------
  468|   801k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (468:17): [True: 18, False: 801k]
  ------------------
  469|     18|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     18|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     18|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  470|       |
  471|   801k|            return pb_dec_bytes(stream, field);
  472|       |
  473|   126k|        case PB_LTYPE_STRING:
  ------------------
  |  |  284|   126k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (473:9): [True: 126k, False: 45.5M]
  ------------------
  474|   126k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (474:17): [True: 15, False: 126k]
  ------------------
  475|     15|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     15|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     15|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  476|       |
  477|   126k|            return pb_dec_string(stream, field);
  478|       |
  479|   189k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  288|   189k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (479:9): [True: 189k, False: 45.4M]
  ------------------
  480|   189k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  293|   189k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (480:9): [True: 0, False: 45.6M]
  ------------------
  481|   189k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (481:17): [True: 23, False: 189k]
  ------------------
  482|     23|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     23|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     23|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 23]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  483|       |
  484|   189k|            return pb_dec_submessage(stream, field);
  485|       |
  486|  27.7M|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  303|  27.7M|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (486:9): [True: 27.7M, False: 17.9M]
  ------------------
  487|  27.7M|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (487:17): [True: 4, False: 27.7M]
  ------------------
  488|      4|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|      4|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      4|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  489|       |
  490|  27.7M|            return pb_dec_fixed_length_bytes(stream, field);
  491|       |
  492|      0|        default:
  ------------------
  |  Branch (492:9): [True: 0, False: 45.6M]
  ------------------
  493|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  494|  45.6M|    }
  495|  45.6M|}
pb_decode.c:pb_dec_bool:
 1477|  3.87M|{
 1478|  3.87M|    return pb_decode_bool(stream, (bool*)field->pData);
 1479|  3.87M|}
pb_decode.c:pb_dec_varint:
 1482|  12.7M|{
 1483|  12.7M|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  328|  12.7M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  12.7M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  270|  12.7M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (1483:9): [True: 1.10M, False: 11.6M]
  ------------------
 1484|  1.10M|    {
 1485|  1.10M|        pb_uint64_t value, clamped;
  ------------------
  |  |   57|  1.10M|#define pb_uint64_t uint64_t
  ------------------
 1486|  1.10M|        if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1486:13): [True: 28, False: 1.10M]
  ------------------
 1487|     28|            return false;
 1488|       |
 1489|       |        /* Cast to the proper field size, while checking for overflows */
 1490|  1.10M|        if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (1490:13): [True: 451k, False: 656k]
  ------------------
 1491|   451k|            clamped = *(pb_uint64_t*)field->pData = value;
 1492|   656k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (1492:18): [True: 629k, False: 27.4k]
  ------------------
 1493|   629k|            clamped = *(uint32_t*)field->pData = (uint32_t)value;
 1494|  27.4k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (1494:18): [True: 13.6k, False: 13.8k]
  ------------------
 1495|  13.6k|            clamped = *(uint_least16_t*)field->pData = (uint_least16_t)value;
 1496|  13.8k|        else if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (1496:18): [True: 13.8k, False: 0]
  ------------------
 1497|  13.8k|            clamped = *(uint_least8_t*)field->pData = (uint_least8_t)value;
 1498|      0|        else
 1499|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1500|       |
 1501|  1.10M|        if (clamped != value)
  ------------------
  |  Branch (1501:13): [True: 112, False: 1.10M]
  ------------------
 1502|    112|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  923|    112|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|    112|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 112]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1503|       |
 1504|  1.10M|        return true;
 1505|  1.10M|    }
 1506|  11.6M|    else
 1507|  11.6M|    {
 1508|  11.6M|        pb_uint64_t value;
  ------------------
  |  |   57|  11.6M|#define pb_uint64_t uint64_t
  ------------------
 1509|  11.6M|        pb_int64_t svalue;
  ------------------
  |  |   56|  11.6M|#define pb_int64_t int64_t
  ------------------
 1510|  11.6M|        pb_int64_t clamped;
  ------------------
  |  |   56|  11.6M|#define pb_int64_t int64_t
  ------------------
 1511|       |
 1512|  11.6M|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  328|  11.6M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  11.6M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  271|  11.6M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (1512:13): [True: 4.99M, False: 6.65M]
  ------------------
 1513|  4.99M|        {
 1514|  4.99M|            if (!pb_decode_svarint(stream, &svalue))
  ------------------
  |  Branch (1514:17): [True: 40, False: 4.99M]
  ------------------
 1515|     40|                return false;
 1516|  4.99M|        }
 1517|  6.65M|        else
 1518|  6.65M|        {
 1519|  6.65M|            if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1519:17): [True: 51, False: 6.65M]
  ------------------
 1520|     51|                return false;
 1521|       |
 1522|       |            /* See issue 97: Google's C++ protobuf allows negative varint values to
 1523|       |            * be cast as int32_t, instead of the int64_t that should be used when
 1524|       |            * encoding. Nanopb versions before 0.2.5 had a bug in encoding. In order to
 1525|       |            * not break decoding of such messages, we cast <=32 bit fields to
 1526|       |            * int32_t first to get the sign correct.
 1527|       |            */
 1528|  6.65M|            if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1528:17): [True: 1.04M, False: 5.61M]
  ------------------
 1529|  1.04M|                svalue = (pb_int64_t)value;
 1530|  5.61M|            else
 1531|  5.61M|                svalue = (int32_t)value;
 1532|  6.65M|        }
 1533|       |
 1534|       |        /* Cast to the proper field size, while checking for overflows */
 1535|  11.6M|        if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1535:13): [True: 5.96M, False: 5.68M]
  ------------------
 1536|  5.96M|            clamped = *(pb_int64_t*)field->pData = svalue;
 1537|  5.68M|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (1537:18): [True: 5.63M, False: 54.5k]
  ------------------
 1538|  5.63M|            clamped = *(int32_t*)field->pData = (int32_t)svalue;
 1539|  54.5k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (1539:18): [True: 27.1k, False: 27.3k]
  ------------------
 1540|  27.1k|            clamped = *(int_least16_t*)field->pData = (int_least16_t)svalue;
 1541|  27.3k|        else if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (1541:18): [True: 27.3k, False: 0]
  ------------------
 1542|  27.3k|            clamped = *(int_least8_t*)field->pData = (int_least8_t)svalue;
 1543|      0|        else
 1544|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1545|       |
 1546|  11.6M|        if (clamped != svalue)
  ------------------
  |  Branch (1546:13): [True: 89, False: 11.6M]
  ------------------
 1547|     89|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  923|     89|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     89|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 89]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1548|       |
 1549|  11.6M|        return true;
 1550|  11.6M|    }
 1551|  12.7M|}
pb_decode.c:pb_dec_bytes:
 1554|   801k|{
 1555|   801k|    uint32_t size;
 1556|   801k|    size_t alloc_size;
 1557|   801k|    pb_bytes_array_t *dest;
 1558|       |    
 1559|   801k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1559:9): [True: 25, False: 801k]
  ------------------
 1560|     25|        return false;
 1561|       |    
 1562|   801k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  342|   801k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1562:9): [True: 32, False: 801k]
  ------------------
 1563|     32|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  923|     32|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     32|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1564|       |    
 1565|   801k|    alloc_size = PB_BYTES_ARRAY_T_ALLOCSIZE(size);
  ------------------
  |  |  406|   801k|#define PB_BYTES_ARRAY_T_ALLOCSIZE(n) ((size_t)n + offsetof(pb_bytes_array_t, bytes))
  ------------------
 1566|   801k|    if (size > alloc_size)
  ------------------
  |  Branch (1566:9): [True: 0, False: 801k]
  ------------------
 1567|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1568|       |    
 1569|   801k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   801k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   801k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   801k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1569:9): [True: 801k, False: 0]
  ------------------
 1570|   801k|    {
 1571|       |#ifndef PB_ENABLE_MALLOC
 1572|       |        PB_RETURN_ERROR(stream, "no malloc support");
 1573|       |#else
 1574|   801k|        if (stream->bytes_left < size)
  ------------------
  |  Branch (1574:13): [True: 32, False: 801k]
  ------------------
 1575|     32|            PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  923|     32|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     32|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1576|       |
 1577|   801k|        if (!allocate_field(stream, field->pData, alloc_size, 1))
  ------------------
  |  Branch (1577:13): [True: 0, False: 801k]
  ------------------
 1578|      0|            return false;
 1579|   801k|        dest = *(pb_bytes_array_t**)field->pData;
 1580|   801k|#endif
 1581|   801k|    }
 1582|      0|    else
 1583|      0|    {
 1584|      0|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1584:13): [True: 0, False: 0]
  ------------------
 1585|      0|            PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1586|      0|        dest = (pb_bytes_array_t*)field->pData;
 1587|      0|    }
 1588|       |
 1589|   801k|    dest->size = (pb_size_t)size;
 1590|   801k|    return pb_read(stream, dest->bytes, (size_t)size);
 1591|   801k|}
pb_decode.c:allocate_field:
  593|  32.7M|{    
  594|  32.7M|    void *ptr = *(void**)pData;
  595|       |    
  596|  32.7M|    if (data_size == 0 || array_size == 0)
  ------------------
  |  Branch (596:9): [True: 0, False: 32.7M]
  |  Branch (596:27): [True: 0, False: 32.7M]
  ------------------
  597|      0|        PB_RETURN_ERROR(stream, "invalid size");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  598|       |    
  599|       |#ifdef __AVR__
  600|       |    /* Workaround for AVR libc bug 53284: http://savannah.nongnu.org/bugs/?53284
  601|       |     * Realloc to size of 1 byte can cause corruption of the malloc structures.
  602|       |     */
  603|       |    if (data_size == 1 && array_size == 1)
  604|       |    {
  605|       |        data_size = 2;
  606|       |    }
  607|       |#endif
  608|       |
  609|       |    /* Check for multiplication overflows.
  610|       |     * This code avoids the costly division if the sizes are small enough.
  611|       |     * Multiplication is safe as long as only half of bits are set
  612|       |     * in either multiplicand.
  613|       |     */
  614|  32.7M|    {
  615|  32.7M|        const size_t check_limit = (size_t)1 << (sizeof(size_t) * 4);
  616|  32.7M|        if (data_size >= check_limit || array_size >= check_limit)
  ------------------
  |  Branch (616:13): [True: 0, False: 32.7M]
  |  Branch (616:41): [True: 0, False: 32.7M]
  ------------------
  617|      0|        {
  618|      0|            const size_t size_max = (size_t)-1;
  619|      0|            if (size_max / array_size < data_size)
  ------------------
  |  Branch (619:17): [True: 0, False: 0]
  ------------------
  620|      0|            {
  621|      0|                PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  622|      0|            }
  623|      0|        }
  624|  32.7M|    }
  625|       |    
  626|       |    /* Allocate new or expand previous allocation */
  627|       |    /* Note: on failure the old pointer will remain in the structure,
  628|       |     * the message must be freed by caller also on error return. */
  629|  32.7M|    ptr = pb_realloc(ptr, array_size * data_size);
  ------------------
  |  |    3|  32.7M|#define pb_realloc(ptr,size) realloc_with_check(ptr,size)
  ------------------
  630|  32.7M|    if (ptr == NULL)
  ------------------
  |  Branch (630:9): [True: 0, False: 32.7M]
  ------------------
  631|      0|        PB_RETURN_ERROR(stream, "realloc failed");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  632|       |    
  633|  32.7M|    *(void**)pData = ptr;
  634|       |    return true;
  635|  32.7M|}
pb_decode.c:pb_dec_string:
 1594|   126k|{
 1595|   126k|    uint32_t size;
 1596|   126k|    size_t alloc_size;
 1597|   126k|    pb_byte_t *dest = (pb_byte_t*)field->pData;
 1598|       |
 1599|   126k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1599:9): [True: 25, False: 126k]
  ------------------
 1600|     25|        return false;
 1601|       |
 1602|   126k|    if (size == (uint32_t)-1)
  ------------------
  |  Branch (1602:9): [True: 3, False: 126k]
  ------------------
 1603|      3|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  923|      3|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      3|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1604|       |
 1605|       |    /* Space for null terminator */
 1606|   126k|    alloc_size = (size_t)(size + 1);
 1607|       |
 1608|   126k|    if (alloc_size < size)
  ------------------
  |  Branch (1608:9): [True: 0, False: 126k]
  ------------------
 1609|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1610|       |
 1611|   126k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   126k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   126k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   126k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1611:9): [True: 124k, False: 1.66k]
  ------------------
 1612|   124k|    {
 1613|       |#ifndef PB_ENABLE_MALLOC
 1614|       |        PB_RETURN_ERROR(stream, "no malloc support");
 1615|       |#else
 1616|   124k|        if (stream->bytes_left < size)
  ------------------
  |  Branch (1616:13): [True: 61, False: 124k]
  ------------------
 1617|     61|            PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  923|     61|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     61|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 61]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1618|       |
 1619|   124k|        if (!allocate_field(stream, field->pData, alloc_size, 1))
  ------------------
  |  Branch (1619:13): [True: 0, False: 124k]
  ------------------
 1620|      0|            return false;
 1621|   124k|        dest = *(pb_byte_t**)field->pData;
 1622|   124k|#endif
 1623|   124k|    }
 1624|  1.66k|    else
 1625|  1.66k|    {
 1626|  1.66k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1626:13): [True: 53, False: 1.61k]
  ------------------
 1627|     53|            PB_RETURN_ERROR(stream, "string overflow");
  ------------------
  |  |  923|     53|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     53|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 53]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1628|  1.66k|    }
 1629|       |    
 1630|   126k|    dest[size] = 0;
 1631|       |
 1632|   126k|    if (!pb_read(stream, dest, (size_t)size))
  ------------------
  |  Branch (1632:9): [True: 5, False: 126k]
  ------------------
 1633|      5|        return false;
 1634|       |
 1635|       |#ifdef PB_VALIDATE_UTF8
 1636|       |    if (!pb_validate_utf8((const char*)dest))
 1637|       |        PB_RETURN_ERROR(stream, "invalid utf8");
 1638|       |#endif
 1639|       |
 1640|   126k|    return true;
 1641|   126k|}
pb_decode.c:pb_dec_submessage:
 1644|   189k|{
 1645|   189k|    bool status = true;
 1646|   189k|    bool submsg_consumed = false;
 1647|   189k|    pb_istream_t substream;
 1648|       |
 1649|   189k|    if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1649:9): [True: 144, False: 189k]
  ------------------
 1650|    144|        return false;
 1651|       |    
 1652|   189k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (1652:9): [True: 0, False: 189k]
  ------------------
 1653|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1654|       |    
 1655|       |    /* Submessages can have a separate message-level callback that is called
 1656|       |     * before decoding the message. Typically it is used to set callback fields
 1657|       |     * inside oneofs. */
 1658|   189k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  328|   189k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   189k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  293|   379k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (1658:9): [True: 0, False: 189k]
  |  Branch (1658:58): [True: 0, False: 0]
  ------------------
 1659|      0|    {
 1660|       |        /* Message callback is stored right before pSize. */
 1661|      0|        pb_callback_t *callback = (pb_callback_t*)field->pSize - 1;
 1662|      0|        if (callback->funcs.decode)
  ------------------
  |  Branch (1662:13): [True: 0, False: 0]
  ------------------
 1663|      0|        {
 1664|      0|            status = callback->funcs.decode(&substream, field, &callback->arg);
 1665|       |
 1666|      0|            if (substream.bytes_left == 0)
  ------------------
  |  Branch (1666:17): [True: 0, False: 0]
  ------------------
 1667|      0|            {
 1668|      0|                submsg_consumed = true;
 1669|      0|            }
 1670|      0|        }
 1671|      0|    }
 1672|       |
 1673|       |    /* Now decode the submessage contents */
 1674|   189k|    if (status && !submsg_consumed)
  ------------------
  |  Branch (1674:9): [True: 189k, False: 0]
  |  Branch (1674:19): [True: 189k, False: 0]
  ------------------
 1675|   189k|    {
 1676|   189k|        unsigned int flags = 0;
 1677|       |
 1678|       |        /* Static required/optional fields are already initialized by top-level
 1679|       |         * pb_decode(), no need to initialize them again. */
 1680|   189k|        if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  326|   189k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   189k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  321|   379k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1680:13): [True: 9.14k, False: 180k]
  ------------------
 1681|  9.14k|            PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  327|  9.14k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  9.14k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  314|  9.14k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1681:13): [True: 9.14k, False: 0]
  ------------------
 1682|  9.14k|        {
 1683|  9.14k|            flags = PB_DECODE_NOINIT;
  ------------------
  |  |  122|  9.14k|#define PB_DECODE_NOINIT          0x01U
  ------------------
 1684|  9.14k|        }
 1685|       |
 1686|   189k|        status = pb_decode_inner(&substream, field->submsg_desc, field->pData, flags);
 1687|   189k|    }
 1688|       |    
 1689|   189k|    if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1689:9): [True: 0, False: 189k]
  ------------------
 1690|      0|        return false;
 1691|       |
 1692|   189k|    return status;
 1693|   189k|}
pb_decode.c:pb_dec_fixed_length_bytes:
 1696|  27.7M|{
 1697|  27.7M|    uint32_t size;
 1698|       |
 1699|  27.7M|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1699:9): [True: 1, False: 27.7M]
  ------------------
 1700|      1|        return false;
 1701|       |
 1702|  27.7M|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  342|  27.7M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1702:9): [True: 33, False: 27.7M]
  ------------------
 1703|     33|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  923|     33|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     33|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 33]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1704|       |
 1705|  27.7M|    if (size == 0)
  ------------------
  |  Branch (1705:9): [True: 26.7M, False: 1.02M]
  ------------------
 1706|  26.7M|    {
 1707|       |        /* As a special case, treat empty bytes string as all zeros for fixed_length_bytes. */
 1708|  26.7M|        memset(field->pData, 0, (size_t)field->data_size);
 1709|  26.7M|        return true;
 1710|  26.7M|    }
 1711|       |
 1712|  1.02M|    if (size != field->data_size)
  ------------------
  |  Branch (1712:9): [True: 43, False: 1.02M]
  ------------------
 1713|     43|        PB_RETURN_ERROR(stream, "incorrect fixed length bytes size");
  ------------------
  |  |  923|     43|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     43|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 43]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1714|       |
 1715|  1.02M|    return pb_read(stream, (pb_byte_t*)field->pData, (size_t)field->data_size);
 1716|  1.02M|}
pb_decode.c:decode_pointer_field:
  655|  30.7M|{
  656|       |#ifndef PB_ENABLE_MALLOC
  657|       |    PB_UNUSED(wire_type);
  658|       |    PB_UNUSED(field);
  659|       |    PB_RETURN_ERROR(stream, "no malloc support");
  660|       |#else
  661|  30.7M|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  327|  30.7M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  30.7M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  662|  30.7M|    {
  663|  1.93M|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  311|  1.93M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (663:9): [True: 1.93M, False: 28.8M]
  ------------------
  664|  1.95M|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  312|  1.95M|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (664:9): [True: 20.6k, False: 30.7M]
  ------------------
  665|  1.96M|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  316|  1.96M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (665:9): [True: 14.7k, False: 30.7M]
  ------------------
  666|  1.96M|            if (PB_LTYPE_IS_SUBMSG(field->type) && *(void**)field->pField != NULL)
  ------------------
  |  |  329|  3.93M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  1.96M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  1.96M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  3.93M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 89.7k, False: 1.87M]
  |  |  ------------------
  |  |  330|  3.93M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  1.87M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  1.87M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  1.87M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 1.87M]
  |  |  ------------------
  ------------------
  |  Branch (666:52): [True: 51.9k, False: 37.8k]
  ------------------
  667|  51.9k|            {
  668|       |                /* Duplicate field, have to release the old allocation first. */
  669|       |                /* FIXME: Does this work correctly for oneofs? */
  670|  51.9k|                pb_release_single_field(field);
  671|  51.9k|            }
  672|       |        
  673|  1.96M|            if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  1.96M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  1.96M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  1.96M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (673:17): [True: 14.7k, False: 1.95M]
  ------------------
  674|  14.7k|            {
  675|  14.7k|                *(pb_size_t*)field->pSize = field->tag;
  676|  14.7k|            }
  677|       |
  678|  1.96M|            if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  328|  1.96M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.96M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  284|  3.93M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (678:17): [True: 99.3k, False: 1.86M]
  ------------------
  679|  1.86M|                PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  328|  1.86M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.86M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  280|  1.86M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (679:17): [True: 17.7k, False: 1.85M]
  ------------------
  680|   117k|            {
  681|       |                /* pb_dec_string and pb_dec_bytes handle allocation themselves */
  682|   117k|                field->pData = field->pField;
  683|   117k|                return decode_basic_field(stream, wire_type, field);
  684|   117k|            }
  685|  1.85M|            else
  686|  1.85M|            {
  687|  1.85M|                if (!allocate_field(stream, field->pField, field->data_size, 1))
  ------------------
  |  Branch (687:21): [True: 0, False: 1.85M]
  ------------------
  688|      0|                    return false;
  689|       |                
  690|  1.85M|                field->pData = *(void**)field->pField;
  691|  1.85M|                initialize_pointer_field(field->pData, field);
  692|  1.85M|                return decode_basic_field(stream, wire_type, field);
  693|  1.85M|            }
  694|       |    
  695|  28.7M|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  314|  28.7M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (695:9): [True: 28.7M, False: 1.96M]
  ------------------
  696|  28.7M|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (696:17): [True: 28.7M, False: 11.1k]
  ------------------
  697|  28.7M|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  328|  28.7M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  28.7M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  276|  28.7M|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (697:20): [True: 122k, False: 28.6M]
  ------------------
  698|   122k|            {
  699|       |                /* Packed array, multiple items come in at once. */
  700|   122k|                bool status = true;
  701|   122k|                pb_size_t *size = (pb_size_t*)field->pSize;
  702|   122k|                size_t allocated_size = *size;
  703|   122k|                pb_istream_t substream;
  704|       |                
  705|   122k|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (705:21): [True: 58, False: 122k]
  ------------------
  706|     58|                    return false;
  707|       |                
  708|  15.1M|                while (substream.bytes_left)
  ------------------
  |  Branch (708:24): [True: 15.0M, False: 122k]
  ------------------
  709|  15.0M|                {
  710|  15.0M|                    if (*size == PB_SIZE_MAX)
  ------------------
  |  |  342|  15.0M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (710:25): [True: 8, False: 15.0M]
  ------------------
  711|      8|                    {
  712|      8|#ifndef PB_NO_ERRMSG
  713|      8|                        stream->errmsg = "too many array entries";
  714|      8|#endif
  715|      8|                        status = false;
  716|      8|                        break;
  717|      8|                    }
  718|       |
  719|  15.0M|                    if ((size_t)*size + 1 > allocated_size)
  ------------------
  |  Branch (719:25): [True: 1.28M, False: 13.7M]
  ------------------
  720|  1.28M|                    {
  721|       |                        /* Allocate more storage. This tries to guess the
  722|       |                         * number of remaining entries. Round the division
  723|       |                         * upwards. */
  724|  1.28M|                        size_t remain = (substream.bytes_left - 1) / field->data_size + 1;
  725|  1.28M|                        if (remain < PB_SIZE_MAX - allocated_size)
  ------------------
  |  |  342|  1.28M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (725:29): [True: 348k, False: 939k]
  ------------------
  726|   348k|                            allocated_size += remain;
  727|   939k|                        else
  728|   939k|                            allocated_size += 1;
  729|       |                        
  730|  1.28M|                        if (!allocate_field(&substream, field->pField, field->data_size, allocated_size))
  ------------------
  |  Branch (730:29): [True: 0, False: 1.28M]
  ------------------
  731|      0|                        {
  732|      0|                            status = false;
  733|      0|                            break;
  734|      0|                        }
  735|  1.28M|                    }
  736|       |
  737|       |                    /* Decode the array entry */
  738|  15.0M|                    field->pData = *(char**)field->pField + field->data_size * (*size);
  739|  15.0M|                    if (field->pData == NULL)
  ------------------
  |  Branch (739:25): [True: 0, False: 15.0M]
  ------------------
  740|      0|                    {
  741|       |                        /* Shouldn't happen, but satisfies static analyzers */
  742|      0|                        status = false;
  743|      0|                        break;
  744|      0|                    }
  745|  15.0M|                    initialize_pointer_field(field->pData, field);
  746|  15.0M|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (746:25): [True: 86, False: 15.0M]
  ------------------
  747|     86|                    {
  748|     86|                        status = false;
  749|     86|                        break;
  750|     86|                    }
  751|       |                    
  752|  15.0M|                    (*size)++;
  753|  15.0M|                }
  754|   122k|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (754:21): [True: 0, False: 122k]
  ------------------
  755|      0|                    return false;
  756|       |                
  757|   122k|                return status;
  758|   122k|            }
  759|  28.6M|            else
  760|  28.6M|            {
  761|       |                /* Normal repeated field, i.e. only one item at a time. */
  762|  28.6M|                pb_size_t *size = (pb_size_t*)field->pSize;
  763|       |
  764|  28.6M|                if (*size == PB_SIZE_MAX)
  ------------------
  |  |  342|  28.6M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (764:21): [True: 1, False: 28.6M]
  ------------------
  765|      1|                    PB_RETURN_ERROR(stream, "too many array entries");
  ------------------
  |  |  923|      1|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      1|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  766|       |                
  767|  28.6M|                if (!allocate_field(stream, field->pField, field->data_size, (size_t)(*size + 1)))
  ------------------
  |  Branch (767:21): [True: 0, False: 28.6M]
  ------------------
  768|      0|                    return false;
  769|       |            
  770|  28.6M|                field->pData = *(char**)field->pField + field->data_size * (*size);
  771|  28.6M|                (*size)++;
  772|  28.6M|                initialize_pointer_field(field->pData, field);
  773|  28.6M|                return decode_basic_field(stream, wire_type, field);
  774|  28.6M|            }
  775|       |
  776|      0|        default:
  ------------------
  |  Branch (776:9): [True: 0, False: 30.7M]
  ------------------
  777|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  778|  30.7M|    }
  779|  30.7M|#endif
  780|  30.7M|}
pb_decode.c:initialize_pointer_field:
  639|  45.5M|{
  640|  45.5M|    if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  328|  45.5M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  45.5M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  284|  91.1M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (640:9): [True: 25.5k, False: 45.5M]
  ------------------
  641|  45.5M|        PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  328|  45.5M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  45.5M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  280|  45.5M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (641:9): [True: 783k, False: 44.7M]
  ------------------
  642|   809k|    {
  643|   809k|        *(void**)pItem = NULL;
  644|   809k|    }
  645|  44.7M|    else if (PB_LTYPE_IS_SUBMSG(field->type))
  ------------------
  |  |  329|  44.7M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  44.7M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  44.7M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  89.4M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 180k, False: 44.5M]
  |  |  ------------------
  |  |  330|  44.7M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  44.5M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  44.5M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  44.5M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 44.5M]
  |  |  ------------------
  ------------------
  646|   180k|    {
  647|       |        /* We memset to zero so that any callbacks are set to NULL.
  648|       |         * Default values will be set by pb_dec_submessage(). */
  649|   180k|        memset(pItem, 0, field->data_size);
  650|   180k|    }
  651|  45.5M|}
pb_decode.c:decode_callback_field:
  783|  8.98k|{
  784|       |    /* Clear any data that may have been decoded for another oneof field
  785|       |     * that has come before this callback field.
  786|       |     */
  787|  8.98k|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  8.98k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  8.98k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  8.98k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (787:9): [True: 8.98k, False: 0]
  ------------------
  788|  8.98k|    {
  789|  8.98k|        if (*(pb_size_t*)field->pSize != 0 && *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (789:13): [True: 8.41k, False: 568]
  |  Branch (789:47): [True: 2.21k, False: 6.20k]
  ------------------
  790|  2.21k|        {
  791|  2.21k|            memset(field->pData, 0, (size_t)field->data_size);
  792|  2.21k|        }
  793|  8.98k|        *(pb_size_t*)field->pSize = field->tag;
  794|  8.98k|    }
  795|       |
  796|  8.98k|    if (!field->descriptor->field_callback)
  ------------------
  |  Branch (796:9): [True: 0, False: 8.98k]
  ------------------
  797|      0|        return pb_skip_field(stream, wire_type);
  798|       |
  799|  8.98k|    if (wire_type == PB_WT_STRING)
  ------------------
  |  Branch (799:9): [True: 2.14k, False: 6.84k]
  ------------------
  800|  2.14k|    {
  801|  2.14k|        pb_istream_t substream;
  802|  2.14k|        size_t prev_bytes_left;
  803|       |        
  804|  2.14k|        if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (804:13): [True: 45, False: 2.09k]
  ------------------
  805|     45|            return false;
  806|       |
  807|       |        /* If the callback field is inside a submsg, first call the submsg_callback which
  808|       |         * should set the decoder for the callback field. */
  809|  2.09k|        if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  328|  2.09k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  2.09k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  293|  4.19k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (809:13): [True: 0, False: 2.09k]
  |  Branch (809:62): [True: 0, False: 0]
  ------------------
  810|      0|            pb_callback_t* callback;
  811|      0|            *(pb_size_t*)field->pSize = field->tag;
  812|      0|            callback = (pb_callback_t*)field->pSize - 1;
  813|       |
  814|      0|            if (callback->funcs.decode)
  ------------------
  |  Branch (814:17): [True: 0, False: 0]
  ------------------
  815|      0|            {
  816|      0|                if (!callback->funcs.decode(&substream, field, &callback->arg)) {
  ------------------
  |  Branch (816:21): [True: 0, False: 0]
  ------------------
  817|      0|                    PB_SET_ERROR(stream, substream.errmsg ? substream.errmsg : "submsg callback failed");
  ------------------
  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  ------------------
  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  Branch (919:92): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  818|      0|                    return false;
  819|      0|                }
  820|      0|            }
  821|      0|        }
  822|       |        
  823|  2.09k|        do
  824|  2.09k|        {
  825|  2.09k|            prev_bytes_left = substream.bytes_left;
  826|  2.09k|            if (!field->descriptor->field_callback(&substream, NULL, field))
  ------------------
  |  Branch (826:17): [True: 0, False: 2.09k]
  ------------------
  827|      0|            {
  828|      0|                PB_SET_ERROR(stream, substream.errmsg ? substream.errmsg : "callback failed");
  ------------------
  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  ------------------
  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  Branch (919:92): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  829|      0|                return false;
  830|      0|            }
  831|  2.09k|        } while (substream.bytes_left > 0 && substream.bytes_left < prev_bytes_left);
  ------------------
  |  Branch (831:18): [True: 560, False: 1.53k]
  |  Branch (831:46): [True: 0, False: 560]
  ------------------
  832|       |        
  833|  2.09k|        if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (833:13): [True: 0, False: 2.09k]
  ------------------
  834|      0|            return false;
  835|       |
  836|  2.09k|        return true;
  837|  2.09k|    }
  838|  6.84k|    else
  839|  6.84k|    {
  840|       |        /* Copy the single scalar value to stack.
  841|       |         * This is required so that we can limit the stream length,
  842|       |         * which in turn allows to use same callback for packed and
  843|       |         * not-packed fields. */
  844|  6.84k|        pb_istream_t substream;
  845|  6.84k|        pb_byte_t buffer[10];
  846|  6.84k|        size_t size = sizeof(buffer);
  847|       |        
  848|  6.84k|        if (!read_raw_value(stream, wire_type, buffer, &size))
  ------------------
  |  Branch (848:13): [True: 47, False: 6.79k]
  ------------------
  849|     47|            return false;
  850|  6.79k|        substream = pb_istream_from_buffer(buffer, size);
  851|       |        
  852|       |        return field->descriptor->field_callback(&substream, NULL, field);
  853|  6.84k|    }
  854|  8.98k|}
pb_decode.c:read_raw_value:
  342|  6.84k|{
  343|  6.84k|    size_t max_size = *size;
  344|  6.84k|    switch (wire_type)
  345|  6.84k|    {
  346|  2.92k|        case PB_WT_VARINT:
  ------------------
  |  Branch (346:9): [True: 2.92k, False: 3.91k]
  ------------------
  347|  2.92k|            *size = 0;
  348|  2.92k|            do
  349|  5.53k|            {
  350|  5.53k|                (*size)++;
  351|  5.53k|                if (*size > max_size)
  ------------------
  |  Branch (351:21): [True: 4, False: 5.53k]
  ------------------
  352|      4|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  923|      4|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      4|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  353|       |
  354|  5.53k|                if (!pb_read(stream, buf, 1))
  ------------------
  |  Branch (354:21): [True: 29, False: 5.50k]
  ------------------
  355|     29|                    return false;
  356|  5.53k|            } while (*buf++ & 0x80);
  ------------------
  |  Branch (356:22): [True: 2.60k, False: 2.89k]
  ------------------
  357|  2.89k|            return true;
  358|       |            
  359|  1.85k|        case PB_WT_64BIT:
  ------------------
  |  Branch (359:9): [True: 1.85k, False: 4.98k]
  ------------------
  360|  1.85k|            *size = 8;
  361|  1.85k|            return pb_read(stream, buf, 8);
  362|       |        
  363|  2.05k|        case PB_WT_32BIT:
  ------------------
  |  Branch (363:9): [True: 2.05k, False: 4.78k]
  ------------------
  364|  2.05k|            *size = 4;
  365|  2.05k|            return pb_read(stream, buf, 4);
  366|       |        
  367|      0|        case PB_WT_STRING:
  ------------------
  |  Branch (367:9): [True: 0, False: 6.84k]
  ------------------
  368|       |            /* Calling read_raw_value with a PB_WT_STRING is an error.
  369|       |             * Explicitly handle this case and fallthrough to default to avoid
  370|       |             * compiler warnings.
  371|       |             */
  372|       |
  373|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (373:2): [True: 0, False: 6.84k]
  ------------------
  374|       |            /* Calling read_raw_value with a PB_WT_PACKED is an error.
  375|       |             * Explicitly handle this case and fallthrough to default to avoid
  376|       |             * compiler warnings.
  377|       |             */
  378|       |
  379|      3|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  923|      3|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      3|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (379:9): [True: 3, False: 6.83k]
  ------------------
  380|  6.84k|    }
  381|  6.84k|}
pb_decode.c:pb_release_single_field:
 1286|  1.18M|{
 1287|  1.18M|    pb_type_t type;
 1288|  1.18M|    type = field->type;
 1289|       |
 1290|  1.18M|    if (PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  1.18M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  1.18M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  1.18M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (1290:9): [True: 80.5k, False: 1.10M]
  ------------------
 1291|  80.5k|    {
 1292|  80.5k|        if (*(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (1292:13): [True: 60.4k, False: 20.0k]
  ------------------
 1293|  60.4k|            return; /* This is not the current field in the union */
 1294|  80.5k|    }
 1295|       |
 1296|       |    /* Release anything contained inside an extension or submsg.
 1297|       |     * This has to be done even if the submsg itself is statically
 1298|       |     * allocated. */
 1299|  1.12M|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  1.12M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.12M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  1.12M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1299:9): [True: 8.89k, False: 1.11M]
  ------------------
 1300|  8.89k|    {
 1301|       |        /* Release fields from all extensions in the linked list */
 1302|  8.89k|        pb_extension_t *ext = *(pb_extension_t**)field->pData;
 1303|  16.1k|        while (ext != NULL)
  ------------------
  |  Branch (1303:16): [True: 7.24k, False: 8.89k]
  ------------------
 1304|  7.24k|        {
 1305|  7.24k|            pb_field_iter_t ext_iter;
 1306|  7.24k|            if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (1306:17): [True: 7.24k, False: 0]
  ------------------
 1307|  7.24k|            {
 1308|  7.24k|                pb_release_single_field(&ext_iter);
 1309|  7.24k|            }
 1310|  7.24k|            ext = ext->next;
 1311|  7.24k|        }
 1312|  8.89k|    }
 1313|  1.11M|    else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  329|  2.22M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  1.11M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  1.11M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  2.22M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 147k, False: 964k]
  |  |  ------------------
  |  |  330|  2.22M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|   964k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|   964k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|   964k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 964k]
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  326|   147k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   147k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|   147k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (1313:42): [True: 146k, False: 1.84k]
  ------------------
 1314|   146k|    {
 1315|       |        /* Release fields in submessage or submsg array */
 1316|   146k|        pb_size_t count = 1;
 1317|       |        
 1318|   146k|        if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   146k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   146k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   146k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1318:13): [True: 137k, False: 9.01k]
  ------------------
 1319|   137k|        {
 1320|   137k|            field->pData = *(void**)field->pField;
 1321|   137k|        }
 1322|  9.01k|        else
 1323|  9.01k|        {
 1324|  9.01k|            field->pData = field->pField;
 1325|  9.01k|        }
 1326|       |        
 1327|   146k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|   146k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   146k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|   146k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1327:13): [True: 17.7k, False: 128k]
  ------------------
 1328|  17.7k|        {
 1329|  17.7k|            count = *(pb_size_t*)field->pSize;
 1330|       |
 1331|  17.7k|            if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > field->array_size)
  ------------------
  |  |  326|  17.7k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  17.7k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > field->array_size)
  ------------------
  |  |  321|  35.5k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1331:17): [True: 0, False: 17.7k]
  |  Branch (1331:54): [True: 0, False: 0]
  ------------------
 1332|      0|            {
 1333|       |                /* Protect against corrupted _count fields */
 1334|      0|                count = field->array_size;
 1335|      0|            }
 1336|  17.7k|        }
 1337|       |        
 1338|   146k|        if (field->pData)
  ------------------
  |  Branch (1338:13): [True: 101k, False: 44.9k]
  ------------------
 1339|   101k|        {
 1340|   290k|            for (; count > 0; count--)
  ------------------
  |  Branch (1340:20): [True: 189k, False: 101k]
  ------------------
 1341|   189k|            {
 1342|   189k|                pb_release(field->submsg_desc, field->pData);
 1343|   189k|                field->pData = (char*)field->pData + field->data_size;
 1344|   189k|            }
 1345|   101k|        }
 1346|   146k|    }
 1347|       |    
 1348|  1.12M|    if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  1.12M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  1.12M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  1.12M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1348:9): [True: 1.09M, False: 28.6k]
  ------------------
 1349|  1.09M|    {
 1350|  1.09M|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  327|  1.09M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  1.09M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  314|  2.18M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1350:13): [True: 186k, False: 906k]
  ------------------
 1351|   186k|            (PB_LTYPE(type) == PB_LTYPE_STRING ||
  ------------------
  |  |  328|   186k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   186k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          (PB_LTYPE(type) == PB_LTYPE_STRING ||
  ------------------
  |  |  284|   373k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (1351:14): [True: 8.89k, False: 177k]
  ------------------
 1352|   177k|             PB_LTYPE(type) == PB_LTYPE_BYTES))
  ------------------
  |  |  328|   177k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   177k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                           PB_LTYPE(type) == PB_LTYPE_BYTES))
  ------------------
  |  |  280|   177k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (1352:14): [True: 8.89k, False: 168k]
  ------------------
 1353|  17.7k|        {
 1354|       |            /* Release entries in repeated string or bytes array */
 1355|  17.7k|            void **pItem = *(void***)field->pField;
 1356|  17.7k|            pb_size_t count = *(pb_size_t*)field->pSize;
 1357|   827k|            for (; count > 0; count--)
  ------------------
  |  Branch (1357:20): [True: 809k, False: 17.7k]
  ------------------
 1358|   809k|            {
 1359|   809k|                pb_free(*pItem);
  ------------------
  |  |    4|   809k|#define pb_free(ptr) free_with_check(ptr)
  ------------------
 1360|   809k|                *pItem++ = NULL;
 1361|   809k|            }
 1362|  17.7k|        }
 1363|       |        
 1364|  1.09M|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|  1.09M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  1.09M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|  1.09M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1364:13): [True: 186k, False: 906k]
  ------------------
 1365|   186k|        {
 1366|       |            /* We are going to release the array, so set the size to 0 */
 1367|   186k|            *(pb_size_t*)field->pSize = 0;
 1368|   186k|        }
 1369|       |        
 1370|       |        /* Release main pointer */
 1371|  1.09M|        pb_free(*(void**)field->pField);
  ------------------
  |  |    4|  1.09M|#define pb_free(ptr) free_with_check(ptr)
  ------------------
 1372|       |        *(void**)field->pField = NULL;
 1373|  1.09M|    }
 1374|  1.12M|}

pb_ostream_from_buffer:
   73|  3.05k|{
   74|  3.05k|    pb_ostream_t stream;
   75|       |#ifdef PB_BUFFER_ONLY
   76|       |    /* In PB_BUFFER_ONLY configuration the callback pointer is just int*.
   77|       |     * NULL pointer marks a sizing field, so put a non-NULL value to mark a buffer stream.
   78|       |     */
   79|       |    static const int marker = 0;
   80|       |    stream.callback = &marker;
   81|       |#else
   82|  3.05k|    stream.callback = &buf_write;
   83|  3.05k|#endif
   84|  3.05k|    stream.state = buf;
   85|  3.05k|    stream.max_size = bufsize;
   86|  3.05k|    stream.bytes_written = 0;
   87|  3.05k|#ifndef PB_NO_ERRMSG
   88|       |    stream.errmsg = NULL;
   89|  3.05k|#endif
   90|  3.05k|    return stream;
   91|  3.05k|}
pb_write:
   94|  41.6M|{
   95|  41.6M|    if (count > 0 && stream->callback != NULL)
  ------------------
  |  Branch (95:9): [True: 41.3M, False: 331k]
  |  Branch (95:22): [True: 35.9M, False: 5.45M]
  ------------------
   96|  35.9M|    {
   97|  35.9M|        if (stream->bytes_written + count < stream->bytes_written ||
  ------------------
  |  Branch (97:13): [True: 0, False: 35.9M]
  ------------------
   98|  35.9M|            stream->bytes_written + count > stream->max_size)
  ------------------
  |  Branch (98:13): [True: 182, False: 35.9M]
  ------------------
   99|    182|        {
  100|    182|            PB_RETURN_ERROR(stream, "stream full");
  ------------------
  |  |  923|    182|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|    182|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 182]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  101|    182|        }
  102|       |
  103|       |#ifdef PB_BUFFER_ONLY
  104|       |        if (!buf_write(stream, buf, count))
  105|       |            PB_RETURN_ERROR(stream, "io error");
  106|       |#else        
  107|  35.9M|        if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (107:13): [True: 0, False: 35.9M]
  ------------------
  108|      0|            PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  109|  35.9M|#endif
  110|  35.9M|    }
  111|       |    
  112|  41.6M|    stream->bytes_written += count;
  113|       |    return true;
  114|  41.6M|}
pb_encode:
  522|   116k|{
  523|   116k|    pb_field_iter_t iter;
  524|   116k|    if (!pb_field_iter_begin_const(&iter, fields, src_struct))
  ------------------
  |  Branch (524:9): [True: 38.3k, False: 77.9k]
  ------------------
  525|  38.3k|        return true; /* Empty message type */
  526|       |    
  527|   489k|    do {
  528|   489k|        if (PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|   489k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   489k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|   489k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (528:13): [True: 2.91k, False: 486k]
  ------------------
  529|  2.91k|        {
  530|       |            /* Special case for the extension field placeholder */
  531|  2.91k|            if (!encode_extension_field(stream, &iter))
  ------------------
  |  Branch (531:17): [True: 40, False: 2.87k]
  ------------------
  532|     40|                return false;
  533|  2.91k|        }
  534|   486k|        else
  535|   486k|        {
  536|       |            /* Regular field */
  537|   486k|            if (!encode_field(stream, &iter))
  ------------------
  |  Branch (537:17): [True: 191, False: 486k]
  ------------------
  538|    191|                return false;
  539|   486k|        }
  540|   489k|    } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (540:14): [True: 411k, False: 77.7k]
  ------------------
  541|       |    
  542|  77.7k|    return true;
  543|  77.9k|}
pb_encode_varint:
  617|  31.4M|{
  618|  31.4M|    if (value <= 0x7F)
  ------------------
  |  Branch (618:9): [True: 18.0M, False: 13.3M]
  ------------------
  619|  18.0M|    {
  620|       |        /* Fast path: single byte */
  621|  18.0M|        pb_byte_t byte = (pb_byte_t)value;
  622|  18.0M|        return pb_write(stream, &byte, 1);
  623|  18.0M|    }
  624|  13.3M|    else
  625|  13.3M|    {
  626|       |#ifdef PB_WITHOUT_64BIT
  627|       |        return pb_encode_varint_32(stream, value, 0);
  628|       |#else
  629|  13.3M|        return pb_encode_varint_32(stream, (uint32_t)value, (uint32_t)(value >> 32));
  630|  13.3M|#endif
  631|  13.3M|    }
  632|  31.4M|}
pb_encode_svarint:
  635|  4.14M|{
  636|  4.14M|    pb_uint64_t zigzagged;
  ------------------
  |  |   46|  4.14M|#define pb_uint64_t uint64_t
  ------------------
  637|  4.14M|    pb_uint64_t mask = ((pb_uint64_t)-1) >> 1; /* Satisfy clang -fsanitize=integer */
  ------------------
  |  |   46|  4.14M|#define pb_uint64_t uint64_t
  ------------------
  638|  4.14M|    if (value < 0)
  ------------------
  |  Branch (638:9): [True: 458k, False: 3.68M]
  ------------------
  639|   458k|        zigzagged = ~(((pb_uint64_t)value & mask) << 1);
  640|  3.68M|    else
  641|  3.68M|        zigzagged = (pb_uint64_t)value << 1;
  642|       |    
  643|  4.14M|    return pb_encode_varint(stream, zigzagged);
  644|  4.14M|}
pb_encode_fixed32:
  647|  21.3k|{
  648|  21.3k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
  649|       |    /* Fast path if we know that we're on little endian */
  650|  21.3k|    return pb_write(stream, (const pb_byte_t*)value, 4);
  651|       |#else
  652|       |    uint32_t val = *(const uint32_t*)value;
  653|       |    pb_byte_t bytes[4];
  654|       |    bytes[0] = (pb_byte_t)(val & 0xFF);
  655|       |    bytes[1] = (pb_byte_t)((val >> 8) & 0xFF);
  656|       |    bytes[2] = (pb_byte_t)((val >> 16) & 0xFF);
  657|       |    bytes[3] = (pb_byte_t)((val >> 24) & 0xFF);
  658|       |    return pb_write(stream, bytes, 4);
  659|       |#endif
  660|  21.3k|}
pb_encode_fixed64:
  664|  14.1k|{
  665|  14.1k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
  666|       |    /* Fast path if we know that we're on little endian */
  667|  14.1k|    return pb_write(stream, (const pb_byte_t*)value, 8);
  668|       |#else
  669|       |    uint64_t val = *(const uint64_t*)value;
  670|       |    pb_byte_t bytes[8];
  671|       |    bytes[0] = (pb_byte_t)(val & 0xFF);
  672|       |    bytes[1] = (pb_byte_t)((val >> 8) & 0xFF);
  673|       |    bytes[2] = (pb_byte_t)((val >> 16) & 0xFF);
  674|       |    bytes[3] = (pb_byte_t)((val >> 24) & 0xFF);
  675|       |    bytes[4] = (pb_byte_t)((val >> 32) & 0xFF);
  676|       |    bytes[5] = (pb_byte_t)((val >> 40) & 0xFF);
  677|       |    bytes[6] = (pb_byte_t)((val >> 48) & 0xFF);
  678|       |    bytes[7] = (pb_byte_t)((val >> 56) & 0xFF);
  679|       |    return pb_write(stream, bytes, 8);
  680|       |#endif
  681|  14.1k|}
pb_encode_tag:
  685|  10.5M|{
  686|  10.5M|    pb_uint64_t tag = ((pb_uint64_t)field_number << 3) | wiretype;
  ------------------
  |  |   46|  10.5M|#define pb_uint64_t uint64_t
  ------------------
  687|  10.5M|    return pb_encode_varint(stream, tag);
  688|  10.5M|}
pb_encode_tag_for_field:
  691|  10.5M|{
  692|  10.5M|    pb_wire_type_t wiretype;
  693|  10.5M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  328|  10.5M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  10.5M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  694|  10.5M|    {
  695|  3.16k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  268|  3.16k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (695:9): [True: 3.16k, False: 10.4M]
  ------------------
  696|   128k|        case PB_LTYPE_VARINT:
  ------------------
  |  |  269|   128k|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (696:9): [True: 125k, False: 10.3M]
  ------------------
  697|   173k|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  270|   173k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (697:9): [True: 44.6k, False: 10.4M]
  ------------------
  698|   191k|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  271|   191k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (698:9): [True: 18.1k, False: 10.4M]
  ------------------
  699|   191k|            wiretype = PB_WT_VARINT;
  700|   191k|            break;
  701|       |        
  702|  16.4k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  272|  16.4k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (702:9): [True: 16.4k, False: 10.4M]
  ------------------
  703|  16.4k|            wiretype = PB_WT_32BIT;
  704|  16.4k|            break;
  705|       |        
  706|  9.46k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  273|  9.46k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (706:9): [True: 9.46k, False: 10.4M]
  ------------------
  707|  9.46k|            wiretype = PB_WT_64BIT;
  708|  9.46k|            break;
  709|       |        
  710|   277k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  280|   277k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (710:9): [True: 277k, False: 10.2M]
  ------------------
  711|   344k|        case PB_LTYPE_STRING:
  ------------------
  |  |  284|   344k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (711:9): [True: 67.0k, False: 10.4M]
  ------------------
  712|   401k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  288|   401k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (712:9): [True: 56.6k, False: 10.4M]
  ------------------
  713|   401k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  293|   401k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (713:9): [True: 0, False: 10.5M]
  ------------------
  714|  10.2M|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  303|  10.2M|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (714:9): [True: 9.88M, False: 618k]
  ------------------
  715|  10.2M|            wiretype = PB_WT_STRING;
  716|  10.2M|            break;
  717|       |        
  718|      0|        default:
  ------------------
  |  Branch (718:9): [True: 0, False: 10.5M]
  ------------------
  719|      0|            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  720|  10.5M|    }
  721|       |    
  722|  10.5M|    return pb_encode_tag(stream, wiretype, field->tag);
  723|  10.5M|}
pb_encode_string:
  726|  10.2M|{
  727|  10.2M|    if (!pb_encode_varint(stream, (pb_uint64_t)size))
  ------------------
  |  Branch (727:9): [True: 8, False: 10.2M]
  ------------------
  728|      8|        return false;
  729|       |    
  730|  10.2M|    return pb_write(stream, buffer, size);
  731|  10.2M|}
pb_encode_submessage:
  734|  56.6k|{
  735|       |    /* First calculate the message size using a non-writing substream. */
  736|  56.6k|    pb_ostream_t substream = PB_OSTREAM_SIZING;
  ------------------
  |  |  126|  56.6k|#define PB_OSTREAM_SIZING {0,0,0,0,0}
  ------------------
  737|  56.6k|#if !defined(PB_NO_ENCODE_SIZE_CHECK) || PB_NO_ENCODE_SIZE_CHECK == 0
  738|  56.6k|    bool status;
  739|  56.6k|    size_t size;
  740|  56.6k|#endif
  741|       |    
  742|  56.6k|    if (!pb_encode(&substream, fields, src_struct))
  ------------------
  |  Branch (742:9): [True: 0, False: 56.6k]
  ------------------
  743|      0|    {
  744|      0|#ifndef PB_NO_ERRMSG
  745|      0|        stream->errmsg = substream.errmsg;
  746|      0|#endif
  747|      0|        return false;
  748|      0|    }
  749|       |    
  750|  56.6k|    if (!pb_encode_varint(stream, (pb_uint64_t)substream.bytes_written))
  ------------------
  |  Branch (750:9): [True: 23, False: 56.6k]
  ------------------
  751|     23|        return false;
  752|       |    
  753|  56.6k|    if (stream->callback == NULL)
  ------------------
  |  Branch (753:9): [True: 0, False: 56.6k]
  ------------------
  754|      0|        return pb_write(stream, NULL, substream.bytes_written); /* Just sizing */
  755|       |    
  756|  56.6k|    if (stream->bytes_written + substream.bytes_written > stream->max_size)
  ------------------
  |  Branch (756:9): [True: 49, False: 56.5k]
  ------------------
  757|     49|        PB_RETURN_ERROR(stream, "stream full");
  ------------------
  |  |  923|     49|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     49|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 49]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  758|       |        
  759|       |#if defined(PB_NO_ENCODE_SIZE_CHECK) && PB_NO_ENCODE_SIZE_CHECK == 1
  760|       |    return pb_encode(stream, fields, src_struct);
  761|       |#else
  762|  56.5k|    size = substream.bytes_written;
  763|       |    /* Use a substream to verify that a callback doesn't write more than
  764|       |     * what it did the first time. */
  765|  56.5k|    substream.callback = stream->callback;
  766|  56.5k|    substream.state = stream->state;
  767|  56.5k|    substream.max_size = size;
  768|  56.5k|    substream.bytes_written = 0;
  769|  56.5k|#ifndef PB_NO_ERRMSG
  770|  56.5k|    substream.errmsg = NULL;
  771|  56.5k|#endif
  772|       |    
  773|  56.5k|    status = pb_encode(&substream, fields, src_struct);
  774|       |    
  775|  56.5k|    stream->bytes_written += substream.bytes_written;
  776|  56.5k|    stream->state = substream.state;
  777|  56.5k|#ifndef PB_NO_ERRMSG
  778|  56.5k|    stream->errmsg = substream.errmsg;
  779|  56.5k|#endif
  780|       |    
  781|  56.5k|    if (substream.bytes_written != size)
  ------------------
  |  Branch (781:9): [True: 0, False: 56.5k]
  ------------------
  782|      0|        PB_RETURN_ERROR(stream, "submsg size changed");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  783|       |
  784|  56.5k|    return status;
  785|  56.5k|#endif
  786|  56.5k|}
pb_encode.c:buf_write:
   54|  35.9M|{
   55|  35.9M|    pb_byte_t *dest = (pb_byte_t*)stream->state;
   56|  35.9M|    stream->state = dest + count;
   57|       |
   58|       |    /* Skip the copy if buf is NULL. Callers should not invoke this with NULL,
   59|       |     * but pb_write may pass NULL for sizing passes. Some compilers
   60|       |     * (e.g. picolibc/arm-zephyr-eabi GCC 12.2) emit a -Wnonnull warning
   61|       |     * against memcpy's nonnull argument even though count would be 0 in
   62|       |     * that case. See #1141.
   63|       |     */
   64|  35.9M|    if (buf != NULL)
  ------------------
  |  Branch (64:9): [True: 35.9M, False: 0]
  ------------------
   65|  35.9M|    {
   66|  35.9M|        memcpy(dest, buf, count * sizeof(pb_byte_t));
   67|  35.9M|    }
   68|       |
   69|       |    return true;
   70|  35.9M|}
pb_encode.c:encode_extension_field:
  497|  2.91k|{
  498|  2.91k|    const pb_extension_t *extension = *(const pb_extension_t* const *)field->pData;
  499|       |
  500|  5.78k|    while (extension)
  ------------------
  |  Branch (500:12): [True: 2.91k, False: 2.87k]
  ------------------
  501|  2.91k|    {
  502|  2.91k|        bool status;
  503|  2.91k|        if (extension->type->encode)
  ------------------
  |  Branch (503:13): [True: 0, False: 2.91k]
  ------------------
  504|      0|            status = extension->type->encode(stream, extension);
  505|  2.91k|        else
  506|  2.91k|            status = default_extension_encoder(stream, extension);
  507|       |
  508|  2.91k|        if (!status)
  ------------------
  |  Branch (508:13): [True: 40, False: 2.87k]
  ------------------
  509|     40|            return false;
  510|       |        
  511|  2.87k|        extension = extension->next;
  512|  2.87k|    }
  513|       |    
  514|  2.87k|    return true;
  515|  2.91k|}
pb_encode.c:default_extension_encoder:
  484|  2.91k|{
  485|  2.91k|    pb_field_iter_t iter;
  486|       |
  487|  2.91k|    if (!pb_field_iter_begin_extension_const(&iter, extension))
  ------------------
  |  Branch (487:9): [True: 0, False: 2.91k]
  ------------------
  488|      0|        PB_RETURN_ERROR(stream, "invalid extension");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  489|       |
  490|  2.91k|    return encode_field(stream, &iter);
  491|  2.91k|}
pb_encode.c:encode_field:
  428|   489k|{
  429|       |    /* Check field presence */
  430|   489k|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|   489k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   489k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|   489k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (430:9): [True: 20.8k, False: 468k]
  ------------------
  431|  20.8k|    {
  432|  20.8k|        if (*(const pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (432:13): [True: 20.2k, False: 590]
  ------------------
  433|  20.2k|        {
  434|       |            /* Different type oneof field */
  435|  20.2k|            return true;
  436|  20.2k|        }
  437|  20.8k|    }
  438|   468k|    else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL)
  ------------------
  |  |  327|   468k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   468k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL)
  ------------------
  |  |  312|   468k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (438:14): [True: 117k, False: 351k]
  ------------------
  439|   117k|    {
  440|   117k|        if (field->pSize)
  ------------------
  |  Branch (440:13): [True: 5.76k, False: 111k]
  ------------------
  441|  5.76k|        {
  442|  5.76k|            if (safe_read_bool(field->pSize) == false)
  ------------------
  |  Branch (442:17): [True: 5.56k, False: 207]
  ------------------
  443|  5.56k|            {
  444|       |                /* Missing optional field */
  445|  5.56k|                return true;
  446|  5.56k|            }
  447|  5.76k|        }
  448|   111k|        else if (PB_ATYPE(field->type) == PB_ATYPE_STATIC)
  ------------------
  |  |  326|   111k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   111k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      else if (PB_ATYPE(field->type) == PB_ATYPE_STATIC)
  ------------------
  |  |  321|   111k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (448:18): [True: 0, False: 111k]
  ------------------
  449|      0|        {
  450|       |            /* Proto3 singular field */
  451|      0|            if (pb_check_proto3_default_value(field))
  ------------------
  |  Branch (451:17): [True: 0, False: 0]
  ------------------
  452|      0|                return true;
  453|      0|        }
  454|   117k|    }
  455|       |
  456|   463k|    if (!field->pData)
  ------------------
  |  Branch (456:9): [True: 160k, False: 303k]
  ------------------
  457|   160k|    {
  458|   160k|        if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED)
  ------------------
  |  |  327|   160k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   160k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED)
  ------------------
  |  |  311|   160k|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (458:13): [True: 0, False: 160k]
  ------------------
  459|      0|            PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  460|       |
  461|       |        /* Pointer field set to NULL */
  462|   160k|        return true;
  463|   160k|    }
  464|       |
  465|       |    /* Then encode field contents */
  466|   303k|    if (PB_ATYPE(field->type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  326|   303k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   303k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|   303k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (466:9): [True: 125, False: 302k]
  ------------------
  467|    125|    {
  468|    125|        return encode_callback_field(stream, field);
  469|    125|    }
  470|   302k|    else if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|   302k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   302k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|   302k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (470:14): [True: 6.03k, False: 296k]
  ------------------
  471|  6.03k|    {
  472|  6.03k|        return encode_array(stream, field);
  473|  6.03k|    }
  474|   296k|    else
  475|   296k|    {
  476|   296k|        return encode_basic_field(stream, field);
  477|   296k|    }
  478|   303k|}
pb_encode.c:safe_read_bool:
  125|  8.93k|{
  126|  8.93k|    const char *p = (const char *)pSize;
  127|  8.93k|    size_t i;
  128|  16.1k|    for (i = 0; i < sizeof(bool); i++)
  ------------------
  |  Branch (128:17): [True: 8.93k, False: 7.25k]
  ------------------
  129|  8.93k|    {
  130|  8.93k|        if (p[i] != 0)
  ------------------
  |  Branch (130:13): [True: 1.68k, False: 7.25k]
  ------------------
  131|  1.68k|            return true;
  132|  8.93k|    }
  133|  7.25k|    return false;
  134|  8.93k|}
pb_encode.c:encode_callback_field:
  417|    125|{
  418|    125|    if (field->descriptor->field_callback != NULL)
  ------------------
  |  Branch (418:9): [True: 125, False: 0]
  ------------------
  419|    125|    {
  420|    125|        if (!field->descriptor->field_callback(NULL, stream, field))
  ------------------
  |  Branch (420:13): [True: 0, False: 125]
  ------------------
  421|      0|            PB_RETURN_ERROR(stream, "callback error");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  422|    125|    }
  423|    125|    return true;
  424|    125|}
pb_encode.c:encode_array:
  138|  6.03k|{
  139|  6.03k|    pb_size_t i;
  140|  6.03k|    pb_size_t count;
  141|  6.03k|#ifndef PB_ENCODE_ARRAYS_UNPACKED
  142|  6.03k|    size_t size;
  143|  6.03k|#endif
  144|       |
  145|  6.03k|    count = *(pb_size_t*)field->pSize;
  146|       |
  147|  6.03k|    if (count == 0)
  ------------------
  |  Branch (147:9): [True: 0, False: 6.03k]
  ------------------
  148|      0|        return true;
  149|       |
  150|  6.03k|    if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size)
  ------------------
  |  |  326|  6.03k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  6.03k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size)
  ------------------
  |  |  322|  12.0k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (150:9): [True: 0, False: 6.03k]
  |  Branch (150:54): [True: 0, False: 0]
  ------------------
  151|      0|        PB_RETURN_ERROR(stream, "array max size exceeded");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  152|       |    
  153|  6.03k|#ifndef PB_ENCODE_ARRAYS_UNPACKED
  154|       |    /* We always pack arrays if the datatype allows it. */
  155|  6.03k|    if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  328|  6.03k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  6.03k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  276|  6.03k|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (155:9): [True: 2.85k, False: 3.17k]
  ------------------
  156|  2.85k|    {
  157|  2.85k|        if (!pb_encode_tag(stream, PB_WT_STRING, field->tag))
  ------------------
  |  Branch (157:13): [True: 2, False: 2.85k]
  ------------------
  158|      2|            return false;
  159|       |        
  160|       |        /* Determine the total size of packed array. */
  161|  2.85k|        if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32)
  ------------------
  |  |  328|  2.85k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  2.85k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32)
  ------------------
  |  |  272|  2.85k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (161:13): [True: 434, False: 2.42k]
  ------------------
  162|    434|        {
  163|    434|            size = 4 * (size_t)count;
  164|    434|        }
  165|  2.42k|        else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  328|  2.42k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  2.42k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  273|  2.42k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (165:18): [True: 237, False: 2.18k]
  ------------------
  166|    237|        {
  167|    237|            size = 8 * (size_t)count;
  168|    237|        }
  169|  2.18k|        else
  170|  2.18k|        { 
  171|  2.18k|            pb_ostream_t sizestream = PB_OSTREAM_SIZING;
  ------------------
  |  |  126|  2.18k|#define PB_OSTREAM_SIZING {0,0,0,0,0}
  ------------------
  172|  2.18k|            void *pData_orig = field->pData;
  173|  5.23M|            for (i = 0; i < count; i++)
  ------------------
  |  Branch (173:25): [True: 5.22M, False: 2.18k]
  ------------------
  174|  5.22M|            {
  175|  5.22M|                if (!pb_enc_varint(&sizestream, field))
  ------------------
  |  Branch (175:21): [True: 0, False: 5.22M]
  ------------------
  176|      0|                    PB_RETURN_ERROR(stream, PB_GET_ERROR(&sizestream));
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  |  Branch (919:92): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  177|  5.22M|                field->pData = (char*)field->pData + field->data_size;
  178|  5.22M|            }
  179|  2.18k|            field->pData = pData_orig;
  180|  2.18k|            size = sizestream.bytes_written;
  181|  2.18k|        }
  182|       |        
  183|  2.85k|        if (!pb_encode_varint(stream, (pb_uint64_t)size))
  ------------------
  |  Branch (183:13): [True: 3, False: 2.85k]
  ------------------
  184|      3|            return false;
  185|       |        
  186|  2.85k|        if (stream->callback == NULL)
  ------------------
  |  Branch (186:13): [True: 0, False: 2.85k]
  ------------------
  187|      0|            return pb_write(stream, NULL, size); /* Just sizing.. */
  188|       |        
  189|       |        /* Write the data */
  190|  5.22M|        for (i = 0; i < count; i++)
  ------------------
  |  Branch (190:21): [True: 5.22M, False: 2.84k]
  ------------------
  191|  5.22M|        {
  192|  5.22M|            if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  328|  5.22M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  5.22M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  272|  10.4M|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  328|  5.21M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  5.21M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  273|  5.21M|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (192:17): [True: 4.88k, False: 5.21M]
  |  Branch (192:62): [True: 4.66k, False: 5.21M]
  ------------------
  193|  9.55k|            {
  194|  9.55k|                if (!pb_enc_fixed(stream, field))
  ------------------
  |  Branch (194:21): [True: 3, False: 9.54k]
  ------------------
  195|      3|                    return false;
  196|  9.55k|            }
  197|  5.21M|            else
  198|  5.21M|            {
  199|  5.21M|                if (!pb_enc_varint(stream, field))
  ------------------
  |  Branch (199:21): [True: 6, False: 5.21M]
  ------------------
  200|      6|                    return false;
  201|  5.21M|            }
  202|       |
  203|  5.22M|            field->pData = (char*)field->pData + field->data_size;
  204|  5.22M|        }
  205|  2.85k|    }
  206|  3.17k|    else /* Unpacked fields */
  207|  3.17k|#endif
  208|  3.17k|    {
  209|  10.2M|        for (i = 0; i < count; i++)
  ------------------
  |  Branch (209:21): [True: 10.2M, False: 3.14k]
  ------------------
  210|  10.2M|        {
  211|       |            /* Normally the data is stored directly in the array entries, but
  212|       |             * for pointer-type string and bytes fields, the array entries are
  213|       |             * actually pointers themselves also. So we have to dereference once
  214|       |             * more to get to the actual data. */
  215|  10.2M|            if (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  326|  10.2M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  10.2M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  322|  20.4M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (215:17): [True: 10.2M, False: 0]
  ------------------
  216|  10.2M|                (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  328|  10.2M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  10.2M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  284|  20.4M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (216:18): [True: 12.1k, False: 10.1M]
  ------------------
  217|  10.1M|                 PB_LTYPE(field->type) == PB_LTYPE_BYTES))
  ------------------
  |  |  328|  10.1M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  10.1M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                               PB_LTYPE(field->type) == PB_LTYPE_BYTES))
  ------------------
  |  |  280|  10.1M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (217:18): [True: 274k, False: 9.91M]
  ------------------
  218|   286k|            {
  219|   286k|                bool status;
  220|   286k|                void *pData_orig = field->pData;
  221|   286k|                field->pData = *(void* const*)field->pData;
  222|       |
  223|   286k|                if (!field->pData)
  ------------------
  |  Branch (223:21): [True: 0, False: 286k]
  ------------------
  224|      0|                {
  225|       |                    /* Null pointer in array is treated as empty string / bytes */
  226|      0|                    status = pb_encode_tag_for_field(stream, field) &&
  ------------------
  |  Branch (226:30): [True: 0, False: 0]
  ------------------
  227|      0|                             pb_encode_varint(stream, 0);
  ------------------
  |  Branch (227:30): [True: 0, False: 0]
  ------------------
  228|      0|                }
  229|   286k|                else
  230|   286k|                {
  231|   286k|                    status = encode_basic_field(stream, field);
  232|   286k|                }
  233|       |
  234|   286k|                field->pData = pData_orig;
  235|       |
  236|   286k|                if (!status)
  ------------------
  |  Branch (236:21): [True: 11, False: 286k]
  ------------------
  237|     11|                    return false;
  238|   286k|            }
  239|  9.91M|            else
  240|  9.91M|            {
  241|  9.91M|                if (!encode_basic_field(stream, field))
  ------------------
  |  Branch (241:21): [True: 19, False: 9.91M]
  ------------------
  242|     19|                    return false;
  243|  9.91M|            }
  244|  10.2M|            field->pData = (char*)field->pData + field->data_size;
  245|  10.2M|        }
  246|  3.17k|    }
  247|       |    
  248|  5.98k|    return true;
  249|  6.03k|}
pb_encode.c:pb_enc_varint:
  798|  10.6M|{
  799|  10.6M|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  328|  10.6M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  10.6M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  270|  10.6M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (799:9): [True: 895k, False: 9.73M]
  ------------------
  800|   895k|    {
  801|       |        /* Perform unsigned integer extension */
  802|   895k|        pb_uint64_t value = 0;
  ------------------
  |  |   46|   895k|#define pb_uint64_t uint64_t
  ------------------
  803|       |
  804|   895k|        if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (804:13): [True: 5.92k, False: 889k]
  ------------------
  805|  5.92k|            value = *(const uint_least8_t*)field->pData;
  806|   889k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (806:18): [True: 5.92k, False: 883k]
  ------------------
  807|  5.92k|            value = *(const uint_least16_t*)field->pData;
  808|   883k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (808:18): [True: 575k, False: 308k]
  ------------------
  809|   575k|            value = *(const uint32_t*)field->pData;
  810|   308k|        else if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (810:18): [True: 308k, False: 0]
  ------------------
  811|   308k|            value = *(const pb_uint64_t*)field->pData;
  812|      0|        else
  813|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  814|       |
  815|   895k|        return pb_encode_varint(stream, value);
  816|   895k|    }
  817|  9.73M|    else
  818|  9.73M|    {
  819|       |        /* Perform signed integer extension */
  820|  9.73M|        pb_int64_t value = 0;
  ------------------
  |  |   45|  9.73M|#define pb_int64_t int64_t
  ------------------
  821|       |
  822|  9.73M|        if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (822:13): [True: 1.46M, False: 8.27M]
  ------------------
  823|  1.46M|            value = *(const int_least8_t*)field->pData;
  824|  8.27M|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (824:18): [True: 11.8k, False: 8.25M]
  ------------------
  825|  11.8k|            value = *(const int_least16_t*)field->pData;
  826|  8.25M|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (826:18): [True: 3.57M, False: 4.68M]
  ------------------
  827|  3.57M|            value = *(const int32_t*)field->pData;
  828|  4.68M|        else if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (828:18): [True: 4.68M, False: 0]
  ------------------
  829|  4.68M|            value = *(const pb_int64_t*)field->pData;
  830|      0|        else
  831|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  832|       |
  833|  9.73M|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  328|  9.73M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  9.73M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  271|  9.73M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (833:13): [True: 4.14M, False: 5.59M]
  ------------------
  834|  4.14M|            return pb_encode_svarint(stream, value);
  835|       |#ifdef PB_WITHOUT_64BIT
  836|       |        else if (value < 0)
  837|       |            return pb_encode_varint_32(stream, (uint32_t)value, (uint32_t)-1);
  838|       |#endif
  839|  5.59M|        else
  840|  5.59M|            return pb_encode_varint(stream, (pb_uint64_t)value);
  841|       |
  842|  9.73M|    }
  843|  10.6M|}
pb_encode.c:pb_enc_fixed:
  846|  35.4k|{
  847|       |#ifdef PB_CONVERT_DOUBLE_FLOAT
  848|       |    if (field->data_size == sizeof(float) && PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  849|       |    {
  850|       |        return pb_encode_float_as_double(stream, *(float*)field->pData);
  851|       |    }
  852|       |#endif
  853|       |
  854|  35.4k|    if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (854:9): [True: 21.3k, False: 14.1k]
  ------------------
  855|  21.3k|    {
  856|  21.3k|        return pb_encode_fixed32(stream, field->pData);
  857|  21.3k|    }
  858|  14.1k|#ifndef PB_WITHOUT_64BIT
  859|  14.1k|    else if (field->data_size == sizeof(uint64_t))
  ------------------
  |  Branch (859:14): [True: 14.1k, False: 0]
  ------------------
  860|  14.1k|    {
  861|  14.1k|        return pb_encode_fixed64(stream, field->pData);
  862|  14.1k|    }
  863|      0|#endif
  864|      0|    else
  865|      0|    {
  866|       |        PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  867|      0|    }
  868|  35.4k|}
pb_encode.c:encode_basic_field:
  372|  10.5M|{
  373|  10.5M|    if (!field->pData)
  ------------------
  |  Branch (373:9): [True: 0, False: 10.5M]
  ------------------
  374|      0|    {
  375|       |        /* Missing pointer field */
  376|      0|        return true;
  377|      0|    }
  378|       |
  379|  10.5M|    if (!pb_encode_tag_for_field(stream, field))
  ------------------
  |  Branch (379:9): [True: 63, False: 10.5M]
  ------------------
  380|     63|        return false;
  381|       |
  382|  10.5M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  328|  10.5M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  10.5M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  383|  10.5M|    {
  384|  3.16k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  268|  3.16k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (384:9): [True: 3.16k, False: 10.4M]
  ------------------
  385|  3.16k|            return pb_enc_bool(stream, field);
  386|       |
  387|   125k|        case PB_LTYPE_VARINT:
  ------------------
  |  |  269|   125k|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (387:9): [True: 125k, False: 10.3M]
  ------------------
  388|   169k|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  270|   169k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (388:9): [True: 44.6k, False: 10.4M]
  ------------------
  389|   187k|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  271|   187k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (389:9): [True: 18.1k, False: 10.4M]
  ------------------
  390|   187k|            return pb_enc_varint(stream, field);
  391|       |
  392|  16.4k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  272|  16.4k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (392:9): [True: 16.4k, False: 10.4M]
  ------------------
  393|  25.8k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  273|  25.8k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (393:9): [True: 9.46k, False: 10.4M]
  ------------------
  394|  25.8k|            return pb_enc_fixed(stream, field);
  395|       |
  396|   277k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  280|   277k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (396:9): [True: 277k, False: 10.2M]
  ------------------
  397|   277k|            return pb_enc_bytes(stream, field);
  398|       |
  399|  67.0k|        case PB_LTYPE_STRING:
  ------------------
  |  |  284|  67.0k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (399:9): [True: 67.0k, False: 10.4M]
  ------------------
  400|  67.0k|            return pb_enc_string(stream, field);
  401|       |
  402|  56.6k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  288|  56.6k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (402:9): [True: 56.6k, False: 10.4M]
  ------------------
  403|  56.6k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  293|  56.6k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (403:9): [True: 0, False: 10.5M]
  ------------------
  404|  56.6k|            return pb_enc_submessage(stream, field);
  405|       |
  406|  9.88M|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  303|  9.88M|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (406:9): [True: 9.88M, False: 618k]
  ------------------
  407|  9.88M|            return pb_enc_fixed_length_bytes(stream, field);
  408|       |
  409|      0|        default:
  ------------------
  |  Branch (409:9): [True: 0, False: 10.5M]
  ------------------
  410|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  411|  10.5M|    }
  412|  10.5M|}
pb_encode.c:pb_enc_bool:
  791|  3.16k|{
  792|  3.16k|    uint32_t value = safe_read_bool(field->pData) ? 1 : 0;
  ------------------
  |  Branch (792:22): [True: 1.47k, False: 1.69k]
  ------------------
  793|  3.16k|    PB_UNUSED(field);
  ------------------
  |  |  172|  3.16k|#define PB_UNUSED(x) (void)(x)
  ------------------
  794|  3.16k|    return pb_encode_varint(stream, value);
  795|  3.16k|}
pb_encode.c:pb_enc_bytes:
  871|   277k|{
  872|   277k|    const pb_bytes_array_t *bytes = NULL;
  873|       |
  874|   277k|    bytes = (const pb_bytes_array_t*)field->pData;
  875|       |    
  876|   277k|    if (bytes == NULL)
  ------------------
  |  Branch (876:9): [True: 0, False: 277k]
  ------------------
  877|      0|    {
  878|       |        /* Treat null pointer as an empty bytes field */
  879|      0|        return pb_encode_string(stream, NULL, 0);
  880|      0|    }
  881|       |    
  882|   277k|    if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  326|   277k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   277k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  321|   555k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (882:9): [True: 0, False: 277k]
  ------------------
  883|      0|        bytes->size > field->data_size - offsetof(pb_bytes_array_t, bytes))
  ------------------
  |  Branch (883:9): [True: 0, False: 0]
  ------------------
  884|      0|    {
  885|      0|        PB_RETURN_ERROR(stream, "bytes size exceeded");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  886|      0|    }
  887|       |    
  888|   277k|    return pb_encode_string(stream, bytes->bytes, (size_t)bytes->size);
  889|   277k|}
pb_encode.c:pb_enc_string:
  892|  67.0k|{
  893|  67.0k|    size_t size = 0;
  894|  67.0k|    size_t max_size = (size_t)field->data_size;
  895|  67.0k|    const char *str = (const char*)field->pData;
  896|       |    
  897|  67.0k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  67.0k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  67.0k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  67.0k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (897:9): [True: 66.8k, False: 207]
  ------------------
  898|  66.8k|    {
  899|  66.8k|        max_size = (size_t)-1;
  900|  66.8k|    }
  901|    207|    else
  902|    207|    {
  903|       |        /* pb_dec_string() assumes string fields end with a null
  904|       |         * terminator when the type isn't PB_ATYPE_POINTER, so we
  905|       |         * shouldn't allow more than max-1 bytes to be written to
  906|       |         * allow space for the null terminator.
  907|       |         */
  908|    207|        if (max_size == 0)
  ------------------
  |  Branch (908:13): [True: 0, False: 207]
  ------------------
  909|      0|            PB_RETURN_ERROR(stream, "zero-length string");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  910|       |
  911|    207|        max_size -= 1;
  912|    207|    }
  913|       |
  914|       |
  915|  67.0k|    if (str == NULL)
  ------------------
  |  Branch (915:9): [True: 0, False: 67.0k]
  ------------------
  916|      0|    {
  917|      0|        size = 0; /* Treat null pointer as an empty string */
  918|      0|    }
  919|  67.0k|    else
  920|  67.0k|    {
  921|  67.0k|        const char *p = str;
  922|       |
  923|       |        /* strnlen() is not always available, so just use a loop */
  924|   310k|        while (size < max_size && *p != '\0')
  ------------------
  |  Branch (924:16): [True: 310k, False: 20]
  |  Branch (924:35): [True: 243k, False: 67.0k]
  ------------------
  925|   243k|        {
  926|   243k|            size++;
  927|   243k|            p++;
  928|   243k|        }
  929|       |
  930|  67.0k|        if (*p != '\0')
  ------------------
  |  Branch (930:13): [True: 0, False: 67.0k]
  ------------------
  931|      0|        {
  932|      0|            PB_RETURN_ERROR(stream, "unterminated string");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  933|      0|        }
  934|  67.0k|    }
  935|       |
  936|       |#ifdef PB_VALIDATE_UTF8
  937|       |    if (!pb_validate_utf8(str))
  938|       |        PB_RETURN_ERROR(stream, "invalid utf8");
  939|       |#endif
  940|       |
  941|  67.0k|    return pb_encode_string(stream, (const pb_byte_t*)str, size);
  942|  67.0k|}
pb_encode.c:pb_enc_submessage:
  945|  56.6k|{
  946|  56.6k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (946:9): [True: 0, False: 56.6k]
  ------------------
  947|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  948|       |
  949|  56.6k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  328|  56.6k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  56.6k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  293|   113k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (949:9): [True: 0, False: 56.6k]
  |  Branch (949:58): [True: 0, False: 0]
  ------------------
  950|      0|    {
  951|       |        /* Message callback is stored right before pSize. */
  952|      0|        pb_callback_t *callback = (pb_callback_t*)field->pSize - 1;
  953|      0|        if (callback->funcs.encode)
  ------------------
  |  Branch (953:13): [True: 0, False: 0]
  ------------------
  954|      0|        {
  955|      0|            if (!callback->funcs.encode(stream, field, &callback->arg))
  ------------------
  |  Branch (955:17): [True: 0, False: 0]
  ------------------
  956|      0|                return false;
  957|      0|        }
  958|      0|    }
  959|       |    
  960|  56.6k|    return pb_encode_submessage(stream, field->submsg_desc, field->pData);
  961|  56.6k|}
pb_encode.c:pb_enc_fixed_length_bytes:
  964|  9.88M|{
  965|  9.88M|    return pb_encode_string(stream, (const pb_byte_t*)field->pData, (size_t)field->data_size);
  966|  9.88M|}
pb_encode.c:pb_encode_varint_32:
  583|  13.3M|{
  584|  13.3M|    size_t i = 0;
  585|  13.3M|    pb_byte_t buffer[10];
  586|  13.3M|    pb_byte_t byte = (pb_byte_t)(low & 0x7F);
  587|  13.3M|    low >>= 7;
  588|       |
  589|  30.4M|    while (i < 4 && (low != 0 || high != 0))
  ------------------
  |  Branch (589:12): [True: 29.3M, False: 1.12M]
  |  Branch (589:22): [True: 17.1M, False: 12.2M]
  |  Branch (589:34): [True: 5.87k, False: 12.2M]
  ------------------
  590|  17.1M|    {
  591|  17.1M|        byte |= 0x80;
  592|  17.1M|        buffer[i++] = byte;
  593|  17.1M|        byte = (pb_byte_t)(low & 0x7F);
  594|  17.1M|        low >>= 7;
  595|  17.1M|    }
  596|       |
  597|  13.3M|    if (high)
  ------------------
  |  Branch (597:9): [True: 1.07M, False: 12.2M]
  ------------------
  598|  1.07M|    {
  599|  1.07M|        byte = (pb_byte_t)(byte | ((high & 0x07) << 4));
  600|  1.07M|        high >>= 3;
  601|       |
  602|  5.93M|        while (high)
  ------------------
  |  Branch (602:16): [True: 4.85M, False: 1.07M]
  ------------------
  603|  4.85M|        {
  604|  4.85M|            byte |= 0x80;
  605|  4.85M|            buffer[i++] = byte;
  606|  4.85M|            byte = (pb_byte_t)(high & 0x7F);
  607|  4.85M|            high >>= 7;
  608|  4.85M|        }
  609|  1.07M|    }
  610|       |
  611|  13.3M|    buffer[i++] = byte;
  612|       |
  613|  13.3M|    return pb_write(stream, buffer, i);
  614|  13.3M|}

malloc_with_check:
   58|  1.44M|{
   59|  1.44M|    const size_t check2 = CHECK2;
  ------------------
  |  |   18|  1.44M|#define CHECK2 ((size_t)0x600DCAFE)
  ------------------
   60|  1.44M|    char *buf = NULL;
   61|       |
   62|  1.44M|    if (size <= g_max_alloc_bytes - g_alloc_bytes)
  ------------------
  |  Branch (62:9): [True: 1.44M, False: 0]
  ------------------
   63|  1.44M|    {
   64|  1.44M|        buf = malloc(round_blocksize(size + GUARD_SIZE));
  ------------------
  |  |   15|  1.44M|#define GUARD_SIZE (sizeof(size_t)*3)
  ------------------
   65|  1.44M|    }
   66|       |
   67|  1.44M|    if (buf)
  ------------------
  |  Branch (67:9): [True: 1.44M, False: 0]
  ------------------
   68|  1.44M|    {
   69|  1.44M|        ((size_t*)buf)[0] = size;
   70|  1.44M|        ((size_t*)buf)[1] = CHECK1;
  ------------------
  |  |   17|  1.44M|#define CHECK1 ((size_t)0xDEADBEEF)
  ------------------
   71|  1.44M|        memcpy(buf + PREFIX_SIZE + size, &check2, sizeof(check2));
  ------------------
  |  |   16|  1.44M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   72|       |
   73|  1.44M|        g_alloc_count++;
   74|  1.44M|        g_alloc_bytes += size;
   75|  1.44M|        if (DEBUG_MALLOC) fprintf(stderr, "Alloc 0x%04x/%u\n", (unsigned)(uintptr_t)(buf + PREFIX_SIZE), (unsigned)size);
  ------------------
  |  |   25|  1.44M|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (25:22): [Folded, False: 1.44M]
  |  |  ------------------
  ------------------
                      if (DEBUG_MALLOC) fprintf(stderr, "Alloc 0x%04x/%u\n", (unsigned)(uintptr_t)(buf + PREFIX_SIZE), (unsigned)size);
  ------------------
  |  |   16|      0|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   76|  1.44M|        return buf + PREFIX_SIZE;
  ------------------
  |  |   16|  1.44M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   77|  1.44M|    }
   78|      0|    else
   79|      0|    {
   80|      0|        if (DEBUG_MALLOC) fprintf(stderr, "malloc(%u) failed\n", (unsigned)size);
  ------------------
  |  |   25|      0|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (25:22): [Folded, False: 0]
  |  |  ------------------
  ------------------
   81|       |        return NULL;
   82|      0|    }
   83|  1.44M|}
free_with_check:
   87|  1.91M|{
   88|  1.91M|    if (mem)
  ------------------
  |  Branch (88:9): [True: 1.44M, False: 468k]
  ------------------
   89|  1.44M|    {
   90|  1.44M|        char *buf = (char*)mem - PREFIX_SIZE;
  ------------------
  |  |   16|  1.44M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   91|  1.44M|        size_t check2 = 0;
   92|  1.44M|        size_t size = ((size_t*)buf)[0];
   93|  1.44M|        if (DEBUG_MALLOC) fprintf(stderr, "Release 0x%04x/%u\n", (unsigned)(uintptr_t)mem, (unsigned)size);
  ------------------
  |  |   25|  1.44M|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (25:22): [Folded, False: 1.44M]
  |  |  ------------------
  ------------------
   94|  1.44M|        assert(((size_t*)buf)[1] == CHECK1);
  ------------------
  |  Branch (94:9): [True: 0, False: 1.44M]
  |  Branch (94:9): [True: 1.44M, False: 0]
  ------------------
   95|  1.44M|        memcpy(&check2, buf + PREFIX_SIZE + size, sizeof(check2));
  ------------------
  |  |   16|  1.44M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   96|  1.44M|        assert(check2 == CHECK2);
  ------------------
  |  Branch (96:9): [True: 0, False: 1.44M]
  |  Branch (96:9): [True: 1.44M, False: 0]
  ------------------
   97|  1.44M|        assert(g_alloc_count > 0);
  ------------------
  |  Branch (97:9): [True: 0, False: 1.44M]
  |  Branch (97:9): [True: 1.44M, False: 0]
  ------------------
   98|  1.44M|        assert(g_alloc_bytes >= size);
  ------------------
  |  Branch (98:9): [True: 0, False: 1.44M]
  |  Branch (98:9): [True: 1.44M, False: 0]
  ------------------
   99|  1.44M|        ((size_t*)buf)[1] = 0;
  100|  1.44M|        memset(buf + PREFIX_SIZE + size, 0, sizeof(check2));
  ------------------
  |  |   16|  1.44M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  101|  1.44M|        g_alloc_count--;
  102|  1.44M|        g_alloc_bytes -= size;
  103|  1.44M|        free(buf);
  104|  1.44M|    }
  105|  1.91M|}
realloc_with_check:
  109|  32.7M|{
  110|  32.7M|    if (!ptr && size)
  ------------------
  |  Branch (110:9): [True: 1.43M, False: 31.3M]
  |  Branch (110:17): [True: 1.43M, False: 0]
  ------------------
  111|  1.43M|    {
  112|       |        /* Allocate new block and write guard values */
  113|  1.43M|        return malloc_with_check(size);
  114|  1.43M|    }
  115|  31.3M|    else if (ptr && size)
  ------------------
  |  Branch (115:14): [True: 31.3M, False: 0]
  |  Branch (115:21): [True: 31.3M, False: 0]
  ------------------
  116|  31.3M|    {
  117|       |        /* Change block size */
  118|  31.3M|        char *buf = (char*)ptr - PREFIX_SIZE;
  ------------------
  |  |   16|  31.3M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  119|  31.3M|        size_t check2 = 0;
  120|  31.3M|        size_t oldsize = ((size_t*)buf)[0];
  121|  31.3M|        assert(((size_t*)buf)[1] == CHECK1);
  ------------------
  |  Branch (121:9): [True: 0, False: 31.3M]
  |  Branch (121:9): [True: 31.3M, False: 0]
  ------------------
  122|  31.3M|        memcpy(&check2, buf + PREFIX_SIZE + oldsize, sizeof(check2));
  ------------------
  |  |   16|  31.3M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  123|  31.3M|        assert(check2 == CHECK2);
  ------------------
  |  Branch (123:9): [True: 0, False: 31.3M]
  |  Branch (123:9): [True: 31.3M, False: 0]
  ------------------
  124|  31.3M|        assert(g_alloc_count > 0);
  ------------------
  |  Branch (124:9): [True: 0, False: 31.3M]
  |  Branch (124:9): [True: 31.3M, False: 0]
  ------------------
  125|  31.3M|        assert(g_alloc_bytes >= oldsize);
  ------------------
  |  Branch (125:9): [True: 0, False: 31.3M]
  |  Branch (125:9): [True: 31.3M, False: 0]
  ------------------
  126|       |
  127|  31.3M|        if (size <= g_max_alloc_bytes - (g_alloc_bytes - oldsize))
  ------------------
  |  Branch (127:13): [True: 31.3M, False: 0]
  ------------------
  128|  31.3M|        {
  129|  31.3M|            size_t new_rounded = round_blocksize(size + GUARD_SIZE);
  ------------------
  |  |   15|  31.3M|#define GUARD_SIZE (sizeof(size_t)*3)
  ------------------
  130|  31.3M|            size_t old_rounded = round_blocksize(oldsize + GUARD_SIZE);
  ------------------
  |  |   15|  31.3M|#define GUARD_SIZE (sizeof(size_t)*3)
  ------------------
  131|       |
  132|  31.3M|            if (new_rounded != old_rounded)
  ------------------
  |  Branch (132:17): [True: 341k, False: 30.9M]
  ------------------
  133|   341k|            {
  134|   341k|                buf = realloc(buf, new_rounded);
  135|   341k|            }
  136|  31.3M|        }
  137|      0|        else
  138|      0|        {
  139|      0|            buf = NULL;
  140|      0|        }
  141|       |
  142|  31.3M|        if (!buf)
  ------------------
  |  Branch (142:13): [True: 0, False: 31.3M]
  ------------------
  143|      0|        {
  144|      0|            if (DEBUG_MALLOC) fprintf(stderr, "Realloc 0x%04x/%u to %u failed\n", (unsigned)(uintptr_t)ptr, (unsigned)oldsize, (unsigned)size);
  ------------------
  |  |   25|      0|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (25:22): [Folded, False: 0]
  |  |  ------------------
  ------------------
  145|      0|            return NULL;
  146|      0|        }
  147|       |
  148|  31.3M|        ((size_t*)buf)[0] = size;
  149|  31.3M|        ((size_t*)buf)[1] = CHECK1;
  ------------------
  |  |   17|  31.3M|#define CHECK1 ((size_t)0xDEADBEEF)
  ------------------
  150|  31.3M|        memcpy(buf + PREFIX_SIZE + size, &check2, sizeof(check2));
  ------------------
  |  |   16|  31.3M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  151|  31.3M|        g_alloc_bytes -= oldsize;
  152|  31.3M|        g_alloc_bytes += size;
  153|       |
  154|  31.3M|        if (DEBUG_MALLOC) fprintf(stderr, "Realloc 0x%04x/%u to 0x%04x/%u\n", (unsigned)(uintptr_t)ptr, (unsigned)oldsize, (unsigned)(uintptr_t)(buf + PREFIX_SIZE), (unsigned)size);
  ------------------
  |  |   25|  31.3M|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (25:22): [Folded, False: 31.3M]
  |  |  ------------------
  ------------------
                      if (DEBUG_MALLOC) fprintf(stderr, "Realloc 0x%04x/%u to 0x%04x/%u\n", (unsigned)(uintptr_t)ptr, (unsigned)oldsize, (unsigned)(uintptr_t)(buf + PREFIX_SIZE), (unsigned)size);
  ------------------
  |  |   16|      0|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  155|  31.3M|        return buf + PREFIX_SIZE;
  ------------------
  |  |   16|  31.3M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  156|  31.3M|    }
  157|      0|    else if (ptr && !size)
  ------------------
  |  Branch (157:14): [True: 0, False: 0]
  |  Branch (157:21): [True: 0, False: 0]
  ------------------
  158|      0|    {
  159|       |        /* Deallocate */
  160|      0|        free_with_check(ptr);
  161|      0|        return NULL;
  162|      0|    }
  163|      0|    else
  164|      0|    {
  165|       |        /* No action */
  166|       |        return NULL;
  167|      0|    }
  168|  32.7M|}
get_alloc_count:
  172|  19.1k|{
  173|  19.1k|    return g_alloc_count;
  174|  19.1k|}
get_allocation_size:
  178|  1.12M|{
  179|  1.12M|    char *buf = (char*)mem - PREFIX_SIZE;
  ------------------
  |  |   16|  1.12M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  180|  1.12M|    return ((size_t*)buf)[0];
  181|  1.12M|}
malloc_wrappers.c:round_blocksize:
   39|  64.0M|{
   40|  64.0M|    if (size < 256)
  ------------------
  |  Branch (40:9): [True: 4.54M, False: 59.5M]
  ------------------
   41|  4.54M|    {
   42|  4.54M|        return size;
   43|  4.54M|    }
   44|  59.5M|    else
   45|  59.5M|    {
   46|  59.5M|        return (size + 1023) / 1024 * 1024;
   47|  59.5M|    }
   48|  64.0M|}

flakystream_callback:
    5|  35.4M|{
    6|  35.4M|    flakystream_t *state = stream->state;
    7|       |
    8|  35.4M|    if (state->position + count > state->msglen)
  ------------------
  |  Branch (8:9): [True: 1.64k, False: 35.4M]
  ------------------
    9|  1.64k|    {
   10|  1.64k|        stream->bytes_left = 0;
   11|  1.64k|        return false;
   12|  1.64k|    }
   13|  35.4M|    else if (state->position + count > state->fail_after)
  ------------------
  |  Branch (13:14): [True: 0, False: 35.4M]
  ------------------
   14|      0|    {
   15|      0|        PB_RETURN_ERROR(stream, "flaky error");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   16|      0|    }
   17|       |
   18|  35.4M|    memcpy(buf, state->buffer + state->position, count);
   19|  35.4M|    state->position += count;
   20|       |    return true;
   21|  35.4M|}
flakystream_init:
   24|  1.64k|{
   25|  1.64k|    memset(stream, 0, sizeof(*stream));
   26|  1.64k|    stream->stream.callback = flakystream_callback;
   27|       |    stream->stream.bytes_left = SIZE_MAX;
   28|  1.64k|    stream->stream.state = stream;
   29|  1.64k|    stream->buffer = buffer;
   30|  1.64k|    stream->position = 0;
   31|  1.64k|    stream->msglen = msglen;
   32|  1.64k|    stream->fail_after = fail_after;
   33|  1.64k|}

do_roundtrip:
  210|  1.64k|{
  211|  1.64k|    bool status;
  212|  1.64k|    uint32_t checksum2, checksum3;
  213|  1.64k|    size_t msglen2, msglen3;
  214|  1.64k|    uint8_t *buf2 = malloc_with_check(g_bufsize);
  215|  1.64k|    void *msg = malloc_with_check(structsize);
  216|       |
  217|       |    /* For proto2 types, we also test extension fields */
  218|  1.64k|    alltypes_static_TestExtension extmsg = alltypes_static_TestExtension_init_zero;
  ------------------
  |  |  260|  1.64k|#define alltypes_static_TestExtension_init_zero  {false, ""}
  ------------------
  219|  1.64k|    pb_extension_t ext = pb_extension_init_zero;
  ------------------
  |  |  506|  1.64k|#define pb_extension_init_zero {NULL,NULL,NULL,false}
  ------------------
  220|  1.64k|    pb_extension_t **ext_field = NULL;
  221|  1.64k|    ext.type = &alltypes_static_TestExtension_testextension;
  222|  1.64k|    ext.dest = &extmsg;
  223|  1.64k|    ext.next = NULL;
  224|       |
  225|  1.64k|    assert(buf2 && msg);
  ------------------
  |  Branch (225:5): [True: 0, False: 1.64k]
  |  Branch (225:5): [True: 0, False: 0]
  |  Branch (225:5): [True: 1.64k, False: 0]
  |  Branch (225:5): [True: 1.64k, False: 0]
  ------------------
  226|       |
  227|  1.64k|    if (msgtype == alltypes_static_AllTypes_fields)
  ------------------
  |  |  520|  1.64k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  |  Branch (227:9): [True: 0, False: 1.64k]
  ------------------
  228|      0|    {
  229|      0|        ext_field = &((alltypes_static_AllTypes*)msg)->extensions;
  230|      0|    }
  231|  1.64k|    else if (msgtype == alltypes_pointer_AllTypes_fields)
  ------------------
  |  |  494|  1.64k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  |  Branch (231:14): [True: 1.64k, False: 0]
  ------------------
  232|  1.64k|    {
  233|  1.64k|        ext_field = &((alltypes_pointer_AllTypes*)msg)->extensions;
  234|  1.64k|    }
  235|       |    
  236|       |    /* Decode and encode the input data.
  237|       |     * This will bring it into canonical format.
  238|       |     */
  239|  1.64k|    {
  240|  1.64k|        pb_istream_t stream = pb_istream_from_buffer(buffer, msglen);
  241|  1.64k|        memset(msg, 0, structsize);
  242|  1.64k|        if (ext_field) *ext_field = &ext;
  ------------------
  |  Branch (242:13): [True: 1.64k, False: 0]
  ------------------
  243|  1.64k|        status = pb_decode(&stream, msgtype, msg);
  244|  1.64k|        if (!status) fprintf(stderr, "pb_decode: %s\n", PB_GET_ERROR(&stream));
  ------------------
  |  |  920|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (920:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (244:13): [True: 0, False: 1.64k]
  ------------------
  245|  1.64k|        assert(status);
  ------------------
  |  Branch (245:9): [True: 0, False: 1.64k]
  |  Branch (245:9): [True: 1.64k, False: 0]
  ------------------
  246|       |
  247|  1.64k|        validate_message(msg, structsize, msgtype);
  248|  1.64k|    }
  249|       |    
  250|  1.64k|    {
  251|  1.64k|        pb_ostream_t stream = pb_ostream_from_buffer(buf2, g_bufsize);
  252|  1.64k|        status = pb_encode(&stream, msgtype, msg);
  253|       |
  254|       |        /* Some messages expand when re-encoding and might no longer fit
  255|       |         * in the buffer. */
  256|  1.64k|        if (!status && strcmp(PB_GET_ERROR(&stream), "stream full") != 0)
  ------------------
  |  |  920|    231|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (920:31): [True: 231, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (256:13): [True: 231, False: 1.41k]
  |  Branch (256:24): [True: 0, False: 231]
  ------------------
  257|      0|        {
  258|      0|            fprintf(stderr, "pb_encode: %s\n", PB_GET_ERROR(&stream));
  ------------------
  |  |  920|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (920:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  259|      0|            assert(status);
  ------------------
  |  Branch (259:13): [True: 0, False: 0]
  |  Branch (259:13): [True: 0, False: 0]
  ------------------
  260|      0|        }
  261|       |
  262|  1.64k|        msglen2 = stream.bytes_written;
  263|  1.64k|        checksum2 = xor32_checksum(buf2, msglen2);
  264|  1.64k|    }
  265|       |    
  266|  1.64k|    pb_release(msgtype, msg);
  267|       |
  268|       |    /* Then decode from canonical format and re-encode. Result should remain the same. */
  269|  1.64k|    if (status)
  ------------------
  |  Branch (269:9): [True: 1.41k, False: 231]
  ------------------
  270|  1.41k|    {
  271|  1.41k|        pb_istream_t stream = pb_istream_from_buffer(buf2, msglen2);
  272|  1.41k|        memset(msg, 0, structsize);
  273|  1.41k|        if (ext_field) *ext_field = &ext;
  ------------------
  |  Branch (273:13): [True: 1.41k, False: 0]
  ------------------
  274|  1.41k|        status = pb_decode(&stream, msgtype, msg);
  275|  1.41k|        if (!status) fprintf(stderr, "pb_decode: %s\n", PB_GET_ERROR(&stream));
  ------------------
  |  |  920|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (920:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (275:13): [True: 0, False: 1.41k]
  ------------------
  276|  1.41k|        assert(status);
  ------------------
  |  Branch (276:9): [True: 0, False: 1.41k]
  |  Branch (276:9): [True: 1.41k, False: 0]
  ------------------
  277|       |
  278|  1.41k|        validate_message(msg, structsize, msgtype);
  279|  1.41k|    }
  280|       |    
  281|  1.64k|    if (status)
  ------------------
  |  Branch (281:9): [True: 1.41k, False: 231]
  ------------------
  282|  1.41k|    {
  283|  1.41k|        pb_ostream_t stream = pb_ostream_from_buffer(buf2, g_bufsize);
  284|  1.41k|        status = pb_encode(&stream, msgtype, msg);
  285|  1.41k|        if (!status) fprintf(stderr, "pb_encode: %s\n", PB_GET_ERROR(&stream));
  ------------------
  |  |  920|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (920:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (285:13): [True: 0, False: 1.41k]
  ------------------
  286|  1.41k|        assert(status);
  ------------------
  |  Branch (286:9): [True: 0, False: 1.41k]
  |  Branch (286:9): [True: 1.41k, False: 0]
  ------------------
  287|  1.41k|        msglen3 = stream.bytes_written;
  288|  1.41k|        checksum3 = xor32_checksum(buf2, msglen3);
  289|       |
  290|  1.41k|        assert(msglen2 == msglen3);
  ------------------
  |  Branch (290:9): [True: 0, False: 1.41k]
  |  Branch (290:9): [True: 1.41k, False: 0]
  ------------------
  291|  1.41k|        assert(checksum2 == checksum3);
  ------------------
  |  Branch (291:9): [True: 0, False: 1.41k]
  |  Branch (291:9): [True: 1.41k, False: 0]
  ------------------
  292|  1.41k|    }
  293|       |    
  294|  1.64k|    pb_release(msgtype, msg);
  295|  1.64k|    free_with_check(msg);
  296|  1.64k|    free_with_check(buf2);
  297|  1.64k|}
do_roundtrips:
  301|  3.96k|{
  302|  3.96k|    size_t initial_alloc_count = get_alloc_count();
  303|  3.96k|    PB_UNUSED(expect_valid); /* Potentially unused depending on configuration */
  ------------------
  |  |  172|  3.96k|#define PB_UNUSED(x) (void)(x)
  ------------------
  304|       |
  305|       |#ifdef FUZZTEST_PROTO2_STATIC
  306|       |    if (do_decode(data, size, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, 0, expect_valid))
  307|       |    {
  308|       |        do_roundtrip(data, size, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields);
  309|       |        do_stream_decode(data, size, SIZE_MAX, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, 0, true);
  310|       |        do_callback_decode(data, size, true);
  311|       |    }
  312|       |#endif
  313|       |
  314|       |#ifdef FUZZTEST_PROTO3_STATIC
  315|       |    if (do_decode(data, size, sizeof(alltypes_proto3_static_AllTypes), alltypes_proto3_static_AllTypes_fields, 0, expect_valid))
  316|       |    {
  317|       |        do_roundtrip(data, size, sizeof(alltypes_proto3_static_AllTypes), alltypes_proto3_static_AllTypes_fields);
  318|       |        do_stream_decode(data, size, SIZE_MAX, sizeof(alltypes_proto3_static_AllTypes), alltypes_proto3_static_AllTypes_fields, 0, true);
  319|       |    }
  320|       |#endif
  321|       |
  322|  3.96k|#ifdef FUZZTEST_PROTO2_POINTER
  323|  3.96k|    if (do_decode(data, size, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields, 0, expect_valid))
  ------------------
  |  |  494|  3.96k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  |  Branch (323:9): [True: 1.64k, False: 2.31k]
  ------------------
  324|  1.64k|    {
  325|  1.64k|        do_roundtrip(data, size, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields);
  ------------------
  |  |  494|  1.64k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  326|  1.64k|        do_stream_decode(data, size, SIZE_MAX, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields, 0, true);
  ------------------
  |  |  494|  1.64k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  327|  1.64k|    }
  328|  3.96k|#endif
  329|       |
  330|       |#ifdef FUZZTEST_PROTO3_POINTER
  331|       |    if (do_decode(data, size, sizeof(alltypes_proto3_pointer_AllTypes), alltypes_proto3_pointer_AllTypes_fields, 0, expect_valid))
  332|       |    {
  333|       |        do_roundtrip(data, size, sizeof(alltypes_proto3_pointer_AllTypes), alltypes_proto3_pointer_AllTypes_fields);
  334|       |        do_stream_decode(data, size, SIZE_MAX, sizeof(alltypes_proto3_pointer_AllTypes), alltypes_proto3_pointer_AllTypes_fields, 0, true);
  335|       |    }
  336|       |#endif
  337|       |
  338|       |#ifdef FUZZTEST_IO_ERRORS
  339|       |    {
  340|       |        size_t orig_max_alloc_bytes = get_max_alloc_bytes();
  341|       |        /* Test decoding when error conditions occur.
  342|       |         * The decoding will end either when running out of memory or when stream returns IO error.
  343|       |         * Testing proto2 is enough for good coverage here, as it has a superset of the field types of proto3.
  344|       |         */
  345|       |        set_max_alloc_bytes(get_alloc_bytes() + 4096);
  346|       |        do_stream_decode(data, size, size - 16, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, 0, false);
  347|       |        do_stream_decode(data, size, size - 16, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields, 0, false);
  348|       |        do_stream_decode(data, size, size - 16, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields, PB_DECODE_DELIMITED, false);
  349|       |        set_max_alloc_bytes(orig_max_alloc_bytes);
  350|       |    }
  351|       |
  352|       |    /* Test pb_decode_ex() modes */
  353|       |    do_decode(data, size, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, PB_DECODE_NOINIT | PB_DECODE_DELIMITED, false);
  354|       |    do_decode(data, size, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, PB_DECODE_NULLTERMINATED, false);
  355|       |
  356|       |    /* Test callbacks also when message is not valid */
  357|       |    do_callback_decode(data, size, false);
  358|       |#endif
  359|       |
  360|       |    assert(get_alloc_count() == initial_alloc_count);
  ------------------
  |  Branch (360:5): [True: 0, False: 3.96k]
  |  Branch (360:5): [True: 3.96k, False: 0]
  ------------------
  361|  3.96k|}
LLVMFuzzerTestOneInput:
  365|  3.96k|{
  366|  3.96k|    if (size > g_bufsize)
  ------------------
  |  Branch (366:9): [True: 4, False: 3.96k]
  ------------------
  367|      4|        return 0;
  368|       |
  369|  3.96k|    do_roundtrips(data, size, false);
  370|       |
  371|  3.96k|    return 0;
  372|  3.96k|}
fuzztest.c:xor32_checksum:
   53|  3.05k|{
   54|  3.05k|    const uint8_t *buf = (const uint8_t*)data;
   55|  3.05k|    uint32_t checksum = 1234;
   56|  84.3M|    for (; len > 0; len--)
  ------------------
  |  Branch (56:12): [True: 84.3M, False: 3.05k]
  ------------------
   57|  84.3M|    {
   58|  84.3M|        checksum ^= checksum << 13;
   59|  84.3M|        checksum ^= checksum >> 17;
   60|  84.3M|        checksum ^= checksum << 5;
   61|  84.3M|        checksum += *buf++;
   62|  84.3M|    }
   63|  3.05k|    return checksum;
   64|  3.05k|}
fuzztest.c:do_decode:
   67|  3.96k|{
   68|  3.96k|    bool status;
   69|  3.96k|    pb_istream_t stream;
   70|  3.96k|    size_t initial_alloc_count = get_alloc_count();
   71|  3.96k|    uint8_t *buf2 = malloc_with_check(g_bufsize); /* This is just to match the amount of memory allocations in do_roundtrips(). */
   72|  3.96k|    void *msg = malloc_with_check(structsize);
   73|  3.96k|    alltypes_static_TestExtension extmsg = alltypes_static_TestExtension_init_zero;
  ------------------
  |  |  260|  3.96k|#define alltypes_static_TestExtension_init_zero  {false, ""}
  ------------------
   74|  3.96k|    pb_extension_t ext = pb_extension_init_zero;
  ------------------
  |  |  506|  3.96k|#define pb_extension_init_zero {NULL,NULL,NULL,false}
  ------------------
   75|  3.96k|    assert(msg);
  ------------------
  |  Branch (75:5): [True: 0, False: 3.96k]
  |  Branch (75:5): [True: 3.96k, False: 0]
  ------------------
   76|       |
   77|  3.96k|    memset(msg, 0, structsize);
   78|  3.96k|    ext.type = &alltypes_static_TestExtension_testextension;
   79|  3.96k|    ext.dest = &extmsg;
   80|  3.96k|    ext.next = NULL;
   81|       |
   82|  3.96k|    if (msgtype == alltypes_static_AllTypes_fields)
  ------------------
  |  |  520|  3.96k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  |  Branch (82:9): [True: 0, False: 3.96k]
  ------------------
   83|      0|    {
   84|      0|        ((alltypes_static_AllTypes*)msg)->extensions = &ext;
   85|      0|    }
   86|  3.96k|    else if (msgtype == alltypes_pointer_AllTypes_fields)
  ------------------
  |  |  494|  3.96k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  |  Branch (86:14): [True: 3.96k, False: 0]
  ------------------
   87|  3.96k|    {
   88|  3.96k|        ((alltypes_pointer_AllTypes*)msg)->extensions = &ext;
   89|  3.96k|    }
   90|       |
   91|  3.96k|    stream = pb_istream_from_buffer(buffer, msglen);
   92|  3.96k|    status = pb_decode_ex(&stream, msgtype, msg, flags);
   93|       |
   94|  3.96k|    if (status)
  ------------------
  |  Branch (94:9): [True: 1.64k, False: 2.31k]
  ------------------
   95|  1.64k|    {
   96|  1.64k|        validate_message(msg, structsize, msgtype);
   97|  1.64k|    }
   98|       |
   99|  3.96k|    if (assert_success)
  ------------------
  |  Branch (99:9): [True: 0, False: 3.96k]
  ------------------
  100|      0|    {
  101|      0|        if (!status) fprintf(stderr, "pb_decode: %s\n", PB_GET_ERROR(&stream));
  ------------------
  |  |  920|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (920:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (101:13): [True: 0, False: 0]
  ------------------
  102|      0|        assert(status);
  ------------------
  |  Branch (102:9): [True: 0, False: 0]
  |  Branch (102:9): [True: 0, False: 0]
  ------------------
  103|      0|    }
  104|       |
  105|  3.96k|    if (status)
  ------------------
  |  Branch (105:9): [True: 1.64k, False: 2.31k]
  ------------------
  106|  1.64k|    {
  107|       |        /* On error return, pb_release() should be called automatically. */
  108|  1.64k|        pb_release(msgtype, msg);
  109|  1.64k|    }
  110|       |
  111|  3.96k|    free_with_check(msg);
  112|  3.96k|    free_with_check(buf2);
  113|  3.96k|    assert(get_alloc_count() == initial_alloc_count);
  ------------------
  |  Branch (113:5): [True: 0, False: 3.96k]
  |  Branch (113:5): [True: 3.96k, False: 0]
  ------------------
  114|       |    
  115|  3.96k|    return status;
  116|  3.96k|}
fuzztest.c:do_stream_decode:
  119|  1.64k|{
  120|  1.64k|    bool status;
  121|  1.64k|    flakystream_t stream;
  122|  1.64k|    size_t initial_alloc_count = get_alloc_count();
  123|  1.64k|    void *msg = malloc_with_check(structsize);
  124|  1.64k|    assert(msg);
  ------------------
  |  Branch (124:5): [True: 0, False: 1.64k]
  |  Branch (124:5): [True: 1.64k, False: 0]
  ------------------
  125|       |
  126|  1.64k|    memset(msg, 0, structsize);
  127|  1.64k|    flakystream_init(&stream, buffer, msglen, fail_after);
  128|  1.64k|    status = pb_decode_ex(&stream.stream, msgtype, msg, flags);
  129|       |
  130|  1.64k|    if (status)
  ------------------
  |  Branch (130:9): [True: 1.64k, False: 0]
  ------------------
  131|  1.64k|    {
  132|  1.64k|        validate_message(msg, structsize, msgtype);
  133|  1.64k|    }
  134|       |
  135|  1.64k|    if (assert_success)
  ------------------
  |  Branch (135:9): [True: 1.64k, False: 0]
  ------------------
  136|  1.64k|    {
  137|  1.64k|        if (!status) fprintf(stderr, "pb_decode: %s\n", PB_GET_ERROR(&stream.stream));
  ------------------
  |  |  920|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (920:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (137:13): [True: 0, False: 1.64k]
  ------------------
  138|  1.64k|        assert(status);
  ------------------
  |  Branch (138:9): [True: 0, False: 1.64k]
  |  Branch (138:9): [True: 1.64k, False: 0]
  ------------------
  139|  1.64k|    }
  140|       |
  141|  1.64k|    if (status)
  ------------------
  |  Branch (141:9): [True: 1.64k, False: 0]
  ------------------
  142|  1.64k|    {
  143|       |        /* On error return, pb_release() should be called automatically. */
  144|  1.64k|        pb_release(msgtype, msg);
  145|  1.64k|    }
  146|       |
  147|  1.64k|    free_with_check(msg);
  148|  1.64k|    assert(get_alloc_count() == initial_alloc_count);
  ------------------
  |  Branch (148:5): [True: 0, False: 1.64k]
  |  Branch (148:5): [True: 1.64k, False: 0]
  ------------------
  149|       |
  150|  1.64k|    return status;
  151|  1.64k|}

validate_static:
    7|  19.0k|{
    8|  19.0k|    pb_size_t count = 1;
    9|  19.0k|    pb_size_t i;
   10|  19.0k|    bool truebool = true;
   11|  19.0k|    bool falsebool = false;
   12|       |
   13|  19.0k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  327|  19.0k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  19.0k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  314|  38.0k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (13:9): [True: 0, False: 19.0k]
  |  Branch (13:54): [True: 0, False: 0]
  ------------------
   14|      0|    {
   15|       |        /* Array count must be between 0 and statically allocated size */
   16|      0|        count = *(pb_size_t*)iter->pSize;
   17|      0|        assert(count <= iter->array_size);
  ------------------
  |  Branch (17:9): [True: 0, False: 0]
  |  Branch (17:9): [True: 0, False: 0]
  ------------------
   18|      0|    }
   19|  19.0k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  327|  19.0k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  19.0k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  312|  38.0k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (19:14): [True: 0, False: 19.0k]
  |  Branch (19:59): [True: 0, False: 0]
  ------------------
   20|      0|    {
   21|       |        /* Boolean has_ field must have a valid value */
   22|      0|        assert(memcmp(iter->pSize, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (22:9): [True: 0, False: 0]
  |  Branch (22:9): [True: 0, False: 0]
  |  Branch (22:9): [True: 0, False: 0]
  |  Branch (22:9): [True: 0, False: 0]
  ------------------
   23|      0|               memcmp(iter->pSize, &falsebool, sizeof(bool)) == 0);
   24|      0|    }
   25|  19.0k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  19.0k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  19.0k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  19.0k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (25:14): [True: 19.0k, False: 0]
  ------------------
   26|  19.0k|    {
   27|  19.0k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (27:13): [True: 18.6k, False: 391]
  ------------------
   28|  18.6k|        {
   29|       |            /* Some different field in oneof */
   30|  18.6k|            return;
   31|  18.6k|        }
   32|  19.0k|    }
   33|       |
   34|    782|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (34:17): [True: 391, False: 391]
  ------------------
   35|    391|    {
   36|    391|        void *pData = (char*)iter->pData + iter->data_size * i;
   37|       |
   38|    391|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  328|    391|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|    391|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  284|    391|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (38:13): [True: 0, False: 391]
  ------------------
   39|      0|        {
   40|       |            /* String length must be at most statically allocated size */
   41|      0|            assert(strlen(pData) + 1 <= iter->data_size);
  ------------------
  |  Branch (41:13): [True: 0, False: 0]
  |  Branch (41:13): [True: 0, False: 0]
  ------------------
   42|      0|        }
   43|    391|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  328|    391|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|    391|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  280|    391|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (43:18): [True: 0, False: 391]
  ------------------
   44|      0|        {
   45|       |            /* Bytes length must be at most statically allocated size */
   46|      0|            pb_bytes_array_t *bytes = pData;
   47|      0|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= iter->data_size);
  ------------------
  |  Branch (47:13): [True: 0, False: 0]
  |  Branch (47:13): [True: 0, False: 0]
  ------------------
   48|      0|        }
   49|    391|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  328|    391|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|    391|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  268|    391|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (49:18): [True: 0, False: 391]
  ------------------
   50|      0|        {
   51|       |            /* Bool fields must have valid value */
   52|      0|            assert(memcmp(pData, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (52:13): [True: 0, False: 0]
  |  Branch (52:13): [True: 0, False: 0]
  |  Branch (52:13): [True: 0, False: 0]
  |  Branch (52:13): [True: 0, False: 0]
  ------------------
   53|      0|                   memcmp(pData, &falsebool, sizeof(bool)) == 0);
   54|      0|        }
   55|    391|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  329|    391|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|    391|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|    391|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|    782|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 336, False: 55]
  |  |  ------------------
  |  |  330|    391|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|     55|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|     55|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|     55|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 55]
  |  |  ------------------
  ------------------
   56|    336|        {
   57|    336|            validate_message(pData, 0, iter->submsg_desc);
   58|    336|        }
   59|    391|    }
   60|    391|}
validate_pointer:
   63|   714k|{
   64|   714k|    pb_size_t count = 1;
   65|   714k|    pb_size_t i;
   66|   714k|    bool truebool = true;
   67|   714k|    bool falsebool = false;
   68|       |
   69|   714k|    if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|   714k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   714k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|   714k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (69:9): [True: 12.6k, False: 702k]
  ------------------
   70|  12.6k|    {
   71|  12.6k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (71:13): [True: 12.0k, False: 608]
  ------------------
   72|  12.0k|        {
   73|       |            /* Some different field in oneof */
   74|  12.0k|            return;
   75|  12.0k|        }
   76|  12.6k|    }
   77|   702k|    else if (!iter->pData)
  ------------------
  |  Branch (77:14): [True: 293k, False: 409k]
  ------------------
   78|   293k|    {
   79|       |        /* Nothing allocated */
   80|   293k|        if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize != &iter->array_size)
  ------------------
  |  |  327|   293k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   293k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize != &iter->array_size)
  ------------------
  |  |  314|   586k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (80:13): [True: 119k, False: 173k]
  |  Branch (80:58): [True: 107k, False: 12.1k]
  ------------------
   81|   107k|        {
   82|   107k|            assert(*(pb_size_t*)iter->pSize == 0);
  ------------------
  |  Branch (82:13): [True: 0, False: 107k]
  |  Branch (82:13): [True: 107k, False: 0]
  ------------------
   83|   107k|        }
   84|   293k|        return;
   85|   293k|    }
   86|       |
   87|   409k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|   409k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   409k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|   409k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (87:9): [True: 13.2k, False: 396k]
  ------------------
   88|  13.2k|    {
   89|       |        /* Check that enough memory has been allocated for array */
   90|  13.2k|        size_t allocated_size = get_allocation_size(iter->pData);
   91|  13.2k|        count = *(pb_size_t*)iter->pSize;
   92|  13.2k|        assert(allocated_size >= count * iter->data_size);
  ------------------
  |  Branch (92:9): [True: 0, False: 13.2k]
  |  Branch (92:9): [True: 13.2k, False: 0]
  ------------------
   93|  13.2k|    }
   94|   396k|    else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  328|   396k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   396k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  284|   792k|#define PB_LTYPE_STRING 0x07U
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  328|   330k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   330k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  280|   330k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (94:14): [True: 330k, False: 65.5k]
  |  Branch (94:57): [True: 323k, False: 7.07k]
  ------------------
   95|   323k|    {
   96|   323k|        size_t allocated_size = get_allocation_size(iter->pData);
   97|   323k|        assert(allocated_size >= iter->data_size);
  ------------------
  |  Branch (97:9): [True: 0, False: 323k]
  |  Branch (97:9): [True: 323k, False: 0]
  ------------------
   98|   323k|    }
   99|       |
  100|  41.1M|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (100:17): [True: 40.7M, False: 409k]
  ------------------
  101|  40.7M|    {
  102|  40.7M|        void *pData = (char*)iter->pData + iter->data_size * i;
  103|       |
  104|  40.7M|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  328|  40.7M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  40.7M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  284|  40.7M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (104:13): [True: 90.8k, False: 40.6M]
  ------------------
  105|  90.8k|        {
  106|       |            /* Check that enough memory is allocated for string and that
  107|       |               the string is properly terminated. */
  108|  90.8k|            const char *str = pData;
  109|       |
  110|  90.8k|            if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|  90.8k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  90.8k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|  90.8k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (110:17): [True: 25.3k, False: 65.5k]
  ------------------
  111|  25.3k|            {
  112|       |                /* String arrays are stored as array of pointers */
  113|  25.3k|                str = ((const char**)iter->pData)[i];
  114|  25.3k|            }
  115|       |
  116|  90.8k|            assert(strlen(str) + 1 <= get_allocation_size(str));
  ------------------
  |  Branch (116:13): [True: 0, False: 90.8k]
  |  Branch (116:13): [True: 90.8k, False: 0]
  ------------------
  117|  90.8k|        }
  118|  40.6M|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  328|  40.6M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  40.6M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  280|  40.6M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (118:18): [True: 701k, False: 39.9M]
  ------------------
  119|   701k|        {
  120|       |            /* Bytes length must be at most statically allocated size */
  121|   701k|            const pb_bytes_array_t *bytes = pData;
  122|       |
  123|   701k|            if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|   701k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   701k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|   701k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (123:17): [True: 694k, False: 7.07k]
  ------------------
  124|   694k|            {
  125|       |                /* Bytes arrays are stored as array of pointers */
  126|   694k|                bytes = ((const pb_bytes_array_t**)iter->pData)[i];
  127|   694k|            }
  128|       |
  129|   701k|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= get_allocation_size(bytes));
  ------------------
  |  Branch (129:13): [True: 0, False: 701k]
  |  Branch (129:13): [True: 701k, False: 0]
  ------------------
  130|   701k|        }
  131|  39.9M|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  328|  39.9M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  39.9M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  268|  39.9M|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (131:18): [True: 1.46M, False: 38.4M]
  ------------------
  132|  1.46M|        {
  133|       |            /* Bool fields must have valid value */
  134|  1.46M|            assert(memcmp(pData, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (134:13): [True: 1.46M, False: 0]
  |  Branch (134:13): [True: 0, False: 0]
  |  Branch (134:13): [True: 173k, False: 1.28M]
  |  Branch (134:13): [True: 1.28M, False: 0]
  ------------------
  135|  1.46M|                   memcmp(pData, &falsebool, sizeof(bool)) == 0);
  136|  1.46M|        }
  137|  38.4M|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  329|  38.4M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  38.4M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  38.4M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  76.9M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 117k, False: 38.3M]
  |  |  ------------------
  |  |  330|  38.4M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  38.3M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  38.3M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  38.3M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 38.3M]
  |  |  ------------------
  ------------------
  138|   117k|        {
  139|   117k|            validate_message(pData, 0, iter->submsg_desc);
  140|   117k|        }
  141|  40.7M|    }
  142|   409k|}
validate_message:
  145|   124k|{
  146|   124k|    pb_field_iter_t iter;
  147|       |
  148|   124k|    if (pb_field_iter_begin_const(&iter, msgtype, msg))
  ------------------
  |  Branch (148:9): [True: 84.0k, False: 40.1k]
  ------------------
  149|  84.0k|    {
  150|  84.0k|        do
  151|   753k|        {
  152|   753k|            if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  326|   753k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   753k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  321|   753k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (152:17): [True: 19.0k, False: 734k]
  ------------------
  153|  19.0k|            {
  154|  19.0k|                validate_static(&iter);
  155|  19.0k|            }
  156|   734k|            else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   734k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   734k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   734k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (156:22): [True: 714k, False: 19.0k]
  ------------------
  157|   714k|            {
  158|   714k|                validate_pointer(&iter);
  159|   714k|            }
  160|   753k|        } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (160:18): [True: 668k, False: 84.0k]
  ------------------
  161|  84.0k|    }
  162|   124k|}

