pb_field_iter_begin:
  157|   606k|{
  158|   606k|    memset(iter, 0, sizeof(*iter));
  159|       |
  160|   606k|    iter->descriptor = desc;
  161|   606k|    iter->message = message;
  162|       |
  163|   606k|    return load_descriptor_values(iter);
  164|   606k|}
pb_field_iter_begin_extension:
  167|   136k|{
  168|   136k|    const pb_msgdesc_t *msg = (const pb_msgdesc_t*)extension->type->arg;
  169|   136k|    bool status;
  170|       |
  171|   136k|    uint32_t word0 = PB_PROGMEM_READU32(msg->field_info[0]);
  ------------------
  |  |  184|   136k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  172|   136k|    if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   136k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   136k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   136k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (172:9): [True: 0, False: 136k]
  ------------------
  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|   136k|    else
  180|   136k|    {
  181|   136k|        status = pb_field_iter_begin(iter, msg, extension->dest);
  182|   136k|    }
  183|       |
  184|   136k|    iter->pSize = &extension->found;
  185|   136k|    return status;
  186|   136k|}
pb_field_iter_next:
  189|  1.80M|{
  190|  1.80M|    advance_iterator(iter);
  191|  1.80M|    (void)load_descriptor_values(iter);
  192|  1.80M|    return iter->index != 0;
  193|  1.80M|}
pb_field_iter_find:
  196|  7.53M|{
  197|  7.53M|    if (iter->tag == tag)
  ------------------
  |  Branch (197:9): [True: 4.42M, False: 3.11M]
  ------------------
  198|  4.42M|    {
  199|  4.42M|        return true; /* Nothing to do, correct field already. */
  200|  4.42M|    }
  201|  3.11M|    else if (tag > iter->descriptor->largest_tag)
  ------------------
  |  Branch (201:14): [True: 1.07M, False: 2.03M]
  ------------------
  202|  1.07M|    {
  203|  1.07M|        return false;
  204|  1.07M|    }
  205|  2.03M|    else
  206|  2.03M|    {
  207|  2.03M|        pb_size_t start = iter->index;
  208|  2.03M|        uint32_t fieldinfo;
  209|       |
  210|  2.03M|        if (tag < iter->tag)
  ------------------
  |  Branch (210:13): [True: 568k, False: 1.46M]
  ------------------
  211|   568k|        {
  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|   568k|            iter->index = iter->descriptor->field_count;
  216|   568k|        }
  217|       |
  218|  2.03M|        do
  219|  27.4M|        {
  220|       |            /* Advance iterator but don't load values yet */
  221|  27.4M|            advance_iterator(iter);
  222|       |
  223|       |            /* Do fast check for tag number match */
  224|  27.4M|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  184|  27.4M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  225|       |
  226|  27.4M|            if (((fieldinfo >> 2) & 0x3F) == (tag & 0x3F))
  ------------------
  |  Branch (226:17): [True: 2.11M, False: 25.3M]
  ------------------
  227|  2.11M|            {
  228|       |                /* Good candidate, check further */
  229|  2.11M|                (void)load_descriptor_values(iter);
  230|       |
  231|  2.11M|                if (iter->tag == tag &&
  ------------------
  |  Branch (231:21): [True: 1.94M, False: 166k]
  ------------------
  232|  1.94M|                    PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  1.94M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.94M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                                  PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  1.94M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (232:21): [True: 1.92M, False: 19.8k]
  ------------------
  233|  1.92M|                {
  234|       |                    /* Found it */
  235|  1.92M|                    return true;
  236|  1.92M|                }
  237|  2.11M|            }
  238|  27.4M|        } while (iter->index != start);
  ------------------
  |  Branch (238:18): [True: 25.4M, False: 112k]
  ------------------
  239|       |
  240|       |        /* Searched all the way back to start, and found nothing. */
  241|   112k|        (void)load_descriptor_values(iter);
  242|       |        return false;
  243|  2.03M|    }
  244|  7.53M|}
pb_field_iter_find_extension:
  247|  26.0k|{
  248|  26.0k|    if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  26.0k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  26.0k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  26.0k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (248:9): [True: 0, False: 26.0k]
  ------------------
  249|      0|    {
  250|      0|        return true;
  251|      0|    }
  252|  26.0k|    else
  253|  26.0k|    {
  254|  26.0k|        pb_size_t start = iter->index;
  255|  26.0k|        uint32_t fieldinfo;
  256|       |
  257|  26.0k|        do
  258|   164k|        {
  259|       |            /* Advance iterator but don't load values yet */
  260|   164k|            advance_iterator(iter);
  261|       |
  262|       |            /* Do fast check for field type */
  263|   164k|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  184|   164k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  264|       |
  265|   164k|            if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|   164k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   164k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|   164k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (265:17): [True: 3.68k, False: 161k]
  ------------------
  266|  3.68k|            {
  267|  3.68k|                return load_descriptor_values(iter);
  268|  3.68k|            }
  269|   164k|        } while (iter->index != start);
  ------------------
  |  Branch (269:18): [True: 138k, False: 22.3k]
  ------------------
  270|       |
  271|       |        /* Searched all the way back to start, and found nothing. */
  272|  22.3k|        (void)load_descriptor_values(iter);
  273|       |        return false;
  274|  26.0k|    }
  275|  26.0k|}
pb_field_iter_begin_const:
  291|  89.9k|{
  292|  89.9k|    return pb_field_iter_begin(iter, desc, pb_const_cast(message));
  293|  89.9k|}
pb_field_iter_begin_extension_const:
  296|  2.61k|{
  297|  2.61k|    return pb_field_iter_begin_extension(iter, (pb_extension_t*)pb_const_cast(extension));
  298|  2.61k|}
pb_default_field_callback:
  301|  82.3k|{
  302|  82.3k|    if (field->data_size == sizeof(pb_callback_t))
  ------------------
  |  Branch (302:9): [True: 82.3k, False: 0]
  ------------------
  303|  82.3k|    {
  304|  82.3k|        pb_callback_t *pCallback = (pb_callback_t*)field->pData;
  305|       |
  306|  82.3k|        if (pCallback != NULL)
  ------------------
  |  Branch (306:13): [True: 82.3k, False: 0]
  ------------------
  307|  82.3k|        {
  308|  82.3k|            if (istream != NULL && pCallback->funcs.decode != NULL)
  ------------------
  |  Branch (308:17): [True: 82.2k, False: 103]
  |  Branch (308:36): [True: 6.35k, False: 75.8k]
  ------------------
  309|  6.35k|            {
  310|  6.35k|                return pCallback->funcs.decode(istream, field, &pCallback->arg);
  311|  6.35k|            }
  312|       |
  313|  75.9k|            if (ostream != NULL && pCallback->funcs.encode != NULL)
  ------------------
  |  Branch (313:17): [True: 103, False: 75.8k]
  |  Branch (313:36): [True: 0, False: 103]
  ------------------
  314|      0|            {
  315|      0|                return pCallback->funcs.encode(ostream, field, &pCallback->arg);
  316|      0|            }
  317|  75.9k|        }
  318|  82.3k|    }
  319|       |
  320|  75.9k|    return true; /* Success, but didn't do anything */
  321|       |
  322|  82.3k|}
pb_common.c:load_descriptor_values:
    9|  4.66M|{
   10|  4.66M|    uint32_t word0;
   11|  4.66M|    uint32_t data_offset;
   12|  4.66M|    int_least8_t size_offset;
   13|       |
   14|  4.66M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (14:9): [True: 171k, False: 4.49M]
  ------------------
   15|   171k|        return false;
   16|       |
   17|  4.49M|    word0 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  184|  4.49M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   18|  4.49M|    iter->type = (pb_type_t)((word0 >> 8) & 0xFF);
   19|       |
   20|  4.49M|    switch(word0 & 3)
   21|  4.49M|    {
   22|   489k|        case 0: {
  ------------------
  |  Branch (22:9): [True: 489k, False: 4.00M]
  ------------------
   23|       |            /* 1-word format */
   24|   489k|            iter->array_size = 1;
   25|   489k|            iter->tag = (pb_size_t)((word0 >> 2) & 0x3F);
   26|   489k|            size_offset = (int_least8_t)((word0 >> 24) & 0x0F);
   27|   489k|            data_offset = (word0 >> 16) & 0xFF;
   28|   489k|            iter->data_size = (pb_size_t)((word0 >> 28) & 0x0F);
   29|   489k|            break;
   30|      0|        }
   31|       |
   32|  3.49M|        case 1: {
  ------------------
  |  Branch (32:9): [True: 3.49M, False: 996k]
  ------------------
   33|       |            /* 2-word format */
   34|  3.49M|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  184|  3.49M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   35|       |
   36|  3.49M|            iter->array_size = (pb_size_t)((word0 >> 16) & 0x0FFF);
   37|  3.49M|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 28) << 6));
   38|  3.49M|            size_offset = (int_least8_t)((word0 >> 28) & 0x0F);
   39|  3.49M|            data_offset = word1 & 0xFFFF;
   40|  3.49M|            iter->data_size = (pb_size_t)((word1 >> 16) & 0x0FFF);
   41|  3.49M|            break;
   42|      0|        }
   43|       |
   44|   437k|        case 2: {
  ------------------
  |  Branch (44:9): [True: 437k, False: 4.05M]
  ------------------
   45|       |            /* 4-word format */
   46|   437k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  184|   437k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   47|   437k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  184|   437k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   48|   437k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  184|   437k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   49|       |
   50|   437k|            iter->array_size = (pb_size_t)(word0 >> 16);
   51|   437k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   52|   437k|            size_offset = (int_least8_t)(word1 & 0xFF);
   53|   437k|            data_offset = word2;
   54|   437k|            iter->data_size = (pb_size_t)word3;
   55|   437k|            break;
   56|      0|        }
   57|       |
   58|  69.2k|        default: {
  ------------------
  |  Branch (58:9): [True: 69.2k, False: 4.42M]
  ------------------
   59|       |            /* 8-word format */
   60|  69.2k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  184|  69.2k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   61|  69.2k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  184|  69.2k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   62|  69.2k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  184|  69.2k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   63|  69.2k|            uint32_t word4 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 4]);
  ------------------
  |  |  184|  69.2k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   64|       |
   65|  69.2k|            iter->array_size = (pb_size_t)word4;
   66|  69.2k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   67|  69.2k|            size_offset = (int_least8_t)(word1 & 0xFF);
   68|  69.2k|            data_offset = word2;
   69|  69.2k|            iter->data_size = (pb_size_t)word3;
   70|  69.2k|            break;
   71|      0|        }
   72|  4.49M|    }
   73|       |
   74|  4.49M|    if (!iter->message)
  ------------------
  |  Branch (74:9): [True: 0, False: 4.49M]
  ------------------
   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|  4.49M|    else
   81|  4.49M|    {
   82|  4.49M|        iter->pField = (char*)iter->message + data_offset;
   83|       |
   84|  4.49M|        if (size_offset)
  ------------------
  |  Branch (84:13): [True: 1.40M, False: 3.08M]
  ------------------
   85|  1.40M|        {
   86|  1.40M|            iter->pSize = (char*)iter->pField - size_offset;
   87|  1.40M|        }
   88|  3.08M|        else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  327|  3.08M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  3.08M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  314|  6.17M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (88:18): [True: 93.0k, False: 2.99M]
  ------------------
   89|  93.0k|                 (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  326|  93.0k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  93.0k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                               (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  321|   186k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (89:19): [True: 43.6k, False: 49.4k]
  ------------------
   90|  49.4k|                  PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  326|  49.4k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  49.4k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                                PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  322|  49.4k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (90:19): [True: 0, False: 49.4k]
  ------------------
   91|  43.6k|        {
   92|       |            /* Fixed count array */
   93|  43.6k|            iter->pSize = &iter->array_size;
   94|  43.6k|        }
   95|  3.04M|        else
   96|  3.04M|        {
   97|  3.04M|            iter->pSize = NULL;
   98|  3.04M|        }
   99|       |
  100|  4.49M|        if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  326|  4.49M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  4.49M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  322|  8.98M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (100:13): [True: 0, False: 4.49M]
  |  Branch (100:57): [True: 0, False: 0]
  ------------------
  101|      0|        {
  102|      0|            iter->pData = *(void**)iter->pField;
  103|      0|        }
  104|  4.49M|        else
  105|  4.49M|        {
  106|  4.49M|            iter->pData = iter->pField;
  107|  4.49M|        }
  108|  4.49M|    }
  109|       |
  110|  4.49M|    if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  329|  4.49M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  4.49M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  4.49M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  8.98M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 650k, False: 3.84M]
  |  |  ------------------
  |  |  330|  4.49M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  3.84M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  3.84M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  3.84M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 46.8k, False: 3.79M]
  |  |  ------------------
  ------------------
  111|   697k|    {
  112|   697k|        iter->submsg_desc = iter->descriptor->submsg_info[iter->submessage_index];
  113|   697k|    }
  114|  3.79M|    else
  115|  3.79M|    {
  116|  3.79M|        iter->submsg_desc = NULL;
  117|  3.79M|    }
  118|       |
  119|       |    return true;
  120|  4.49M|}
pb_common.c:advance_iterator:
  123|  29.4M|{
  124|  29.4M|    iter->index++;
  125|       |
  126|  29.4M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (126:9): [True: 880k, False: 28.5M]
  ------------------
  127|   880k|    {
  128|       |        /* Restart */
  129|   880k|        iter->index = 0;
  130|   880k|        iter->field_info_index = 0;
  131|   880k|        iter->submessage_index = 0;
  132|   880k|        iter->required_field_index = 0;
  133|   880k|    }
  134|  28.5M|    else
  135|  28.5M|    {
  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|  28.5M|        uint32_t prev_descriptor = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  184|  28.5M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  143|  28.5M|        pb_type_t prev_type = (prev_descriptor >> 8) & 0xFF;
  144|  28.5M|        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|  28.5M|        iter->field_info_index = (pb_size_t)(iter->field_info_index + descriptor_len);
  151|  28.5M|        iter->required_field_index = (pb_size_t)(iter->required_field_index + (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED));
  ------------------
  |  |  327|  28.5M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  28.5M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      iter->required_field_index = (pb_size_t)(iter->required_field_index + (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED));
  ------------------
  |  |  311|  28.5M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  152|  28.5M|        iter->submessage_index = (pb_size_t)(iter->submessage_index + PB_LTYPE_IS_SUBMSG(prev_type));
  ------------------
  |  |  329|  28.5M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  28.5M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  28.5M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  57.1M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 3.57M, False: 24.9M]
  |  |  ------------------
  |  |  330|  28.5M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  24.9M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  24.9M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  24.9M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 142k, False: 24.8M]
  |  |  ------------------
  ------------------
  153|  28.5M|    }
  154|  29.4M|}
pb_common.c:pb_const_cast:
  278|  92.5k|{
  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|  92.5k|    union {
  283|  92.5k|        void *p1;
  284|  92.5k|        const void *p2;
  285|  92.5k|    } t;
  286|  92.5k|    t.p2 = p;
  287|  92.5k|    return t.p1;
  288|  92.5k|}

pb_read:
   82|  2.83M|{
   83|  2.83M|    if (count == 0)
  ------------------
  |  Branch (83:9): [True: 195k, False: 2.64M]
  ------------------
   84|   195k|        return true;
   85|       |
   86|  2.64M|#ifndef PB_BUFFER_ONLY
   87|  2.64M|	if (buf == NULL && stream->callback != buf_read)
  ------------------
  |  Branch (87:6): [True: 333k, False: 2.30M]
  |  Branch (87:21): [True: 76.1k, False: 257k]
  ------------------
   88|  76.1k|	{
   89|       |		/* Skip input bytes */
   90|  76.1k|		pb_byte_t tmp[16];
   91|   567k|		while (count > 16)
  ------------------
  |  Branch (91:10): [True: 491k, False: 76.1k]
  ------------------
   92|   491k|		{
   93|   491k|			if (!pb_read(stream, tmp, 16))
  ------------------
  |  Branch (93:8): [True: 0, False: 491k]
  ------------------
   94|      0|				return false;
   95|       |			
   96|   491k|			count -= 16;
   97|   491k|		}
   98|       |		
   99|  76.1k|		return pb_read(stream, tmp, count);
  100|  76.1k|	}
  101|  2.56M|#endif
  102|       |
  103|  2.56M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (103:9): [True: 262, False: 2.56M]
  ------------------
  104|    262|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  923|    262|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|    262|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 262]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  105|       |    
  106|  2.56M|#ifndef PB_BUFFER_ONLY
  107|  2.56M|    if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (107:9): [True: 0, False: 2.56M]
  ------------------
  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|  2.56M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (114:9): [True: 0, False: 2.56M]
  ------------------
  115|      0|        stream->bytes_left = 0;
  116|  2.56M|    else
  117|  2.56M|        stream->bytes_left -= count;
  118|       |
  119|       |    return true;
  120|  2.56M|}
pb_istream_from_buffer:
  143|   129k|{
  144|   129k|    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|   129k|    union {
  149|   129k|        void *state;
  150|   129k|        const void *c_state;
  151|   129k|    } state;
  152|       |#ifdef PB_BUFFER_ONLY
  153|       |    stream.callback = NULL;
  154|       |#else
  155|   129k|    stream.callback = &buf_read;
  156|   129k|#endif
  157|   129k|    state.c_state = buf;
  158|   129k|    stream.state = state.state;
  159|   129k|    stream.bytes_left = msglen;
  160|   129k|#ifndef PB_NO_ERRMSG
  161|   129k|    stream.errmsg = NULL;
  162|   129k|#endif
  163|       |#ifdef PB_MESSAGE_NESTING_MAX
  164|       |    stream.depth = 0;
  165|       |#endif
  166|   129k|    return stream;
  167|   129k|}
