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

pb_read:
   82|  2.48M|{
   83|  2.48M|    if (count == 0)
  ------------------
  |  Branch (83:9): [True: 741k, False: 1.74M]
  ------------------
   84|   741k|        return true;
   85|       |
   86|  1.74M|#ifndef PB_BUFFER_ONLY
   87|  1.74M|	if (buf == NULL && stream->callback != buf_read)
  ------------------
  |  Branch (87:6): [True: 93.1k, False: 1.65M]
  |  Branch (87:21): [True: 30.6k, False: 62.4k]
  ------------------
   88|  30.6k|	{
   89|       |		/* Skip input bytes */
   90|  30.6k|		pb_byte_t tmp[16];
   91|   185k|		while (count > 16)
  ------------------
  |  Branch (91:10): [True: 155k, False: 30.6k]
  ------------------
   92|   155k|		{
   93|   155k|			if (!pb_read(stream, tmp, 16))
  ------------------
  |  Branch (93:8): [True: 0, False: 155k]
  ------------------
   94|      0|				return false;
   95|       |			
   96|   155k|			count -= 16;
   97|   155k|		}
   98|       |		
   99|  30.6k|		return pb_read(stream, tmp, count);
  100|  30.6k|	}
  101|  1.71M|#endif
  102|       |
  103|  1.71M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (103:9): [True: 292, False: 1.71M]
  ------------------
  104|    292|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  930|    292|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|    292|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 292]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  105|       |    
  106|  1.71M|#ifndef PB_BUFFER_ONLY
  107|  1.71M|    if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (107:9): [True: 0, False: 1.71M]
  ------------------
  108|      0|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  109|       |#else
  110|       |    if (!buf_read(stream, buf, count))
  111|       |        return false;
  112|       |#endif
  113|       |    
  114|  1.71M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (114:9): [True: 0, False: 1.71M]
  ------------------
  115|      0|        stream->bytes_left = 0;
  116|  1.71M|    else
  117|  1.71M|        stream->bytes_left -= count;
  118|       |
  119|       |    return true;
  120|  1.71M|}
pb_istream_from_buffer:
  143|  12.0k|{
  144|  12.0k|    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|  12.0k|    union {
  149|  12.0k|        void *state;
  150|  12.0k|        const void *c_state;
  151|  12.0k|    } state;
  152|       |#ifdef PB_BUFFER_ONLY
  153|       |    stream.callback = NULL;
  154|       |#else
  155|  12.0k|    stream.callback = &buf_read;
  156|  12.0k|#endif
  157|  12.0k|    state.c_state = buf;
  158|  12.0k|    stream.state = state.state;
  159|  12.0k|    stream.bytes_left = msglen;
  160|  12.0k|#ifndef PB_NO_ERRMSG
  161|  12.0k|    stream.errmsg = NULL;
  162|  12.0k|#endif
  163|       |#ifdef PB_MESSAGE_NESTING_MAX
  164|       |    stream.depth = 0;
  165|       |#endif
  166|  12.0k|    return stream;
  167|  12.0k|}
pb_decode_varint32:
  175|  66.0M|{
  176|  66.0M|    pb_byte_t byte;
  177|  66.0M|    uint32_t result;
  178|       |    
  179|  66.0M|    if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (179:9): [True: 1.93k, False: 66.0M]
  ------------------
  180|  1.93k|    {
  181|  1.93k|        return false;
  182|  1.93k|    }
  183|       |    
  184|  66.0M|    if ((byte & 0x80) == 0)
  ------------------
  |  Branch (184:9): [True: 35.3M, False: 30.7M]
  ------------------
  185|  35.3M|    {
  186|       |        /* Quick case, 1 byte value */
  187|  35.3M|        result = byte;
  188|  35.3M|    }
  189|  30.7M|    else
  190|  30.7M|    {
  191|       |        /* Multibyte case */
  192|  30.7M|        uint_fast8_t bitpos = 7;
  193|  30.7M|        result = byte & 0x7F;
  194|       |        
  195|  30.7M|        do
  196|  30.8M|        {
  197|  30.8M|            if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (197:17): [True: 59, False: 30.8M]
  ------------------
  198|     59|                return false;
  199|       |            
  200|  30.8M|            if (bitpos >= 32)
  ------------------
  |  Branch (200:17): [True: 7.38k, False: 30.8M]
  ------------------
  201|  7.38k|            {
  202|       |                /* Note: The varint could have trailing 0x80 bytes, or 0xFF for negative. */
  203|  7.38k|                pb_byte_t sign_extension = (bitpos < 63) ? 0xFF : 0x01;
  ------------------
  |  Branch (203:44): [True: 7.22k, False: 158]
  ------------------
  204|  7.38k|                bool valid_extension = ((byte & 0x7F) == 0x00 ||
  ------------------
  |  Branch (204:41): [True: 3.86k, False: 3.52k]
  ------------------
  205|  3.52k|                         ((result >> 31) != 0 && byte == sign_extension));
  ------------------
  |  Branch (205:27): [True: 3.50k, False: 16]
  |  Branch (205:50): [True: 3.44k, False: 62]
  ------------------
  206|       |
  207|  7.38k|                if (bitpos >= 64 || !valid_extension)
  ------------------
  |  Branch (207:21): [True: 2, False: 7.38k]
  |  Branch (207:37): [True: 77, False: 7.30k]
  ------------------
  208|     79|                {
  209|     79|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  930|     79|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     79|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 79]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  210|     79|                }
  211|  7.38k|            }
  212|  30.8M|            else if (bitpos == 28)
  ------------------
  |  Branch (212:22): [True: 11.1k, False: 30.8M]
  ------------------
  213|  11.1k|            {
  214|  11.1k|                if ((byte & 0x70) != 0 && (byte & 0x78) != 0x78)
  ------------------
  |  Branch (214:21): [True: 6.91k, False: 4.20k]
  |  Branch (214:43): [True: 38, False: 6.87k]
  ------------------
  215|     38|                {
  216|     38|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  930|     38|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     38|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 38]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  217|     38|                }
  218|  11.0k|                result |= (uint32_t)(byte & 0x0F) << bitpos;
  219|  11.0k|            }
  220|  30.8M|            else
  221|  30.8M|            {
  222|  30.8M|                result |= (uint32_t)(byte & 0x7F) << bitpos;
  223|  30.8M|            }
  224|  30.8M|            bitpos = (uint_fast8_t)(bitpos + 7);
  225|  30.8M|        } while (byte & 0x80);
  ------------------
  |  Branch (225:18): [True: 113k, False: 30.7M]
  ------------------
  226|  30.7M|   }
  227|       |   
  228|  66.0M|   *dest = result;
  229|       |   return true;
  230|  66.0M|}
pb_decode_varint:
  234|  9.28M|{
  235|  9.28M|    pb_byte_t byte;
  236|  9.28M|    uint_fast8_t bitpos = 0;
  237|  9.28M|    uint64_t result = 0;
  238|       |    
  239|  9.28M|    do
  240|  15.5M|    {
  241|  15.5M|        if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (241:13): [True: 86, False: 15.5M]
  ------------------
  242|     86|            return false;
  243|       |
  244|  15.5M|        if (bitpos >= 63 && (byte & 0xFE) != 0)
  ------------------
  |  Branch (244:13): [True: 69.5k, False: 15.4M]
  |  Branch (244:29): [True: 34, False: 69.4k]
  ------------------
  245|     34|            PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  930|     34|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     34|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 34]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  246|       |
  247|  15.5M|        result |= (uint64_t)(byte & 0x7F) << bitpos;
  248|  15.5M|        bitpos = (uint_fast8_t)(bitpos + 7);
  249|  15.5M|    } while (byte & 0x80);
  ------------------
  |  Branch (249:14): [True: 6.26M, False: 9.28M]
  ------------------
  250|       |    
  251|  9.28M|    *dest = result;
  252|       |    return true;
  253|  9.28M|}
pb_decode_tag:
  282|  32.3M|{
  283|  32.3M|    uint32_t temp;
  284|  32.3M|    *eof = false;
  285|  32.3M|    *wire_type = (pb_wire_type_t) 0;
  286|  32.3M|    *tag = 0;
  287|       |
  288|  32.3M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (288:9): [True: 178k, False: 32.1M]
  ------------------
  289|   178k|    {
  290|   178k|        *eof = true;
  291|   178k|        return false;
  292|   178k|    }
  293|       |
  294|  32.1M|    if (!pb_decode_varint32(stream, &temp))
  ------------------
  |  Branch (294:9): [True: 1.80k, False: 32.1M]
  ------------------
  295|  1.80k|    {
  296|  1.80k|#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.80k|        if (stream->callback != buf_read && stream->bytes_left == 0)
  ------------------
  |  Branch (304:13): [True: 1.69k, False: 112]
  |  Branch (304:45): [True: 1.69k, False: 0]
  ------------------
  305|  1.69k|        {
  306|  1.69k|#ifndef PB_NO_ERRMSG
  307|  1.69k|            if (strcmp(stream->errmsg, "io error") == 0)
  ------------------
  |  Branch (307:17): [True: 1.69k, False: 0]
  ------------------
  308|  1.69k|                stream->errmsg = NULL;
  309|  1.69k|#endif
  310|  1.69k|            *eof = true;
  311|  1.69k|        }
  312|  1.80k|#endif
  313|  1.80k|        return false;
  314|  1.80k|    }
  315|       |    
  316|  32.1M|    *tag = temp >> 3;
  317|  32.1M|    *wire_type = (pb_wire_type_t)(temp & 7);
  318|       |    return true;
  319|  32.1M|}
pb_skip_field:
  322|   329k|{
  323|   329k|    switch (wire_type)
  324|   329k|    {
  325|   128k|        case PB_WT_VARINT: return pb_skip_varint(stream);
  ------------------
  |  Branch (325:9): [True: 128k, False: 201k]
  ------------------
  326|  10.8k|        case PB_WT_64BIT: return pb_read(stream, NULL, 8);
  ------------------
  |  Branch (326:9): [True: 10.8k, False: 318k]
  ------------------
  327|   147k|        case PB_WT_STRING: return pb_skip_string(stream);
  ------------------
  |  Branch (327:9): [True: 147k, False: 182k]
  ------------------
  328|  43.0k|        case PB_WT_32BIT: return pb_read(stream, NULL, 4);
  ------------------
  |  Branch (328:9): [True: 43.0k, False: 286k]
  ------------------
  329|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (329:2): [True: 0, False: 329k]
  ------------------
  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|     93|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  930|     93|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     93|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 93]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (334:9): [True: 93, False: 329k]
  ------------------
  335|   329k|    }
  336|   329k|}
pb_make_string_substream:
  387|   248k|{
  388|   248k|    uint32_t size;
  389|   248k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (389:9): [True: 123, False: 248k]
  ------------------
  390|    123|        return false;
  391|       |    
  392|   248k|    *substream = *stream;
  393|   248k|    if (substream->bytes_left < size)
  ------------------
  |  Branch (393:9): [True: 107, False: 248k]
  ------------------
  394|    107|        PB_RETURN_ERROR(stream, "parent stream too short");
  ------------------
  |  |  930|    107|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|    107|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 107]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|   248k|    substream->bytes_left = (size_t)size;
  403|   248k|    stream->bytes_left -= (size_t)size;
  404|       |    return true;
  405|   248k|}
pb_close_string_substream:
  408|   248k|{
  409|   248k|    if (substream->bytes_left) {
  ------------------
  |  Branch (409:9): [True: 746, False: 247k]
  ------------------
  410|    746|        if (!pb_read(substream, NULL, substream->bytes_left))
  ------------------
  |  Branch (410:13): [True: 0, False: 746]
  ------------------
  411|      0|            return false;
  412|    746|    }
  413|       |
  414|   248k|    stream->state = substream->state;
  415|       |
  416|   248k|#ifndef PB_NO_ERRMSG
  417|   248k|    stream->errmsg = substream->errmsg;
  418|   248k|#endif
  419|       |    return true;
  420|   248k|}
pb_decode_ex:
 1220|  8.88k|{
 1221|  8.88k|    bool status;
 1222|       |
 1223|  8.88k|    if ((flags & PB_DECODE_DELIMITED) == 0)
  ------------------
  |  |  123|  8.88k|#define PB_DECODE_DELIMITED       0x02U
  ------------------
  |  Branch (1223:9): [True: 8.88k, False: 0]
  ------------------
 1224|  8.88k|    {
 1225|  8.88k|      status = pb_decode_inner(stream, fields, dest_struct, flags);
 1226|  8.88k|    }
 1227|      0|    else
 1228|      0|    {
 1229|      0|      pb_istream_t substream;
 1230|      0|      if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1230:11): [True: 0, False: 0]
  ------------------
 1231|      0|        return false;
 1232|       |
 1233|      0|      status = pb_decode_inner(&substream, fields, dest_struct, flags);
 1234|       |
 1235|      0|      if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1235:11): [True: 0, False: 0]
  ------------------
 1236|      0|        status = false;
 1237|      0|    }
 1238|       |    
 1239|  8.88k|#ifdef PB_ENABLE_MALLOC
 1240|  8.88k|    if (!status)
  ------------------
  |  Branch (1240:9): [True: 2.34k, False: 6.54k]
  ------------------
 1241|  2.34k|        pb_release(fields, dest_struct);
 1242|  8.88k|#endif
 1243|       |    
 1244|  8.88k|    return status;
 1245|  8.88k|}
pb_decode:
 1248|  3.15k|{
 1249|  3.15k|    return pb_decode_ex(stream, fields, dest_struct, 0);
 1250|  3.15k|}
pb_release:
 1377|   184k|{
 1378|   184k|    pb_field_iter_t iter;
 1379|       |    
 1380|   184k|    if (!dest_struct)
  ------------------
  |  Branch (1380:9): [True: 0, False: 184k]
  ------------------
 1381|      0|        return; /* Ignore NULL pointers, similar to free() */
 1382|       |
 1383|   184k|    if (!pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1383:9): [True: 59.5k, False: 124k]
  ------------------
 1384|  59.5k|        return; /* Empty message type */
 1385|       |    
 1386|   124k|    do
 1387|  1.08M|    {
 1388|  1.08M|        pb_release_single_field(&iter);
 1389|  1.08M|    } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (1389:14): [True: 961k, False: 124k]
  ------------------
 1390|   124k|}
pb_decode_bool:
 1403|  3.31M|{
 1404|  3.31M|    uint32_t value;
 1405|  3.31M|    if (!pb_decode_varint32(stream, &value))
  ------------------
  |  Branch (1405:9): [True: 72, False: 3.31M]
  ------------------
 1406|     72|        return false;
 1407|       |
 1408|  3.31M|    *(bool*)dest = (value != 0);
 1409|       |    return true;
 1410|  3.31M|}
pb_decode_svarint:
 1413|  3.98M|{
 1414|  3.98M|    pb_uint64_t value;
  ------------------
  |  |   57|  3.98M|#define pb_uint64_t uint64_t
  ------------------
 1415|  3.98M|    if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1415:9): [True: 36, False: 3.98M]
  ------------------
 1416|     36|        return false;
 1417|       |    
 1418|  3.98M|    if (value & 1)
  ------------------
  |  Branch (1418:9): [True: 561k, False: 3.42M]
  ------------------
 1419|   561k|        *dest = (pb_int64_t)(~(value >> 1));
 1420|  3.42M|    else
 1421|  3.42M|        *dest = (pb_int64_t)(value >> 1);
 1422|       |    
 1423|       |    return true;
 1424|  3.98M|}
pb_decode_fixed32:
 1427|   111k|{
 1428|   111k|    union {
 1429|   111k|        uint32_t fixed32;
 1430|   111k|        pb_byte_t bytes[4];
 1431|   111k|    } u;
 1432|       |
 1433|   111k|    if (!pb_read(stream, u.bytes, 4))
  ------------------
  |  Branch (1433:9): [True: 21, False: 111k]
  ------------------
 1434|     21|        return false;
 1435|       |
 1436|   111k|#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|   111k|    *(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|   111k|}
pb_decode_fixed64:
 1450|  59.0k|{
 1451|  59.0k|    union {
 1452|  59.0k|        uint64_t fixed64;
 1453|  59.0k|        pb_byte_t bytes[8];
 1454|  59.0k|    } u;
 1455|       |
 1456|  59.0k|    if (!pb_read(stream, u.bytes, 8))
  ------------------
  |  Branch (1456:9): [True: 24, False: 59.0k]
  ------------------
 1457|     24|        return false;
 1458|       |
 1459|  59.0k|#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|  59.0k|    *(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|  59.0k|}
pb_decode.c:buf_read:
   69|  79.9M|{
   70|  79.9M|    const pb_byte_t *source = (const pb_byte_t*)stream->state;
   71|  79.9M|    stream->state = (pb_byte_t*)stream->state + count;
   72|       |    
   73|  79.9M|    if (buf != NULL)
  ------------------
  |  Branch (73:9): [True: 79.9M, False: 62.3k]
  ------------------
   74|  79.9M|    {
   75|  79.9M|        memcpy(buf, source, count * sizeof(pb_byte_t));
   76|  79.9M|    }
   77|       |    
   78|       |    return true;
   79|  79.9M|}
pb_decode.c:pb_readbyte:
  125|   112M|{
  126|   112M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (126:9): [True: 381, False: 112M]
  ------------------
  127|    381|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  930|    381|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|    381|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 381]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  128|       |
  129|   112M|#ifndef PB_BUFFER_ONLY
  130|   112M|    if (!stream->callback(stream, buf, 1))
  ------------------
  |  Branch (130:9): [True: 1.69k, False: 112M]
  ------------------
  131|  1.69k|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  930|  1.69k|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|  1.69k|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 1.69k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  132|       |#else
  133|       |    *buf = *(const pb_byte_t*)stream->state;
  134|       |    stream->state = (pb_byte_t*)stream->state + 1;
  135|       |#endif
  136|       |
  137|   112M|    stream->bytes_left--;
  138|       |    
  139|       |    return true;    
  140|   112M|}
pb_decode.c:pb_skip_varint:
  257|   128k|{
  258|   128k|    pb_byte_t byte;
  259|   128k|    do
  260|   147k|    {
  261|   147k|        if (!pb_read(stream, &byte, 1))
  ------------------
  |  Branch (261:13): [True: 76, False: 147k]
  ------------------
  262|     76|            return false;
  263|   147k|    } while (byte & 0x80);
  ------------------
  |  Branch (263:14): [True: 19.4k, False: 128k]
  ------------------
  264|   128k|    return true;
  265|   128k|}
pb_decode.c:pb_skip_string:
  268|   147k|{
  269|   147k|    uint32_t length;
  270|   147k|    if (!pb_decode_varint32(stream, &length))
  ------------------
  |  Branch (270:9): [True: 53, False: 147k]
  ------------------
  271|     53|        return false;
  272|       |    
  273|   147k|    if ((size_t)length != length)
  ------------------
  |  Branch (273:9): [True: 0, False: 147k]
  ------------------
  274|      0|    {
  275|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  276|      0|    }
  277|       |
  278|   147k|    return pb_read(stream, NULL, (size_t)length);
  279|   147k|}
pb_decode.c:pb_decode_inner:
 1049|   182k|{
 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|   182k|    uint32_t extension_range_start = 0;
 1055|   182k|    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|   182k|    pb_size_t fixed_count_field = PB_SIZE_MAX;
  ------------------
  |  |  342|   182k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
 1062|   182k|    pb_size_t fixed_count_size = 0;
 1063|   182k|    pb_size_t fixed_count_total_size = 0;
 1064|       |
 1065|       |    /* Tag and wire type of next field from the input stream */
 1066|   182k|    uint32_t tag;
 1067|   182k|    pb_wire_type_t wire_type;
 1068|   182k|    bool eof;
 1069|       |
 1070|       |    /* Track presence of required fields */
 1071|   182k|    pb_fields_seen_t fields_seen = {{0, 0}};
 1072|   182k|    const uint32_t allbits = ~(uint32_t)0;
 1073|       |
 1074|       |    /* Descriptor for the structure field matching the tag decoded from stream */
 1075|   182k|    pb_field_iter_t iter;
 1076|       |
 1077|   182k|    if (pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1077:9): [True: 122k, False: 59.4k]
  ------------------
 1078|   122k|    {
 1079|   122k|        if ((flags & PB_DECODE_NOINIT) == 0)
  ------------------
  |  |  122|   122k|#define PB_DECODE_NOINIT          0x01U
  ------------------
  |  Branch (1079:13): [True: 111k, False: 11.2k]
  ------------------
 1080|   111k|        {
 1081|   111k|            if (!pb_message_set_to_defaults(&iter))
  ------------------
  |  Branch (1081:17): [True: 0, False: 111k]
  ------------------
 1082|      0|                PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1083|   111k|        }
 1084|   122k|    }
 1085|       |
 1086|  32.3M|    while (pb_decode_tag(stream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1086:12): [True: 32.1M, False: 180k]
  ------------------
 1087|  32.1M|    {
 1088|  32.1M|        if (tag == 0)
  ------------------
  |  Branch (1088:13): [True: 86, False: 32.1M]
  ------------------
 1089|     86|        {
 1090|     86|          if (flags & PB_DECODE_NULLTERMINATED)
  ------------------
  |  |  124|     86|#define PB_DECODE_NULLTERMINATED  0x04U
  ------------------
  |  Branch (1090:15): [True: 0, False: 86]
  ------------------
 1091|      0|          {
 1092|      0|            eof = true;
 1093|      0|            break;
 1094|      0|          }
 1095|     86|          else
 1096|     86|          {
 1097|     86|            PB_RETURN_ERROR(stream, "zero tag");
  ------------------
  |  |  930|     86|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     86|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 86]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1098|     86|          }
 1099|     86|        }
 1100|       |
 1101|  32.1M|        if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  31.8M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  31.8M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  31.8M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1101:13): [True: 331k, False: 31.8M]
  |  Branch (1101:48): [True: 1.12k, False: 31.8M]
  ------------------
 1102|   332k|        {
 1103|       |            /* No match found, check if it matches an extension. */
 1104|   332k|            if (extension_range_start == 0)
  ------------------
  |  Branch (1104:17): [True: 9.90k, False: 322k]
  ------------------
 1105|  9.90k|            {
 1106|  9.90k|                if (pb_field_iter_find_extension(&iter))
  ------------------
  |  Branch (1106:21): [True: 4.03k, False: 5.87k]
  ------------------
 1107|  4.03k|                {
 1108|  4.03k|                    extensions = *(pb_extension_t* const *)iter.pData;
 1109|  4.03k|                    extension_range_start = iter.tag;
 1110|  4.03k|                }
 1111|       |
 1112|  9.90k|                if (!extensions)
  ------------------
  |  Branch (1112:21): [True: 6.54k, False: 3.36k]
  ------------------
 1113|  6.54k|                {
 1114|  6.54k|                    extension_range_start = (uint32_t)-1;
 1115|  6.54k|                }
 1116|  9.90k|            }
 1117|       |
 1118|   332k|            if (tag >= extension_range_start)
  ------------------
  |  Branch (1118:17): [True: 73.2k, False: 259k]
  ------------------
 1119|  73.2k|            {
 1120|  73.2k|                size_t pos = stream->bytes_left;
 1121|       |
 1122|  73.2k|                if (!decode_extension(stream, tag, wire_type, extensions))
  ------------------
  |  Branch (1122:21): [True: 111, False: 73.1k]
  ------------------
 1123|    111|                    return false;
 1124|       |
 1125|  73.1k|                if (pos != stream->bytes_left)
  ------------------
  |  Branch (1125:21): [True: 3.50k, False: 69.5k]
  ------------------
 1126|  3.50k|                {
 1127|       |                    /* The field was handled */
 1128|  3.50k|                    continue;
 1129|  3.50k|                }
 1130|  73.1k|            }
 1131|       |
 1132|       |            /* No match found, skip data */
 1133|   329k|            if (!pb_skip_field(stream, wire_type))
  ------------------
  |  Branch (1133:17): [True: 336, False: 328k]
  ------------------
 1134|    336|                return false;
 1135|   328k|            continue;
 1136|   329k|        }
 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|  31.8M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  327|  31.8M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  31.8M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  314|  63.6M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1141:13): [True: 30.2M, False: 1.58M]
  |  Branch (1141:57): [True: 1.27k, False: 30.2M]
  ------------------
 1142|  1.27k|        {
 1143|  1.27k|            if (fixed_count_field != iter.index) {
  ------------------
  |  Branch (1143:17): [True: 1.04k, False: 231]
  ------------------
 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|  1.04k|                if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  342|  2.08k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1148:21): [True: 586, False: 456]
  ------------------
 1149|    586|                    fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1149:21): [True: 2, False: 584]
  ------------------
 1150|      2|                {
 1151|      2|                    PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  930|      2|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      2|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1152|      2|                }
 1153|       |
 1154|  1.04k|                fixed_count_field = iter.index;
 1155|  1.04k|                fixed_count_size = 0;
 1156|  1.04k|                fixed_count_total_size = iter.array_size;
 1157|  1.04k|            }
 1158|       |
 1159|  1.27k|            iter.pSize = &fixed_count_size;
 1160|  1.27k|        }
 1161|       |
 1162|  31.8M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  327|  31.8M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  31.8M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  311|  63.6M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (1162:13): [True: 1.53M, False: 30.3M]
  ------------------
 1163|  1.53M|            && iter.required_field_index < PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  233|  1.53M|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1163:16): [True: 1.53M, False: 0]
  ------------------
 1164|  1.53M|        {
 1165|  1.53M|            uint32_t tmp = ((uint32_t)1 << (iter.required_field_index & 31));
 1166|  1.53M|            fields_seen.bitfield[iter.required_field_index >> 5] |= tmp;
 1167|  1.53M|        }
 1168|       |
 1169|  31.8M|        if (!decode_field(stream, wire_type, &iter))
  ------------------
  |  Branch (1169:13): [True: 1.48k, False: 31.8M]
  ------------------
 1170|  1.48k|            return false;
 1171|  31.8M|    }
 1172|       |
 1173|   180k|    if (!eof)
  ------------------
  |  Branch (1173:9): [True: 112, False: 180k]
  ------------------
 1174|    112|    {
 1175|       |        /* pb_decode_tag() returned error before end of stream */
 1176|    112|        return false;
 1177|    112|    }
 1178|       |
 1179|       |    /* Check that all elements of the last decoded fixed count field were present. */
 1180|   180k|    if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  342|   360k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1180:9): [True: 408, False: 179k]
  ------------------
 1181|    408|        fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1181:9): [True: 46, False: 362]
  ------------------
 1182|     46|    {
 1183|     46|        PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  930|     46|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     46|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 46]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1184|     46|    }
 1185|       |
 1186|       |    /* Check that all required fields were present. */
 1187|   180k|    {
 1188|   180k|        pb_size_t req_field_count = iter.descriptor->required_field_count;
 1189|       |
 1190|   180k|        if (req_field_count > 0)
  ------------------
  |  Branch (1190:13): [True: 113k, False: 67.0k]
  ------------------
 1191|   113k|        {
 1192|   113k|            pb_size_t i;
 1193|       |
 1194|   113k|            if (req_field_count > PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  233|   113k|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1194:17): [True: 0, False: 113k]
  ------------------
 1195|      0|                req_field_count = PB_MAX_REQUIRED_FIELDS;
  ------------------
  |  |  233|      0|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
 1196|       |
 1197|       |            /* Check the whole words */
 1198|   113k|            for (i = 0; i < (req_field_count >> 5); i++)
  ------------------
  |  Branch (1198:25): [True: 0, False: 113k]
  ------------------
 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");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1202|      0|            }
 1203|       |
 1204|       |            /* Check the remaining bits (if any) */
 1205|   113k|            if ((req_field_count & 31) != 0)
  ------------------
  |  Branch (1205:17): [True: 113k, False: 0]
  ------------------
 1206|   113k|            {
 1207|   113k|                if (fields_seen.bitfield[req_field_count >> 5] !=
  ------------------
  |  Branch (1207:21): [True: 511, False: 112k]
  ------------------
 1208|   113k|                    (allbits >> (uint_least8_t)(32 - (req_field_count & 31))))
 1209|    511|                {
 1210|    511|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  930|    511|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|    511|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 511]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1211|    511|                }
 1212|   113k|            }
 1213|   113k|        }
 1214|   180k|    }
 1215|       |
 1216|   179k|    return true;
 1217|   180k|}