pb_decode_varint32:
  175|  9.29M|{
  176|  9.29M|    pb_byte_t byte;
  177|  9.29M|    uint32_t result;
  178|       |    
  179|  9.29M|    if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (179:9): [True: 1.44k, False: 9.29M]
  ------------------
  180|  1.44k|    {
  181|  1.44k|        return false;
  182|  1.44k|    }
  183|       |    
  184|  9.29M|    if ((byte & 0x80) == 0)
  ------------------
  |  Branch (184:9): [True: 7.99M, False: 1.29M]
  ------------------
  185|  7.99M|    {
  186|       |        /* Quick case, 1 byte value */
  187|  7.99M|        result = byte;
  188|  7.99M|    }
  189|  1.29M|    else
  190|  1.29M|    {
  191|       |        /* Multibyte case */
  192|  1.29M|        uint_fast8_t bitpos = 7;
  193|  1.29M|        result = byte & 0x7F;
  194|       |        
  195|  1.29M|        do
  196|  1.62M|        {
  197|  1.62M|            if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (197:17): [True: 52, False: 1.62M]
  ------------------
  198|     52|                return false;
  199|       |            
  200|  1.62M|            if (bitpos >= 32)
  ------------------
  |  Branch (200:17): [True: 18.3k, False: 1.60M]
  ------------------
  201|  18.3k|            {
  202|       |                /* Note: The varint could have trailing 0x80 bytes, or 0xFF for negative. */
  203|  18.3k|                pb_byte_t sign_extension = (bitpos < 63) ? 0xFF : 0x01;
  ------------------
  |  Branch (203:44): [True: 17.7k, False: 529]
  ------------------
  204|  18.3k|                bool valid_extension = ((byte & 0x7F) == 0x00 ||
  ------------------
  |  Branch (204:41): [True: 4.61k, False: 13.7k]
  ------------------
  205|  13.7k|                         ((result >> 31) != 0 && byte == sign_extension));
  ------------------
  |  Branch (205:27): [True: 13.6k, False: 16]
  |  Branch (205:50): [True: 13.6k, False: 51]
  ------------------
  206|       |
  207|  18.3k|                if (bitpos >= 64 || !valid_extension)
  ------------------
  |  Branch (207:21): [True: 3, False: 18.3k]
  |  Branch (207:37): [True: 65, False: 18.2k]
  ------------------
  208|     68|                {
  209|     68|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  923|     68|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     68|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 68]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  210|     68|                }
  211|  18.3k|            }
  212|  1.60M|            else if (bitpos == 28)
  ------------------
  |  Branch (212:22): [True: 11.6k, False: 1.59M]
  ------------------
  213|  11.6k|            {
  214|  11.6k|                if ((byte & 0x70) != 0 && (byte & 0x78) != 0x78)
  ------------------
  |  Branch (214:21): [True: 4.79k, False: 6.82k]
  |  Branch (214:43): [True: 14, False: 4.77k]
  ------------------
  215|     14|                {
  216|     14|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  217|     14|                }
  218|  11.6k|                result |= (uint32_t)(byte & 0x0F) << bitpos;
  219|  11.6k|            }
  220|  1.59M|            else
  221|  1.59M|            {
  222|  1.59M|                result |= (uint32_t)(byte & 0x7F) << bitpos;
  223|  1.59M|            }
  224|  1.62M|            bitpos = (uint_fast8_t)(bitpos + 7);
  225|  1.62M|        } while (byte & 0x80);
  ------------------
  |  Branch (225:18): [True: 327k, False: 1.29M]
  ------------------
  226|  1.29M|   }
  227|       |   
  228|  9.29M|   *dest = result;
  229|       |   return true;
  230|  9.29M|}
pb_decode_varint:
  234|  5.31M|{
  235|  5.31M|    pb_byte_t byte;
  236|  5.31M|    uint_fast8_t bitpos = 0;
  237|  5.31M|    uint64_t result = 0;
  238|       |    
  239|  5.31M|    do
  240|  6.57M|    {
  241|  6.57M|        if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (241:13): [True: 54, False: 6.57M]
  ------------------
  242|     54|            return false;
  243|       |
  244|  6.57M|        if (bitpos >= 63 && (byte & 0xFE) != 0)
  ------------------
  |  Branch (244:13): [True: 54.5k, False: 6.51M]
  |  Branch (244:29): [True: 25, False: 54.5k]
  ------------------
  245|     25|            PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  923|     25|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     25|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  246|       |
  247|  6.57M|        result |= (uint64_t)(byte & 0x7F) << bitpos;
  248|  6.57M|        bitpos = (uint_fast8_t)(bitpos + 7);
  249|  6.57M|    } while (byte & 0x80);
  ------------------
  |  Branch (249:14): [True: 1.25M, False: 5.31M]
  ------------------
  250|       |    
  251|  5.31M|    *dest = result;
  252|       |    return true;
  253|  5.31M|}
pb_decode_tag:
  282|  8.40M|{
  283|  8.40M|    uint32_t temp;
  284|  8.40M|    *eof = false;
  285|  8.40M|    *wire_type = (pb_wire_type_t) 0;
  286|  8.40M|    *tag = 0;
  287|       |
  288|  8.40M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (288:9): [True: 285k, False: 8.12M]
  ------------------
  289|   285k|    {
  290|   285k|        *eof = true;
  291|   285k|        return false;
  292|   285k|    }
  293|       |
  294|  8.12M|    if (!pb_decode_varint32(stream, &temp))
  ------------------
  |  Branch (294:9): [True: 1.41k, False: 8.12M]
  ------------------
  295|  1.41k|    {
  296|  1.41k|#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.41k|        if (stream->callback != buf_read && stream->bytes_left == 0)
  ------------------
  |  Branch (304:13): [True: 1.30k, False: 110]
  |  Branch (304:45): [True: 1.30k, False: 0]
  ------------------
  305|  1.30k|        {
  306|  1.30k|#ifndef PB_NO_ERRMSG
  307|  1.30k|            if (strcmp(stream->errmsg, "io error") == 0)
  ------------------
  |  Branch (307:17): [True: 1.30k, False: 0]
  ------------------
  308|  1.30k|                stream->errmsg = NULL;
  309|  1.30k|#endif
  310|  1.30k|            *eof = true;
  311|  1.30k|        }
  312|  1.41k|#endif
  313|  1.41k|        return false;
  314|  1.41k|    }
  315|       |    
  316|  8.12M|    *tag = temp >> 3;
  317|  8.12M|    *wire_type = (pb_wire_type_t)(temp & 7);
  318|       |    return true;
  319|  8.12M|}
pb_skip_field:
  322|  1.18M|{
  323|  1.18M|    switch (wire_type)
  324|  1.18M|    {
  325|   787k|        case PB_WT_VARINT: return pb_skip_varint(stream);
  ------------------
  |  Branch (325:9): [True: 787k, False: 392k]
  ------------------
  326|  80.9k|        case PB_WT_64BIT: return pb_read(stream, NULL, 8);
  ------------------
  |  Branch (326:9): [True: 80.9k, False: 1.09M]
  ------------------
  327|   180k|        case PB_WT_STRING: return pb_skip_string(stream);
  ------------------
  |  Branch (327:9): [True: 180k, False: 1.00M]
  ------------------
  328|   131k|        case PB_WT_32BIT: return pb_read(stream, NULL, 4);
  ------------------
  |  Branch (328:9): [True: 131k, False: 1.04M]
  ------------------
  329|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (329:2): [True: 0, False: 1.18M]
  ------------------
  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|     90|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  923|     90|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     90|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 90]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (334:9): [True: 90, False: 1.18M]
  ------------------
  335|  1.18M|    }
  336|  1.18M|}
pb_make_string_substream:
  387|   380k|{
  388|   380k|    uint32_t size;
  389|   380k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (389:9): [True: 78, False: 380k]
  ------------------
  390|     78|        return false;
  391|       |    
  392|   380k|    *substream = *stream;
  393|   380k|    if (substream->bytes_left < size)
  ------------------
  |  Branch (393:9): [True: 129, False: 380k]
  ------------------
  394|    129|        PB_RETURN_ERROR(stream, "parent stream too short");
  ------------------
  |  |  923|    129|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|    129|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 129]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|   380k|    substream->bytes_left = (size_t)size;
  403|   380k|    stream->bytes_left -= (size_t)size;
  404|       |    return true;
  405|   380k|}
pb_close_string_substream:
  408|   380k|{
  409|   380k|    if (substream->bytes_left) {
  ------------------
  |  Branch (409:9): [True: 24.3k, False: 355k]
  ------------------
  410|  24.3k|        if (!pb_read(substream, NULL, substream->bytes_left))
  ------------------
  |  Branch (410:13): [True: 0, False: 24.3k]
  ------------------
  411|      0|            return false;
  412|  24.3k|    }
  413|       |
  414|   380k|    stream->state = substream->state;
  415|       |
  416|   380k|#ifndef PB_NO_ERRMSG
  417|   380k|    stream->errmsg = substream->errmsg;
  418|   380k|#endif
  419|       |    return true;
  420|   380k|}
pb_decode_ex:
 1220|  8.41k|{
 1221|  8.41k|    bool status;
 1222|       |
 1223|  8.41k|    if ((flags & PB_DECODE_DELIMITED) == 0)
  ------------------
  |  |  123|  8.41k|#define PB_DECODE_DELIMITED       0x02U
  ------------------
  |  Branch (1223:9): [True: 8.41k, False: 0]
  ------------------
 1224|  8.41k|    {
 1225|  8.41k|      status = pb_decode_inner(stream, fields, dest_struct, flags);
 1226|  8.41k|    }
 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|       |#ifdef PB_ENABLE_MALLOC
 1240|       |    if (!status)
 1241|       |        pb_release(fields, dest_struct);
 1242|       |#endif
 1243|       |    
 1244|  8.41k|    return status;
 1245|  8.41k|}
pb_decode:
 1248|  3.91k|{
 1249|  3.91k|    return pb_decode_ex(stream, fields, dest_struct, 0);
 1250|  3.91k|}
pb_release:
 1393|  6.53k|{
 1394|       |    /* Nothing to release without PB_ENABLE_MALLOC. */
 1395|  6.53k|    PB_UNUSED(fields);
  ------------------
  |  |  172|  6.53k|#define PB_UNUSED(x) (void)(x)
  ------------------
 1396|  6.53k|    PB_UNUSED(dest_struct);
  ------------------
  |  |  172|  6.53k|#define PB_UNUSED(x) (void)(x)
  ------------------
 1397|  6.53k|}
pb_decode_bool:
 1403|   318k|{
 1404|   318k|    uint32_t value;
 1405|   318k|    if (!pb_decode_varint32(stream, &value))
  ------------------
  |  Branch (1405:9): [True: 16, False: 318k]
  ------------------
 1406|     16|        return false;
 1407|       |
 1408|   318k|    *(bool*)dest = (value != 0);
 1409|       |    return true;
 1410|   318k|}
pb_decode_svarint:
 1413|   179k|{
 1414|   179k|    pb_uint64_t value;
  ------------------
  |  |   57|   179k|#define pb_uint64_t uint64_t
  ------------------
 1415|   179k|    if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1415:9): [True: 19, False: 179k]
  ------------------
 1416|     19|        return false;
 1417|       |    
 1418|   179k|    if (value & 1)
  ------------------
  |  Branch (1418:9): [True: 30.0k, False: 149k]
  ------------------
 1419|  30.0k|        *dest = (pb_int64_t)(~(value >> 1));
 1420|   149k|    else
 1421|   149k|        *dest = (pb_int64_t)(value >> 1);
 1422|       |    
 1423|       |    return true;
 1424|   179k|}
pb_decode_fixed32:
 1427|   303k|{
 1428|   303k|    union {
 1429|   303k|        uint32_t fixed32;
 1430|   303k|        pb_byte_t bytes[4];
 1431|   303k|    } u;
 1432|       |
 1433|   303k|    if (!pb_read(stream, u.bytes, 4))
  ------------------
  |  Branch (1433:9): [True: 12, False: 303k]
  ------------------
 1434|     12|        return false;
 1435|       |
 1436|   303k|#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|   303k|    *(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|   303k|}
pb_decode_fixed64:
 1450|   247k|{
 1451|   247k|    union {
 1452|   247k|        uint64_t fixed64;
 1453|   247k|        pb_byte_t bytes[8];
 1454|   247k|    } u;
 1455|       |
 1456|   247k|    if (!pb_read(stream, u.bytes, 8))
  ------------------
  |  Branch (1456:9): [True: 14, False: 247k]
  ------------------
 1457|     14|        return false;
 1458|       |
 1459|   247k|#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|   247k|    *(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|   247k|}
pb_decode.c:buf_read:
   69|  15.3M|{
   70|  15.3M|    const pb_byte_t *source = (const pb_byte_t*)stream->state;
   71|  15.3M|    stream->state = (pb_byte_t*)stream->state + count;
   72|       |    
   73|  15.3M|    if (buf != NULL)
  ------------------
  |  Branch (73:9): [True: 15.0M, False: 257k]
  ------------------
   74|  15.0M|    {
   75|  15.0M|        memcpy(buf, source, count * sizeof(pb_byte_t));
   76|  15.0M|    }
   77|       |    
   78|       |    return true;
   79|  15.3M|}
pb_decode.c:pb_readbyte:
  125|  17.4M|{
  126|  17.4M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (126:9): [True: 244, False: 17.4M]
  ------------------
  127|    244|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  923|    244|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|    244|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 244]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  128|       |
  129|  17.4M|#ifndef PB_BUFFER_ONLY
  130|  17.4M|    if (!stream->callback(stream, buf, 1))
  ------------------
  |  Branch (130:9): [True: 1.30k, False: 17.4M]
  ------------------
  131|  1.30k|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  923|  1.30k|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|  1.30k|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 1.30k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  132|       |#else
  133|       |    *buf = *(const pb_byte_t*)stream->state;
  134|       |    stream->state = (pb_byte_t*)stream->state + 1;
  135|       |#endif
  136|       |
  137|  17.4M|    stream->bytes_left--;
  138|       |    
  139|       |    return true;    
  140|  17.4M|}
pb_decode.c:pb_skip_varint:
  257|   787k|{
  258|   787k|    pb_byte_t byte;
  259|   787k|    do
  260|   985k|    {
  261|   985k|        if (!pb_read(stream, &byte, 1))
  ------------------
  |  Branch (261:13): [True: 60, False: 985k]
  ------------------
  262|     60|            return false;
  263|   985k|    } while (byte & 0x80);
  ------------------
  |  Branch (263:14): [True: 197k, False: 787k]
  ------------------
  264|   787k|    return true;
  265|   787k|}
pb_decode.c:pb_skip_string:
  268|   180k|{
  269|   180k|    uint32_t length;
  270|   180k|    if (!pb_decode_varint32(stream, &length))
  ------------------
  |  Branch (270:9): [True: 56, False: 180k]
  ------------------
  271|     56|        return false;
  272|       |    
  273|   180k|    if ((size_t)length != length)
  ------------------
  |  Branch (273:9): [True: 0, False: 180k]
  ------------------
  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|   180k|    return pb_read(stream, NULL, (size_t)length);
  279|   180k|}
pb_decode.c:pb_decode_inner:
 1049|   288k|{
 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|   288k|    uint32_t extension_range_start = 0;
 1055|   288k|    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|   288k|    pb_size_t fixed_count_field = PB_SIZE_MAX;
  ------------------
  |  |  342|   288k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
 1062|   288k|    pb_size_t fixed_count_size = 0;
 1063|   288k|    pb_size_t fixed_count_total_size = 0;
 1064|       |
 1065|       |    /* Tag and wire type of next field from the input stream */
 1066|   288k|    uint32_t tag;
 1067|   288k|    pb_wire_type_t wire_type;
 1068|   288k|    bool eof;
 1069|       |
 1070|       |    /* Track presence of required fields */
 1071|   288k|    pb_fields_seen_t fields_seen = {{0, 0}};
 1072|   288k|    const uint32_t allbits = ~(uint32_t)0;
 1073|       |
 1074|       |    /* Descriptor for the structure field matching the tag decoded from stream */
 1075|   288k|    pb_field_iter_t iter;
 1076|       |
 1077|   288k|    if (pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1077:9): [True: 158k, False: 129k]
  ------------------
 1078|   158k|    {
 1079|   158k|        if ((flags & PB_DECODE_NOINIT) == 0)
  ------------------
  |  |  122|   158k|#define PB_DECODE_NOINIT          0x01U
  ------------------
  |  Branch (1079:13): [True: 12.4k, False: 146k]
  ------------------
 1080|  12.4k|        {
 1081|  12.4k|            if (!pb_message_set_to_defaults(&iter))
  ------------------
  |  Branch (1081:17): [True: 0, False: 12.4k]
  ------------------
 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|  12.4k|        }
 1084|   158k|    }
 1085|       |
 1086|  7.82M|    while (pb_decode_tag(stream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1086:12): [True: 7.53M, False: 287k]
  ------------------
 1087|  7.53M|    {
 1088|  7.53M|        if (tag == 0)
  ------------------
  |  Branch (1088:13): [True: 67, False: 7.53M]
  ------------------
 1089|     67|        {
 1090|     67|          if (flags & PB_DECODE_NULLTERMINATED)
  ------------------
  |  |  124|     67|#define PB_DECODE_NULLTERMINATED  0x04U
  ------------------
  |  Branch (1090:15): [True: 0, False: 67]
  ------------------
 1091|      0|          {
 1092|      0|            eof = true;
 1093|      0|            break;
 1094|      0|          }
 1095|     67|          else
 1096|     67|          {
 1097|     67|            PB_RETURN_ERROR(stream, "zero tag");
  ------------------
  |  |  923|     67|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     67|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 67]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1098|     67|          }
 1099|     67|        }
 1100|       |
 1101|  7.53M|        if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  6.34M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  6.34M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  6.34M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1101:13): [True: 1.18M, False: 6.34M]
  |  Branch (1101:48): [True: 452, False: 6.34M]
  ------------------
 1102|  1.18M|        {
 1103|       |            /* No match found, check if it matches an extension. */
 1104|  1.18M|            if (extension_range_start == 0)
  ------------------
  |  Branch (1104:17): [True: 26.0k, False: 1.16M]
  ------------------
 1105|  26.0k|            {
 1106|  26.0k|                if (pb_field_iter_find_extension(&iter))
  ------------------
  |  Branch (1106:21): [True: 3.68k, False: 22.3k]
  ------------------
 1107|  3.68k|                {
 1108|  3.68k|                    extensions = *(pb_extension_t* const *)iter.pData;
 1109|  3.68k|                    extension_range_start = iter.tag;
 1110|  3.68k|                }
 1111|       |
 1112|  26.0k|                if (!extensions)
  ------------------
  |  Branch (1112:21): [True: 23.2k, False: 2.73k]
  ------------------
 1113|  23.2k|                {
 1114|  23.2k|                    extension_range_start = (uint32_t)-1;
 1115|  23.2k|                }
 1116|  26.0k|            }
 1117|       |
 1118|  1.18M|            if (tag >= extension_range_start)
  ------------------
  |  Branch (1118:17): [True: 128k, False: 1.05M]
  ------------------
 1119|   128k|            {
 1120|   128k|                size_t pos = stream->bytes_left;
 1121|       |
 1122|   128k|                if (!decode_extension(stream, tag, wire_type, extensions))
  ------------------
  |  Branch (1122:21): [True: 38, False: 128k]
  ------------------
 1123|     38|                    return false;
 1124|       |
 1125|   128k|                if (pos != stream->bytes_left)
  ------------------
  |  Branch (1125:21): [True: 5.96k, False: 122k]
  ------------------
 1126|  5.96k|                {
 1127|       |                    /* The field was handled */
 1128|  5.96k|                    continue;
 1129|  5.96k|                }
 1130|   128k|            }
 1131|       |
 1132|       |            /* No match found, skip data */
 1133|  1.18M|            if (!pb_skip_field(stream, wire_type))
  ------------------
  |  Branch (1133:17): [True: 321, False: 1.18M]
  ------------------
 1134|    321|                return false;
 1135|  1.18M|            continue;
 1136|  1.18M|        }
 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|  6.34M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  327|  6.34M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  6.34M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  314|  12.6M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1141:13): [True: 39.9k, False: 6.30M]
  |  Branch (1141:57): [True: 3.60k, False: 36.3k]
  ------------------
 1142|  3.60k|        {
 1143|  3.60k|            if (fixed_count_field != iter.index) {
  ------------------
  |  Branch (1143:17): [True: 3.26k, False: 341]
  ------------------
 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|  3.26k|                if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  342|  6.53k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1148:21): [True: 1.65k, False: 1.60k]
  ------------------
 1149|  1.65k|                    fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1149:21): [True: 3, False: 1.65k]
  ------------------
 1150|      3|                {
 1151|      3|                    PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1152|      3|                }
 1153|       |
 1154|  3.26k|                fixed_count_field = iter.index;
 1155|  3.26k|                fixed_count_size = 0;
 1156|  3.26k|                fixed_count_total_size = iter.array_size;
 1157|  3.26k|            }
 1158|       |
 1159|  3.60k|            iter.pSize = &fixed_count_size;
 1160|  3.60k|        }
 1161|       |
 1162|  6.34M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  327|  6.34M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  6.34M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  311|  12.6M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (1162:13): [True: 5.82M, False: 526k]
  ------------------
 1163|  5.82M|            && iter.required_field_index < PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  233|  5.82M|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1163:16): [True: 5.82M, False: 0]
  ------------------
 1164|  5.82M|        {
 1165|  5.82M|            uint32_t tmp = ((uint32_t)1 << (iter.required_field_index & 31));
 1166|  5.82M|            fields_seen.bitfield[iter.required_field_index >> 5] |= tmp;
 1167|  5.82M|        }
 1168|       |
 1169|  6.34M|        if (!decode_field(stream, wire_type, &iter))
  ------------------
  |  Branch (1169:13): [True: 1.26k, False: 6.34M]
  ------------------
 1170|  1.26k|            return false;
 1171|  6.34M|    }
 1172|       |
 1173|   287k|    if (!eof)
  ------------------
  |  Branch (1173:9): [True: 110, False: 287k]
  ------------------
 1174|    110|    {
 1175|       |        /* pb_decode_tag() returned error before end of stream */
 1176|    110|        return false;
 1177|    110|    }
 1178|       |
 1179|       |    /* Check that all elements of the last decoded fixed count field were present. */
 1180|   287k|    if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  342|   574k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1180:9): [True: 1.55k, False: 285k]
  ------------------
 1181|  1.55k|        fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1181:9): [True: 10, False: 1.54k]
  ------------------
 1182|     10|    {
 1183|     10|        PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  923|     10|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     10|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1184|     10|    }
 1185|       |
 1186|       |    /* Check that all required fields were present. */
 1187|   287k|    {
 1188|   287k|        pb_size_t req_field_count = iter.descriptor->required_field_count;
 1189|       |
 1190|   287k|        if (req_field_count > 0)
  ------------------
  |  Branch (1190:13): [True: 151k, False: 135k]
  ------------------
 1191|   151k|        {
 1192|   151k|            pb_size_t i;
 1193|       |
 1194|   151k|            if (req_field_count > PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  233|   151k|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1194:17): [True: 0, False: 151k]
  ------------------
 1195|      0|                req_field_count = PB_MAX_REQUIRED_FIELDS;
  ------------------
  |  |  233|      0|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
 1196|       |
 1197|       |            /* Check the whole words */
 1198|   151k|            for (i = 0; i < (req_field_count >> 5); i++)
  ------------------
  |  Branch (1198:25): [True: 0, False: 151k]
  ------------------
 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|   151k|            if ((req_field_count & 31) != 0)
  ------------------
  |  Branch (1205:17): [True: 151k, False: 0]
  ------------------
 1206|   151k|            {
 1207|   151k|                if (fields_seen.bitfield[req_field_count >> 5] !=
  ------------------
  |  Branch (1207:21): [True: 342, False: 150k]
  ------------------
 1208|   151k|                    (allbits >> (uint_least8_t)(32 - (req_field_count & 31))))
 1209|    342|                {
 1210|    342|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  923|    342|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|    342|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 342]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1211|    342|                }
 1212|   151k|            }
 1213|   151k|        }
 1214|   287k|    }
 1215|       |
 1216|   286k|    return true;
 1217|   287k|}
pb_decode.c:pb_message_set_to_defaults:
 1010|   109k|{
 1011|   109k|    pb_istream_t defstream = PB_ISTREAM_EMPTY;
  ------------------
  |  |   71|   109k|#  define PB_ISTREAM_EMPTY {0,0,0,0}
  ------------------
 1012|   109k|    uint32_t tag = 0;
 1013|   109k|    pb_wire_type_t wire_type = PB_WT_VARINT;
 1014|   109k|    bool eof;
 1015|       |
 1016|   109k|    if (iter->descriptor->default_value)
  ------------------
  |  Branch (1016:9): [True: 103k, False: 5.80k]
  ------------------
 1017|   103k|    {
 1018|   103k|        defstream = pb_istream_from_buffer(iter->descriptor->default_value, (size_t)-1);
 1019|   103k|        if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1019:13): [True: 0, False: 103k]
  ------------------
 1020|      0|            return false;
 1021|   103k|    }
 1022|       |
 1023|   109k|    do
 1024|   965k|    {
 1025|   965k|        if (!pb_field_set_to_default(iter))
  ------------------
  |  Branch (1025:13): [True: 0, False: 965k]
  ------------------
 1026|      0|            return false;
 1027|       |
 1028|   965k|        if (tag != 0 && iter->tag == tag)
  ------------------
  |  Branch (1028:13): [True: 867k, False: 98.4k]
  |  Branch (1028:25): [True: 481k, False: 385k]
  ------------------
 1029|   481k|        {
 1030|       |            /* We have a default value for this field in the defstream */
 1031|   481k|            if (!decode_field(&defstream, wire_type, iter))
  ------------------
  |  Branch (1031:17): [True: 0, False: 481k]
  ------------------
 1032|      0|                return false;
 1033|   481k|            if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1033:17): [True: 0, False: 481k]
  ------------------
 1034|      0|                return false;
 1035|       |
 1036|   481k|            if (iter->pSize)
  ------------------
  |  Branch (1036:17): [True: 234k, False: 247k]
  ------------------
 1037|   234k|                *(bool*)iter->pSize = false;
 1038|   481k|        }
 1039|   965k|    } while (pb_field_iter_next(iter));
  ------------------
  |  Branch (1039:14): [True: 855k, False: 109k]
  ------------------
 1040|       |
 1041|   109k|    return true;
 1042|   109k|}
pb_decode.c:pb_field_set_to_default:
  928|   965k|{
  929|   965k|    pb_type_t type;
  930|   965k|    type = field->type;
  931|       |
  932|   965k|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|   965k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   965k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|   965k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (932:9): [True: 8.41k, False: 957k]
  ------------------
  933|  8.41k|    {
  934|  8.41k|        pb_extension_t *ext = *(pb_extension_t* const *)field->pData;
  935|  14.2k|        while (ext != NULL)
  ------------------
  |  Branch (935:16): [True: 5.80k, False: 8.41k]
  ------------------
  936|  5.80k|        {
  937|  5.80k|            pb_field_iter_t ext_iter;
  938|  5.80k|            if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (938:17): [True: 5.80k, False: 0]
  ------------------
  939|  5.80k|            {
  940|  5.80k|                ext->found = false;
  941|  5.80k|                if (!pb_message_set_to_defaults(&ext_iter))
  ------------------
  |  Branch (941:21): [True: 0, False: 5.80k]
  ------------------
  942|      0|                    return false;
  943|  5.80k|            }
  944|  5.80k|            ext = ext->next;
  945|  5.80k|        }
  946|  8.41k|    }
  947|   957k|    else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  326|   957k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   957k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  321|   957k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (947:14): [True: 885k, False: 71.6k]
  ------------------
  948|   885k|    {
  949|   885k|        bool init_data = true;
  950|   885k|        if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  327|   885k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   885k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  312|  1.77M|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (950:13): [True: 251k, False: 634k]
  |  Branch (950:52): [True: 251k, False: 0]
  ------------------
  951|   251k|        {
  952|       |            /* Set has_field to false. Still initialize the optional field
  953|       |             * itself also. */
  954|   251k|            *(bool*)field->pSize = false;
  955|   251k|        }
  956|   634k|        else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  327|   634k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   634k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  314|  1.26M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (956:18): [True: 149k, False: 484k]
  ------------------
  957|   484k|                 PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|   484k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   484k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                               PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|   484k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (957:18): [True: 42.0k, False: 442k]
  ------------------
  958|   191k|        {
  959|       |            /* REPEATED: Set array count to 0, no need to initialize contents.
  960|       |               ONEOF: Set which_field to 0. */
  961|   191k|            *(pb_size_t*)field->pSize = 0;
  962|   191k|            init_data = false;
  963|   191k|        }
  964|       |
  965|   885k|        if (init_data)
  ------------------
  |  Branch (965:13): [True: 694k, False: 191k]
  ------------------
  966|   694k|        {
  967|   694k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  329|  1.38M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|   694k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|   694k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  1.38M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 64.7k, False: 629k]
  |  |  ------------------
  |  |  330|  1.38M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|   629k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|   629k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|   629k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 629k]
  |  |  ------------------
  ------------------
  968|  64.7k|                (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (968:18): [True: 25.2k, False: 39.4k]
  ------------------
  969|  39.4k|                 field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (969:18): [True: 0, False: 39.4k]
  ------------------
  970|  39.4k|                 field->submsg_desc->submsg_info[0] != NULL))
  ------------------
  |  Branch (970:18): [True: 0, False: 39.4k]
  ------------------
  971|  25.2k|            {
  972|       |                /* Initialize submessage to defaults.
  973|       |                 * Only needed if it has default values
  974|       |                 * or callback/submessage fields. */
  975|  25.2k|                pb_field_iter_t submsg_iter;
  976|  25.2k|                if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (976:21): [True: 25.2k, False: 0]
  ------------------
  977|  25.2k|                {
  978|  25.2k|                    if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (978:25): [True: 0, False: 25.2k]
  ------------------
  979|      0|                        return false;
  980|  25.2k|                }
  981|  25.2k|            }
  982|   668k|            else
  983|   668k|            {
  984|       |                /* Initialize to zeros */
  985|   668k|                memset(field->pData, 0, (size_t)field->data_size);
  986|   668k|            }
  987|   694k|        }
  988|   885k|    }
  989|  71.6k|    else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  71.6k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  71.6k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  71.6k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (989:14): [True: 0, False: 71.6k]
  ------------------
  990|      0|    {
  991|       |        /* Initialize the pointer to NULL. */
  992|      0|        *(void**)field->pField = NULL;
  993|       |
  994|       |        /* Initialize array count to 0. */
  995|      0|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  327|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  314|      0|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (995:13): [True: 0, False: 0]
  ------------------
  996|      0|            PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|      0|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (996:13): [True: 0, False: 0]
  ------------------
  997|      0|        {
  998|      0|            *(pb_size_t*)field->pSize = 0;
  999|      0|        }
 1000|      0|    }
 1001|  71.6k|    else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  326|  71.6k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  71.6k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|  71.6k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (1001:14): [True: 71.6k, False: 0]
  ------------------
 1002|  71.6k|    {
 1003|       |        /* Don't overwrite callback */
 1004|  71.6k|    }
 1005|       |
 1006|   965k|    return true;
 1007|   965k|}
pb_decode.c:decode_extension:
  906|   128k|{
  907|   128k|    size_t pos = stream->bytes_left;
  908|       |    
  909|   256k|    while (extension != NULL && pos == stream->bytes_left)
  ------------------
  |  Branch (909:12): [True: 128k, False: 128k]
  |  Branch (909:33): [True: 128k, False: 0]
  ------------------
  910|   128k|    {
  911|   128k|        bool status;
  912|   128k|        if (extension->type->decode)
  ------------------
  |  Branch (912:13): [True: 0, False: 128k]
  ------------------
  913|      0|            status = extension->type->decode(stream, extension, tag, wire_type);
  914|   128k|        else
  915|   128k|            status = default_extension_decoder(stream, extension, tag, wire_type);
  916|       |
  917|   128k|        if (!status)
  ------------------
  |  Branch (917:13): [True: 38, False: 128k]
  ------------------
  918|     38|            return false;
  919|       |        
  920|   128k|        extension = extension->next;
  921|   128k|    }
  922|       |    
  923|   128k|    return true;
  924|   128k|}
pb_decode.c:default_extension_decoder:
  889|   128k|{
  890|   128k|    pb_field_iter_t iter;
  891|       |
  892|   128k|    if (!pb_field_iter_begin_extension(&iter, extension))
  ------------------
  |  Branch (892:9): [True: 0, False: 128k]
  ------------------
  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|   128k|    if (iter.tag != tag || !iter.message)
  ------------------
  |  Branch (895:9): [True: 122k, False: 6.00k]
  |  Branch (895:28): [True: 0, False: 6.00k]
  ------------------
  896|   122k|        return true;
  897|       |
  898|  6.00k|    extension->found = true;
  899|  6.00k|    return decode_field(stream, wire_type, &iter);
  900|   128k|}
pb_decode.c:decode_field:
  857|  6.83M|{
  858|       |#ifdef PB_ENABLE_MALLOC
  859|       |    /* When decoding an oneof field, check if there is old data that must be
  860|       |     * released first. */
  861|       |    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  862|       |    {
  863|       |        if (!pb_release_union_field(stream, field))
  864|       |            return false;
  865|       |    }
  866|       |#endif
  867|       |
  868|  6.83M|    switch (PB_ATYPE(field->type))
  ------------------
  |  |  326|  6.83M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  6.83M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
  869|  6.83M|    {
  870|  6.75M|        case PB_ATYPE_STATIC:
  ------------------
  |  |  321|  6.75M|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (870:9): [True: 6.75M, False: 82.3k]
  ------------------
  871|  6.75M|            return decode_static_field(stream, wire_type, field);
  872|       |        
  873|      0|        case PB_ATYPE_POINTER:
  ------------------
  |  |  322|      0|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (873:9): [True: 0, False: 6.83M]
  ------------------
  874|      0|            return decode_pointer_field(stream, wire_type, field);
  875|       |        
  876|  82.3k|        case PB_ATYPE_CALLBACK:
  ------------------
  |  |  323|  82.3k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (876:9): [True: 82.3k, False: 6.75M]
  ------------------
  877|  82.3k|            return decode_callback_field(stream, wire_type, field);
  878|       |        
  879|      0|        default:
  ------------------
  |  Branch (879:9): [True: 0, False: 6.83M]
  ------------------
  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|  6.83M|    }
  882|  6.83M|}