pb_decode.c:pb_message_set_to_defaults:
 1010|   118k|{
 1011|   118k|    pb_istream_t defstream = PB_ISTREAM_EMPTY;
  ------------------
  |  |   71|   118k|#  define PB_ISTREAM_EMPTY {0,0,0,0}
  ------------------
 1012|   118k|    uint32_t tag = 0;
 1013|   118k|    pb_wire_type_t wire_type = PB_WT_VARINT;
 1014|   118k|    bool eof;
 1015|       |
 1016|   118k|    if (iter->descriptor->default_value)
  ------------------
  |  Branch (1016:9): [True: 0, False: 118k]
  ------------------
 1017|      0|    {
 1018|      0|        defstream = pb_istream_from_buffer(iter->descriptor->default_value, (size_t)-1);
 1019|      0|        if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1019:13): [True: 0, False: 0]
  ------------------
 1020|      0|            return false;
 1021|      0|    }
 1022|       |
 1023|   118k|    do
 1024|  1.05M|    {
 1025|  1.05M|        if (!pb_field_set_to_default(iter))
  ------------------
  |  Branch (1025:13): [True: 0, False: 1.05M]
  ------------------
 1026|      0|            return false;
 1027|       |
 1028|  1.05M|        if (tag != 0 && iter->tag == tag)
  ------------------
  |  Branch (1028:13): [True: 0, False: 1.05M]
  |  Branch (1028:25): [True: 0, False: 0]
  ------------------
 1029|      0|        {
 1030|       |            /* We have a default value for this field in the defstream */
 1031|      0|            if (!decode_field(&defstream, wire_type, iter))
  ------------------
  |  Branch (1031:17): [True: 0, False: 0]
  ------------------
 1032|      0|                return false;
 1033|      0|            if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1033:17): [True: 0, False: 0]
  ------------------
 1034|      0|                return false;
 1035|       |
 1036|      0|            if (iter->pSize)
  ------------------
  |  Branch (1036:17): [True: 0, False: 0]
  ------------------
 1037|      0|                *(bool*)iter->pSize = false;
 1038|      0|        }
 1039|  1.05M|    } while (pb_field_iter_next(iter));
  ------------------
  |  Branch (1039:14): [True: 940k, False: 118k]
  ------------------
 1040|       |
 1041|   118k|    return true;
 1042|   118k|}
pb_decode.c:pb_field_set_to_default:
  928|  1.05M|{
  929|  1.05M|    pb_type_t type;
  930|  1.05M|    type = field->type;
  931|       |
  932|  1.05M|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  1.05M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.05M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  1.05M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (932:9): [True: 8.88k, False: 1.05M]
  ------------------
  933|  8.88k|    {
  934|  8.88k|        pb_extension_t *ext = *(pb_extension_t* const *)field->pData;
  935|  16.0k|        while (ext != NULL)
  ------------------
  |  Branch (935:16): [True: 7.19k, False: 8.88k]
  ------------------
  936|  7.19k|        {
  937|  7.19k|            pb_field_iter_t ext_iter;
  938|  7.19k|            if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (938:17): [True: 7.19k, False: 0]
  ------------------
  939|  7.19k|            {
  940|  7.19k|                ext->found = false;
  941|  7.19k|                if (!pb_message_set_to_defaults(&ext_iter))
  ------------------
  |  Branch (941:21): [True: 0, False: 7.19k]
  ------------------
  942|      0|                    return false;
  943|  7.19k|            }
  944|  7.19k|            ext = ext->next;
  945|  7.19k|        }
  946|  8.88k|    }
  947|  1.05M|    else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  326|  1.05M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  1.05M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  321|  1.05M|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (947:14): [True: 33.8k, False: 1.01M]
  ------------------
  948|  33.8k|    {
  949|  33.8k|        bool init_data = true;
  950|  33.8k|        if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  327|  33.8k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  33.8k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  312|  67.6k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (950:13): [True: 0, False: 33.8k]
  |  Branch (950:52): [True: 0, False: 0]
  ------------------
  951|      0|        {
  952|       |            /* Set has_field to false. Still initialize the optional field
  953|       |             * itself also. */
  954|      0|            *(bool*)field->pSize = false;
  955|      0|        }
  956|  33.8k|        else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  327|  33.8k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  33.8k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  314|  67.6k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (956:18): [True: 0, False: 33.8k]
  ------------------
  957|  33.8k|                 PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  33.8k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  33.8k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                               PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  33.8k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (957:18): [True: 26.6k, False: 7.19k]
  ------------------
  958|  26.6k|        {
  959|       |            /* REPEATED: Set array count to 0, no need to initialize contents.
  960|       |               ONEOF: Set which_field to 0. */
  961|  26.6k|            *(pb_size_t*)field->pSize = 0;
  962|  26.6k|            init_data = false;
  963|  26.6k|        }
  964|       |
  965|  33.8k|        if (init_data)
  ------------------
  |  Branch (965:13): [True: 7.19k, False: 26.6k]
  ------------------
  966|  7.19k|        {
  967|  7.19k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  329|  14.3k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  7.19k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  7.19k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  14.3k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 7.19k, False: 0]
  |  |  ------------------
  |  |  330|  14.3k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|      0|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  968|  7.19k|                (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (968:18): [True: 0, False: 7.19k]
  ------------------
  969|  7.19k|                 field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (969:18): [True: 0, False: 7.19k]
  ------------------
  970|  7.19k|                 field->submsg_desc->submsg_info[0] != NULL))
  ------------------
  |  Branch (970:18): [True: 0, False: 7.19k]
  ------------------
  971|      0|            {
  972|       |                /* Initialize submessage to defaults.
  973|       |                 * Only needed if it has default values
  974|       |                 * or callback/submessage fields. */
  975|      0|                pb_field_iter_t submsg_iter;
  976|      0|                if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (976:21): [True: 0, False: 0]
  ------------------
  977|      0|                {
  978|      0|                    if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (978:25): [True: 0, False: 0]
  ------------------
  979|      0|                        return false;
  980|      0|                }
  981|      0|            }
  982|  7.19k|            else
  983|  7.19k|            {
  984|       |                /* Initialize to zeros */
  985|  7.19k|                memset(field->pData, 0, (size_t)field->data_size);
  986|  7.19k|            }
  987|  7.19k|        }
  988|  33.8k|    }
  989|  1.01M|    else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  1.01M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  1.01M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  1.01M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (989:14): [True: 999k, False: 17.7k]
  ------------------
  990|   999k|    {
  991|       |        /* Initialize the pointer to NULL. */
  992|   999k|        *(void**)field->pField = NULL;
  993|       |
  994|       |        /* Initialize array count to 0. */
  995|   999k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  327|   999k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   999k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  314|  1.99M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (995:13): [True: 186k, False: 812k]
  ------------------
  996|   812k|            PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|   812k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   812k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|   812k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (996:13): [True: 17.7k, False: 794k]
  ------------------
  997|   204k|        {
  998|   204k|            *(pb_size_t*)field->pSize = 0;
  999|   204k|        }
 1000|   999k|    }
 1001|  17.7k|    else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  326|  17.7k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  17.7k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|  17.7k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (1001:14): [True: 17.7k, False: 0]
  ------------------
 1002|  17.7k|    {
 1003|       |        /* Don't overwrite callback */
 1004|  17.7k|    }
 1005|       |
 1006|  1.05M|    return true;
 1007|  1.05M|}
pb_decode.c:decode_extension:
  906|  73.2k|{
  907|  73.2k|    size_t pos = stream->bytes_left;
  908|       |    
  909|   146k|    while (extension != NULL && pos == stream->bytes_left)
  ------------------
  |  Branch (909:12): [True: 73.2k, False: 73.1k]
  |  Branch (909:33): [True: 73.2k, False: 0]
  ------------------
  910|  73.2k|    {
  911|  73.2k|        bool status;
  912|  73.2k|        if (extension->type->decode)
  ------------------
  |  Branch (912:13): [True: 0, False: 73.2k]
  ------------------
  913|      0|            status = extension->type->decode(stream, extension, tag, wire_type);
  914|  73.2k|        else
  915|  73.2k|            status = default_extension_decoder(stream, extension, tag, wire_type);
  916|       |
  917|  73.2k|        if (!status)
  ------------------
  |  Branch (917:13): [True: 111, False: 73.1k]
  ------------------
  918|    111|            return false;
  919|       |        
  920|  73.1k|        extension = extension->next;
  921|  73.1k|    }
  922|       |    
  923|  73.1k|    return true;
  924|  73.2k|}
pb_decode.c:default_extension_decoder:
  889|  73.2k|{
  890|  73.2k|    pb_field_iter_t iter;
  891|       |
  892|  73.2k|    if (!pb_field_iter_begin_extension(&iter, extension))
  ------------------
  |  Branch (892:9): [True: 0, False: 73.2k]
  ------------------
  893|      0|        PB_RETURN_ERROR(stream, "invalid extension");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  894|       |
  895|  73.2k|    if (iter.tag != tag || !iter.message)
  ------------------
  |  Branch (895:9): [True: 69.5k, False: 3.61k]
  |  Branch (895:28): [True: 0, False: 3.61k]
  ------------------
  896|  69.5k|        return true;
  897|       |
  898|  3.61k|    extension->found = true;
  899|  3.61k|    return decode_field(stream, wire_type, &iter);
  900|  73.2k|}