pb_decode.c:decode_static_field:
  498|  6.75M|{
  499|  6.75M|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  327|  6.75M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  6.75M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  500|  6.75M|    {
  501|  6.02M|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  311|  6.02M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (501:9): [True: 6.02M, False: 727k]
  ------------------
  502|  6.02M|            return decode_basic_field(stream, wire_type, field);
  503|       |            
  504|   500k|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  312|   500k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (504:9): [True: 500k, False: 6.25M]
  ------------------
  505|   500k|            if (field->pSize != NULL)
  ------------------
  |  Branch (505:17): [True: 500k, False: 0]
  ------------------
  506|   500k|                *(bool*)field->pSize = true;
  507|   500k|            return decode_basic_field(stream, wire_type, field);
  508|       |    
  509|  32.1k|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  314|  32.1k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (509:9): [True: 32.1k, False: 6.72M]
  ------------------
  510|  32.1k|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (510:17): [True: 23.0k, False: 9.10k]
  ------------------
  511|  23.0k|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  328|  23.0k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  23.0k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  276|  23.0k|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (511:20): [True: 10.9k, False: 12.0k]
  ------------------
  512|  10.9k|            {
  513|       |                /* Packed array */
  514|  10.9k|                bool status = true;
  515|  10.9k|                pb_istream_t substream;
  516|  10.9k|                pb_size_t *size = (pb_size_t*)field->pSize;
  517|  10.9k|                field->pData = (char*)field->pField + field->data_size * (*size);
  518|       |
  519|  10.9k|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (519:21): [True: 65, False: 10.8k]
  ------------------
  520|     65|                    return false;
  521|       |
  522|  46.1k|                while (substream.bytes_left > 0 && *size < field->array_size)
  ------------------
  |  Branch (522:24): [True: 35.3k, False: 10.7k]
  |  Branch (522:52): [True: 35.3k, False: 27]
  ------------------
  523|  35.3k|                {
  524|  35.3k|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (524:25): [True: 27, False: 35.2k]
  ------------------
  525|     27|                    {
  526|     27|                        status = false;
  527|     27|                        break;
  528|     27|                    }
  529|  35.2k|                    (*size)++;
  530|  35.2k|                    field->pData = (char*)field->pData + field->data_size;
  531|  35.2k|                }
  532|       |
  533|  10.8k|                if (substream.bytes_left != 0)
  ------------------
  |  Branch (533:21): [True: 47, False: 10.8k]
  ------------------
  534|     47|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  923|     47|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     47|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  535|  10.8k|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (535:21): [True: 0, False: 10.8k]
  ------------------
  536|      0|                    return false;
  537|       |
  538|  10.8k|                return status;
  539|  10.8k|            }
  540|  21.1k|            else
  541|  21.1k|            {
  542|       |                /* Repeated field */
  543|  21.1k|                pb_size_t *size = (pb_size_t*)field->pSize;
  544|  21.1k|                field->pData = (char*)field->pField + field->data_size * (*size);
  545|       |
  546|  21.1k|                if ((*size)++ >= field->array_size)
  ------------------
  |  Branch (546:21): [True: 2, False: 21.1k]
  ------------------
  547|      2|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  923|      2|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      2|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  548|       |
  549|  21.1k|                return decode_basic_field(stream, wire_type, field);
  550|  21.1k|            }
  551|       |
  552|   194k|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  316|   194k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (552:9): [True: 194k, False: 6.55M]
  ------------------
  553|   194k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  329|   389k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|   194k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|   194k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|   389k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 150k, False: 44.5k]
  |  |  ------------------
  |  |  330|   389k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  44.5k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  44.5k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  44.5k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 44.1k, False: 384]
  |  |  ------------------
  ------------------
  554|   194k|                *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (554:17): [True: 112k, False: 81.8k]
  ------------------
  555|   112k|            {
  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|   112k|                memset(field->pData, 0, (size_t)field->data_size);
  564|       |
  565|       |                /* Set default values for the submessage fields. */
  566|   112k|                if (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (566:21): [True: 66.1k, False: 46.4k]
  ------------------
  567|  46.4k|                    field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (567:21): [True: 0, False: 46.4k]
  ------------------
  568|  46.4k|                    field->submsg_desc->submsg_info[0] != NULL)
  ------------------
  |  Branch (568:21): [True: 0, False: 46.4k]
  ------------------
  569|  66.1k|                {
  570|  66.1k|                    pb_field_iter_t submsg_iter;
  571|  66.1k|                    if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (571:25): [True: 66.1k, False: 0]
  ------------------
  572|  66.1k|                    {
  573|  66.1k|                        if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (573:29): [True: 0, False: 66.1k]
  ------------------
  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|  66.1k|                    }
  576|  66.1k|                }
  577|   112k|            }
  578|   194k|            *(pb_size_t*)field->pSize = field->tag;
  579|       |
  580|   194k|            return decode_basic_field(stream, wire_type, field);
  581|       |
  582|      0|        default:
  ------------------
  |  Branch (582:9): [True: 0, False: 6.75M]
  ------------------
  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|  6.75M|    }
  585|  6.75M|}
pb_decode.c:decode_basic_field:
  427|  6.77M|{
  428|  6.77M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  328|  6.77M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  6.77M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  429|  6.77M|    {
  430|   318k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  268|   318k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (430:9): [True: 318k, False: 6.46M]
  ------------------
  431|   318k|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (431:17): [True: 1.39k, False: 316k]
  |  Branch (431:46): [True: 12, False: 1.38k]
  ------------------
  432|     12|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     12|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     12|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  433|       |
  434|   318k|            return pb_dec_bool(stream, field);
  435|       |
  436|  4.76M|        case PB_LTYPE_VARINT:
  ------------------
  |  |  269|  4.76M|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (436:9): [True: 4.76M, False: 2.01M]
  ------------------
  437|  5.13M|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  270|  5.13M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (437:9): [True: 374k, False: 6.40M]
  ------------------
  438|  5.31M|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  271|  5.31M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (438:9): [True: 179k, False: 6.59M]
  ------------------
  439|  5.31M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (439:17): [True: 23.4k, False: 5.28M]
  |  Branch (439:46): [True: 54, False: 23.3k]
  ------------------
  440|     54|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     54|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     54|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 54]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  441|       |
  442|  5.31M|            return pb_dec_varint(stream, field);
  443|       |
  444|   303k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  272|   303k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (444:9): [True: 303k, False: 6.47M]
  ------------------
  445|   303k|            if (wire_type != PB_WT_32BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (445:17): [True: 5.67k, False: 297k]
  |  Branch (445:45): [True: 16, False: 5.65k]
  ------------------
  446|     16|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     16|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     16|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  447|       |
  448|   303k|            return pb_decode_fixed32(stream, field->pData);
  449|       |
  450|   247k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  273|   247k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (450:9): [True: 247k, False: 6.53M]
  ------------------
  451|   247k|            if (wire_type != PB_WT_64BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (451:17): [True: 4.93k, False: 242k]
  |  Branch (451:45): [True: 11, False: 4.92k]
  ------------------
  452|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|   247k|            return pb_decode_fixed64(stream, field->pData);
  465|      0|#endif
  466|       |
  467|  49.1k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  280|  49.1k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (467:9): [True: 49.1k, False: 6.72M]
  ------------------
  468|  49.1k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (468:17): [True: 16, False: 49.1k]
  ------------------
  469|     16|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     16|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     16|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  470|       |
  471|  49.1k|            return pb_dec_bytes(stream, field);
  472|       |
  473|   212k|        case PB_LTYPE_STRING:
  ------------------
  |  |  284|   212k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (473:9): [True: 212k, False: 6.56M]
  ------------------
  474|   212k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (474:17): [True: 10, False: 212k]
  ------------------
  475|     10|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     10|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     10|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  476|       |
  477|   212k|            return pb_dec_string(stream, field);
  478|       |
  479|   261k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  288|   261k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (479:9): [True: 261k, False: 6.51M]
  ------------------
  480|   305k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  293|   305k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (480:9): [True: 44.1k, False: 6.73M]
  ------------------
  481|   305k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (481:17): [True: 18, False: 305k]
  ------------------
  482|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  483|       |
  484|   305k|            return pb_dec_submessage(stream, field);
  485|       |
  486|  28.8k|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  303|  28.8k|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (486:9): [True: 28.8k, False: 6.74M]
  ------------------
  487|  28.8k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (487:17): [True: 5, False: 28.8k]
  ------------------
  488|      5|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|      5|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      5|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  489|       |
  490|  28.8k|            return pb_dec_fixed_length_bytes(stream, field);
  491|       |
  492|      0|        default:
  ------------------
  |  Branch (492:9): [True: 0, False: 6.77M]
  ------------------
  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|  6.77M|    }
  495|  6.77M|}
pb_decode.c:pb_dec_bool:
 1477|   318k|{
 1478|   318k|    return pb_decode_bool(stream, (bool*)field->pData);
 1479|   318k|}
pb_decode.c:pb_dec_varint:
 1482|  5.31M|{
 1483|  5.31M|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  328|  5.31M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  5.31M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  270|  5.31M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (1483:9): [True: 374k, False: 4.93M]
  ------------------
 1484|   374k|    {
 1485|   374k|        pb_uint64_t value, clamped;
  ------------------
  |  |   57|   374k|#define pb_uint64_t uint64_t
  ------------------
 1486|   374k|        if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1486:13): [True: 14, False: 374k]
  ------------------
 1487|     14|            return false;
 1488|       |
 1489|       |        /* Cast to the proper field size, while checking for overflows */
 1490|   374k|        if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (1490:13): [True: 167k, False: 206k]
  ------------------
 1491|   167k|            clamped = *(pb_uint64_t*)field->pData = value;
 1492|   206k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (1492:18): [True: 181k, False: 25.6k]
  ------------------
 1493|   181k|            clamped = *(uint32_t*)field->pData = (uint32_t)value;
 1494|  25.6k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (1494:18): [True: 12.7k, False: 12.8k]
  ------------------
 1495|  12.7k|            clamped = *(uint_least16_t*)field->pData = (uint_least16_t)value;
 1496|  12.8k|        else if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (1496:18): [True: 12.8k, False: 0]
  ------------------
 1497|  12.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|   374k|        if (clamped != value)
  ------------------
  |  Branch (1501:13): [True: 112, False: 373k]
  ------------------
 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|   373k|        return true;
 1505|   374k|    }
 1506|  4.93M|    else
 1507|  4.93M|    {
 1508|  4.93M|        pb_uint64_t value;
  ------------------
  |  |   57|  4.93M|#define pb_uint64_t uint64_t
  ------------------
 1509|  4.93M|        pb_int64_t svalue;
  ------------------
  |  |   56|  4.93M|#define pb_int64_t int64_t
  ------------------
 1510|  4.93M|        pb_int64_t clamped;
  ------------------
  |  |   56|  4.93M|#define pb_int64_t int64_t
  ------------------
 1511|       |
 1512|  4.93M|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  328|  4.93M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  4.93M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  271|  4.93M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (1512:13): [True: 179k, False: 4.76M]
  ------------------
 1513|   179k|        {
 1514|   179k|            if (!pb_decode_svarint(stream, &svalue))
  ------------------
  |  Branch (1514:17): [True: 19, False: 179k]
  ------------------
 1515|     19|                return false;
 1516|   179k|        }
 1517|  4.76M|        else
 1518|  4.76M|        {
 1519|  4.76M|            if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1519:17): [True: 46, False: 4.76M]
  ------------------
 1520|     46|                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|  4.76M|            if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1528:17): [True: 155k, False: 4.60M]
  ------------------
 1529|   155k|                svalue = (pb_int64_t)value;
 1530|  4.60M|            else
 1531|  4.60M|                svalue = (int32_t)value;
 1532|  4.76M|        }
 1533|       |
 1534|       |        /* Cast to the proper field size, while checking for overflows */
 1535|  4.93M|        if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1535:13): [True: 237k, False: 4.70M]
  ------------------
 1536|   237k|            clamped = *(pb_int64_t*)field->pData = svalue;
 1537|  4.70M|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (1537:18): [True: 4.65M, False: 50.8k]
  ------------------
 1538|  4.65M|            clamped = *(int32_t*)field->pData = (int32_t)svalue;
 1539|  50.8k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (1539:18): [True: 25.4k, False: 25.4k]
  ------------------
 1540|  25.4k|            clamped = *(int_least16_t*)field->pData = (int_least16_t)svalue;
 1541|  25.4k|        else if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (1541:18): [True: 25.4k, False: 0]
  ------------------
 1542|  25.4k|            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|  4.93M|        if (clamped != svalue)
  ------------------
  |  Branch (1546:13): [True: 96, False: 4.93M]
  ------------------
 1547|     96|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  923|     96|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     96|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 96]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1548|       |
 1549|  4.93M|        return true;
 1550|  4.93M|    }
 1551|  5.31M|}
pb_decode.c:pb_dec_bytes:
 1554|  49.1k|{
 1555|  49.1k|    uint32_t size;
 1556|  49.1k|    size_t alloc_size;
 1557|  49.1k|    pb_bytes_array_t *dest;
 1558|       |    
 1559|  49.1k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1559:9): [True: 5, False: 49.1k]
  ------------------
 1560|      5|        return false;
 1561|       |    
 1562|  49.1k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  342|  49.1k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1562:9): [True: 31, False: 49.0k]
  ------------------
 1563|     31|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  923|     31|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     31|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 31]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1564|       |    
 1565|  49.0k|    alloc_size = PB_BYTES_ARRAY_T_ALLOCSIZE(size);
  ------------------
  |  |  406|  49.0k|#define PB_BYTES_ARRAY_T_ALLOCSIZE(n) ((size_t)n + offsetof(pb_bytes_array_t, bytes))
  ------------------
 1566|  49.0k|    if (size > alloc_size)
  ------------------
  |  Branch (1566:9): [True: 0, False: 49.0k]
  ------------------
 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|  49.0k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  49.0k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  49.0k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  49.0k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1569:9): [True: 0, False: 49.0k]
  ------------------
 1570|      0|    {
 1571|      0|#ifndef PB_ENABLE_MALLOC
 1572|      0|        PB_RETURN_ERROR(stream, "no malloc support");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1573|       |#else
 1574|       |        if (stream->bytes_left < size)
 1575|       |            PB_RETURN_ERROR(stream, "end-of-stream");
 1576|       |
 1577|       |        if (!allocate_field(stream, field->pData, alloc_size, 1))
 1578|       |            return false;
 1579|       |        dest = *(pb_bytes_array_t**)field->pData;
 1580|       |#endif
 1581|      0|    }
 1582|  49.0k|    else
 1583|  49.0k|    {
 1584|  49.0k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1584:13): [True: 45, False: 49.0k]
  ------------------
 1585|     45|            PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  923|     45|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     45|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 45]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1586|  49.0k|        dest = (pb_bytes_array_t*)field->pData;
 1587|  49.0k|    }
 1588|       |
 1589|  49.0k|    dest->size = (pb_size_t)size;
 1590|  49.0k|    return pb_read(stream, dest->bytes, (size_t)size);
 1591|  49.0k|}
pb_decode.c:pb_dec_string:
 1594|   212k|{
 1595|   212k|    uint32_t size;
 1596|   212k|    size_t alloc_size;
 1597|   212k|    pb_byte_t *dest = (pb_byte_t*)field->pData;
 1598|       |
 1599|   212k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1599:9): [True: 4, False: 212k]
  ------------------
 1600|      4|        return false;
 1601|       |
 1602|   212k|    if (size == (uint32_t)-1)
  ------------------
  |  Branch (1602:9): [True: 1, False: 212k]
  ------------------
 1603|      1|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1604|       |
 1605|       |    /* Space for null terminator */
 1606|   212k|    alloc_size = (size_t)(size + 1);
 1607|       |
 1608|   212k|    if (alloc_size < size)
  ------------------
  |  Branch (1608:9): [True: 0, False: 212k]
  ------------------
 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|   212k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   212k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   212k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   212k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1611:9): [True: 0, False: 212k]
  ------------------
 1612|      0|    {
 1613|      0|#ifndef PB_ENABLE_MALLOC
 1614|      0|        PB_RETURN_ERROR(stream, "no malloc support");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1615|       |#else
 1616|       |        if (stream->bytes_left < size)
 1617|       |            PB_RETURN_ERROR(stream, "end-of-stream");
 1618|       |
 1619|       |        if (!allocate_field(stream, field->pData, alloc_size, 1))
 1620|       |            return false;
 1621|       |        dest = *(pb_byte_t**)field->pData;
 1622|       |#endif
 1623|      0|    }
 1624|   212k|    else
 1625|   212k|    {
 1626|   212k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1626:13): [True: 93, False: 212k]
  ------------------
 1627|     93|            PB_RETURN_ERROR(stream, "string overflow");
  ------------------
  |  |  923|     93|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     93|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 93]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1628|   212k|    }
 1629|       |    
 1630|   212k|    dest[size] = 0;
 1631|       |
 1632|   212k|    if (!pb_read(stream, dest, (size_t)size))
  ------------------
  |  Branch (1632:9): [True: 10, False: 212k]
  ------------------
 1633|     10|        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|   212k|    return true;
 1641|   212k|}
pb_decode.c:pb_dec_submessage:
 1644|   305k|{
 1645|   305k|    bool status = true;
 1646|   305k|    bool submsg_consumed = false;
 1647|   305k|    pb_istream_t substream;
 1648|       |
 1649|   305k|    if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1649:9): [True: 100, False: 305k]
  ------------------
 1650|    100|        return false;
 1651|       |    
 1652|   305k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (1652:9): [True: 0, False: 305k]
  ------------------
 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|   305k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  328|   305k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   305k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  293|   611k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (1658:9): [True: 44.1k, False: 261k]
  |  Branch (1658:58): [True: 44.1k, False: 0]
  ------------------
 1659|  44.1k|    {
 1660|       |        /* Message callback is stored right before pSize. */
 1661|  44.1k|        pb_callback_t *callback = (pb_callback_t*)field->pSize - 1;
 1662|  44.1k|        if (callback->funcs.decode)
  ------------------
  |  Branch (1662:13): [True: 44.1k, False: 0]
  ------------------
 1663|  44.1k|        {
 1664|  44.1k|            status = callback->funcs.decode(&substream, field, &callback->arg);
 1665|       |
 1666|  44.1k|            if (substream.bytes_left == 0)
  ------------------
  |  Branch (1666:17): [True: 25.4k, False: 18.7k]
  ------------------
 1667|  25.4k|            {
 1668|  25.4k|                submsg_consumed = true;
 1669|  25.4k|            }
 1670|  44.1k|        }
 1671|  44.1k|    }
 1672|       |
 1673|       |    /* Now decode the submessage contents */
 1674|   305k|    if (status && !submsg_consumed)
  ------------------
  |  Branch (1674:9): [True: 305k, False: 0]
  |  Branch (1674:19): [True: 280k, False: 25.4k]
  ------------------
 1675|   280k|    {
 1676|   280k|        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|   280k|        if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  326|   280k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   280k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  321|   560k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1680:13): [True: 280k, False: 0]
  ------------------
 1681|   280k|            PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  327|   280k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   280k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  314|   280k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1681:13): [True: 275k, False: 5.12k]
  ------------------
 1682|   275k|        {
 1683|   275k|            flags = PB_DECODE_NOINIT;
  ------------------
  |  |  122|   275k|#define PB_DECODE_NOINIT          0x01U
  ------------------
 1684|   275k|        }
 1685|       |
 1686|   280k|        status = pb_decode_inner(&substream, field->submsg_desc, field->pData, flags);
 1687|   280k|    }
 1688|       |    
 1689|   305k|    if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1689:9): [True: 0, False: 305k]
  ------------------
 1690|      0|        return false;
 1691|       |
 1692|   305k|    return status;
 1693|   305k|}
pb_decode.c:pb_dec_fixed_length_bytes:
 1696|  28.8k|{
 1697|  28.8k|    uint32_t size;
 1698|       |
 1699|  28.8k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1699:9): [True: 3, False: 28.8k]
  ------------------
 1700|      3|        return false;
 1701|       |
 1702|  28.8k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  342|  28.8k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1702:9): [True: 32, False: 28.8k]
  ------------------
 1703|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1704|       |
 1705|  28.8k|    if (size == 0)
  ------------------
  |  Branch (1705:9): [True: 16.2k, False: 12.6k]
  ------------------
 1706|  16.2k|    {
 1707|       |        /* As a special case, treat empty bytes string as all zeros for fixed_length_bytes. */
 1708|  16.2k|        memset(field->pData, 0, (size_t)field->data_size);
 1709|  16.2k|        return true;
 1710|  16.2k|    }
 1711|       |
 1712|  12.6k|    if (size != field->data_size)
  ------------------
  |  Branch (1712:9): [True: 46, False: 12.5k]
  ------------------
 1713|     46|        PB_RETURN_ERROR(stream, "incorrect fixed length bytes size");
  ------------------
  |  |  923|     46|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     46|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 46]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1714|       |
 1715|  12.5k|    return pb_read(stream, (pb_byte_t*)field->pData, (size_t)field->data_size);
 1716|  12.6k|}
pb_decode.c:decode_callback_field:
  783|  82.3k|{
  784|       |    /* Clear any data that may have been decoded for another oneof field
  785|       |     * that has come before this callback field.
  786|       |     */
  787|  82.3k|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  82.3k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  82.3k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  82.3k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (787:9): [True: 12.9k, False: 69.3k]
  ------------------
  788|  12.9k|    {
  789|  12.9k|        if (*(pb_size_t*)field->pSize != 0 && *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (789:13): [True: 12.4k, False: 489]
  |  Branch (789:47): [True: 1.75k, False: 10.7k]
  ------------------
  790|  1.75k|        {
  791|  1.75k|            memset(field->pData, 0, (size_t)field->data_size);
  792|  1.75k|        }
  793|  12.9k|        *(pb_size_t*)field->pSize = field->tag;
  794|  12.9k|    }
  795|       |
  796|  82.3k|    if (!field->descriptor->field_callback)
  ------------------
  |  Branch (796:9): [True: 0, False: 82.3k]
  ------------------
  797|      0|        return pb_skip_field(stream, wire_type);
  798|       |
  799|  82.3k|    if (wire_type == PB_WT_STRING)
  ------------------
  |  Branch (799:9): [True: 63.3k, False: 18.9k]
  ------------------
  800|  63.3k|    {
  801|  63.3k|        pb_istream_t substream;
  802|  63.3k|        size_t prev_bytes_left;
  803|       |        
  804|  63.3k|        if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (804:13): [True: 42, False: 63.3k]
  ------------------
  805|     42|            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|  63.3k|        if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  328|  63.3k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  63.3k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  293|   126k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (809:13): [True: 0, False: 63.3k]
  |  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|  63.3k|        do
  824|  63.3k|        {
  825|  63.3k|            prev_bytes_left = substream.bytes_left;
  826|  63.3k|            if (!field->descriptor->field_callback(&substream, NULL, field))
  ------------------
  |  Branch (826:17): [True: 0, False: 63.3k]
  ------------------
  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|  63.3k|        } while (substream.bytes_left > 0 && substream.bytes_left < prev_bytes_left);
  ------------------
  |  Branch (831:18): [True: 24.3k, False: 39.0k]
  |  Branch (831:46): [True: 0, False: 24.3k]
  ------------------
  832|       |        
  833|  63.3k|        if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (833:13): [True: 0, False: 63.3k]
  ------------------
  834|      0|            return false;
  835|       |
  836|  63.3k|        return true;
  837|  63.3k|    }
  838|  18.9k|    else
  839|  18.9k|    {
  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|  18.9k|        pb_istream_t substream;
  845|  18.9k|        pb_byte_t buffer[10];
  846|  18.9k|        size_t size = sizeof(buffer);
  847|       |        
  848|  18.9k|        if (!read_raw_value(stream, wire_type, buffer, &size))
  ------------------
  |  Branch (848:13): [True: 44, False: 18.8k]
  ------------------
  849|     44|            return false;
  850|  18.8k|        substream = pb_istream_from_buffer(buffer, size);
  851|       |        
  852|       |        return field->descriptor->field_callback(&substream, NULL, field);
  853|  18.9k|    }
  854|  82.3k|}
pb_decode.c:read_raw_value:
  342|  18.9k|{
  343|  18.9k|    size_t max_size = *size;
  344|  18.9k|    switch (wire_type)
  345|  18.9k|    {
  346|  12.7k|        case PB_WT_VARINT:
  ------------------
  |  Branch (346:9): [True: 12.7k, False: 6.17k]
  ------------------
  347|  12.7k|            *size = 0;
  348|  12.7k|            do
  349|  29.3k|            {
  350|  29.3k|                (*size)++;
  351|  29.3k|                if (*size > max_size)
  ------------------
  |  Branch (351:21): [True: 4, False: 29.3k]
  ------------------
  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|  29.3k|                if (!pb_read(stream, buf, 1))
  ------------------
  |  Branch (354:21): [True: 25, False: 29.3k]
  ------------------
  355|     25|                    return false;
  356|  29.3k|            } while (*buf++ & 0x80);
  ------------------
  |  Branch (356:22): [True: 16.6k, False: 12.7k]
  ------------------
  357|  12.7k|            return true;
  358|       |            
  359|  5.23k|        case PB_WT_64BIT:
  ------------------
  |  Branch (359:9): [True: 5.23k, False: 13.6k]
  ------------------
  360|  5.23k|            *size = 8;
  361|  5.23k|            return pb_read(stream, buf, 8);
  362|       |        
  363|    932|        case PB_WT_32BIT:
  ------------------
  |  Branch (363:9): [True: 932, False: 17.9k]
  ------------------
  364|    932|            *size = 4;
  365|    932|            return pb_read(stream, buf, 4);
  366|       |        
  367|      0|        case PB_WT_STRING:
  ------------------
  |  Branch (367:9): [True: 0, False: 18.9k]
  ------------------
  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: 18.9k]
  ------------------
  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|      4|        default: PB_RETURN_ERROR(stream, "invalid 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (379:9): [True: 4, False: 18.9k]
  ------------------
  380|  18.9k|    }
  381|  18.9k|}

pb_ostream_from_buffer:
   73|  2.61k|{
   74|  2.61k|    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|  2.61k|    stream.callback = &buf_write;
   83|  2.61k|#endif
   84|  2.61k|    stream.state = buf;
   85|  2.61k|    stream.max_size = bufsize;
   86|  2.61k|    stream.bytes_written = 0;
   87|  2.61k|#ifndef PB_NO_ERRMSG
   88|       |    stream.errmsg = NULL;
   89|  2.61k|#endif
   90|  2.61k|    return stream;
   91|  2.61k|}
pb_write:
   94|   494k|{
   95|   494k|    if (count > 0 && stream->callback != NULL)
  ------------------
  |  Branch (95:9): [True: 481k, False: 13.1k]
  |  Branch (95:22): [True: 333k, False: 148k]
  ------------------
   96|   333k|    {
   97|   333k|        if (stream->bytes_written + count < stream->bytes_written ||
  ------------------
  |  Branch (97:13): [True: 0, False: 333k]
  ------------------
   98|   333k|            stream->bytes_written + count > stream->max_size)
  ------------------
  |  Branch (98:13): [True: 0, False: 333k]
  ------------------
   99|      0|        {
  100|      0|            PB_RETURN_ERROR(stream, "stream full");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  101|      0|        }
  102|       |
  103|       |#ifdef PB_BUFFER_ONLY
  104|       |        if (!buf_write(stream, buf, count))
  105|       |            PB_RETURN_ERROR(stream, "io error");
  106|       |#else        
  107|   333k|        if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (107:13): [True: 0, False: 333k]
  ------------------
  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|   333k|#endif
  110|   333k|    }
  111|       |    
  112|   494k|    stream->bytes_written += count;
  113|       |    return true;
  114|   494k|}
pb_encode:
  522|  41.5k|{
  523|  41.5k|    pb_field_iter_t iter;
  524|  41.5k|    if (!pb_field_iter_begin_const(&iter, fields, src_struct))
  ------------------
  |  Branch (524:9): [True: 7.89k, False: 33.6k]
  ------------------
  525|  7.89k|        return true; /* Empty message type */
  526|       |    
  527|   323k|    do {
  528|   323k|        if (PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|   323k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   323k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|   323k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (528:13): [True: 2.61k, False: 320k]
  ------------------
  529|  2.61k|        {
  530|       |            /* Special case for the extension field placeholder */
  531|  2.61k|            if (!encode_extension_field(stream, &iter))
  ------------------
  |  Branch (531:17): [True: 0, False: 2.61k]
  ------------------
  532|      0|                return false;
  533|  2.61k|        }
  534|   320k|        else
  535|   320k|        {
  536|       |            /* Regular field */
  537|   320k|            if (!encode_field(stream, &iter))
  ------------------
  |  Branch (537:17): [True: 0, False: 320k]
  ------------------
  538|      0|                return false;
  539|   320k|        }
  540|   323k|    } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (540:14): [True: 289k, False: 33.6k]
  ------------------
  541|       |    
  542|  33.6k|    return true;
  543|  33.6k|}
pb_encode_varint:
  617|   439k|{
  618|   439k|    if (value <= 0x7F)
  ------------------
  |  Branch (618:9): [True: 362k, False: 77.4k]
  ------------------
  619|   362k|    {
  620|       |        /* Fast path: single byte */
  621|   362k|        pb_byte_t byte = (pb_byte_t)value;
  622|   362k|        return pb_write(stream, &byte, 1);
  623|   362k|    }
  624|  77.4k|    else
  625|  77.4k|    {
  626|       |#ifdef PB_WITHOUT_64BIT
  627|       |        return pb_encode_varint_32(stream, value, 0);
  628|       |#else
  629|  77.4k|        return pb_encode_varint_32(stream, (uint32_t)value, (uint32_t)(value >> 32));
  630|  77.4k|#endif
  631|  77.4k|    }
  632|   439k|}
pb_encode_svarint:
  635|  22.4k|{
  636|  22.4k|    pb_uint64_t zigzagged;
  ------------------
  |  |   46|  22.4k|#define pb_uint64_t uint64_t
  ------------------
  637|  22.4k|    pb_uint64_t mask = ((pb_uint64_t)-1) >> 1; /* Satisfy clang -fsanitize=integer */
  ------------------
  |  |   46|  22.4k|#define pb_uint64_t uint64_t
  ------------------
  638|  22.4k|    if (value < 0)
  ------------------
  |  Branch (638:9): [True: 9.40k, False: 13.0k]
  ------------------
  639|  9.40k|        zigzagged = ~(((pb_uint64_t)value & mask) << 1);
  640|  13.0k|    else
  641|  13.0k|        zigzagged = (pb_uint64_t)value << 1;
  642|       |    
  643|  22.4k|    return pb_encode_varint(stream, zigzagged);
  644|  22.4k|}
pb_encode_fixed32:
  647|  20.3k|{
  648|  20.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|  20.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|  20.3k|}
pb_encode_fixed64:
  664|  11.8k|{
  665|  11.8k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
  666|       |    /* Fast path if we know that we're on little endian */
  667|  11.8k|    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|  11.8k|}
pb_encode_tag:
  685|   205k|{
  686|   205k|    pb_uint64_t tag = ((pb_uint64_t)field_number << 3) | wiretype;
  ------------------
  |  |   46|   205k|#define pb_uint64_t uint64_t
  ------------------
  687|   205k|    return pb_encode_varint(stream, tag);
  688|   205k|}
pb_encode_tag_for_field:
  691|   196k|{
  692|   196k|    pb_wire_type_t wiretype;
  693|   196k|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  328|   196k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   196k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  694|   196k|    {
  695|  2.76k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  268|  2.76k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (695:9): [True: 2.76k, False: 194k]
  ------------------
  696|  78.4k|        case PB_LTYPE_VARINT:
  ------------------
  |  |  269|  78.4k|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (696:9): [True: 75.7k, False: 121k]
  ------------------
  697|   118k|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  270|   118k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (697:9): [True: 40.0k, False: 156k]
  ------------------
  698|   134k|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  271|   134k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (698:9): [True: 15.9k, False: 181k]
  ------------------
  699|   134k|            wiretype = PB_WT_VARINT;
  700|   134k|            break;
  701|       |        
  702|  11.1k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  272|  11.1k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (702:9): [True: 11.1k, False: 185k]
  ------------------
  703|  11.1k|            wiretype = PB_WT_32BIT;
  704|  11.1k|            break;
  705|       |        
  706|  8.87k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  273|  8.87k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (706:9): [True: 8.87k, False: 188k]
  ------------------
  707|  8.87k|            wiretype = PB_WT_64BIT;
  708|  8.87k|            break;
  709|       |        
  710|  3.83k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  280|  3.83k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (710:9): [True: 3.83k, False: 193k]
  ------------------
  711|  18.8k|        case PB_LTYPE_STRING:
  ------------------
  |  |  284|  18.8k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (711:9): [True: 15.0k, False: 181k]
  ------------------
  712|  38.3k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  288|  38.3k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (712:9): [True: 19.4k, False: 177k]
  ------------------
  713|  38.3k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  293|  38.3k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (713:9): [True: 0, False: 196k]
  ------------------
  714|  42.4k|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  303|  42.4k|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (714:9): [True: 4.07k, False: 192k]
  ------------------
  715|  42.4k|            wiretype = PB_WT_STRING;
  716|  42.4k|            break;
  717|       |        
  718|      0|        default:
  ------------------
  |  Branch (718:9): [True: 0, False: 196k]
  ------------------
  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|   196k|    }
  721|       |    
  722|   196k|    return pb_encode_tag(stream, wiretype, field->tag);
  723|   196k|}
pb_encode_string:
  726|  22.9k|{
  727|  22.9k|    if (!pb_encode_varint(stream, (pb_uint64_t)size))
  ------------------
  |  Branch (727:9): [True: 0, False: 22.9k]
  ------------------
  728|      0|        return false;
  729|       |    
  730|  22.9k|    return pb_write(stream, buffer, size);
  731|  22.9k|}
pb_encode_submessage:
  734|  19.4k|{
  735|       |    /* First calculate the message size using a non-writing substream. */
  736|  19.4k|    pb_ostream_t substream = PB_OSTREAM_SIZING;
  ------------------
  |  |  126|  19.4k|#define PB_OSTREAM_SIZING {0,0,0,0,0}
  ------------------
  737|  19.4k|#if !defined(PB_NO_ENCODE_SIZE_CHECK) || PB_NO_ENCODE_SIZE_CHECK == 0
  738|  19.4k|    bool status;
  739|  19.4k|    size_t size;
  740|  19.4k|#endif
  741|       |    
  742|  19.4k|    if (!pb_encode(&substream, fields, src_struct))
  ------------------
  |  Branch (742:9): [True: 0, False: 19.4k]
  ------------------
  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|  19.4k|    if (!pb_encode_varint(stream, (pb_uint64_t)substream.bytes_written))
  ------------------
  |  Branch (750:9): [True: 0, False: 19.4k]
  ------------------
  751|      0|        return false;
  752|       |    
  753|  19.4k|    if (stream->callback == NULL)
  ------------------
  |  Branch (753:9): [True: 0, False: 19.4k]
  ------------------
  754|      0|        return pb_write(stream, NULL, substream.bytes_written); /* Just sizing */
  755|       |    
  756|  19.4k|    if (stream->bytes_written + substream.bytes_written > stream->max_size)
  ------------------
  |  Branch (756:9): [True: 0, False: 19.4k]
  ------------------
  757|      0|        PB_RETURN_ERROR(stream, "stream full");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|  19.4k|    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|  19.4k|    substream.callback = stream->callback;
  766|  19.4k|    substream.state = stream->state;
  767|  19.4k|    substream.max_size = size;
  768|  19.4k|    substream.bytes_written = 0;
  769|  19.4k|#ifndef PB_NO_ERRMSG
  770|  19.4k|    substream.errmsg = NULL;
  771|  19.4k|#endif
  772|       |    
  773|  19.4k|    status = pb_encode(&substream, fields, src_struct);
  774|       |    
  775|  19.4k|    stream->bytes_written += substream.bytes_written;
  776|  19.4k|    stream->state = substream.state;
  777|  19.4k|#ifndef PB_NO_ERRMSG
  778|  19.4k|    stream->errmsg = substream.errmsg;
  779|  19.4k|#endif
  780|       |    
  781|  19.4k|    if (substream.bytes_written != size)
  ------------------
  |  Branch (781:9): [True: 0, False: 19.4k]
  ------------------
  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|  19.4k|    return status;
  785|  19.4k|#endif
  786|  19.4k|}
pb_encode.c:buf_write:
   54|   333k|{
   55|   333k|    pb_byte_t *dest = (pb_byte_t*)stream->state;
   56|   333k|    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|   333k|    if (buf != NULL)
  ------------------
  |  Branch (64:9): [True: 333k, False: 0]
  ------------------
   65|   333k|    {
   66|   333k|        memcpy(dest, buf, count * sizeof(pb_byte_t));
   67|   333k|    }
   68|       |
   69|       |    return true;
   70|   333k|}
pb_encode.c:encode_extension_field:
  497|  2.61k|{
  498|  2.61k|    const pb_extension_t *extension = *(const pb_extension_t* const *)field->pData;
  499|       |
  500|  5.22k|    while (extension)
  ------------------
  |  Branch (500:12): [True: 2.61k, False: 2.61k]
  ------------------
  501|  2.61k|    {
  502|  2.61k|        bool status;
  503|  2.61k|        if (extension->type->encode)
  ------------------
  |  Branch (503:13): [True: 0, False: 2.61k]
  ------------------
  504|      0|            status = extension->type->encode(stream, extension);
  505|  2.61k|        else
  506|  2.61k|            status = default_extension_encoder(stream, extension);
  507|       |
  508|  2.61k|        if (!status)
  ------------------
  |  Branch (508:13): [True: 0, False: 2.61k]
  ------------------
  509|      0|            return false;
  510|       |        
  511|  2.61k|        extension = extension->next;
  512|  2.61k|    }
  513|       |    
  514|  2.61k|    return true;
  515|  2.61k|}
pb_encode.c:default_extension_encoder:
  484|  2.61k|{
  485|  2.61k|    pb_field_iter_t iter;
  486|       |
  487|  2.61k|    if (!pb_field_iter_begin_extension_const(&iter, extension))
  ------------------
  |  Branch (487:9): [True: 0, False: 2.61k]
  ------------------
  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.61k|    return encode_field(stream, &iter);
  491|  2.61k|}
pb_encode.c:encode_field:
  428|   323k|{
  429|       |    /* Check field presence */
  430|   323k|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|   323k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   323k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|   323k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (430:9): [True: 18.2k, False: 304k]
  ------------------
  431|  18.2k|    {
  432|  18.2k|        if (*(const pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (432:13): [True: 17.4k, False: 883]
  ------------------
  433|  17.4k|        {
  434|       |            /* Different type oneof field */
  435|  17.4k|            return true;
  436|  17.4k|        }
  437|  18.2k|    }
  438|   304k|    else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL)
  ------------------
  |  |  327|   304k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   304k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL)
  ------------------
  |  |  312|   304k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (438:14): [True: 67.6k, False: 237k]
  ------------------
  439|  67.6k|    {
  440|  67.6k|        if (field->pSize)
  ------------------
  |  Branch (440:13): [True: 67.6k, False: 0]
  ------------------
  441|  67.6k|        {
  442|  67.6k|            if (safe_read_bool(field->pSize) == false)
  ------------------
  |  Branch (442:17): [True: 59.6k, False: 8.00k]
  ------------------
  443|  59.6k|            {
  444|       |                /* Missing optional field */
  445|  59.6k|                return true;
  446|  59.6k|            }
  447|  67.6k|        }
  448|      0|        else if (PB_ATYPE(field->type) == PB_ATYPE_STATIC)
  ------------------
  |  |  326|      0|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|      0|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      else if (PB_ATYPE(field->type) == PB_ATYPE_STATIC)
  ------------------
  |  |  321|      0|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (448:18): [True: 0, False: 0]
  ------------------
  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|  67.6k|    }
  455|       |
  456|   245k|    if (!field->pData)
  ------------------
  |  Branch (456:9): [True: 0, False: 245k]
  ------------------
  457|      0|    {
  458|      0|        if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED)
  ------------------
  |  |  327|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED)
  ------------------
  |  |  311|      0|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (458:13): [True: 0, False: 0]
  ------------------
  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|      0|        return true;
  463|      0|    }
  464|       |
  465|       |    /* Then encode field contents */
  466|   245k|    if (PB_ATYPE(field->type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  326|   245k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   245k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|   245k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (466:9): [True: 103, False: 245k]
  ------------------
  467|    103|    {
  468|    103|        return encode_callback_field(stream, field);
  469|    103|    }
  470|   245k|    else if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|   245k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   245k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|   245k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (470:14): [True: 54.8k, False: 191k]
  ------------------
  471|  54.8k|    {
  472|  54.8k|        return encode_array(stream, field);
  473|  54.8k|    }
  474|   191k|    else
  475|   191k|    {
  476|   191k|        return encode_basic_field(stream, field);
  477|   191k|    }
  478|   245k|}
pb_encode.c:safe_read_bool:
  125|  70.3k|{
  126|  70.3k|    const char *p = (const char *)pSize;
  127|  70.3k|    size_t i;
  128|   130k|    for (i = 0; i < sizeof(bool); i++)
  ------------------
  |  Branch (128:17): [True: 70.3k, False: 60.3k]
  ------------------
  129|  70.3k|    {
  130|  70.3k|        if (p[i] != 0)
  ------------------
  |  Branch (130:13): [True: 10.0k, False: 60.3k]
  ------------------
  131|  10.0k|            return true;
  132|  70.3k|    }
  133|  60.3k|    return false;
  134|  70.3k|}
pb_encode.c:encode_callback_field:
  417|    103|{
  418|    103|    if (field->descriptor->field_callback != NULL)
  ------------------
  |  Branch (418:9): [True: 103, False: 0]
  ------------------
  419|    103|    {
  420|    103|        if (!field->descriptor->field_callback(NULL, stream, field))
  ------------------
  |  Branch (420:13): [True: 0, False: 103]
  ------------------
  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|    103|    }
  423|    103|    return true;
  424|    103|}
pb_encode.c:encode_array:
  138|  54.8k|{
  139|  54.8k|    pb_size_t i;
  140|  54.8k|    pb_size_t count;
  141|  54.8k|#ifndef PB_ENCODE_ARRAYS_UNPACKED
  142|  54.8k|    size_t size;
  143|  54.8k|#endif
  144|       |
  145|  54.8k|    count = *(pb_size_t*)field->pSize;
  146|       |
  147|  54.8k|    if (count == 0)
  ------------------
  |  Branch (147:9): [True: 44.2k, False: 10.6k]
  ------------------
  148|  44.2k|        return true;
  149|       |
  150|  10.6k|    if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size)
  ------------------
  |  |  326|  10.6k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  10.6k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size)
  ------------------
  |  |  322|  21.2k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (150:9): [True: 10.6k, False: 0]
  |  Branch (150:54): [True: 0, False: 10.6k]
  ------------------
  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|  10.6k|#ifndef PB_ENCODE_ARRAYS_UNPACKED
  154|       |    /* We always pack arrays if the datatype allows it. */
  155|  10.6k|    if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  328|  10.6k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  10.6k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  276|  10.6k|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (155:9): [True: 8.99k, False: 1.61k]
  ------------------
  156|  8.99k|    {
  157|  8.99k|        if (!pb_encode_tag(stream, PB_WT_STRING, field->tag))
  ------------------
  |  Branch (157:13): [True: 0, False: 8.99k]
  ------------------
  158|      0|            return false;
  159|       |        
  160|       |        /* Determine the total size of packed array. */
  161|  8.99k|        if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32)
  ------------------
  |  |  328|  8.99k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  8.99k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32)
  ------------------
  |  |  272|  8.99k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (161:13): [True: 3.14k, False: 5.85k]
  ------------------
  162|  3.14k|        {
  163|  3.14k|            size = 4 * (size_t)count;
  164|  3.14k|        }
  165|  5.85k|        else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  328|  5.85k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  5.85k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  273|  5.85k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (165:18): [True: 730, False: 5.12k]
  ------------------
  166|    730|        {
  167|    730|            size = 8 * (size_t)count;
  168|    730|        }
  169|  5.12k|        else
  170|  5.12k|        { 
  171|  5.12k|            pb_ostream_t sizestream = PB_OSTREAM_SIZING;
  ------------------
  |  |  126|  5.12k|#define PB_OSTREAM_SIZING {0,0,0,0,0}
  ------------------
  172|  5.12k|            void *pData_orig = field->pData;
  173|  28.9k|            for (i = 0; i < count; i++)
  ------------------
  |  Branch (173:25): [True: 23.8k, False: 5.12k]
  ------------------
  174|  23.8k|            {
  175|  23.8k|                if (!pb_enc_varint(&sizestream, field))
  ------------------
  |  Branch (175:21): [True: 0, False: 23.8k]
  ------------------
  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|  23.8k|                field->pData = (char*)field->pData + field->data_size;
  178|  23.8k|            }
  179|  5.12k|            field->pData = pData_orig;
  180|  5.12k|            size = sizestream.bytes_written;
  181|  5.12k|        }
  182|       |        
  183|  8.99k|        if (!pb_encode_varint(stream, (pb_uint64_t)size))
  ------------------
  |  Branch (183:13): [True: 0, False: 8.99k]
  ------------------
  184|      0|            return false;
  185|       |        
  186|  8.99k|        if (stream->callback == NULL)
  ------------------
  |  Branch (186:13): [True: 0, False: 8.99k]
  ------------------
  187|      0|            return pb_write(stream, NULL, size); /* Just sizing.. */
  188|       |        
  189|       |        /* Write the data */
  190|  44.9k|        for (i = 0; i < count; i++)
  ------------------
  |  Branch (190:21): [True: 35.9k, False: 8.99k]
  ------------------
  191|  35.9k|        {
  192|  35.9k|            if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  328|  35.9k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  35.9k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  272|  71.9k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  328|  26.8k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  26.8k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  273|  26.8k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (192:17): [True: 9.16k, False: 26.8k]
  |  Branch (192:62): [True: 2.99k, False: 23.8k]
  ------------------
  193|  12.1k|            {
  194|  12.1k|                if (!pb_enc_fixed(stream, field))
  ------------------
  |  Branch (194:21): [True: 0, False: 12.1k]
  ------------------
  195|      0|                    return false;
  196|  12.1k|            }
  197|  23.8k|            else
  198|  23.8k|            {
  199|  23.8k|                if (!pb_enc_varint(stream, field))
  ------------------
  |  Branch (199:21): [True: 0, False: 23.8k]
  ------------------
  200|      0|                    return false;
  201|  23.8k|            }
  202|       |
  203|  35.9k|            field->pData = (char*)field->pData + field->data_size;
  204|  35.9k|        }
  205|  8.99k|    }
  206|  1.61k|    else /* Unpacked fields */
  207|  1.61k|#endif
  208|  1.61k|    {
  209|  7.53k|        for (i = 0; i < count; i++)
  ------------------
  |  Branch (209:21): [True: 5.91k, False: 1.61k]
  ------------------
  210|  5.91k|        {
  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|  5.91k|            if (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  326|  5.91k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  5.91k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  322|  11.8k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (215:17): [True: 0, False: 5.91k]
  ------------------
  216|      0|                (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  328|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  284|      0|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (216:18): [True: 0, False: 0]
  ------------------
  217|      0|                 PB_LTYPE(field->type) == PB_LTYPE_BYTES))
  ------------------
  |  |  328|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                               PB_LTYPE(field->type) == PB_LTYPE_BYTES))
  ------------------
  |  |  280|      0|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (217:18): [True: 0, False: 0]
  ------------------
  218|      0|            {
  219|      0|                bool status;
  220|      0|                void *pData_orig = field->pData;
  221|      0|                field->pData = *(void* const*)field->pData;
  222|       |
  223|      0|                if (!field->pData)
  ------------------
  |  Branch (223:21): [True: 0, False: 0]
  ------------------
  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|      0|                else
  230|      0|                {
  231|      0|                    status = encode_basic_field(stream, field);
  232|      0|                }
  233|       |
  234|      0|                field->pData = pData_orig;
  235|       |
  236|      0|                if (!status)
  ------------------
  |  Branch (236:21): [True: 0, False: 0]
  ------------------
  237|      0|                    return false;
  238|      0|            }
  239|  5.91k|            else
  240|  5.91k|            {
  241|  5.91k|                if (!encode_basic_field(stream, field))
  ------------------
  |  Branch (241:21): [True: 0, False: 5.91k]
  ------------------
  242|      0|                    return false;
  243|  5.91k|            }
  244|  5.91k|            field->pData = (char*)field->pData + field->data_size;
  245|  5.91k|        }
  246|  1.61k|    }
  247|       |    
  248|  10.6k|    return true;
  249|  10.6k|}