pb_decode.c:decode_field:
  857|  31.8M|{
  858|  31.8M|#ifdef PB_ENABLE_MALLOC
  859|       |    /* When decoding an oneof field, check if there is old data that must be
  860|       |     * released first. */
  861|  31.8M|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  31.8M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  31.8M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  31.8M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (861:9): [True: 29.4k, False: 31.8M]
  ------------------
  862|  29.4k|    {
  863|  29.4k|        if (!pb_release_union_field(stream, field))
  ------------------
  |  Branch (863:13): [True: 0, False: 29.4k]
  ------------------
  864|      0|            return false;
  865|  29.4k|    }
  866|  31.8M|#endif
  867|       |
  868|  31.8M|    switch (PB_ATYPE(field->type))
  ------------------
  |  |  326|  31.8M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  31.8M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
  869|  31.8M|    {
  870|  15.8k|        case PB_ATYPE_STATIC:
  ------------------
  |  |  321|  15.8k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (870:9): [True: 15.8k, False: 31.8M]
  ------------------
  871|  15.8k|            return decode_static_field(stream, wire_type, field);
  872|       |        
  873|  31.8M|        case PB_ATYPE_POINTER:
  ------------------
  |  |  322|  31.8M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (873:9): [True: 31.8M, False: 22.4k]
  ------------------
  874|  31.8M|            return decode_pointer_field(stream, wire_type, field);
  875|       |        
  876|  6.60k|        case PB_ATYPE_CALLBACK:
  ------------------
  |  |  323|  6.60k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (876:9): [True: 6.60k, False: 31.8M]
  ------------------
  877|  6.60k|            return decode_callback_field(stream, wire_type, field);
  878|       |        
  879|      0|        default:
  ------------------
  |  Branch (879:9): [True: 0, False: 31.8M]
  ------------------
  880|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  881|  31.8M|    }
  882|  31.8M|}
pb_decode.c:pb_release_union_field:
 1256|  29.4k|{
 1257|  29.4k|    pb_field_iter_t old_field = *field;
 1258|  29.4k|    pb_size_t old_tag = *(pb_size_t*)field->pSize; /* Previous which_ value */
 1259|  29.4k|    pb_size_t new_tag = field->tag; /* New which_ value */
 1260|       |
 1261|  29.4k|    if (old_tag == 0)
  ------------------
  |  Branch (1261:9): [True: 1.77k, False: 27.6k]
  ------------------
 1262|  1.77k|        return true; /* Ok, no old data in union */
 1263|       |
 1264|  27.6k|    if (old_tag == new_tag)
  ------------------
  |  Branch (1264:9): [True: 13.8k, False: 13.7k]
  ------------------
 1265|  13.8k|        return true; /* Ok, old data is of same type => merge */
 1266|       |
 1267|       |    /* Release old data. The find can fail if the message struct contains
 1268|       |     * invalid data. */
 1269|  13.7k|    if (!pb_field_iter_find(&old_field, old_tag))
  ------------------
  |  Branch (1269:9): [True: 0, False: 13.7k]
  ------------------
 1270|      0|        PB_RETURN_ERROR(stream, "invalid union tag");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1271|       |
 1272|  13.7k|    pb_release_single_field(&old_field);
 1273|       |
 1274|  13.7k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  13.7k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  13.7k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  13.7k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1274:9): [True: 2.85k, False: 10.9k]
  ------------------
 1275|  2.85k|    {
 1276|       |        /* Initialize the pointer to NULL to make sure it is valid
 1277|       |         * even in case of error return. */
 1278|  2.85k|        *(void**)field->pField = NULL;
 1279|  2.85k|        field->pData = NULL;
 1280|  2.85k|    }
 1281|       |
 1282|       |    return true;
 1283|  13.7k|}
pb_decode.c:decode_static_field:
  498|  15.8k|{
  499|  15.8k|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  327|  15.8k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  15.8k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  500|  15.8k|    {
  501|  3.61k|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  311|  3.61k|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (501:9): [True: 3.61k, False: 12.2k]
  ------------------
  502|  3.61k|            return decode_basic_field(stream, wire_type, field);
  503|       |            
  504|  1.20k|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  312|  1.20k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (504:9): [True: 1.20k, False: 14.6k]
  ------------------
  505|  1.20k|            if (field->pSize != NULL)
  ------------------
  |  Branch (505:17): [True: 1.20k, False: 0]
  ------------------
  506|  1.20k|                *(bool*)field->pSize = true;
  507|  1.20k|            return decode_basic_field(stream, wire_type, field);
  508|       |    
  509|      0|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  314|      0|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (509:9): [True: 0, False: 15.8k]
  ------------------
  510|      0|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (510:17): [True: 0, False: 0]
  ------------------
  511|      0|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  328|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  276|      0|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (511:20): [True: 0, False: 0]
  ------------------
  512|      0|            {
  513|       |                /* Packed array */
  514|      0|                bool status = true;
  515|      0|                pb_istream_t substream;
  516|      0|                pb_size_t *size = (pb_size_t*)field->pSize;
  517|      0|                field->pData = (char*)field->pField + field->data_size * (*size);
  518|       |
  519|      0|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (519:21): [True: 0, False: 0]
  ------------------
  520|      0|                    return false;
  521|       |
  522|      0|                while (substream.bytes_left > 0 && *size < field->array_size)
  ------------------
  |  Branch (522:24): [True: 0, False: 0]
  |  Branch (522:52): [True: 0, False: 0]
  ------------------
  523|      0|                {
  524|      0|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (524:25): [True: 0, False: 0]
  ------------------
  525|      0|                    {
  526|      0|                        status = false;
  527|      0|                        break;
  528|      0|                    }
  529|      0|                    (*size)++;
  530|      0|                    field->pData = (char*)field->pData + field->data_size;
  531|      0|                }
  532|       |
  533|      0|                if (substream.bytes_left != 0)
  ------------------
  |  Branch (533:21): [True: 0, False: 0]
  ------------------
  534|      0|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  535|      0|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (535:21): [True: 0, False: 0]
  ------------------
  536|      0|                    return false;
  537|       |
  538|      0|                return status;
  539|      0|            }
  540|      0|            else
  541|      0|            {
  542|       |                /* Repeated field */
  543|      0|                pb_size_t *size = (pb_size_t*)field->pSize;
  544|      0|                field->pData = (char*)field->pField + field->data_size * (*size);
  545|       |
  546|      0|                if ((*size)++ >= field->array_size)
  ------------------
  |  Branch (546:21): [True: 0, False: 0]
  ------------------
  547|      0|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  548|       |
  549|      0|                return decode_basic_field(stream, wire_type, field);
  550|      0|            }
  551|       |
  552|  11.0k|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  316|  11.0k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (552:9): [True: 11.0k, False: 4.82k]
  ------------------
  553|  11.0k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  329|  22.1k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  11.0k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  11.0k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  22.1k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 7.72k, False: 3.33k]
  |  |  ------------------
  |  |  330|  22.1k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  3.33k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  3.33k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  3.33k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 3.33k]
  |  |  ------------------
  ------------------
  554|  7.72k|                *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (554:17): [True: 5.17k, False: 2.55k]
  ------------------
  555|  5.17k|            {
  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|  5.17k|                memset(field->pData, 0, (size_t)field->data_size);
  564|       |
  565|       |                /* Set default values for the submessage fields. */
  566|  5.17k|                if (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (566:21): [True: 0, False: 5.17k]
  ------------------
  567|  5.17k|                    field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (567:21): [True: 0, False: 5.17k]
  ------------------
  568|  5.17k|                    field->submsg_desc->submsg_info[0] != NULL)
  ------------------
  |  Branch (568:21): [True: 0, False: 5.17k]
  ------------------
  569|      0|                {
  570|      0|                    pb_field_iter_t submsg_iter;
  571|      0|                    if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (571:25): [True: 0, False: 0]
  ------------------
  572|      0|                    {
  573|      0|                        if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (573:29): [True: 0, False: 0]
  ------------------
  574|      0|                            PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  575|      0|                    }
  576|      0|                }
  577|  5.17k|            }
  578|  11.0k|            *(pb_size_t*)field->pSize = field->tag;
  579|       |
  580|  11.0k|            return decode_basic_field(stream, wire_type, field);
  581|       |
  582|      0|        default:
  ------------------
  |  Branch (582:9): [True: 0, False: 15.8k]
  ------------------
  583|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  584|  15.8k|    }
  585|  15.8k|}
pb_decode.c:decode_basic_field:
  427|  43.1M|{
  428|  43.1M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  328|  43.1M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  43.1M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  429|  43.1M|    {
  430|  3.31M|        case PB_LTYPE_BOOL:
  ------------------
  |  |  268|  3.31M|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (430:9): [True: 3.31M, False: 39.8M]
  ------------------
  431|  3.31M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (431:17): [True: 2.98M, False: 333k]
  |  Branch (431:46): [True: 13, False: 2.98M]
  ------------------
  432|     13|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     13|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     13|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  433|       |
  434|  3.31M|            return pb_dec_bool(stream, field);
  435|       |
  436|  4.46M|        case PB_LTYPE_VARINT:
  ------------------
  |  |  269|  4.46M|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (436:9): [True: 4.46M, False: 38.6M]
  ------------------
  437|  5.29M|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  270|  5.29M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (437:9): [True: 830k, False: 42.3M]
  ------------------
  438|  9.28M|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  271|  9.28M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (438:9): [True: 3.98M, False: 39.1M]
  ------------------
  439|  9.28M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (439:17): [True: 8.34M, False: 942k]
  |  Branch (439:46): [True: 68, False: 8.34M]
  ------------------
  440|     68|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     68|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     68|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 68]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  441|       |
  442|  9.28M|            return pb_dec_varint(stream, field);
  443|       |
  444|   111k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  272|   111k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (444:9): [True: 111k, False: 43.0M]
  ------------------
  445|   111k|            if (wire_type != PB_WT_32BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (445:17): [True: 41.3k, False: 69.8k]
  |  Branch (445:45): [True: 15, False: 41.3k]
  ------------------
  446|     15|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     15|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     15|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  447|       |
  448|   111k|            return pb_decode_fixed32(stream, field->pData);
  449|       |
  450|  59.0k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  273|  59.0k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (450:9): [True: 59.0k, False: 43.0M]
  ------------------
  451|  59.0k|            if (wire_type != PB_WT_64BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (451:17): [True: 14.0k, False: 45.0k]
  |  Branch (451:45): [True: 24, False: 14.0k]
  ------------------
  452|     24|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     24|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     24|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 24]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|  59.0k|            return pb_decode_fixed64(stream, field->pData);
  465|      0|#endif
  466|       |
  467|   518k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  280|   518k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (467:9): [True: 518k, False: 42.6M]
  ------------------
  468|   518k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (468:17): [True: 16, False: 518k]
  ------------------
  469|     16|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     16|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     16|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  470|       |
  471|   518k|            return pb_dec_bytes(stream, field);
  472|       |
  473|   143k|        case PB_LTYPE_STRING:
  ------------------
  |  |  284|   143k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (473:9): [True: 143k, False: 43.0M]
  ------------------
  474|   143k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (474:17): [True: 15, False: 143k]
  ------------------
  475|     15|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     15|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     15|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  476|       |
  477|   143k|            return pb_dec_string(stream, field);
  478|       |
  479|   173k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  288|   173k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (479:9): [True: 173k, False: 42.9M]
  ------------------
  480|   173k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  293|   173k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (480:9): [True: 0, False: 43.1M]
  ------------------
  481|   173k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (481:17): [True: 23, False: 173k]
  ------------------
  482|     23|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     23|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     23|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 23]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  483|       |
  484|   173k|            return pb_dec_submessage(stream, field);
  485|       |
  486|  29.5M|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  303|  29.5M|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (486:9): [True: 29.5M, False: 13.6M]
  ------------------
  487|  29.5M|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (487:17): [True: 5, False: 29.5M]
  ------------------
  488|      5|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|      5|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      5|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  489|       |
  490|  29.5M|            return pb_dec_fixed_length_bytes(stream, field);
  491|       |
  492|      0|        default:
  ------------------
  |  Branch (492:9): [True: 0, False: 43.1M]
  ------------------
  493|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  494|  43.1M|    }
  495|  43.1M|}
pb_decode.c:pb_dec_bool:
 1477|  3.31M|{
 1478|  3.31M|    return pb_decode_bool(stream, (bool*)field->pData);
 1479|  3.31M|}