pb_encode.c:pb_enc_varint:
  798|   179k|{
  799|   179k|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  328|   179k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   179k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  270|   179k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (799:9): [True: 46.6k, False: 132k]
  ------------------
  800|  46.6k|    {
  801|       |        /* Perform unsigned integer extension */
  802|  46.6k|        pb_uint64_t value = 0;
  ------------------
  |  |   46|  46.6k|#define pb_uint64_t uint64_t
  ------------------
  803|       |
  804|  46.6k|        if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (804:13): [True: 5.22k, False: 41.4k]
  ------------------
  805|  5.22k|            value = *(const uint_least8_t*)field->pData;
  806|  41.4k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (806:18): [True: 5.22k, False: 36.1k]
  ------------------
  807|  5.22k|            value = *(const uint_least16_t*)field->pData;
  808|  36.1k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (808:18): [True: 20.1k, False: 16.0k]
  ------------------
  809|  20.1k|            value = *(const uint32_t*)field->pData;
  810|  16.0k|        else if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (810:18): [True: 16.0k, False: 0]
  ------------------
  811|  16.0k|            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|  46.6k|        return pb_encode_varint(stream, value);
  816|  46.6k|    }
  817|   132k|    else
  818|   132k|    {
  819|       |        /* Perform signed integer extension */
  820|   132k|        pb_int64_t value = 0;
  ------------------
  |  |   45|   132k|#define pb_int64_t int64_t
  ------------------
  821|       |
  822|   132k|        if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (822:13): [True: 11.8k, False: 120k]
  ------------------
  823|  11.8k|            value = *(const int_least8_t*)field->pData;
  824|   120k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (824:18): [True: 10.4k, False: 110k]
  ------------------
  825|  10.4k|            value = *(const int_least16_t*)field->pData;
  826|   110k|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (826:18): [True: 88.1k, False: 22.2k]
  ------------------
  827|  88.1k|            value = *(const int32_t*)field->pData;
  828|  22.2k|        else if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (828:18): [True: 22.2k, False: 0]
  ------------------
  829|  22.2k|            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|   132k|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  328|   132k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   132k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  271|   132k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (833:13): [True: 22.4k, False: 110k]
  ------------------
  834|  22.4k|            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|   110k|        else
  840|   110k|            return pb_encode_varint(stream, (pb_uint64_t)value);
  841|       |
  842|   132k|    }
  843|   179k|}
pb_encode.c:pb_enc_fixed:
  846|  32.2k|{
  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|  32.2k|    if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (854:9): [True: 20.3k, False: 11.8k]
  ------------------
  855|  20.3k|    {
  856|  20.3k|        return pb_encode_fixed32(stream, field->pData);
  857|  20.3k|    }
  858|  11.8k|#ifndef PB_WITHOUT_64BIT
  859|  11.8k|    else if (field->data_size == sizeof(uint64_t))
  ------------------
  |  Branch (859:14): [True: 11.8k, False: 0]
  ------------------
  860|  11.8k|    {
  861|  11.8k|        return pb_encode_fixed64(stream, field->pData);
  862|  11.8k|    }
  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|  32.2k|}
pb_encode.c:encode_basic_field:
  372|   196k|{
  373|   196k|    if (!field->pData)
  ------------------
  |  Branch (373:9): [True: 0, False: 196k]
  ------------------
  374|      0|    {
  375|       |        /* Missing pointer field */
  376|      0|        return true;
  377|      0|    }
  378|       |
  379|   196k|    if (!pb_encode_tag_for_field(stream, field))
  ------------------
  |  Branch (379:9): [True: 0, False: 196k]
  ------------------
  380|      0|        return false;
  381|       |
  382|   196k|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  328|   196k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   196k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  383|   196k|    {
  384|  2.76k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  268|  2.76k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (384:9): [True: 2.76k, False: 194k]
  ------------------
  385|  2.76k|            return pb_enc_bool(stream, field);
  386|       |
  387|  75.7k|        case PB_LTYPE_VARINT:
  ------------------
  |  |  269|  75.7k|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (387:9): [True: 75.7k, False: 121k]
  ------------------
  388|   115k|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  270|   115k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (388:9): [True: 40.0k, False: 156k]
  ------------------
  389|   131k|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  271|   131k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (389:9): [True: 15.9k, False: 181k]
  ------------------
  390|   131k|            return pb_enc_varint(stream, field);
  391|       |
  392|  11.1k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  272|  11.1k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (392:9): [True: 11.1k, False: 185k]
  ------------------
  393|  20.0k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  273|  20.0k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (393:9): [True: 8.87k, False: 188k]
  ------------------
  394|  20.0k|            return pb_enc_fixed(stream, field);
  395|       |
  396|  3.83k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  280|  3.83k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (396:9): [True: 3.83k, False: 193k]
  ------------------
  397|  3.83k|            return pb_enc_bytes(stream, field);
  398|       |
  399|  15.0k|        case PB_LTYPE_STRING:
  ------------------
  |  |  284|  15.0k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (399:9): [True: 15.0k, False: 181k]
  ------------------
  400|  15.0k|            return pb_enc_string(stream, field);
  401|       |
  402|  19.4k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  288|  19.4k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (402:9): [True: 19.4k, False: 177k]
  ------------------
  403|  19.4k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  293|  19.4k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (403:9): [True: 0, False: 196k]
  ------------------
  404|  19.4k|            return pb_enc_submessage(stream, field);
  405|       |
  406|  4.07k|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  303|  4.07k|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (406:9): [True: 4.07k, False: 192k]
  ------------------
  407|  4.07k|            return pb_enc_fixed_length_bytes(stream, field);
  408|       |
  409|      0|        default:
  ------------------
  |  Branch (409:9): [True: 0, False: 196k]
  ------------------
  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|   196k|    }
  412|   196k|}
pb_encode.c:pb_enc_bool:
  791|  2.76k|{
  792|  2.76k|    uint32_t value = safe_read_bool(field->pData) ? 1 : 0;
  ------------------
  |  Branch (792:22): [True: 2.05k, False: 710]
  ------------------
  793|  2.76k|    PB_UNUSED(field);
  ------------------
  |  |  172|  2.76k|#define PB_UNUSED(x) (void)(x)
  ------------------
  794|  2.76k|    return pb_encode_varint(stream, value);
  795|  2.76k|}
pb_encode.c:pb_enc_bytes:
  871|  3.83k|{
  872|  3.83k|    const pb_bytes_array_t *bytes = NULL;
  873|       |
  874|  3.83k|    bytes = (const pb_bytes_array_t*)field->pData;
  875|       |    
  876|  3.83k|    if (bytes == NULL)
  ------------------
  |  Branch (876:9): [True: 0, False: 3.83k]
  ------------------
  877|      0|    {
  878|       |        /* Treat null pointer as an empty bytes field */
  879|      0|        return pb_encode_string(stream, NULL, 0);
  880|      0|    }
  881|       |    
  882|  3.83k|    if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  326|  3.83k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  3.83k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  321|  7.66k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (882:9): [True: 3.83k, False: 0]
  ------------------
  883|  3.83k|        bytes->size > field->data_size - offsetof(pb_bytes_array_t, bytes))
  ------------------
  |  Branch (883:9): [True: 0, False: 3.83k]
  ------------------
  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|  3.83k|    return pb_encode_string(stream, bytes->bytes, (size_t)bytes->size);
  889|  3.83k|}
pb_encode.c:pb_enc_string:
  892|  15.0k|{
  893|  15.0k|    size_t size = 0;
  894|  15.0k|    size_t max_size = (size_t)field->data_size;
  895|  15.0k|    const char *str = (const char*)field->pData;
  896|       |    
  897|  15.0k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  15.0k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  15.0k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  15.0k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (897:9): [True: 0, False: 15.0k]
  ------------------
  898|      0|    {
  899|      0|        max_size = (size_t)-1;
  900|      0|    }
  901|  15.0k|    else
  902|  15.0k|    {
  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|  15.0k|        if (max_size == 0)
  ------------------
  |  Branch (908:13): [True: 0, False: 15.0k]
  ------------------
  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|  15.0k|        max_size -= 1;
  912|  15.0k|    }
  913|       |
  914|       |
  915|  15.0k|    if (str == NULL)
  ------------------
  |  Branch (915:9): [True: 0, False: 15.0k]
  ------------------
  916|      0|    {
  917|      0|        size = 0; /* Treat null pointer as an empty string */
  918|      0|    }
  919|  15.0k|    else
  920|  15.0k|    {
  921|  15.0k|        const char *p = str;
  922|       |
  923|       |        /* strnlen() is not always available, so just use a loop */
  924|  74.0k|        while (size < max_size && *p != '\0')
  ------------------
  |  Branch (924:16): [True: 73.7k, False: 330]
  |  Branch (924:35): [True: 59.0k, False: 14.7k]
  ------------------
  925|  59.0k|        {
  926|  59.0k|            size++;
  927|  59.0k|            p++;
  928|  59.0k|        }
  929|       |
  930|  15.0k|        if (*p != '\0')
  ------------------
  |  Branch (930:13): [True: 0, False: 15.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|  15.0k|    }
  935|       |
  936|       |#ifdef PB_VALIDATE_UTF8
  937|       |    if (!pb_validate_utf8(str))
  938|       |        PB_RETURN_ERROR(stream, "invalid utf8");
  939|       |#endif
  940|       |
  941|  15.0k|    return pb_encode_string(stream, (const pb_byte_t*)str, size);
  942|  15.0k|}
pb_encode.c:pb_enc_submessage:
  945|  19.4k|{
  946|  19.4k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (946:9): [True: 0, False: 19.4k]
  ------------------
  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|  19.4k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  328|  19.4k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  19.4k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  293|  38.9k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (949:9): [True: 0, False: 19.4k]
  |  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|  19.4k|    return pb_encode_submessage(stream, field->submsg_desc, field->pData);
  961|  19.4k|}
pb_encode.c:pb_enc_fixed_length_bytes:
  964|  4.07k|{
  965|  4.07k|    return pb_encode_string(stream, (const pb_byte_t*)field->pData, (size_t)field->data_size);
  966|  4.07k|}
pb_encode.c:pb_encode_varint_32:
  583|  77.4k|{
  584|  77.4k|    size_t i = 0;
  585|  77.4k|    pb_byte_t buffer[10];
  586|  77.4k|    pb_byte_t byte = (pb_byte_t)(low & 0x7F);
  587|  77.4k|    low >>= 7;
  588|       |
  589|   210k|    while (i < 4 && (low != 0 || high != 0))
  ------------------
  |  Branch (589:12): [True: 197k, False: 13.1k]
  |  Branch (589:22): [True: 132k, False: 64.6k]
  |  Branch (589:34): [True: 290, False: 64.3k]
  ------------------
  590|   132k|    {
  591|   132k|        byte |= 0x80;
  592|   132k|        buffer[i++] = byte;
  593|   132k|        byte = (pb_byte_t)(low & 0x7F);
  594|   132k|        low >>= 7;
  595|   132k|    }
  596|       |
  597|  77.4k|    if (high)
  ------------------
  |  Branch (597:9): [True: 11.3k, False: 66.1k]
  ------------------
  598|  11.3k|    {
  599|  11.3k|        byte = (pb_byte_t)(byte | ((high & 0x07) << 4));
  600|  11.3k|        high >>= 3;
  601|       |
  602|  57.2k|        while (high)
  ------------------
  |  Branch (602:16): [True: 45.9k, False: 11.3k]
  ------------------
  603|  45.9k|        {
  604|  45.9k|            byte |= 0x80;
  605|  45.9k|            buffer[i++] = byte;
  606|  45.9k|            byte = (pb_byte_t)(high & 0x7F);
  607|  45.9k|            high >>= 7;
  608|  45.9k|        }
  609|  11.3k|    }
  610|       |
  611|  77.4k|    buffer[i++] = byte;
  612|       |
  613|  77.4k|    return pb_write(stream, buffer, i);
  614|  77.4k|}

malloc_with_check:
   58|  11.6k|{
   59|  11.6k|    const size_t check2 = CHECK2;
  ------------------
  |  |   18|  11.6k|#define CHECK2 ((size_t)0x600DCAFE)
  ------------------
   60|  11.6k|    char *buf = NULL;
   61|       |
   62|  11.6k|    if (size <= g_max_alloc_bytes - g_alloc_bytes)
  ------------------
  |  Branch (62:9): [True: 11.6k, False: 0]
  ------------------
   63|  11.6k|    {
   64|  11.6k|        buf = malloc(round_blocksize(size + GUARD_SIZE));
  ------------------
  |  |   15|  11.6k|#define GUARD_SIZE (sizeof(size_t)*3)
  ------------------
   65|  11.6k|    }
   66|       |
   67|  11.6k|    if (buf)
  ------------------
  |  Branch (67:9): [True: 11.6k, False: 0]
  ------------------
   68|  11.6k|    {
   69|  11.6k|        ((size_t*)buf)[0] = size;
   70|  11.6k|        ((size_t*)buf)[1] = CHECK1;
  ------------------
  |  |   17|  11.6k|#define CHECK1 ((size_t)0xDEADBEEF)
  ------------------
   71|  11.6k|        memcpy(buf + PREFIX_SIZE + size, &check2, sizeof(check2));
  ------------------
  |  |   16|  11.6k|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   72|       |
   73|  11.6k|        g_alloc_count++;
   74|  11.6k|        g_alloc_bytes += size;
   75|  11.6k|        if (DEBUG_MALLOC) fprintf(stderr, "Alloc 0x%04x/%u\n", (unsigned)(uintptr_t)(buf + PREFIX_SIZE), (unsigned)size);
  ------------------
  |  |   25|  11.6k|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (25:22): [Folded, False: 11.6k]
  |  |  ------------------
  ------------------
                      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|  11.6k|        return buf + PREFIX_SIZE;
  ------------------
  |  |   16|  11.6k|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   77|  11.6k|    }
   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|  11.6k|}
free_with_check:
   87|  11.6k|{
   88|  11.6k|    if (mem)
  ------------------
  |  Branch (88:9): [True: 11.6k, False: 0]
  ------------------
   89|  11.6k|    {
   90|  11.6k|        char *buf = (char*)mem - PREFIX_SIZE;
  ------------------
  |  |   16|  11.6k|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   91|  11.6k|        size_t check2 = 0;
   92|  11.6k|        size_t size = ((size_t*)buf)[0];
   93|  11.6k|        if (DEBUG_MALLOC) fprintf(stderr, "Release 0x%04x/%u\n", (unsigned)(uintptr_t)mem, (unsigned)size);
  ------------------
  |  |   25|  11.6k|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (25:22): [Folded, False: 11.6k]
  |  |  ------------------
  ------------------
   94|  11.6k|        assert(((size_t*)buf)[1] == CHECK1);
  ------------------
  |  Branch (94:9): [True: 0, False: 11.6k]
  |  Branch (94:9): [True: 11.6k, False: 0]
  ------------------
   95|  11.6k|        memcpy(&check2, buf + PREFIX_SIZE + size, sizeof(check2));
  ------------------
  |  |   16|  11.6k|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   96|  11.6k|        assert(check2 == CHECK2);
  ------------------
  |  Branch (96:9): [True: 0, False: 11.6k]
  |  Branch (96:9): [True: 11.6k, False: 0]
  ------------------
   97|  11.6k|        assert(g_alloc_count > 0);
  ------------------
  |  Branch (97:9): [True: 0, False: 11.6k]
  |  Branch (97:9): [True: 11.6k, False: 0]
  ------------------
   98|  11.6k|        assert(g_alloc_bytes >= size);
  ------------------
  |  Branch (98:9): [True: 0, False: 11.6k]
  |  Branch (98:9): [True: 11.6k, False: 0]
  ------------------
   99|  11.6k|        ((size_t*)buf)[1] = 0;
  100|  11.6k|        memset(buf + PREFIX_SIZE + size, 0, sizeof(check2));
  ------------------
  |  |   16|  11.6k|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  101|  11.6k|        g_alloc_count--;
  102|  11.6k|        g_alloc_bytes -= size;
  103|  11.6k|        free(buf);
  104|  11.6k|    }
  105|  11.6k|}
get_alloc_count:
  172|  18.0k|{
  173|  18.0k|    return g_alloc_count;
  174|  18.0k|}
malloc_wrappers.c:round_blocksize:
   39|  11.6k|{
   40|  11.6k|    if (size < 256)
  ------------------
  |  Branch (40:9): [True: 0, False: 11.6k]
  ------------------
   41|      0|    {
   42|      0|        return size;
   43|      0|    }
   44|  11.6k|    else
   45|  11.6k|    {
   46|  11.6k|        return (size + 1023) / 1024 * 1024;
   47|  11.6k|    }
   48|  11.6k|}

flakystream_callback:
    5|  4.73M|{
    6|  4.73M|    flakystream_t *state = stream->state;
    7|       |
    8|  4.73M|    if (state->position + count > state->msglen)
  ------------------
  |  Branch (8:9): [True: 1.30k, False: 4.73M]
  ------------------
    9|  1.30k|    {
   10|  1.30k|        stream->bytes_left = 0;
   11|  1.30k|        return false;
   12|  1.30k|    }
   13|  4.73M|    else if (state->position + count > state->fail_after)
  ------------------
  |  Branch (13:14): [True: 0, False: 4.73M]
  ------------------
   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|  4.73M|    memcpy(buf, state->buffer + state->position, count);
   19|  4.73M|    state->position += count;
   20|       |    return true;
   21|  4.73M|}
flakystream_init:
   24|  1.30k|{
   25|  1.30k|    memset(stream, 0, sizeof(*stream));
   26|  1.30k|    stream->stream.callback = flakystream_callback;
   27|       |    stream->stream.bytes_left = SIZE_MAX;
   28|  1.30k|    stream->stream.state = stream;
   29|  1.30k|    stream->buffer = buffer;
   30|  1.30k|    stream->position = 0;
   31|  1.30k|    stream->msglen = msglen;
   32|  1.30k|    stream->fail_after = fail_after;
   33|  1.30k|}

do_callback_decode:
  172|  1.30k|{
  173|  1.30k|    bool status;
  174|  1.30k|    pb_istream_t stream;
  175|  1.30k|    size_t initial_alloc_count = get_alloc_count();
  176|  1.30k|    alltypes_callback_AllTypes *msg = malloc_with_check(sizeof(alltypes_callback_AllTypes));
  177|  1.30k|    assert(msg);
  ------------------
  |  Branch (177:5): [True: 0, False: 1.30k]
  |  Branch (177:5): [True: 1.30k, False: 0]
  ------------------
  178|       |
  179|  1.30k|    memset(msg, 0, sizeof(alltypes_callback_AllTypes));
  180|  1.30k|    stream = pb_istream_from_buffer(buffer, msglen);
  181|       |
  182|  1.30k|    msg->rep_int32.funcs.decode = &field_callback;
  183|  1.30k|    msg->rep_int32.arg = &g_sentinel;
  184|  1.30k|    msg->rep_string.funcs.decode = &field_callback;
  185|  1.30k|    msg->rep_string.arg = &g_sentinel;
  186|  1.30k|    msg->rep_farray.funcs.decode = &field_callback;
  187|  1.30k|    msg->rep_farray.arg = &g_sentinel;
  188|  1.30k|    msg->req_limits.int64_min.funcs.decode = &field_callback;
  189|  1.30k|    msg->req_limits.int64_min.arg = &g_sentinel;
  190|  1.30k|    msg->cb_oneof.funcs.decode = &submsg_callback;
  191|  1.30k|    msg->cb_oneof.arg = &g_sentinel;
  192|       |
  193|  1.30k|    status = pb_decode(&stream, alltypes_callback_AllTypes_fields, msg);
  ------------------
  |  |  495|  1.30k|#define alltypes_callback_AllTypes_fields &alltypes_callback_AllTypes_msg
  ------------------
  194|       |
  195|  1.30k|    if (assert_success)
  ------------------
  |  Branch (195:9): [True: 1.30k, False: 0]
  ------------------
  196|  1.30k|    {
  197|  1.30k|        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 (197:13): [True: 0, False: 1.30k]
  ------------------
  198|  1.30k|        assert(status);
  ------------------
  |  Branch (198:9): [True: 0, False: 1.30k]
  |  Branch (198:9): [True: 1.30k, False: 0]
  ------------------
  199|  1.30k|    }
  200|       |
  201|  1.30k|    pb_release(alltypes_callback_AllTypes_fields, msg);
  ------------------
  |  |  495|  1.30k|#define alltypes_callback_AllTypes_fields &alltypes_callback_AllTypes_msg
  ------------------
  202|  1.30k|    free_with_check(msg);
  203|  1.30k|    assert(get_alloc_count() == initial_alloc_count);
  ------------------
  |  Branch (203:5): [True: 0, False: 1.30k]
  |  Branch (203:5): [True: 1.30k, False: 0]
  ------------------
  204|       |
  205|  1.30k|    return status;
  206|  1.30k|}
do_roundtrip:
  210|  1.30k|{
  211|  1.30k|    bool status;
  212|  1.30k|    uint32_t checksum2, checksum3;
  213|  1.30k|    size_t msglen2, msglen3;
  214|  1.30k|    uint8_t *buf2 = malloc_with_check(g_bufsize);
  215|  1.30k|    void *msg = malloc_with_check(structsize);
  216|       |
  217|       |    /* For proto2 types, we also test extension fields */
  218|  1.30k|    alltypes_static_TestExtension extmsg = alltypes_static_TestExtension_init_zero;
  ------------------
  |  |  260|  1.30k|#define alltypes_static_TestExtension_init_zero  {false, ""}
  ------------------
  219|  1.30k|    pb_extension_t ext = pb_extension_init_zero;
  ------------------
  |  |  506|  1.30k|#define pb_extension_init_zero {NULL,NULL,NULL,false}
  ------------------
  220|  1.30k|    pb_extension_t **ext_field = NULL;
  221|  1.30k|    ext.type = &alltypes_static_TestExtension_testextension;
  222|  1.30k|    ext.dest = &extmsg;
  223|  1.30k|    ext.next = NULL;
  224|       |
  225|  1.30k|    assert(buf2 && msg);
  ------------------
  |  Branch (225:5): [True: 0, False: 1.30k]
  |  Branch (225:5): [True: 0, False: 0]
  |  Branch (225:5): [True: 1.30k, False: 0]
  |  Branch (225:5): [True: 1.30k, False: 0]
  ------------------
  226|       |
  227|  1.30k|    if (msgtype == alltypes_static_AllTypes_fields)
  ------------------
  |  |  520|  1.30k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  |  Branch (227:9): [True: 1.30k, False: 0]
  ------------------
  228|  1.30k|    {
  229|  1.30k|        ext_field = &((alltypes_static_AllTypes*)msg)->extensions;
  230|  1.30k|    }
  231|      0|    else if (msgtype == alltypes_pointer_AllTypes_fields)
  ------------------
  |  |  494|      0|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  |  Branch (231:14): [True: 0, False: 0]
  ------------------
  232|      0|    {
  233|      0|        ext_field = &((alltypes_pointer_AllTypes*)msg)->extensions;
  234|      0|    }
  235|       |    
  236|       |    /* Decode and encode the input data.
  237|       |     * This will bring it into canonical format.
  238|       |     */
  239|  1.30k|    {
  240|  1.30k|        pb_istream_t stream = pb_istream_from_buffer(buffer, msglen);
  241|  1.30k|        memset(msg, 0, structsize);
  242|  1.30k|        if (ext_field) *ext_field = &ext;
  ------------------
  |  Branch (242:13): [True: 1.30k, False: 0]
  ------------------
  243|  1.30k|        status = pb_decode(&stream, msgtype, msg);
  244|  1.30k|        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.30k]
  ------------------
  245|  1.30k|        assert(status);
  ------------------
  |  Branch (245:9): [True: 0, False: 1.30k]
  |  Branch (245:9): [True: 1.30k, False: 0]
  ------------------
  246|       |
  247|  1.30k|        validate_message(msg, structsize, msgtype);
  248|  1.30k|    }
  249|       |    
  250|  1.30k|    {
  251|  1.30k|        pb_ostream_t stream = pb_ostream_from_buffer(buf2, g_bufsize);
  252|  1.30k|        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.30k|        if (!status && strcmp(PB_GET_ERROR(&stream), "stream full") != 0)
  ------------------
  |  |  920|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (920:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (256:13): [True: 0, False: 1.30k]
  |  Branch (256:24): [True: 0, False: 0]
  ------------------
  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.30k|        msglen2 = stream.bytes_written;
  263|  1.30k|        checksum2 = xor32_checksum(buf2, msglen2);
  264|  1.30k|    }
  265|       |    
  266|  1.30k|    pb_release(msgtype, msg);
  267|       |
  268|       |    /* Then decode from canonical format and re-encode. Result should remain the same. */
  269|  1.30k|    if (status)
  ------------------
  |  Branch (269:9): [True: 1.30k, False: 0]
  ------------------
  270|  1.30k|    {
  271|  1.30k|        pb_istream_t stream = pb_istream_from_buffer(buf2, msglen2);
  272|  1.30k|        memset(msg, 0, structsize);
  273|  1.30k|        if (ext_field) *ext_field = &ext;
  ------------------
  |  Branch (273:13): [True: 1.30k, False: 0]
  ------------------
  274|  1.30k|        status = pb_decode(&stream, msgtype, msg);
  275|  1.30k|        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.30k]
  ------------------
  276|  1.30k|        assert(status);
  ------------------
  |  Branch (276:9): [True: 0, False: 1.30k]
  |  Branch (276:9): [True: 1.30k, False: 0]
  ------------------
  277|       |
  278|  1.30k|        validate_message(msg, structsize, msgtype);
  279|  1.30k|    }
  280|       |    
  281|  1.30k|    if (status)
  ------------------
  |  Branch (281:9): [True: 1.30k, False: 0]
  ------------------
  282|  1.30k|    {
  283|  1.30k|        pb_ostream_t stream = pb_ostream_from_buffer(buf2, g_bufsize);
  284|  1.30k|        status = pb_encode(&stream, msgtype, msg);
  285|  1.30k|        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.30k]
  ------------------
  286|  1.30k|        assert(status);
  ------------------
  |  Branch (286:9): [True: 0, False: 1.30k]
  |  Branch (286:9): [True: 1.30k, False: 0]
  ------------------
  287|  1.30k|        msglen3 = stream.bytes_written;
  288|  1.30k|        checksum3 = xor32_checksum(buf2, msglen3);
  289|       |
  290|  1.30k|        assert(msglen2 == msglen3);
  ------------------
  |  Branch (290:9): [True: 0, False: 1.30k]
  |  Branch (290:9): [True: 1.30k, False: 0]
  ------------------
  291|  1.30k|        assert(checksum2 == checksum3);
  ------------------
  |  Branch (291:9): [True: 0, False: 1.30k]
  |  Branch (291:9): [True: 1.30k, False: 0]
  ------------------
  292|  1.30k|    }
  293|       |    
  294|  1.30k|    pb_release(msgtype, msg);
  295|  1.30k|    free_with_check(msg);
  296|  1.30k|    free_with_check(buf2);
  297|  1.30k|}