pb_decode.c:pb_dec_varint:
 1482|  9.28M|{
 1483|  9.28M|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  328|  9.28M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  9.28M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  270|  9.28M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (1483:9): [True: 830k, False: 8.45M]
  ------------------
 1484|   830k|    {
 1485|   830k|        pb_uint64_t value, clamped;
  ------------------
  |  |   57|   830k|#define pb_uint64_t uint64_t
  ------------------
 1486|   830k|        if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1486:13): [True: 37, False: 830k]
  ------------------
 1487|     37|            return false;
 1488|       |
 1489|       |        /* Cast to the proper field size, while checking for overflows */
 1490|   830k|        if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (1490:13): [True: 500k, False: 329k]
  ------------------
 1491|   500k|            clamped = *(pb_uint64_t*)field->pData = value;
 1492|   329k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (1492:18): [True: 306k, False: 23.4k]
  ------------------
 1493|   306k|            clamped = *(uint32_t*)field->pData = (uint32_t)value;
 1494|  23.4k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (1494:18): [True: 11.5k, False: 11.8k]
  ------------------
 1495|  11.5k|            clamped = *(uint_least16_t*)field->pData = (uint_least16_t)value;
 1496|  11.8k|        else if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (1496:18): [True: 11.8k, False: 0]
  ------------------
 1497|  11.8k|            clamped = *(uint_least8_t*)field->pData = (uint_least8_t)value;
 1498|      0|        else
 1499|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1500|       |
 1501|   830k|        if (clamped != value)
  ------------------
  |  Branch (1501:13): [True: 115, False: 830k]
  ------------------
 1502|    115|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  930|    115|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|    115|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 115]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1503|       |
 1504|   830k|        return true;
 1505|   830k|    }
 1506|  8.45M|    else
 1507|  8.45M|    {
 1508|  8.45M|        pb_uint64_t value;
  ------------------
  |  |   57|  8.45M|#define pb_uint64_t uint64_t
  ------------------
 1509|  8.45M|        pb_int64_t svalue;
  ------------------
  |  |   56|  8.45M|#define pb_int64_t int64_t
  ------------------
 1510|  8.45M|        pb_int64_t clamped;
  ------------------
  |  |   56|  8.45M|#define pb_int64_t int64_t
  ------------------
 1511|       |
 1512|  8.45M|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  328|  8.45M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  8.45M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  271|  8.45M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (1512:13): [True: 3.98M, False: 4.46M]
  ------------------
 1513|  3.98M|        {
 1514|  3.98M|            if (!pb_decode_svarint(stream, &svalue))
  ------------------
  |  Branch (1514:17): [True: 36, False: 3.98M]
  ------------------
 1515|     36|                return false;
 1516|  3.98M|        }
 1517|  4.46M|        else
 1518|  4.46M|        {
 1519|  4.46M|            if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1519:17): [True: 47, False: 4.46M]
  ------------------
 1520|     47|                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.46M|            if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1528:17): [True: 632k, False: 3.83M]
  ------------------
 1529|   632k|                svalue = (pb_int64_t)value;
 1530|  3.83M|            else
 1531|  3.83M|                svalue = (int32_t)value;
 1532|  4.46M|        }
 1533|       |
 1534|       |        /* Cast to the proper field size, while checking for overflows */
 1535|  8.45M|        if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1535:13): [True: 4.54M, False: 3.90M]
  ------------------
 1536|  4.54M|            clamped = *(pb_int64_t*)field->pData = svalue;
 1537|  3.90M|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (1537:18): [True: 3.86M, False: 46.4k]
  ------------------
 1538|  3.86M|            clamped = *(int32_t*)field->pData = (int32_t)svalue;
 1539|  46.4k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (1539:18): [True: 23.1k, False: 23.3k]
  ------------------
 1540|  23.1k|            clamped = *(int_least16_t*)field->pData = (int_least16_t)svalue;
 1541|  23.3k|        else if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (1541:18): [True: 23.3k, False: 0]
  ------------------
 1542|  23.3k|            clamped = *(int_least8_t*)field->pData = (int_least8_t)svalue;
 1543|      0|        else
 1544|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1545|       |
 1546|  8.45M|        if (clamped != svalue)
  ------------------
  |  Branch (1546:13): [True: 89, False: 8.45M]
  ------------------
 1547|     89|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  930|     89|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     89|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 89]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1548|       |
 1549|  8.45M|        return true;
 1550|  8.45M|    }
 1551|  9.28M|}
pb_decode.c:pb_dec_bytes:
 1554|   518k|{
 1555|   518k|    uint32_t size;
 1556|   518k|    size_t alloc_size;
 1557|   518k|    pb_bytes_array_t *dest;
 1558|       |    
 1559|   518k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1559:9): [True: 22, False: 518k]
  ------------------
 1560|     22|        return false;
 1561|       |    
 1562|   518k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  342|   518k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1562:9): [True: 31, False: 518k]
  ------------------
 1563|     31|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  930|     31|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     31|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 31]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1564|       |    
 1565|   518k|    alloc_size = PB_BYTES_ARRAY_T_ALLOCSIZE(size);
  ------------------
  |  |  411|   518k|    (((size_t)(n) + offsetof(pb_bytes_array_t, bytes)) < sizeof(pb_bytes_array_t) \
  |  |  ------------------
  |  |  |  Branch (411:6): [True: 509k, False: 9.07k]
  |  |  ------------------
  |  |  412|   518k|        ? sizeof(pb_bytes_array_t) \
  |  |  413|   518k|        : ((size_t)(n) + offsetof(pb_bytes_array_t, bytes)))
  ------------------
 1566|   518k|    if (size > alloc_size)
  ------------------
  |  Branch (1566:9): [True: 0, False: 518k]
  ------------------
 1567|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1568|       |    
 1569|   518k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   518k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   518k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   518k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1569:9): [True: 518k, False: 0]
  ------------------
 1570|   518k|    {
 1571|       |#ifndef PB_ENABLE_MALLOC
 1572|       |        PB_RETURN_ERROR(stream, "no malloc support");
 1573|       |#else
 1574|   518k|        if (stream->bytes_left < size)
  ------------------
  |  Branch (1574:13): [True: 50, False: 518k]
  ------------------
 1575|     50|            PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  930|     50|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     50|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 50]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1576|       |
 1577|   518k|        if (!allocate_field(stream, field->pData, alloc_size, 1))
  ------------------
  |  Branch (1577:13): [True: 0, False: 518k]
  ------------------
 1578|      0|            return false;
 1579|   518k|        dest = *(pb_bytes_array_t**)field->pData;
 1580|   518k|#endif
 1581|   518k|    }
 1582|      0|    else
 1583|      0|    {
 1584|      0|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1584:13): [True: 0, False: 0]
  ------------------
 1585|      0|            PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1586|      0|        dest = (pb_bytes_array_t*)field->pData;
 1587|      0|    }
 1588|       |
 1589|   518k|    dest->size = (pb_size_t)size;
 1590|   518k|    return pb_read(stream, dest->bytes, (size_t)size);
 1591|   518k|}
pb_decode.c:allocate_field:
  593|  33.2M|{    
  594|  33.2M|    void *ptr = *(void**)pData;
  595|       |    
  596|  33.2M|    if (data_size == 0 || array_size == 0)
  ------------------
  |  Branch (596:9): [True: 0, False: 33.2M]
  |  Branch (596:27): [True: 0, False: 33.2M]
  ------------------
  597|      0|        PB_RETURN_ERROR(stream, "invalid size");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  598|       |    
  599|       |#ifdef __AVR__
  600|       |    /* Workaround for AVR libc bug 53284: http://savannah.nongnu.org/bugs/?53284
  601|       |     * Realloc to size of 1 byte can cause corruption of the malloc structures.
  602|       |     */
  603|       |    if (data_size == 1 && array_size == 1)
  604|       |    {
  605|       |        data_size = 2;
  606|       |    }
  607|       |#endif
  608|       |
  609|       |    /* Check for multiplication overflows.
  610|       |     * This code avoids the costly division if the sizes are small enough.
  611|       |     * Multiplication is safe as long as only half of bits are set
  612|       |     * in either multiplicand.
  613|       |     */
  614|  33.2M|    {
  615|  33.2M|        const size_t check_limit = (size_t)1 << (sizeof(size_t) * 4);
  616|  33.2M|        if (data_size >= check_limit || array_size >= check_limit)
  ------------------
  |  Branch (616:13): [True: 0, False: 33.2M]
  |  Branch (616:41): [True: 0, False: 33.2M]
  ------------------
  617|      0|        {
  618|      0|            const size_t size_max = (size_t)-1;
  619|      0|            if (size_max / array_size < data_size)
  ------------------
  |  Branch (619:17): [True: 0, False: 0]
  ------------------
  620|      0|            {
  621|      0|                PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  622|      0|            }
  623|      0|        }
  624|  33.2M|    }
  625|       |    
  626|       |    /* Allocate new or expand previous allocation */
  627|       |    /* Note: on failure the old pointer will remain in the structure,
  628|       |     * the message must be freed by caller also on error return. */
  629|  33.2M|    ptr = pb_realloc(ptr, array_size * data_size);
  ------------------
  |  |    3|  33.2M|#define pb_realloc(ptr,size) realloc_with_check(ptr,size)
  ------------------
  630|  33.2M|    if (ptr == NULL)
  ------------------
  |  Branch (630:9): [True: 0, False: 33.2M]
  ------------------
  631|      0|        PB_RETURN_ERROR(stream, "realloc failed");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  632|       |    
  633|  33.2M|    *(void**)pData = ptr;
  634|       |    return true;
  635|  33.2M|}
pb_decode.c:pb_dec_string:
 1594|   143k|{
 1595|   143k|    uint32_t size;
 1596|   143k|    size_t alloc_size;
 1597|   143k|    pb_byte_t *dest = (pb_byte_t*)field->pData;
 1598|       |
 1599|   143k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1599:9): [True: 27, False: 143k]
  ------------------
 1600|     27|        return false;
 1601|       |
 1602|   143k|    if (size == (uint32_t)-1)
  ------------------
  |  Branch (1602:9): [True: 3, False: 143k]
  ------------------
 1603|      3|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  930|      3|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      3|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1604|       |
 1605|       |    /* Space for null terminator */
 1606|   143k|    alloc_size = (size_t)(size + 1);
 1607|       |
 1608|   143k|    if (alloc_size < size)
  ------------------
  |  Branch (1608:9): [True: 0, False: 143k]
  ------------------
 1609|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1610|       |
 1611|   143k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   143k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   143k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   143k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1611:9): [True: 142k, False: 1.19k]
  ------------------
 1612|   142k|    {
 1613|       |#ifndef PB_ENABLE_MALLOC
 1614|       |        PB_RETURN_ERROR(stream, "no malloc support");
 1615|       |#else
 1616|   142k|        if (stream->bytes_left < size)
  ------------------
  |  Branch (1616:13): [True: 61, False: 142k]
  ------------------
 1617|     61|            PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  930|     61|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     61|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 61]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1618|       |
 1619|   142k|        if (!allocate_field(stream, field->pData, alloc_size, 1))
  ------------------
  |  Branch (1619:13): [True: 0, False: 142k]
  ------------------
 1620|      0|            return false;
 1621|   142k|        dest = *(pb_byte_t**)field->pData;
 1622|   142k|#endif
 1623|   142k|    }
 1624|  1.19k|    else
 1625|  1.19k|    {
 1626|  1.19k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1626:13): [True: 47, False: 1.14k]
  ------------------
 1627|     47|            PB_RETURN_ERROR(stream, "string overflow");
  ------------------
  |  |  930|     47|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     47|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1628|  1.19k|    }
 1629|       |    
 1630|   143k|    dest[size] = 0;
 1631|       |
 1632|   143k|    if (!pb_read(stream, dest, (size_t)size))
  ------------------
  |  Branch (1632:9): [True: 6, False: 143k]
  ------------------
 1633|      6|        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|   143k|    return true;
 1641|   143k|}
pb_decode.c:pb_dec_submessage:
 1644|   173k|{
 1645|   173k|    bool status = true;
 1646|   173k|    bool submsg_consumed = false;
 1647|   173k|    pb_istream_t substream;
 1648|       |
 1649|   173k|    if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1649:9): [True: 133, False: 173k]
  ------------------
 1650|    133|        return false;
 1651|       |    
 1652|   173k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (1652:9): [True: 0, False: 173k]
  ------------------
 1653|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926: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|   173k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  328|   173k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   173k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  293|   347k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (1658:9): [True: 0, False: 173k]
  |  Branch (1658:58): [True: 0, False: 0]
  ------------------
 1659|      0|    {
 1660|       |        /* Message callback is stored right before pSize. */
 1661|      0|        pb_callback_t *callback = (pb_callback_t*)field->pSize - 1;
 1662|      0|        if (callback->funcs.decode)
  ------------------
  |  Branch (1662:13): [True: 0, False: 0]
  ------------------
 1663|      0|        {
 1664|      0|            status = callback->funcs.decode(&substream, field, &callback->arg);
 1665|       |
 1666|      0|            if (substream.bytes_left == 0)
  ------------------
  |  Branch (1666:17): [True: 0, False: 0]
  ------------------
 1667|      0|            {
 1668|      0|                submsg_consumed = true;
 1669|      0|            }
 1670|      0|        }
 1671|      0|    }
 1672|       |
 1673|       |    /* Now decode the submessage contents */
 1674|   173k|    if (status && !submsg_consumed)
  ------------------
  |  Branch (1674:9): [True: 173k, False: 0]
  |  Branch (1674:19): [True: 173k, False: 0]
  ------------------
 1675|   173k|    {
 1676|   173k|        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|   173k|        if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  326|   173k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   173k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  321|   347k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1680:13): [True: 11.2k, False: 162k]
  ------------------
 1681|  11.2k|            PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  327|  11.2k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  11.2k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  314|  11.2k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1681:13): [True: 11.2k, False: 0]
  ------------------
 1682|  11.2k|        {
 1683|  11.2k|            flags = PB_DECODE_NOINIT;
  ------------------
  |  |  122|  11.2k|#define PB_DECODE_NOINIT          0x01U
  ------------------
 1684|  11.2k|        }
 1685|       |
 1686|   173k|        status = pb_decode_inner(&substream, field->submsg_desc, field->pData, flags);
 1687|   173k|    }
 1688|       |    
 1689|   173k|    if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1689:9): [True: 0, False: 173k]
  ------------------
 1690|      0|        return false;
 1691|       |
 1692|   173k|    return status;
 1693|   173k|}
pb_decode.c:pb_dec_fixed_length_bytes:
 1696|  29.5M|{
 1697|  29.5M|    uint32_t size;
 1698|       |
 1699|  29.5M|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1699:9): [True: 3, False: 29.5M]
  ------------------
 1700|      3|        return false;
 1701|       |
 1702|  29.5M|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  342|  29.5M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1702:9): [True: 32, False: 29.5M]
  ------------------
 1703|     32|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  930|     32|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     32|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1704|       |
 1705|  29.5M|    if (size == 0)
  ------------------
  |  Branch (1705:9): [True: 28.4M, False: 1.11M]
  ------------------
 1706|  28.4M|    {
 1707|       |        /* As a special case, treat empty bytes string as all zeros for fixed_length_bytes. */
 1708|  28.4M|        memset(field->pData, 0, (size_t)field->data_size);
 1709|  28.4M|        return true;
 1710|  28.4M|    }
 1711|       |
 1712|  1.11M|    if (size != field->data_size)
  ------------------
  |  Branch (1712:9): [True: 54, False: 1.11M]
  ------------------
 1713|     54|        PB_RETURN_ERROR(stream, "incorrect fixed length bytes size");
  ------------------
  |  |  930|     54|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     54|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 54]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1714|       |
 1715|  1.11M|    return pb_read(stream, (pb_byte_t*)field->pData, (size_t)field->data_size);
 1716|  1.11M|}
pb_decode.c:decode_pointer_field:
  655|  31.8M|{
  656|       |#ifndef PB_ENABLE_MALLOC
  657|       |    PB_UNUSED(wire_type);
  658|       |    PB_UNUSED(field);
  659|       |    PB_RETURN_ERROR(stream, "no malloc support");
  660|       |#else
  661|  31.8M|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  327|  31.8M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  31.8M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  662|  31.8M|    {
  663|  1.53M|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  311|  1.53M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (663:9): [True: 1.53M, False: 30.2M]
  ------------------
  664|  1.55M|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  312|  1.55M|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (664:9): [True: 17.6k, False: 31.8M]
  ------------------
  665|  1.56M|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  316|  1.56M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (665:9): [True: 11.7k, False: 31.8M]
  ------------------
  666|  1.56M|            if (PB_LTYPE_IS_SUBMSG(field->type) && *(void**)field->pField != NULL)
  ------------------
  |  |  329|  3.13M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  1.56M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  1.56M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  3.13M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 75.1k, False: 1.49M]
  |  |  ------------------
  |  |  330|  3.13M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  1.49M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  1.49M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  1.49M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 1.49M]
  |  |  ------------------
  ------------------
  |  Branch (666:52): [True: 37.8k, False: 37.3k]
  ------------------
  667|  37.8k|            {
  668|       |                /* Duplicate field, have to release the old allocation first. */
  669|       |                /* FIXME: Does this work correctly for oneofs? */
  670|  37.8k|                pb_release_single_field(field);
  671|  37.8k|            }
  672|       |        
  673|  1.56M|            if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  1.56M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  1.56M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  1.56M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (673:17): [True: 11.7k, False: 1.55M]
  ------------------
  674|  11.7k|            {
  675|  11.7k|                *(pb_size_t*)field->pSize = field->tag;
  676|  11.7k|            }
  677|       |
  678|  1.56M|            if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  328|  1.56M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.56M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  284|  3.13M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (678:17): [True: 87.1k, False: 1.48M]
  ------------------
  679|  1.48M|                PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  328|  1.48M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.48M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  280|  1.48M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (679:17): [True: 16.1k, False: 1.46M]
  ------------------
  680|   103k|            {
  681|       |                /* pb_dec_string and pb_dec_bytes handle allocation themselves */
  682|   103k|                field->pData = field->pField;
  683|   103k|                return decode_basic_field(stream, wire_type, field);
  684|   103k|            }
  685|  1.46M|            else
  686|  1.46M|            {
  687|  1.46M|                if (!allocate_field(stream, field->pField, field->data_size, 1))
  ------------------
  |  Branch (687:21): [True: 0, False: 1.46M]
  ------------------
  688|      0|                    return false;
  689|       |                
  690|  1.46M|                field->pData = *(void**)field->pField;
  691|  1.46M|                initialize_pointer_field(field->pData, field);
  692|  1.46M|                return decode_basic_field(stream, wire_type, field);
  693|  1.46M|            }
  694|       |    
  695|  30.2M|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  314|  30.2M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (695:9): [True: 30.2M, False: 1.56M]
  ------------------
  696|  30.2M|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (696:17): [True: 30.2M, False: 8.86k]
  ------------------
  697|  30.2M|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  328|  30.2M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  30.2M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  276|  30.2M|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (697:20): [True: 73.5k, False: 30.1M]
  ------------------
  698|  73.5k|            {
  699|       |                /* Packed array, multiple items come in at once. */
  700|  73.5k|                bool status = true;
  701|  73.5k|                pb_size_t *size = (pb_size_t*)field->pSize;
  702|  73.5k|                size_t allocated_size = *size;
  703|  73.5k|                pb_istream_t substream;
  704|       |                
  705|  73.5k|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (705:21): [True: 51, False: 73.5k]
  ------------------
  706|     51|                    return false;
  707|       |                
  708|  11.4M|                while (substream.bytes_left)
  ------------------
  |  Branch (708:24): [True: 11.3M, False: 73.4k]
  ------------------
  709|  11.3M|                {
  710|  11.3M|                    if (*size == PB_SIZE_MAX)
  ------------------
  |  |  342|  11.3M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (710:25): [True: 7, False: 11.3M]
  ------------------
  711|      7|                    {
  712|      7|#ifndef PB_NO_ERRMSG
  713|      7|                        stream->errmsg = "too many array entries";
  714|      7|#endif
  715|      7|                        status = false;
  716|      7|                        break;
  717|      7|                    }
  718|       |
  719|  11.3M|                    if ((size_t)*size + 1 > allocated_size)
  ------------------
  |  Branch (719:25): [True: 923k, False: 10.4M]
  ------------------
  720|   923k|                    {
  721|       |                        /* Allocate more storage. This tries to guess the
  722|       |                         * number of remaining entries. Round the division
  723|       |                         * upwards. */
  724|   923k|                        size_t remain = (substream.bytes_left - 1) / field->data_size + 1;
  725|   923k|                        if (remain < PB_SIZE_MAX - allocated_size)
  ------------------
  |  |  342|   923k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (725:29): [True: 221k, False: 701k]
  ------------------
  726|   221k|                            allocated_size += remain;
  727|   701k|                        else
  728|   701k|                            allocated_size += 1;
  729|       |                        
  730|   923k|                        if (!allocate_field(&substream, field->pField, field->data_size, allocated_size))
  ------------------
  |  Branch (730:29): [True: 0, False: 923k]
  ------------------
  731|      0|                        {
  732|      0|                            status = false;
  733|      0|                            break;
  734|      0|                        }
  735|   923k|                    }
  736|       |
  737|       |                    /* Decode the array entry */
  738|  11.3M|                    field->pData = *(char**)field->pField + field->data_size * (*size);
  739|  11.3M|                    if (field->pData == NULL)
  ------------------
  |  Branch (739:25): [True: 0, False: 11.3M]
  ------------------
  740|      0|                    {
  741|       |                        /* Shouldn't happen, but satisfies static analyzers */
  742|      0|                        status = false;
  743|      0|                        break;
  744|      0|                    }
  745|  11.3M|                    initialize_pointer_field(field->pData, field);
  746|  11.3M|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (746:25): [True: 91, False: 11.3M]
  ------------------
  747|     91|                    {
  748|     91|                        status = false;
  749|     91|                        break;
  750|     91|                    }
  751|       |                    
  752|  11.3M|                    (*size)++;
  753|  11.3M|                }
  754|  73.5k|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (754:21): [True: 0, False: 73.5k]
  ------------------
  755|      0|                    return false;
  756|       |                
  757|  73.5k|                return status;
  758|  73.5k|            }
  759|  30.1M|            else
  760|  30.1M|            {
  761|       |                /* Normal repeated field, i.e. only one item at a time. */
  762|  30.1M|                pb_size_t *size = (pb_size_t*)field->pSize;
  763|       |
  764|  30.1M|                if (*size == PB_SIZE_MAX)
  ------------------
  |  |  342|  30.1M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (764:21): [True: 1, False: 30.1M]
  ------------------
  765|      1|                    PB_RETURN_ERROR(stream, "too many array entries");
  ------------------
  |  |  930|      1|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      1|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  766|       |                
  767|  30.1M|                if (!allocate_field(stream, field->pField, field->data_size, (size_t)(*size + 1)))
  ------------------
  |  Branch (767:21): [True: 0, False: 30.1M]
  ------------------
  768|      0|                    return false;
  769|       |            
  770|  30.1M|                field->pData = *(char**)field->pField + field->data_size * (*size);
  771|  30.1M|                (*size)++;
  772|  30.1M|                initialize_pointer_field(field->pData, field);
  773|  30.1M|                return decode_basic_field(stream, wire_type, field);
  774|  30.1M|            }
  775|       |
  776|      0|        default:
  ------------------
  |  Branch (776:9): [True: 0, False: 31.8M]
  ------------------
  777|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  778|  31.8M|    }
  779|  31.8M|#endif
  780|  31.8M|}
pb_decode.c:initialize_pointer_field:
  639|  43.0M|{
  640|  43.0M|    if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  328|  43.0M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  43.0M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  284|  86.0M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (640:9): [True: 55.1k, False: 42.9M]
  ------------------
  641|  42.9M|        PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  328|  42.9M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  42.9M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  280|  42.9M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (641:9): [True: 502k, False: 42.4M]
  ------------------
  642|   557k|    {
  643|   557k|        *(void**)pItem = NULL;
  644|   557k|    }
  645|  42.4M|    else if (PB_LTYPE_IS_SUBMSG(field->type))
  ------------------
  |  |  329|  42.4M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  42.4M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  42.4M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  84.9M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 162k, False: 42.3M]
  |  |  ------------------
  |  |  330|  42.4M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  42.3M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  42.3M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  42.3M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 42.3M]
  |  |  ------------------
  ------------------
  646|   162k|    {
  647|       |        /* We memset to zero so that any callbacks are set to NULL.
  648|       |         * Default values will be set by pb_dec_submessage(). */
  649|   162k|        memset(pItem, 0, field->data_size);
  650|   162k|    }
  651|  43.0M|}
pb_decode.c:decode_callback_field:
  783|  6.60k|{
  784|       |    /* Clear any data that may have been decoded for another oneof field
  785|       |     * that has come before this callback field.
  786|       |     */
  787|  6.60k|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  6.60k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  6.60k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  6.60k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (787:9): [True: 6.60k, False: 0]
  ------------------
  788|  6.60k|    {
  789|  6.60k|        if (*(pb_size_t*)field->pSize != 0 && *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (789:13): [True: 6.00k, False: 600]
  |  Branch (789:47): [True: 3.19k, False: 2.81k]
  ------------------
  790|  3.19k|        {
  791|  3.19k|            memset(field->pData, 0, (size_t)field->data_size);
  792|  3.19k|        }
  793|  6.60k|        *(pb_size_t*)field->pSize = field->tag;
  794|  6.60k|    }
  795|       |
  796|  6.60k|    if (!field->descriptor->field_callback)
  ------------------
  |  Branch (796:9): [True: 0, False: 6.60k]
  ------------------
  797|      0|        return pb_skip_field(stream, wire_type);
  798|       |
  799|  6.60k|    if (wire_type == PB_WT_STRING)
  ------------------
  |  Branch (799:9): [True: 1.65k, False: 4.95k]
  ------------------
  800|  1.65k|    {
  801|  1.65k|        pb_istream_t substream;
  802|  1.65k|        size_t prev_bytes_left;
  803|       |        
  804|  1.65k|        if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (804:13): [True: 46, False: 1.60k]
  ------------------
  805|     46|            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|  1.60k|        if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  328|  1.60k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.60k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  293|  3.21k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (809:13): [True: 0, False: 1.60k]
  |  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");
  ------------------
  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  ------------------
  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  Branch (926:92): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  818|      0|                    return false;
  819|      0|                }
  820|      0|            }
  821|      0|        }
  822|       |        
  823|  1.60k|        do
  824|  1.60k|        {
  825|  1.60k|            prev_bytes_left = substream.bytes_left;
  826|  1.60k|            if (!field->descriptor->field_callback(&substream, NULL, field))
  ------------------
  |  Branch (826:17): [True: 0, False: 1.60k]
  ------------------
  827|      0|            {
  828|      0|                PB_SET_ERROR(stream, substream.errmsg ? substream.errmsg : "callback failed");
  ------------------
  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  ------------------
  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  Branch (926:92): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  829|      0|                return false;
  830|      0|            }
  831|  1.60k|        } while (substream.bytes_left > 0 && substream.bytes_left < prev_bytes_left);
  ------------------
  |  Branch (831:18): [True: 635, False: 970]
  |  Branch (831:46): [True: 0, False: 635]
  ------------------
  832|       |        
  833|  1.60k|        if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (833:13): [True: 0, False: 1.60k]
  ------------------
  834|      0|            return false;
  835|       |
  836|  1.60k|        return true;
  837|  1.60k|    }
  838|  4.95k|    else
  839|  4.95k|    {
  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|  4.95k|        pb_istream_t substream;
  845|  4.95k|        pb_byte_t buffer[10];
  846|  4.95k|        size_t size = sizeof(buffer);
  847|       |        
  848|  4.95k|        if (!read_raw_value(stream, wire_type, buffer, &size))
  ------------------
  |  Branch (848:13): [True: 50, False: 4.90k]
  ------------------
  849|     50|            return false;
  850|  4.90k|        substream = pb_istream_from_buffer(buffer, size);
  851|       |        
  852|       |        return field->descriptor->field_callback(&substream, NULL, field);
  853|  4.95k|    }
  854|  6.60k|}