do_roundtrips:
  301|  3.19k|{
  302|  3.19k|    size_t initial_alloc_count = get_alloc_count();
  303|  3.19k|    PB_UNUSED(expect_valid); /* Potentially unused depending on configuration */
  ------------------
  |  |  172|  3.19k|#define PB_UNUSED(x) (void)(x)
  ------------------
  304|       |
  305|  3.19k|#ifdef FUZZTEST_PROTO2_STATIC
  306|  3.19k|    if (do_decode(data, size, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, 0, expect_valid))
  ------------------
  |  |  520|  3.19k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  |  Branch (306:9): [True: 1.30k, False: 1.88k]
  ------------------
  307|  1.30k|    {
  308|  1.30k|        do_roundtrip(data, size, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields);
  ------------------
  |  |  520|  1.30k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  309|  1.30k|        do_stream_decode(data, size, SIZE_MAX, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, 0, true);
  ------------------
  |  |  520|  1.30k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  310|  1.30k|        do_callback_decode(data, size, true);
  311|  1.30k|    }
  312|  3.19k|#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|       |#ifdef FUZZTEST_PROTO2_POINTER
  323|       |    if (do_decode(data, size, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields, 0, expect_valid))
  324|       |    {
  325|       |        do_roundtrip(data, size, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields);
  326|       |        do_stream_decode(data, size, SIZE_MAX, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields, 0, true);
  327|       |    }
  328|       |#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.19k]
  |  Branch (360:5): [True: 3.19k, False: 0]
  ------------------
  361|  3.19k|}
LLVMFuzzerTestOneInput:
  365|  3.19k|{
  366|  3.19k|    if (size > g_bufsize)
  ------------------
  |  Branch (366:9): [True: 4, False: 3.19k]
  ------------------
  367|      4|        return 0;
  368|       |
  369|  3.19k|    do_roundtrips(data, size, false);
  370|       |
  371|  3.19k|    return 0;
  372|  3.19k|}
fuzztest.c:field_callback:
  156|  6.35k|{
  157|  6.35k|    assert(stream);
  ------------------
  |  Branch (157:5): [True: 0, False: 6.35k]
  |  Branch (157:5): [True: 6.35k, False: 0]
  ------------------
  158|  6.35k|    assert(field);
  ------------------
  |  Branch (158:5): [True: 0, False: 6.35k]
  |  Branch (158:5): [True: 6.35k, False: 0]
  ------------------
  159|  6.35k|    assert(*arg == &g_sentinel);
  ------------------
  |  Branch (159:5): [True: 0, False: 6.35k]
  |  Branch (159:5): [True: 6.35k, False: 0]
  ------------------
  160|  6.35k|    return pb_read(stream, NULL, stream->bytes_left);
  161|  6.35k|}
fuzztest.c:submsg_callback:
  164|  44.1k|{
  165|  44.1k|    assert(stream);
  ------------------
  |  Branch (165:5): [True: 0, False: 44.1k]
  |  Branch (165:5): [True: 44.1k, False: 0]
  ------------------
  166|  44.1k|    assert(field);
  ------------------
  |  Branch (166:5): [True: 0, False: 44.1k]
  |  Branch (166:5): [True: 44.1k, False: 0]
  ------------------
  167|  44.1k|    assert(*arg == &g_sentinel);
  ------------------
  |  Branch (167:5): [True: 0, False: 44.1k]
  |  Branch (167:5): [True: 44.1k, False: 0]
  ------------------
  168|  44.1k|    return true;
  169|  44.1k|}
fuzztest.c:xor32_checksum:
   53|  2.61k|{
   54|  2.61k|    const uint8_t *buf = (const uint8_t*)data;
   55|  2.61k|    uint32_t checksum = 1234;
   56|   660k|    for (; len > 0; len--)
  ------------------
  |  Branch (56:12): [True: 658k, False: 2.61k]
  ------------------
   57|   658k|    {
   58|   658k|        checksum ^= checksum << 13;
   59|   658k|        checksum ^= checksum >> 17;
   60|   658k|        checksum ^= checksum << 5;
   61|   658k|        checksum += *buf++;
   62|   658k|    }
   63|  2.61k|    return checksum;
   64|  2.61k|}
fuzztest.c:do_decode:
   67|  3.19k|{
   68|  3.19k|    bool status;
   69|  3.19k|    pb_istream_t stream;
   70|  3.19k|    size_t initial_alloc_count = get_alloc_count();
   71|  3.19k|    uint8_t *buf2 = malloc_with_check(g_bufsize); /* This is just to match the amount of memory allocations in do_roundtrips(). */
   72|  3.19k|    void *msg = malloc_with_check(structsize);
   73|  3.19k|    alltypes_static_TestExtension extmsg = alltypes_static_TestExtension_init_zero;
  ------------------
  |  |  260|  3.19k|#define alltypes_static_TestExtension_init_zero  {false, ""}
  ------------------
   74|  3.19k|    pb_extension_t ext = pb_extension_init_zero;
  ------------------
  |  |  506|  3.19k|#define pb_extension_init_zero {NULL,NULL,NULL,false}
  ------------------
   75|  3.19k|    assert(msg);
  ------------------
  |  Branch (75:5): [True: 0, False: 3.19k]
  |  Branch (75:5): [True: 3.19k, False: 0]
  ------------------
   76|       |
   77|  3.19k|    memset(msg, 0, structsize);
   78|  3.19k|    ext.type = &alltypes_static_TestExtension_testextension;
   79|  3.19k|    ext.dest = &extmsg;
   80|  3.19k|    ext.next = NULL;
   81|       |
   82|  3.19k|    if (msgtype == alltypes_static_AllTypes_fields)
  ------------------
  |  |  520|  3.19k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  |  Branch (82:9): [True: 3.19k, False: 0]
  ------------------
   83|  3.19k|    {
   84|  3.19k|        ((alltypes_static_AllTypes*)msg)->extensions = &ext;
   85|  3.19k|    }
   86|      0|    else if (msgtype == alltypes_pointer_AllTypes_fields)
  ------------------
  |  |  494|      0|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  |  Branch (86:14): [True: 0, False: 0]
  ------------------
   87|      0|    {
   88|      0|        ((alltypes_pointer_AllTypes*)msg)->extensions = &ext;
   89|      0|    }
   90|       |
   91|  3.19k|    stream = pb_istream_from_buffer(buffer, msglen);
   92|  3.19k|    status = pb_decode_ex(&stream, msgtype, msg, flags);
   93|       |
   94|  3.19k|    if (status)
  ------------------
  |  Branch (94:9): [True: 1.30k, False: 1.88k]
  ------------------
   95|  1.30k|    {
   96|  1.30k|        validate_message(msg, structsize, msgtype);
   97|  1.30k|    }
   98|       |
   99|  3.19k|    if (assert_success)
  ------------------
  |  Branch (99:9): [True: 0, False: 3.19k]
  ------------------
  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.19k|    if (status)
  ------------------
  |  Branch (105:9): [True: 1.30k, False: 1.88k]
  ------------------
  106|  1.30k|    {
  107|       |        /* On error return, pb_release() should be called automatically. */
  108|  1.30k|        pb_release(msgtype, msg);
  109|  1.30k|    }
  110|       |
  111|  3.19k|    free_with_check(msg);
  112|  3.19k|    free_with_check(buf2);
  113|  3.19k|    assert(get_alloc_count() == initial_alloc_count);
  ------------------
  |  Branch (113:5): [True: 0, False: 3.19k]
  |  Branch (113:5): [True: 3.19k, False: 0]
  ------------------
  114|       |    
  115|  3.19k|    return status;
  116|  3.19k|}
fuzztest.c:do_stream_decode:
  119|  1.30k|{
  120|  1.30k|    bool status;
  121|  1.30k|    flakystream_t stream;
  122|  1.30k|    size_t initial_alloc_count = get_alloc_count();
  123|  1.30k|    void *msg = malloc_with_check(structsize);
  124|  1.30k|    assert(msg);
  ------------------
  |  Branch (124:5): [True: 0, False: 1.30k]
  |  Branch (124:5): [True: 1.30k, False: 0]
  ------------------
  125|       |
  126|  1.30k|    memset(msg, 0, structsize);
  127|  1.30k|    flakystream_init(&stream, buffer, msglen, fail_after);
  128|  1.30k|    status = pb_decode_ex(&stream.stream, msgtype, msg, flags);
  129|       |
  130|  1.30k|    if (status)
  ------------------
  |  Branch (130:9): [True: 1.30k, False: 0]
  ------------------
  131|  1.30k|    {
  132|  1.30k|        validate_message(msg, structsize, msgtype);
  133|  1.30k|    }
  134|       |
  135|  1.30k|    if (assert_success)
  ------------------
  |  Branch (135:9): [True: 1.30k, False: 0]
  ------------------
  136|  1.30k|    {
  137|  1.30k|        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.30k]
  ------------------
  138|  1.30k|        assert(status);
  ------------------
  |  Branch (138:9): [True: 0, False: 1.30k]
  |  Branch (138:9): [True: 1.30k, False: 0]
  ------------------
  139|  1.30k|    }
  140|       |
  141|  1.30k|    if (status)
  ------------------
  |  Branch (141:9): [True: 1.30k, False: 0]
  ------------------
  142|  1.30k|    {
  143|       |        /* On error return, pb_release() should be called automatically. */
  144|  1.30k|        pb_release(msgtype, msg);
  145|  1.30k|    }
  146|       |
  147|  1.30k|    free_with_check(msg);
  148|  1.30k|    assert(get_alloc_count() == initial_alloc_count);
  ------------------
  |  Branch (148:5): [True: 0, False: 1.30k]
  |  Branch (148:5): [True: 1.30k, False: 0]
  ------------------
  149|       |
  150|  1.30k|    return status;
  151|  1.30k|}

validate_static:
    7|   504k|{
    8|   504k|    pb_size_t count = 1;
    9|   504k|    pb_size_t i;
   10|   504k|    bool truebool = true;
   11|   504k|    bool falsebool = false;
   12|       |
   13|   504k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  327|   504k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   504k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  314|  1.00M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (13:9): [True: 109k, False: 394k]
  |  Branch (13:54): [True: 109k, False: 0]
  ------------------
   14|   109k|    {
   15|       |        /* Array count must be between 0 and statically allocated size */
   16|   109k|        count = *(pb_size_t*)iter->pSize;
   17|   109k|        assert(count <= iter->array_size);
  ------------------
  |  Branch (17:9): [True: 0, False: 109k]
  |  Branch (17:9): [True: 109k, False: 0]
  ------------------
   18|   109k|    }
   19|   394k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  327|   394k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   394k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  312|   789k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (19:14): [True: 119k, False: 275k]
  |  Branch (19:59): [True: 119k, False: 0]
  ------------------
   20|   119k|    {
   21|       |        /* Boolean has_ field must have a valid value */
   22|   119k|        assert(memcmp(iter->pSize, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (22:9): [True: 119k, False: 0]
  |  Branch (22:9): [True: 0, False: 0]
  |  Branch (22:9): [True: 12.0k, False: 107k]
  |  Branch (22:9): [True: 107k, False: 0]
  ------------------
   23|   119k|               memcmp(iter->pSize, &falsebool, sizeof(bool)) == 0);
   24|   119k|    }
   25|   275k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|   275k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   275k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|   275k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (25:14): [True: 26.1k, False: 249k]
  ------------------
   26|  26.1k|    {
   27|  26.1k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (27:13): [True: 24.5k, False: 1.56k]
  ------------------
   28|  24.5k|        {
   29|       |            /* Some different field in oneof */
   30|  24.5k|            return;
   31|  24.5k|        }
   32|  26.1k|    }
   33|       |
   34|   933k|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (34:17): [True: 453k, False: 479k]
  ------------------
   35|   453k|    {
   36|   453k|        void *pData = (char*)iter->pData + iter->data_size * i;
   37|       |
   38|   453k|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  328|   453k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   453k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  284|   453k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (38:13): [True: 27.9k, False: 426k]
  ------------------
   39|  27.9k|        {
   40|       |            /* String length must be at most statically allocated size */
   41|  27.9k|            assert(strlen(pData) + 1 <= iter->data_size);
  ------------------
  |  Branch (41:13): [True: 0, False: 27.9k]
  |  Branch (41:13): [True: 27.9k, False: 0]
  ------------------
   42|  27.9k|        }
   43|   426k|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  328|   426k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   426k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  280|   426k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (43:18): [True: 12.3k, False: 413k]
  ------------------
   44|  12.3k|        {
   45|       |            /* Bytes length must be at most statically allocated size */
   46|  12.3k|            pb_bytes_array_t *bytes = pData;
   47|  12.3k|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= iter->data_size);
  ------------------
  |  Branch (47:13): [True: 0, False: 12.3k]
  |  Branch (47:13): [True: 12.3k, False: 0]
  ------------------
   48|  12.3k|        }
   49|   413k|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  328|   413k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   413k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  268|   413k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (49:18): [True: 11.8k, False: 401k]
  ------------------
   50|  11.8k|        {
   51|       |            /* Bool fields must have valid value */
   52|  11.8k|            assert(memcmp(pData, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (52:13): [True: 11.8k, False: 0]
  |  Branch (52:13): [True: 0, False: 0]
  |  Branch (52:13): [True: 5.10k, False: 6.76k]
  |  Branch (52:13): [True: 6.76k, False: 0]
  ------------------
   53|  11.8k|                   memcmp(pData, &falsebool, sizeof(bool)) == 0);
   54|  11.8k|        }
   55|   401k|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  329|   401k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|   401k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|   401k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|   803k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 43.1k, False: 358k]
  |  |  ------------------
  |  |  330|   401k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|   358k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|   358k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|   358k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 358k]
  |  |  ------------------
  ------------------
   56|  43.1k|        {
   57|  43.1k|            validate_message(pData, 0, iter->submsg_desc);
   58|  43.1k|        }
   59|   453k|    }
   60|   479k|}
validate_message:
  145|  48.3k|{
  146|  48.3k|    pb_field_iter_t iter;
  147|       |
  148|  48.3k|    if (pb_field_iter_begin_const(&iter, msgtype, msg))
  ------------------
  |  Branch (148:9): [True: 35.8k, False: 12.5k]
  ------------------
  149|  35.8k|    {
  150|  35.8k|        do
  151|   520k|        {
  152|   520k|            if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  326|   520k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   520k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  321|   520k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (152:17): [True: 504k, False: 15.6k]
  ------------------
  153|   504k|            {
  154|   504k|                validate_static(&iter);
  155|   504k|            }
  156|  15.6k|            else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  15.6k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  15.6k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  15.6k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (156:22): [True: 0, False: 15.6k]
  ------------------
  157|      0|            {
  158|      0|                validate_pointer(&iter);
  159|      0|            }
  160|   520k|        } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (160:18): [True: 484k, False: 35.8k]
  ------------------
  161|  35.8k|    }
  162|  48.3k|}