pb_decode.c:read_raw_value:
  342|  4.95k|{
  343|  4.95k|    size_t max_size = *size;
  344|  4.95k|    switch (wire_type)
  345|  4.95k|    {
  346|  3.10k|        case PB_WT_VARINT:
  ------------------
  |  Branch (346:9): [True: 3.10k, False: 1.85k]
  ------------------
  347|  3.10k|            *size = 0;
  348|  3.10k|            do
  349|  4.45k|            {
  350|  4.45k|                (*size)++;
  351|  4.45k|                if (*size > max_size)
  ------------------
  |  Branch (351:21): [True: 1, False: 4.45k]
  ------------------
  352|      1|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  930|      1|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      1|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  353|       |
  354|  4.45k|                if (!pb_read(stream, buf, 1))
  ------------------
  |  Branch (354:21): [True: 33, False: 4.42k]
  ------------------
  355|     33|                    return false;
  356|  4.45k|            } while (*buf++ & 0x80);
  ------------------
  |  Branch (356:22): [True: 1.35k, False: 3.07k]
  ------------------
  357|  3.07k|            return true;
  358|       |            
  359|    732|        case PB_WT_64BIT:
  ------------------
  |  Branch (359:9): [True: 732, False: 4.22k]
  ------------------
  360|    732|            *size = 8;
  361|    732|            return pb_read(stream, buf, 8);
  362|       |        
  363|  1.11k|        case PB_WT_32BIT:
  ------------------
  |  Branch (363:9): [True: 1.11k, False: 3.84k]
  ------------------
  364|  1.11k|            *size = 4;
  365|  1.11k|            return pb_read(stream, buf, 4);
  366|       |        
  367|      0|        case PB_WT_STRING:
  ------------------
  |  Branch (367:9): [True: 0, False: 4.95k]
  ------------------
  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: 4.95k]
  ------------------
  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");
  ------------------
  |  |  930|      4|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      4|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (379:9): [True: 4, False: 4.95k]
  ------------------
  380|  4.95k|    }
  381|  4.95k|}
pb_decode.c:pb_release_single_field:
 1286|  1.14M|{
 1287|  1.14M|    pb_type_t type;
 1288|  1.14M|    type = field->type;
 1289|       |
 1290|  1.14M|    if (PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  1.14M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  1.14M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  1.14M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (1290:9): [True: 85.7k, False: 1.05M]
  ------------------
 1291|  85.7k|    {
 1292|  85.7k|        if (*(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (1292:13): [True: 62.0k, False: 23.7k]
  ------------------
 1293|  62.0k|            return; /* This is not the current field in the union */
 1294|  85.7k|    }
 1295|       |
 1296|       |    /* Release anything contained inside an extension or submsg.
 1297|       |     * This has to be done even if the submsg itself is statically
 1298|       |     * allocated. */
 1299|  1.08M|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  1.08M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.08M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  1.08M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1299:9): [True: 9.12k, False: 1.07M]
  ------------------
 1300|  9.12k|    {
 1301|       |        /* Release fields from all extensions in the linked list */
 1302|  9.12k|        pb_extension_t *ext = *(pb_extension_t**)field->pData;
 1303|  16.5k|        while (ext != NULL)
  ------------------
  |  Branch (1303:16): [True: 7.42k, False: 9.12k]
  ------------------
 1304|  7.42k|        {
 1305|  7.42k|            pb_field_iter_t ext_iter;
 1306|  7.42k|            if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (1306:17): [True: 7.42k, False: 0]
  ------------------
 1307|  7.42k|            {
 1308|  7.42k|                pb_release_single_field(&ext_iter);
 1309|  7.42k|            }
 1310|  7.42k|            ext = ext->next;
 1311|  7.42k|        }
 1312|  9.12k|    }
 1313|  1.07M|    else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  329|  2.14M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  1.07M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  1.07M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  2.14M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 138k, False: 935k]
  |  |  ------------------
  |  |  330|  2.14M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|   935k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|   935k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|   935k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 935k]
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  326|   138k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   138k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|   138k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (1313:42): [True: 136k, False: 2.32k]
  ------------------
 1314|   136k|    {
 1315|       |        /* Release fields in submessage or submsg array */
 1316|   136k|        pb_size_t count = 1;
 1317|       |        
 1318|   136k|        if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   136k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   136k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   136k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1318:13): [True: 123k, False: 12.6k]
  ------------------
 1319|   123k|        {
 1320|   123k|            field->pData = *(void**)field->pField;
 1321|   123k|        }
 1322|  12.6k|        else
 1323|  12.6k|        {
 1324|  12.6k|            field->pData = field->pField;
 1325|  12.6k|        }
 1326|       |        
 1327|   136k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|   136k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   136k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|   136k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1327:13): [True: 18.2k, False: 117k]
  ------------------
 1328|  18.2k|        {
 1329|  18.2k|            count = *(pb_size_t*)field->pSize;
 1330|       |
 1331|  18.2k|            if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > field->array_size)
  ------------------
  |  |  326|  18.2k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  18.2k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > field->array_size)
  ------------------
  |  |  321|  36.4k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1331:17): [True: 0, False: 18.2k]
  |  Branch (1331:54): [True: 0, False: 0]
  ------------------
 1332|      0|            {
 1333|       |                /* Protect against corrupted _count fields */
 1334|      0|                count = field->array_size;
 1335|      0|            }
 1336|  18.2k|        }
 1337|       |        
 1338|   136k|        if (field->pData)
  ------------------
  |  Branch (1338:13): [True: 90.1k, False: 45.9k]
  ------------------
 1339|  90.1k|        {
 1340|   265k|            for (; count > 0; count--)
  ------------------
  |  Branch (1340:20): [True: 174k, False: 90.1k]
  ------------------
 1341|   174k|            {
 1342|   174k|                pb_release(field->submsg_desc, field->pData);
 1343|   174k|                field->pData = (char*)field->pData + field->data_size;
 1344|   174k|            }
 1345|  90.1k|        }
 1346|   136k|    }
 1347|       |    
 1348|  1.08M|    if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  1.08M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  1.08M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  1.08M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1348:9): [True: 1.04M, False: 35.9k]
  ------------------
 1349|  1.04M|    {
 1350|  1.04M|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  327|  1.04M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  1.04M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  314|  2.09M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1350:13): [True: 191k, False: 855k]
  ------------------
 1351|   191k|            (PB_LTYPE(type) == PB_LTYPE_STRING ||
  ------------------
  |  |  328|   191k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   191k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          (PB_LTYPE(type) == PB_LTYPE_STRING ||
  ------------------
  |  |  284|   383k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (1351:14): [True: 9.12k, False: 182k]
  ------------------
 1352|   182k|             PB_LTYPE(type) == PB_LTYPE_BYTES))
  ------------------
  |  |  328|   182k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   182k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                           PB_LTYPE(type) == PB_LTYPE_BYTES))
  ------------------
  |  |  280|   182k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (1352:14): [True: 9.12k, False: 173k]
  ------------------
 1353|  18.2k|        {
 1354|       |            /* Release entries in repeated string or bytes array */
 1355|  18.2k|            void **pItem = *(void***)field->pField;
 1356|  18.2k|            pb_size_t count = *(pb_size_t*)field->pSize;
 1357|   575k|            for (; count > 0; count--)
  ------------------
  |  Branch (1357:20): [True: 557k, False: 18.2k]
  ------------------
 1358|   557k|            {
 1359|   557k|                pb_free(*pItem);
  ------------------
  |  |    4|   557k|#define pb_free(ptr) free_with_check(ptr)
  ------------------
 1360|   557k|                *pItem++ = NULL;
 1361|   557k|            }
 1362|  18.2k|        }
 1363|       |        
 1364|  1.04M|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|  1.04M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  1.04M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|  1.04M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1364:13): [True: 191k, False: 855k]
  ------------------
 1365|   191k|        {
 1366|       |            /* We are going to release the array, so set the size to 0 */
 1367|   191k|            *(pb_size_t*)field->pSize = 0;
 1368|   191k|        }
 1369|       |        
 1370|       |        /* Release main pointer */
 1371|  1.04M|        pb_free(*(void**)field->pField);
  ------------------
  |  |    4|  1.04M|#define pb_free(ptr) free_with_check(ptr)
  ------------------
 1372|       |        *(void**)field->pField = NULL;
 1373|  1.04M|    }
 1374|  1.08M|}

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

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

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

do_roundtrip:
  210|  1.69k|{
  211|  1.69k|    bool status;
  212|  1.69k|    uint32_t checksum2, checksum3;
  213|  1.69k|    size_t msglen2, msglen3;
  214|  1.69k|    uint8_t *buf2 = malloc_with_check(g_bufsize);
  215|  1.69k|    void *msg = malloc_with_check(structsize);
  216|       |
  217|       |    /* For proto2 types, we also test extension fields */
  218|  1.69k|    alltypes_static_TestExtension extmsg = alltypes_static_TestExtension_init_zero;
  ------------------
  |  |  260|  1.69k|#define alltypes_static_TestExtension_init_zero  {false, ""}
  ------------------
  219|  1.69k|    pb_extension_t ext = pb_extension_init_zero;
  ------------------
  |  |  513|  1.69k|#define pb_extension_init_zero {NULL,NULL,NULL,false}
  ------------------
  220|  1.69k|    pb_extension_t **ext_field = NULL;
  221|  1.69k|    ext.type = &alltypes_static_TestExtension_testextension;
  222|  1.69k|    ext.dest = &extmsg;
  223|  1.69k|    ext.next = NULL;
  224|       |
  225|  1.69k|    assert(buf2 && msg);
  ------------------
  |  Branch (225:5): [True: 0, False: 1.69k]
  |  Branch (225:5): [True: 0, False: 0]
  |  Branch (225:5): [True: 1.69k, False: 0]
  |  Branch (225:5): [True: 1.69k, False: 0]
  ------------------
  226|       |
  227|  1.69k|    if (msgtype == alltypes_static_AllTypes_fields)
  ------------------
  |  |  520|  1.69k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  |  Branch (227:9): [True: 0, False: 1.69k]
  ------------------
  228|      0|    {
  229|      0|        ext_field = &((alltypes_static_AllTypes*)msg)->extensions;
  230|      0|    }
  231|  1.69k|    else if (msgtype == alltypes_pointer_AllTypes_fields)
  ------------------
  |  |  494|  1.69k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  |  Branch (231:14): [True: 1.69k, False: 0]
  ------------------
  232|  1.69k|    {
  233|  1.69k|        ext_field = &((alltypes_pointer_AllTypes*)msg)->extensions;
  234|  1.69k|    }
  235|       |    
  236|       |    /* Decode and encode the input data.
  237|       |     * This will bring it into canonical format.
  238|       |     */
  239|  1.69k|    {
  240|  1.69k|        pb_istream_t stream = pb_istream_from_buffer(buffer, msglen);
  241|  1.69k|        memset(msg, 0, structsize);
  242|  1.69k|        if (ext_field) *ext_field = &ext;
  ------------------
  |  Branch (242:13): [True: 1.69k, False: 0]
  ------------------
  243|  1.69k|        status = pb_decode(&stream, msgtype, msg);
  244|  1.69k|        if (!status) fprintf(stderr, "pb_decode: %s\n", PB_GET_ERROR(&stream));
  ------------------
  |  |  927|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (927:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (244:13): [True: 0, False: 1.69k]
  ------------------
  245|  1.69k|        assert(status);
  ------------------
  |  Branch (245:9): [True: 0, False: 1.69k]
  |  Branch (245:9): [True: 1.69k, False: 0]
  ------------------
  246|       |
  247|  1.69k|        validate_message(msg, structsize, msgtype);
  248|  1.69k|    }
  249|       |    
  250|  1.69k|    {
  251|  1.69k|        pb_ostream_t stream = pb_ostream_from_buffer(buf2, g_bufsize);
  252|  1.69k|        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.69k|        if (!status && strcmp(PB_GET_ERROR(&stream), "stream full") != 0)
  ------------------
  |  |  927|    237|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (927:31): [True: 237, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (256:13): [True: 237, False: 1.45k]
  |  Branch (256:24): [True: 0, False: 237]
  ------------------
  257|      0|        {
  258|      0|            fprintf(stderr, "pb_encode: %s\n", PB_GET_ERROR(&stream));
  ------------------
  |  |  927|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (927: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.69k|        msglen2 = stream.bytes_written;
  263|  1.69k|        checksum2 = xor32_checksum(buf2, msglen2);
  264|  1.69k|    }
  265|       |    
  266|  1.69k|    pb_release(msgtype, msg);
  267|       |
  268|       |    /* Then decode from canonical format and re-encode. Result should remain the same. */
  269|  1.69k|    if (status)
  ------------------
  |  Branch (269:9): [True: 1.45k, False: 237]
  ------------------
  270|  1.45k|    {
  271|  1.45k|        pb_istream_t stream = pb_istream_from_buffer(buf2, msglen2);
  272|  1.45k|        memset(msg, 0, structsize);
  273|  1.45k|        if (ext_field) *ext_field = &ext;
  ------------------
  |  Branch (273:13): [True: 1.45k, False: 0]
  ------------------
  274|  1.45k|        status = pb_decode(&stream, msgtype, msg);
  275|  1.45k|        if (!status) fprintf(stderr, "pb_decode: %s\n", PB_GET_ERROR(&stream));
  ------------------
  |  |  927|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (927:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (275:13): [True: 0, False: 1.45k]
  ------------------
  276|  1.45k|        assert(status);
  ------------------
  |  Branch (276:9): [True: 0, False: 1.45k]
  |  Branch (276:9): [True: 1.45k, False: 0]
  ------------------
  277|       |
  278|  1.45k|        validate_message(msg, structsize, msgtype);
  279|  1.45k|    }
  280|       |    
  281|  1.69k|    if (status)
  ------------------
  |  Branch (281:9): [True: 1.45k, False: 237]
  ------------------
  282|  1.45k|    {
  283|  1.45k|        pb_ostream_t stream = pb_ostream_from_buffer(buf2, g_bufsize);
  284|  1.45k|        status = pb_encode(&stream, msgtype, msg);
  285|  1.45k|        if (!status) fprintf(stderr, "pb_encode: %s\n", PB_GET_ERROR(&stream));
  ------------------
  |  |  927|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (927:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (285:13): [True: 0, False: 1.45k]
  ------------------
  286|  1.45k|        assert(status);
  ------------------
  |  Branch (286:9): [True: 0, False: 1.45k]
  |  Branch (286:9): [True: 1.45k, False: 0]
  ------------------
  287|  1.45k|        msglen3 = stream.bytes_written;
  288|  1.45k|        checksum3 = xor32_checksum(buf2, msglen3);
  289|       |
  290|  1.45k|        assert(msglen2 == msglen3);
  ------------------
  |  Branch (290:9): [True: 0, False: 1.45k]
  |  Branch (290:9): [True: 1.45k, False: 0]
  ------------------
  291|  1.45k|        assert(checksum2 == checksum3);
  ------------------
  |  Branch (291:9): [True: 0, False: 1.45k]
  |  Branch (291:9): [True: 1.45k, False: 0]
  ------------------
  292|  1.45k|    }
  293|       |    
  294|  1.69k|    pb_release(msgtype, msg);
  295|  1.69k|    free_with_check(msg);
  296|  1.69k|    free_with_check(buf2);
  297|  1.69k|}
do_roundtrips:
  301|  4.03k|{
  302|  4.03k|    size_t initial_alloc_count = get_alloc_count();
  303|  4.03k|    PB_UNUSED(expect_valid); /* Potentially unused depending on configuration */
  ------------------
  |  |  172|  4.03k|#define PB_UNUSED(x) (void)(x)
  ------------------
  304|       |
  305|       |#ifdef FUZZTEST_PROTO2_STATIC
  306|       |    if (do_decode(data, size, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, 0, expect_valid))
  307|       |    {
  308|       |        do_roundtrip(data, size, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields);
  309|       |        do_stream_decode(data, size, SIZE_MAX, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, 0, true);
  310|       |        do_callback_decode(data, size, true);
  311|       |    }
  312|       |#endif
  313|       |
  314|       |#ifdef FUZZTEST_PROTO3_STATIC
  315|       |    if (do_decode(data, size, sizeof(alltypes_proto3_static_AllTypes), alltypes_proto3_static_AllTypes_fields, 0, expect_valid))
  316|       |    {
  317|       |        do_roundtrip(data, size, sizeof(alltypes_proto3_static_AllTypes), alltypes_proto3_static_AllTypes_fields);
  318|       |        do_stream_decode(data, size, SIZE_MAX, sizeof(alltypes_proto3_static_AllTypes), alltypes_proto3_static_AllTypes_fields, 0, true);
  319|       |    }
  320|       |#endif
  321|       |
  322|  4.03k|#ifdef FUZZTEST_PROTO2_POINTER
  323|  4.03k|    if (do_decode(data, size, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields, 0, expect_valid))
  ------------------
  |  |  494|  4.03k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  |  Branch (323:9): [True: 1.69k, False: 2.34k]
  ------------------
  324|  1.69k|    {
  325|  1.69k|        do_roundtrip(data, size, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields);
  ------------------
  |  |  494|  1.69k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  326|  1.69k|        do_stream_decode(data, size, SIZE_MAX, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields, 0, true);
  ------------------
  |  |  494|  1.69k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  327|  1.69k|    }
  328|  4.03k|#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: 4.03k]
  |  Branch (360:5): [True: 4.03k, False: 0]
  ------------------
  361|  4.03k|}
LLVMFuzzerTestOneInput:
  365|  4.04k|{
  366|  4.04k|    if (size > g_bufsize)
  ------------------
  |  Branch (366:9): [True: 4, False: 4.03k]
  ------------------
  367|      4|        return 0;
  368|       |
  369|  4.03k|    do_roundtrips(data, size, false);
  370|       |
  371|  4.03k|    return 0;
  372|  4.04k|}
fuzztest.c:xor32_checksum:
   53|  3.15k|{
   54|  3.15k|    const uint8_t *buf = (const uint8_t*)data;
   55|  3.15k|    uint32_t checksum = 1234;
   56|  85.1M|    for (; len > 0; len--)
  ------------------
  |  Branch (56:12): [True: 85.1M, False: 3.15k]
  ------------------
   57|  85.1M|    {
   58|  85.1M|        checksum ^= checksum << 13;
   59|  85.1M|        checksum ^= checksum >> 17;
   60|  85.1M|        checksum ^= checksum << 5;
   61|  85.1M|        checksum += *buf++;
   62|  85.1M|    }
   63|  3.15k|    return checksum;
   64|  3.15k|}
fuzztest.c:do_decode:
   67|  4.03k|{
   68|  4.03k|    bool status;
   69|  4.03k|    pb_istream_t stream;
   70|  4.03k|    size_t initial_alloc_count = get_alloc_count();
   71|  4.03k|    uint8_t *buf2 = malloc_with_check(g_bufsize); /* This is just to match the amount of memory allocations in do_roundtrips(). */
   72|  4.03k|    void *msg = malloc_with_check(structsize);
   73|  4.03k|    alltypes_static_TestExtension extmsg = alltypes_static_TestExtension_init_zero;
  ------------------
  |  |  260|  4.03k|#define alltypes_static_TestExtension_init_zero  {false, ""}
  ------------------
   74|  4.03k|    pb_extension_t ext = pb_extension_init_zero;
  ------------------
  |  |  513|  4.03k|#define pb_extension_init_zero {NULL,NULL,NULL,false}
  ------------------
   75|  4.03k|    assert(msg);
  ------------------
  |  Branch (75:5): [True: 0, False: 4.03k]
  |  Branch (75:5): [True: 4.03k, False: 0]
  ------------------
   76|       |
   77|  4.03k|    memset(msg, 0, structsize);
   78|  4.03k|    ext.type = &alltypes_static_TestExtension_testextension;
   79|  4.03k|    ext.dest = &extmsg;
   80|  4.03k|    ext.next = NULL;
   81|       |
   82|  4.03k|    if (msgtype == alltypes_static_AllTypes_fields)
  ------------------
  |  |  520|  4.03k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  |  Branch (82:9): [True: 0, False: 4.03k]
  ------------------
   83|      0|    {
   84|      0|        ((alltypes_static_AllTypes*)msg)->extensions = &ext;
   85|      0|    }
   86|  4.03k|    else if (msgtype == alltypes_pointer_AllTypes_fields)
  ------------------
  |  |  494|  4.03k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  |  Branch (86:14): [True: 4.03k, False: 0]
  ------------------
   87|  4.03k|    {
   88|  4.03k|        ((alltypes_pointer_AllTypes*)msg)->extensions = &ext;
   89|  4.03k|    }
   90|       |
   91|  4.03k|    stream = pb_istream_from_buffer(buffer, msglen);
   92|  4.03k|    status = pb_decode_ex(&stream, msgtype, msg, flags);
   93|       |
   94|  4.03k|    if (status)
  ------------------
  |  Branch (94:9): [True: 1.69k, False: 2.34k]
  ------------------
   95|  1.69k|    {
   96|  1.69k|        validate_message(msg, structsize, msgtype);
   97|  1.69k|    }
   98|       |
   99|  4.03k|    if (assert_success)
  ------------------
  |  Branch (99:9): [True: 0, False: 4.03k]
  ------------------
  100|      0|    {
  101|      0|        if (!status) fprintf(stderr, "pb_decode: %s\n", PB_GET_ERROR(&stream));
  ------------------
  |  |  927|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (927: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|  4.03k|    if (status)
  ------------------
  |  Branch (105:9): [True: 1.69k, False: 2.34k]
  ------------------
  106|  1.69k|    {
  107|       |        /* On error return, pb_release() should be called automatically. */
  108|  1.69k|        pb_release(msgtype, msg);
  109|  1.69k|    }
  110|       |
  111|  4.03k|    free_with_check(msg);
  112|  4.03k|    free_with_check(buf2);
  113|  4.03k|    assert(get_alloc_count() == initial_alloc_count);
  ------------------
  |  Branch (113:5): [True: 0, False: 4.03k]
  |  Branch (113:5): [True: 4.03k, False: 0]
  ------------------
  114|       |    
  115|  4.03k|    return status;
  116|  4.03k|}
fuzztest.c:do_stream_decode:
  119|  1.69k|{
  120|  1.69k|    bool status;
  121|  1.69k|    flakystream_t stream;
  122|  1.69k|    size_t initial_alloc_count = get_alloc_count();
  123|  1.69k|    void *msg = malloc_with_check(structsize);
  124|  1.69k|    assert(msg);
  ------------------
  |  Branch (124:5): [True: 0, False: 1.69k]
  |  Branch (124:5): [True: 1.69k, False: 0]
  ------------------
  125|       |
  126|  1.69k|    memset(msg, 0, structsize);
  127|  1.69k|    flakystream_init(&stream, buffer, msglen, fail_after);
  128|  1.69k|    status = pb_decode_ex(&stream.stream, msgtype, msg, flags);
  129|       |
  130|  1.69k|    if (status)
  ------------------
  |  Branch (130:9): [True: 1.69k, False: 0]
  ------------------
  131|  1.69k|    {
  132|  1.69k|        validate_message(msg, structsize, msgtype);
  133|  1.69k|    }
  134|       |
  135|  1.69k|    if (assert_success)
  ------------------
  |  Branch (135:9): [True: 1.69k, False: 0]
  ------------------
  136|  1.69k|    {
  137|  1.69k|        if (!status) fprintf(stderr, "pb_decode: %s\n", PB_GET_ERROR(&stream.stream));
  ------------------
  |  |  927|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (927:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (137:13): [True: 0, False: 1.69k]
  ------------------
  138|  1.69k|        assert(status);
  ------------------
  |  Branch (138:9): [True: 0, False: 1.69k]
  |  Branch (138:9): [True: 1.69k, False: 0]
  ------------------
  139|  1.69k|    }
  140|       |
  141|  1.69k|    if (status)
  ------------------
  |  Branch (141:9): [True: 1.69k, False: 0]
  ------------------
  142|  1.69k|    {
  143|       |        /* On error return, pb_release() should be called automatically. */
  144|  1.69k|        pb_release(msgtype, msg);
  145|  1.69k|    }
  146|       |
  147|  1.69k|    free_with_check(msg);
  148|  1.69k|    assert(get_alloc_count() == initial_alloc_count);
  ------------------
  |  Branch (148:5): [True: 0, False: 1.69k]
  |  Branch (148:5): [True: 1.69k, False: 0]
  ------------------
  149|       |
  150|  1.69k|    return status;
  151|  1.69k|}

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

