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

pb_read:
   82|  3.04M|{
   83|  3.04M|    if (count == 0)
  ------------------
  |  Branch (83:9): [True: 1.24M, False: 1.80M]
  ------------------
   84|  1.24M|        return true;
   85|       |
   86|  1.80M|#ifndef PB_BUFFER_ONLY
   87|  1.80M|	if (buf == NULL && stream->callback != buf_read)
  ------------------
  |  Branch (87:6): [True: 125k, False: 1.67M]
  |  Branch (87:21): [True: 41.4k, False: 83.8k]
  ------------------
   88|  41.4k|	{
   89|       |		/* Skip input bytes */
   90|  41.4k|		pb_byte_t tmp[16];
   91|   220k|		while (count > 16)
  ------------------
  |  Branch (91:10): [True: 179k, False: 41.4k]
  ------------------
   92|   179k|		{
   93|   179k|			if (!pb_read(stream, tmp, 16))
  ------------------
  |  Branch (93:8): [True: 0, False: 179k]
  ------------------
   94|      0|				return false;
   95|       |			
   96|   179k|			count -= 16;
   97|   179k|		}
   98|       |		
   99|  41.4k|		return pb_read(stream, tmp, count);
  100|  41.4k|	}
  101|  1.75M|#endif
  102|       |
  103|  1.75M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (103:9): [True: 274, False: 1.75M]
  ------------------
  104|    274|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  923|    274|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|    274|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 274]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  105|       |    
  106|  1.75M|#ifndef PB_BUFFER_ONLY
  107|  1.75M|    if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (107:9): [True: 0, False: 1.75M]
  ------------------
  108|      0|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  109|       |#else
  110|       |    if (!buf_read(stream, buf, count))
  111|       |        return false;
  112|       |#endif
  113|       |    
  114|  1.75M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (114:9): [True: 0, False: 1.75M]
  ------------------
  115|      0|        stream->bytes_left = 0;
  116|  1.75M|    else
  117|  1.75M|        stream->bytes_left -= count;
  118|       |
  119|       |    return true;
  120|  1.75M|}
pb_istream_from_buffer:
  143|  14.1k|{
  144|  14.1k|    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|  14.1k|    union {
  149|  14.1k|        void *state;
  150|  14.1k|        const void *c_state;
  151|  14.1k|    } state;
  152|       |#ifdef PB_BUFFER_ONLY
  153|       |    stream.callback = NULL;
  154|       |#else
  155|  14.1k|    stream.callback = &buf_read;
  156|  14.1k|#endif
  157|  14.1k|    state.c_state = buf;
  158|  14.1k|    stream.state = state.state;
  159|  14.1k|    stream.bytes_left = msglen;
  160|  14.1k|#ifndef PB_NO_ERRMSG
  161|  14.1k|    stream.errmsg = NULL;
  162|  14.1k|#endif
  163|       |#ifdef PB_MESSAGE_NESTING_MAX
  164|       |    stream.depth = 0;
  165|       |#endif
  166|  14.1k|    return stream;
  167|  14.1k|}
pb_decode_varint32:
  175|  64.1M|{
  176|  64.1M|    pb_byte_t byte;
  177|  64.1M|    uint32_t result;
  178|       |    
  179|  64.1M|    if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (179:9): [True: 1.84k, False: 64.1M]
  ------------------
  180|  1.84k|    {
  181|  1.84k|        return false;
  182|  1.84k|    }
  183|       |    
  184|  64.1M|    if ((byte & 0x80) == 0)
  ------------------
  |  Branch (184:9): [True: 34.9M, False: 29.2M]
  ------------------
  185|  34.9M|    {
  186|       |        /* Quick case, 1 byte value */
  187|  34.9M|        result = byte;
  188|  34.9M|    }
  189|  29.2M|    else
  190|  29.2M|    {
  191|       |        /* Multibyte case */
  192|  29.2M|        uint_fast8_t bitpos = 7;
  193|  29.2M|        result = byte & 0x7F;
  194|       |        
  195|  29.2M|        do
  196|  29.3M|        {
  197|  29.3M|            if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (197:17): [True: 64, False: 29.3M]
  ------------------
  198|     64|                return false;
  199|       |            
  200|  29.3M|            if (bitpos >= 32)
  ------------------
  |  Branch (200:17): [True: 12.3k, False: 29.3M]
  ------------------
  201|  12.3k|            {
  202|       |                /* Note: The varint could have trailing 0x80 bytes, or 0xFF for negative. */
  203|  12.3k|                pb_byte_t sign_extension = (bitpos < 63) ? 0xFF : 0x01;
  ------------------
  |  Branch (203:44): [True: 12.2k, False: 110]
  ------------------
  204|  12.3k|                bool valid_extension = ((byte & 0x7F) == 0x00 ||
  ------------------
  |  Branch (204:41): [True: 7.00k, False: 5.35k]
  ------------------
  205|  5.35k|                         ((result >> 31) != 0 && byte == sign_extension));
  ------------------
  |  Branch (205:27): [True: 5.34k, False: 16]
  |  Branch (205:50): [True: 5.28k, False: 63]
  ------------------
  206|       |
  207|  12.3k|                if (bitpos >= 64 || !valid_extension)
  ------------------
  |  Branch (207:21): [True: 3, False: 12.3k]
  |  Branch (207:37): [True: 78, False: 12.2k]
  ------------------
  208|     81|                {
  209|     81|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  923|     81|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     81|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 81]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  210|     81|                }
  211|  12.3k|            }
  212|  29.3M|            else if (bitpos == 28)
  ------------------
  |  Branch (212:22): [True: 18.1k, False: 29.3M]
  ------------------
  213|  18.1k|            {
  214|  18.1k|                if ((byte & 0x70) != 0 && (byte & 0x78) != 0x78)
  ------------------
  |  Branch (214:21): [True: 12.8k, False: 5.24k]
  |  Branch (214:43): [True: 28, False: 12.8k]
  ------------------
  215|     28|                {
  216|     28|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  923|     28|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     28|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 28]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  217|     28|                }
  218|  18.1k|                result |= (uint32_t)(byte & 0x0F) << bitpos;
  219|  18.1k|            }
  220|  29.3M|            else
  221|  29.3M|            {
  222|  29.3M|                result |= (uint32_t)(byte & 0x7F) << bitpos;
  223|  29.3M|            }
  224|  29.3M|            bitpos = (uint_fast8_t)(bitpos + 7);
  225|  29.3M|        } while (byte & 0x80);
  ------------------
  |  Branch (225:18): [True: 167k, False: 29.2M]
  ------------------
  226|  29.2M|   }
  227|       |   
  228|  64.1M|   *dest = result;
  229|       |   return true;
  230|  64.1M|}
pb_decode_varint:
  234|  13.6M|{
  235|  13.6M|    pb_byte_t byte;
  236|  13.6M|    uint_fast8_t bitpos = 0;
  237|  13.6M|    uint64_t result = 0;
  238|       |    
  239|  13.6M|    do
  240|  24.1M|    {
  241|  24.1M|        if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (241:13): [True: 94, False: 24.1M]
  ------------------
  242|     94|            return false;
  243|       |
  244|  24.1M|        if (bitpos >= 63 && (byte & 0xFE) != 0)
  ------------------
  |  Branch (244:13): [True: 90.0k, False: 24.0M]
  |  Branch (244:29): [True: 34, False: 89.9k]
  ------------------
  245|     34|            PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  923|     34|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     34|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 34]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  246|       |
  247|  24.1M|        result |= (uint64_t)(byte & 0x7F) << bitpos;
  248|  24.1M|        bitpos = (uint_fast8_t)(bitpos + 7);
  249|  24.1M|    } while (byte & 0x80);
  ------------------
  |  Branch (249:14): [True: 10.4M, False: 13.6M]
  ------------------
  250|       |    
  251|  13.6M|    *dest = result;
  252|       |    return true;
  253|  13.6M|}
pb_decode_tag:
  282|  31.3M|{
  283|  31.3M|    uint32_t temp;
  284|  31.3M|    *eof = false;
  285|  31.3M|    *wire_type = (pb_wire_type_t) 0;
  286|  31.3M|    *tag = 0;
  287|       |
  288|  31.3M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (288:9): [True: 206k, False: 31.1M]
  ------------------
  289|   206k|    {
  290|   206k|        *eof = true;
  291|   206k|        return false;
  292|   206k|    }
  293|       |
  294|  31.1M|    if (!pb_decode_varint32(stream, &temp))
  ------------------
  |  Branch (294:9): [True: 1.74k, False: 31.1M]
  ------------------
  295|  1.74k|    {
  296|  1.74k|#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.74k|        if (stream->callback != buf_read && stream->bytes_left == 0)
  ------------------
  |  Branch (304:13): [True: 1.62k, False: 123]
  |  Branch (304:45): [True: 1.62k, False: 0]
  ------------------
  305|  1.62k|        {
  306|  1.62k|#ifndef PB_NO_ERRMSG
  307|  1.62k|            if (strcmp(stream->errmsg, "io error") == 0)
  ------------------
  |  Branch (307:17): [True: 1.62k, False: 0]
  ------------------
  308|  1.62k|                stream->errmsg = NULL;
  309|  1.62k|#endif
  310|  1.62k|            *eof = true;
  311|  1.62k|        }
  312|  1.74k|#endif
  313|  1.74k|        return false;
  314|  1.74k|    }
  315|       |    
  316|  31.1M|    *tag = temp >> 3;
  317|  31.1M|    *wire_type = (pb_wire_type_t)(temp & 7);
  318|       |    return true;
  319|  31.1M|}
pb_skip_field:
  322|   361k|{
  323|   361k|    switch (wire_type)
  324|   361k|    {
  325|   171k|        case PB_WT_VARINT: return pb_skip_varint(stream);
  ------------------
  |  Branch (325:9): [True: 171k, False: 190k]
  ------------------
  326|  12.7k|        case PB_WT_64BIT: return pb_read(stream, NULL, 8);
  ------------------
  |  Branch (326:9): [True: 12.7k, False: 348k]
  ------------------
  327|   118k|        case PB_WT_STRING: return pb_skip_string(stream);
  ------------------
  |  Branch (327:9): [True: 118k, False: 242k]
  ------------------
  328|  58.8k|        case PB_WT_32BIT: return pb_read(stream, NULL, 4);
  ------------------
  |  Branch (328:9): [True: 58.8k, False: 302k]
  ------------------
  329|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (329:2): [True: 0, False: 361k]
  ------------------
  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|     82|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  923|     82|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     82|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 82]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (334:9): [True: 82, False: 361k]
  ------------------
  335|   361k|    }
  336|   361k|}
pb_make_string_substream:
  387|   333k|{
  388|   333k|    uint32_t size;
  389|   333k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (389:9): [True: 121, False: 333k]
  ------------------
  390|    121|        return false;
  391|       |    
  392|   333k|    *substream = *stream;
  393|   333k|    if (substream->bytes_left < size)
  ------------------
  |  Branch (393:9): [True: 123, False: 333k]
  ------------------
  394|    123|        PB_RETURN_ERROR(stream, "parent stream too short");
  ------------------
  |  |  923|    123|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|    123|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 123]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|   333k|    substream->bytes_left = (size_t)size;
  403|   333k|    stream->bytes_left -= (size_t)size;
  404|       |    return true;
  405|   333k|}
pb_close_string_substream:
  408|   333k|{
  409|   333k|    if (substream->bytes_left) {
  ------------------
  |  Branch (409:9): [True: 712, False: 332k]
  ------------------
  410|    712|        if (!pb_read(substream, NULL, substream->bytes_left))
  ------------------
  |  Branch (410:13): [True: 0, False: 712]
  ------------------
  411|      0|            return false;
  412|    712|    }
  413|       |
  414|   333k|    stream->state = substream->state;
  415|       |
  416|   333k|#ifndef PB_NO_ERRMSG
  417|   333k|    stream->errmsg = substream->errmsg;
  418|   333k|#endif
  419|       |    return true;
  420|   333k|}
pb_decode_ex:
 1220|  8.56k|{
 1221|  8.56k|    bool status;
 1222|       |
 1223|  8.56k|    if ((flags & PB_DECODE_DELIMITED) == 0)
  ------------------
  |  |  123|  8.56k|#define PB_DECODE_DELIMITED       0x02U
  ------------------
  |  Branch (1223:9): [True: 8.56k, False: 0]
  ------------------
 1224|  8.56k|    {
 1225|  8.56k|      status = pb_decode_inner(stream, fields, dest_struct, flags);
 1226|  8.56k|    }
 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.56k|#ifdef PB_ENABLE_MALLOC
 1240|  8.56k|    if (!status)
  ------------------
  |  Branch (1240:9): [True: 2.30k, False: 6.25k]
  ------------------
 1241|  2.30k|        pb_release(fields, dest_struct);
 1242|  8.56k|#endif
 1243|       |    
 1244|  8.56k|    return status;
 1245|  8.56k|}
pb_decode:
 1248|  3.01k|{
 1249|  3.01k|    return pb_decode_ex(stream, fields, dest_struct, 0);
 1250|  3.01k|}
pb_release:
 1377|   209k|{
 1378|   209k|    pb_field_iter_t iter;
 1379|       |    
 1380|   209k|    if (!dest_struct)
  ------------------
  |  Branch (1380:9): [True: 0, False: 209k]
  ------------------
 1381|      0|        return; /* Ignore NULL pointers, similar to free() */
 1382|       |
 1383|   209k|    if (!pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1383:9): [True: 67.6k, False: 142k]
  ------------------
 1384|  67.6k|        return; /* Empty message type */
 1385|       |    
 1386|   142k|    do
 1387|  1.14M|    {
 1388|  1.14M|        pb_release_single_field(&iter);
 1389|  1.14M|    } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (1389:14): [True: 998k, False: 142k]
  ------------------
 1390|   142k|}
pb_decode_bool:
 1403|  3.94M|{
 1404|  3.94M|    uint32_t value;
 1405|  3.94M|    if (!pb_decode_varint32(stream, &value))
  ------------------
  |  Branch (1405:9): [True: 51, False: 3.94M]
  ------------------
 1406|     51|        return false;
 1407|       |
 1408|  3.94M|    *(bool*)dest = (value != 0);
 1409|       |    return true;
 1410|  3.94M|}
pb_decode_svarint:
 1413|  5.21M|{
 1414|  5.21M|    pb_uint64_t value;
  ------------------
  |  |   57|  5.21M|#define pb_uint64_t uint64_t
  ------------------
 1415|  5.21M|    if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1415:9): [True: 38, False: 5.21M]
  ------------------
 1416|     38|        return false;
 1417|       |    
 1418|  5.21M|    if (value & 1)
  ------------------
  |  Branch (1418:9): [True: 704k, False: 4.50M]
  ------------------
 1419|   704k|        *dest = (pb_int64_t)(~(value >> 1));
 1420|  4.50M|    else
 1421|  4.50M|        *dest = (pb_int64_t)(value >> 1);
 1422|       |    
 1423|       |    return true;
 1424|  5.21M|}
pb_decode_fixed32:
 1427|   123k|{
 1428|   123k|    union {
 1429|   123k|        uint32_t fixed32;
 1430|   123k|        pb_byte_t bytes[4];
 1431|   123k|    } u;
 1432|       |
 1433|   123k|    if (!pb_read(stream, u.bytes, 4))
  ------------------
  |  Branch (1433:9): [True: 21, False: 123k]
  ------------------
 1434|     21|        return false;
 1435|       |
 1436|   123k|#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|   123k|    *(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|   123k|}
pb_decode_fixed64:
 1450|  62.1k|{
 1451|  62.1k|    union {
 1452|  62.1k|        uint64_t fixed64;
 1453|  62.1k|        pb_byte_t bytes[8];
 1454|  62.1k|    } u;
 1455|       |
 1456|  62.1k|    if (!pb_read(stream, u.bytes, 8))
  ------------------
  |  Branch (1456:9): [True: 19, False: 62.1k]
  ------------------
 1457|     19|        return false;
 1458|       |
 1459|  62.1k|#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|  62.1k|    *(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|  62.1k|}
pb_decode.c:buf_read:
   69|  83.6M|{
   70|  83.6M|    const pb_byte_t *source = (const pb_byte_t*)stream->state;
   71|  83.6M|    stream->state = (pb_byte_t*)stream->state + count;
   72|       |    
   73|  83.6M|    if (buf != NULL)
  ------------------
  |  Branch (73:9): [True: 83.5M, False: 83.6k]
  ------------------
   74|  83.5M|    {
   75|  83.5M|        memcpy(buf, source, count * sizeof(pb_byte_t));
   76|  83.5M|    }
   77|       |    
   78|       |    return true;
   79|  83.6M|}
pb_decode.c:pb_readbyte:
  125|   117M|{
  126|   117M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (126:9): [True: 380, False: 117M]
  ------------------
  127|    380|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  923|    380|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|    380|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 380]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  128|       |
  129|   117M|#ifndef PB_BUFFER_ONLY
  130|   117M|    if (!stream->callback(stream, buf, 1))
  ------------------
  |  Branch (130:9): [True: 1.62k, False: 117M]
  ------------------
  131|  1.62k|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  923|  1.62k|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|  1.62k|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 1.62k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  132|       |#else
  133|       |    *buf = *(const pb_byte_t*)stream->state;
  134|       |    stream->state = (pb_byte_t*)stream->state + 1;
  135|       |#endif
  136|       |
  137|   117M|    stream->bytes_left--;
  138|       |    
  139|       |    return true;    
  140|   117M|}
pb_decode.c:pb_skip_varint:
  257|   171k|{
  258|   171k|    pb_byte_t byte;
  259|   171k|    do
  260|   194k|    {
  261|   194k|        if (!pb_read(stream, &byte, 1))
  ------------------
  |  Branch (261:13): [True: 70, False: 194k]
  ------------------
  262|     70|            return false;
  263|   194k|    } while (byte & 0x80);
  ------------------
  |  Branch (263:14): [True: 23.5k, False: 171k]
  ------------------
  264|   171k|    return true;
  265|   171k|}
pb_decode.c:pb_skip_string:
  268|   118k|{
  269|   118k|    uint32_t length;
  270|   118k|    if (!pb_decode_varint32(stream, &length))
  ------------------
  |  Branch (270:9): [True: 48, False: 118k]
  ------------------
  271|     48|        return false;
  272|       |    
  273|   118k|    if ((size_t)length != length)
  ------------------
  |  Branch (273:9): [True: 0, False: 118k]
  ------------------
  274|      0|    {
  275|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  276|      0|    }
  277|       |
  278|   118k|    return pb_read(stream, NULL, (size_t)length);
  279|   118k|}
pb_decode.c:pb_decode_inner:
 1049|   209k|{
 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|   209k|    uint32_t extension_range_start = 0;
 1055|   209k|    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|   209k|    pb_size_t fixed_count_field = PB_SIZE_MAX;
  ------------------
  |  |  342|   209k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
 1062|   209k|    pb_size_t fixed_count_size = 0;
 1063|   209k|    pb_size_t fixed_count_total_size = 0;
 1064|       |
 1065|       |    /* Tag and wire type of next field from the input stream */
 1066|   209k|    uint32_t tag;
 1067|   209k|    pb_wire_type_t wire_type;
 1068|   209k|    bool eof;
 1069|       |
 1070|       |    /* Track presence of required fields */
 1071|   209k|    pb_fields_seen_t fields_seen = {{0, 0}};
 1072|   209k|    const uint32_t allbits = ~(uint32_t)0;
 1073|       |
 1074|       |    /* Descriptor for the structure field matching the tag decoded from stream */
 1075|   209k|    pb_field_iter_t iter;
 1076|       |
 1077|   209k|    if (pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1077:9): [True: 142k, False: 67.5k]
  ------------------
 1078|   142k|    {
 1079|   142k|        if ((flags & PB_DECODE_NOINIT) == 0)
  ------------------
  |  |  122|   142k|#define PB_DECODE_NOINIT          0x01U
  ------------------
  |  Branch (1079:13): [True: 132k, False: 9.30k]
  ------------------
 1080|   132k|        {
 1081|   132k|            if (!pb_message_set_to_defaults(&iter))
  ------------------
  |  Branch (1081:17): [True: 0, False: 132k]
  ------------------
 1082|      0|                PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1083|   132k|        }
 1084|   142k|    }
 1085|       |
 1086|  31.3M|    while (pb_decode_tag(stream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1086:12): [True: 31.1M, False: 207k]
  ------------------
 1087|  31.1M|    {
 1088|  31.1M|        if (tag == 0)
  ------------------
  |  Branch (1088:13): [True: 87, False: 31.1M]
  ------------------
 1089|     87|        {
 1090|     87|          if (flags & PB_DECODE_NULLTERMINATED)
  ------------------
  |  |  124|     87|#define PB_DECODE_NULLTERMINATED  0x04U
  ------------------
  |  Branch (1090:15): [True: 0, False: 87]
  ------------------
 1091|      0|          {
 1092|      0|            eof = true;
 1093|      0|            break;
 1094|      0|          }
 1095|     87|          else
 1096|     87|          {
 1097|     87|            PB_RETURN_ERROR(stream, "zero tag");
  ------------------
  |  |  923|     87|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     87|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 87]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1098|     87|          }
 1099|     87|        }
 1100|       |
 1101|  31.1M|        if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  30.7M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  30.7M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  30.7M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1101:13): [True: 364k, False: 30.7M]
  |  Branch (1101:48): [True: 861, False: 30.7M]
  ------------------
 1102|   365k|        {
 1103|       |            /* No match found, check if it matches an extension. */
 1104|   365k|            if (extension_range_start == 0)
  ------------------
  |  Branch (1104:17): [True: 12.2k, False: 353k]
  ------------------
 1105|  12.2k|            {
 1106|  12.2k|                if (pb_field_iter_find_extension(&iter))
  ------------------
  |  Branch (1106:21): [True: 4.21k, False: 8.07k]
  ------------------
 1107|  4.21k|                {
 1108|  4.21k|                    extensions = *(pb_extension_t* const *)iter.pData;
 1109|  4.21k|                    extension_range_start = iter.tag;
 1110|  4.21k|                }
 1111|       |
 1112|  12.2k|                if (!extensions)
  ------------------
  |  Branch (1112:21): [True: 8.83k, False: 3.45k]
  ------------------
 1113|  8.83k|                {
 1114|  8.83k|                    extension_range_start = (uint32_t)-1;
 1115|  8.83k|                }
 1116|  12.2k|            }
 1117|       |
 1118|   365k|            if (tag >= extension_range_start)
  ------------------
  |  Branch (1118:17): [True: 105k, False: 260k]
  ------------------
 1119|   105k|            {
 1120|   105k|                size_t pos = stream->bytes_left;
 1121|       |
 1122|   105k|                if (!decode_extension(stream, tag, wire_type, extensions))
  ------------------
  |  Branch (1122:21): [True: 107, False: 105k]
  ------------------
 1123|    107|                    return false;
 1124|       |
 1125|   105k|                if (pos != stream->bytes_left)
  ------------------
  |  Branch (1125:21): [True: 4.23k, False: 101k]
  ------------------
 1126|  4.23k|                {
 1127|       |                    /* The field was handled */
 1128|  4.23k|                    continue;
 1129|  4.23k|                }
 1130|   105k|            }
 1131|       |
 1132|       |            /* No match found, skip data */
 1133|   361k|            if (!pb_skip_field(stream, wire_type))
  ------------------
  |  Branch (1133:17): [True: 311, False: 361k]
  ------------------
 1134|    311|                return false;
 1135|   361k|            continue;
 1136|   361k|        }
 1137|       |
 1138|       |        /* If a repeated fixed count field was found, get size from
 1139|       |         * 'fixed_count_field' as there is no counter contained in the struct.
 1140|       |         */
 1141|  30.7M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  327|  30.7M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  30.7M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  314|  61.5M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1141:13): [True: 28.6M, False: 2.09M]
  |  Branch (1141:57): [True: 1.41k, False: 28.6M]
  ------------------
 1142|  1.41k|        {
 1143|  1.41k|            if (fixed_count_field != iter.index) {
  ------------------
  |  Branch (1143:17): [True: 942, False: 476]
  ------------------
 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|    942|                if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  342|  1.88k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1148:21): [True: 396, False: 546]
  ------------------
 1149|    396|                    fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1149:21): [True: 33, False: 363]
  ------------------
 1150|     33|                {
 1151|     33|                    PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  923|     33|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     33|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 33]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1152|     33|                }
 1153|       |
 1154|    909|                fixed_count_field = iter.index;
 1155|    909|                fixed_count_size = 0;
 1156|    909|                fixed_count_total_size = iter.array_size;
 1157|    909|            }
 1158|       |
 1159|  1.38k|            iter.pSize = &fixed_count_size;
 1160|  1.38k|        }
 1161|       |
 1162|  30.7M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  327|  30.7M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  30.7M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  311|  61.5M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (1162:13): [True: 2.04M, False: 28.7M]
  ------------------
 1163|  2.04M|            && iter.required_field_index < PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  233|  2.04M|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1163:16): [True: 2.04M, False: 0]
  ------------------
 1164|  2.04M|        {
 1165|  2.04M|            uint32_t tmp = ((uint32_t)1 << (iter.required_field_index & 31));
 1166|  2.04M|            fields_seen.bitfield[iter.required_field_index >> 5] |= tmp;
 1167|  2.04M|        }
 1168|       |
 1169|  30.7M|        if (!decode_field(stream, wire_type, &iter))
  ------------------
  |  Branch (1169:13): [True: 1.46k, False: 30.7M]
  ------------------
 1170|  1.46k|            return false;
 1171|  30.7M|    }
 1172|       |
 1173|   207k|    if (!eof)
  ------------------
  |  Branch (1173:9): [True: 123, False: 207k]
  ------------------
 1174|    123|    {
 1175|       |        /* pb_decode_tag() returned error before end of stream */
 1176|    123|        return false;
 1177|    123|    }
 1178|       |
 1179|       |    /* Check that all elements of the last decoded fixed count field were present. */
 1180|   207k|    if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  342|   415k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1180:9): [True: 452, False: 207k]
  ------------------
 1181|    452|        fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1181:9): [True: 46, False: 406]
  ------------------
 1182|     46|    {
 1183|     46|        PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  923|     46|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     46|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 46]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1184|     46|    }
 1185|       |
 1186|       |    /* Check that all required fields were present. */
 1187|   207k|    {
 1188|   207k|        pb_size_t req_field_count = iter.descriptor->required_field_count;
 1189|       |
 1190|   207k|        if (req_field_count > 0)
  ------------------
  |  Branch (1190:13): [True: 135k, False: 72.3k]
  ------------------
 1191|   135k|        {
 1192|   135k|            pb_size_t i;
 1193|       |
 1194|   135k|            if (req_field_count > PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  233|   135k|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1194:17): [True: 0, False: 135k]
  ------------------
 1195|      0|                req_field_count = PB_MAX_REQUIRED_FIELDS;
  ------------------
  |  |  233|      0|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
 1196|       |
 1197|       |            /* Check the whole words */
 1198|   135k|            for (i = 0; i < (req_field_count >> 5); i++)
  ------------------
  |  Branch (1198:25): [True: 0, False: 135k]
  ------------------
 1199|      0|            {
 1200|      0|                if (fields_seen.bitfield[i] != allbits)
  ------------------
  |  Branch (1200:21): [True: 0, False: 0]
  ------------------
 1201|      0|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1202|      0|            }
 1203|       |
 1204|       |            /* Check the remaining bits (if any) */
 1205|   135k|            if ((req_field_count & 31) != 0)
  ------------------
  |  Branch (1205:17): [True: 135k, False: 0]
  ------------------
 1206|   135k|            {
 1207|   135k|                if (fields_seen.bitfield[req_field_count >> 5] !=
  ------------------
  |  Branch (1207:21): [True: 476, False: 134k]
  ------------------
 1208|   135k|                    (allbits >> (uint_least8_t)(32 - (req_field_count & 31))))
 1209|    476|                {
 1210|    476|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  923|    476|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|    476|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 476]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1211|    476|                }
 1212|   135k|            }
 1213|   135k|        }
 1214|   207k|    }
 1215|       |
 1216|   207k|    return true;
 1217|   207k|}
pb_decode.c:pb_message_set_to_defaults:
 1010|   139k|{
 1011|   139k|    pb_istream_t defstream = PB_ISTREAM_EMPTY;
  ------------------
  |  |   71|   139k|#  define PB_ISTREAM_EMPTY {0,0,0,0}
  ------------------
 1012|   139k|    uint32_t tag = 0;
 1013|   139k|    pb_wire_type_t wire_type = PB_WT_VARINT;
 1014|   139k|    bool eof;
 1015|       |
 1016|   139k|    if (iter->descriptor->default_value)
  ------------------
  |  Branch (1016:9): [True: 0, False: 139k]
  ------------------
 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|   139k|    do
 1024|  1.11M|    {
 1025|  1.11M|        if (!pb_field_set_to_default(iter))
  ------------------
  |  Branch (1025:13): [True: 0, False: 1.11M]
  ------------------
 1026|      0|            return false;
 1027|       |
 1028|  1.11M|        if (tag != 0 && iter->tag == tag)
  ------------------
  |  Branch (1028:13): [True: 0, False: 1.11M]
  |  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.11M|    } while (pb_field_iter_next(iter));
  ------------------
  |  Branch (1039:14): [True: 979k, False: 139k]
  ------------------
 1040|       |
 1041|   139k|    return true;
 1042|   139k|}
pb_decode.c:pb_field_set_to_default:
  928|  1.11M|{
  929|  1.11M|    pb_type_t type;
  930|  1.11M|    type = field->type;
  931|       |
  932|  1.11M|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  1.11M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.11M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  1.11M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (932:9): [True: 8.56k, False: 1.11M]
  ------------------
  933|  8.56k|    {
  934|  8.56k|        pb_extension_t *ext = *(pb_extension_t* const *)field->pData;
  935|  15.5k|        while (ext != NULL)
  ------------------
  |  Branch (935:16): [True: 6.94k, False: 8.56k]
  ------------------
  936|  6.94k|        {
  937|  6.94k|            pb_field_iter_t ext_iter;
  938|  6.94k|            if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (938:17): [True: 6.94k, False: 0]
  ------------------
  939|  6.94k|            {
  940|  6.94k|                ext->found = false;
  941|  6.94k|                if (!pb_message_set_to_defaults(&ext_iter))
  ------------------
  |  Branch (941:21): [True: 0, False: 6.94k]
  ------------------
  942|      0|                    return false;
  943|  6.94k|            }
  944|  6.94k|            ext = ext->next;
  945|  6.94k|        }
  946|  8.56k|    }
  947|  1.11M|    else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  326|  1.11M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  1.11M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  321|  1.11M|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (947:14): [True: 32.6k, False: 1.07M]
  ------------------
  948|  32.6k|    {
  949|  32.6k|        bool init_data = true;
  950|  32.6k|        if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  327|  32.6k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  32.6k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  312|  65.2k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (950:13): [True: 0, False: 32.6k]
  |  Branch (950:52): [True: 0, False: 0]
  ------------------
  951|      0|        {
  952|       |            /* Set has_field to false. Still initialize the optional field
  953|       |             * itself also. */
  954|      0|            *(bool*)field->pSize = false;
  955|      0|        }
  956|  32.6k|        else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  327|  32.6k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  32.6k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  314|  65.2k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (956:18): [True: 0, False: 32.6k]
  ------------------
  957|  32.6k|                 PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  32.6k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  32.6k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                               PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  32.6k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (957:18): [True: 25.6k, False: 6.94k]
  ------------------
  958|  25.6k|        {
  959|       |            /* REPEATED: Set array count to 0, no need to initialize contents.
  960|       |               ONEOF: Set which_field to 0. */
  961|  25.6k|            *(pb_size_t*)field->pSize = 0;
  962|  25.6k|            init_data = false;
  963|  25.6k|        }
  964|       |
  965|  32.6k|        if (init_data)
  ------------------
  |  Branch (965:13): [True: 6.94k, False: 25.6k]
  ------------------
  966|  6.94k|        {
  967|  6.94k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  329|  13.8k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  6.94k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  6.94k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  13.8k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 6.94k, False: 0]
  |  |  ------------------
  |  |  330|  13.8k|                               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|  6.94k|                (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (968:18): [True: 0, False: 6.94k]
  ------------------
  969|  6.94k|                 field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (969:18): [True: 0, False: 6.94k]
  ------------------
  970|  6.94k|                 field->submsg_desc->submsg_info[0] != NULL))
  ------------------
  |  Branch (970:18): [True: 0, False: 6.94k]
  ------------------
  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|  6.94k|            else
  983|  6.94k|            {
  984|       |                /* Initialize to zeros */
  985|  6.94k|                memset(field->pData, 0, (size_t)field->data_size);
  986|  6.94k|            }
  987|  6.94k|        }
  988|  32.6k|    }
  989|  1.07M|    else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  1.07M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  1.07M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  1.07M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (989:14): [True: 1.06M, False: 17.1k]
  ------------------
  990|  1.06M|    {
  991|       |        /* Initialize the pointer to NULL. */
  992|  1.06M|        *(void**)field->pField = NULL;
  993|       |
  994|       |        /* Initialize array count to 0. */
  995|  1.06M|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  327|  1.06M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  1.06M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  314|  2.12M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (995:13): [True: 179k, False: 881k]
  ------------------
  996|   881k|            PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|   881k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   881k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|   881k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (996:13): [True: 17.1k, False: 864k]
  ------------------
  997|   196k|        {
  998|   196k|            *(pb_size_t*)field->pSize = 0;
  999|   196k|        }
 1000|  1.06M|    }
 1001|  17.1k|    else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  326|  17.1k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  17.1k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|  17.1k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (1001:14): [True: 17.1k, False: 0]
  ------------------
 1002|  17.1k|    {
 1003|       |        /* Don't overwrite callback */
 1004|  17.1k|    }
 1005|       |
 1006|  1.11M|    return true;
 1007|  1.11M|}
pb_decode.c:decode_extension:
  906|   105k|{
  907|   105k|    size_t pos = stream->bytes_left;
  908|       |    
  909|   211k|    while (extension != NULL && pos == stream->bytes_left)
  ------------------
  |  Branch (909:12): [True: 105k, False: 105k]
  |  Branch (909:33): [True: 105k, False: 0]
  ------------------
  910|   105k|    {
  911|   105k|        bool status;
  912|   105k|        if (extension->type->decode)
  ------------------
  |  Branch (912:13): [True: 0, False: 105k]
  ------------------
  913|      0|            status = extension->type->decode(stream, extension, tag, wire_type);
  914|   105k|        else
  915|   105k|            status = default_extension_decoder(stream, extension, tag, wire_type);
  916|       |
  917|   105k|        if (!status)
  ------------------
  |  Branch (917:13): [True: 107, False: 105k]
  ------------------
  918|    107|            return false;
  919|       |        
  920|   105k|        extension = extension->next;
  921|   105k|    }
  922|       |    
  923|   105k|    return true;
  924|   105k|}
pb_decode.c:default_extension_decoder:
  889|   105k|{
  890|   105k|    pb_field_iter_t iter;
  891|       |
  892|   105k|    if (!pb_field_iter_begin_extension(&iter, extension))
  ------------------
  |  Branch (892:9): [True: 0, False: 105k]
  ------------------
  893|      0|        PB_RETURN_ERROR(stream, "invalid extension");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  894|       |
  895|   105k|    if (iter.tag != tag || !iter.message)
  ------------------
  |  Branch (895:9): [True: 101k, False: 4.34k]
  |  Branch (895:28): [True: 0, False: 4.34k]
  ------------------
  896|   101k|        return true;
  897|       |
  898|  4.34k|    extension->found = true;
  899|  4.34k|    return decode_field(stream, wire_type, &iter);
  900|   105k|}
pb_decode.c:decode_field:
  857|  30.7M|{
  858|  30.7M|#ifdef PB_ENABLE_MALLOC
  859|       |    /* When decoding an oneof field, check if there is old data that must be
  860|       |     * released first. */
  861|  30.7M|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  30.7M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  30.7M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  30.7M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (861:9): [True: 25.7k, False: 30.7M]
  ------------------
  862|  25.7k|    {
  863|  25.7k|        if (!pb_release_union_field(stream, field))
  ------------------
  |  Branch (863:13): [True: 0, False: 25.7k]
  ------------------
  864|      0|            return false;
  865|  25.7k|    }
  866|  30.7M|#endif
  867|       |
  868|  30.7M|    switch (PB_ATYPE(field->type))
  ------------------
  |  |  326|  30.7M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  30.7M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
  869|  30.7M|    {
  870|  11.8k|        case PB_ATYPE_STATIC:
  ------------------
  |  |  321|  11.8k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (870:9): [True: 11.8k, False: 30.7M]
  ------------------
  871|  11.8k|            return decode_static_field(stream, wire_type, field);
  872|       |        
  873|  30.7M|        case PB_ATYPE_POINTER:
  ------------------
  |  |  322|  30.7M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (873:9): [True: 30.7M, False: 21.7k]
  ------------------
  874|  30.7M|            return decode_pointer_field(stream, wire_type, field);
  875|       |        
  876|  9.89k|        case PB_ATYPE_CALLBACK:
  ------------------
  |  |  323|  9.89k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (876:9): [True: 9.89k, False: 30.7M]
  ------------------
  877|  9.89k|            return decode_callback_field(stream, wire_type, field);
  878|       |        
  879|      0|        default:
  ------------------
  |  Branch (879:9): [True: 0, False: 30.7M]
  ------------------
  880|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  881|  30.7M|    }
  882|  30.7M|}
pb_decode.c:pb_release_union_field:
 1256|  25.7k|{
 1257|  25.7k|    pb_field_iter_t old_field = *field;
 1258|  25.7k|    pb_size_t old_tag = *(pb_size_t*)field->pSize; /* Previous which_ value */
 1259|  25.7k|    pb_size_t new_tag = field->tag; /* New which_ value */
 1260|       |
 1261|  25.7k|    if (old_tag == 0)
  ------------------
  |  Branch (1261:9): [True: 1.68k, False: 24.1k]
  ------------------
 1262|  1.68k|        return true; /* Ok, no old data in union */
 1263|       |
 1264|  24.1k|    if (old_tag == new_tag)
  ------------------
  |  Branch (1264:9): [True: 17.7k, False: 6.37k]
  ------------------
 1265|  17.7k|        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|  6.37k|    if (!pb_field_iter_find(&old_field, old_tag))
  ------------------
  |  Branch (1269:9): [True: 0, False: 6.37k]
  ------------------
 1270|      0|        PB_RETURN_ERROR(stream, "invalid union tag");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1271|       |
 1272|  6.37k|    pb_release_single_field(&old_field);
 1273|       |
 1274|  6.37k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  6.37k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  6.37k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  6.37k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1274:9): [True: 2.38k, False: 3.99k]
  ------------------
 1275|  2.38k|    {
 1276|       |        /* Initialize the pointer to NULL to make sure it is valid
 1277|       |         * even in case of error return. */
 1278|  2.38k|        *(void**)field->pField = NULL;
 1279|  2.38k|        field->pData = NULL;
 1280|  2.38k|    }
 1281|       |
 1282|       |    return true;
 1283|  6.37k|}
pb_decode.c:decode_static_field:
  498|  11.8k|{
  499|  11.8k|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  327|  11.8k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  11.8k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  500|  11.8k|    {
  501|  4.34k|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  311|  4.34k|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (501:9): [True: 4.34k, False: 7.49k]
  ------------------
  502|  4.34k|            return decode_basic_field(stream, wire_type, field);
  503|       |            
  504|  1.28k|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  312|  1.28k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (504:9): [True: 1.28k, False: 10.5k]
  ------------------
  505|  1.28k|            if (field->pSize != NULL)
  ------------------
  |  Branch (505:17): [True: 1.28k, False: 0]
  ------------------
  506|  1.28k|                *(bool*)field->pSize = true;
  507|  1.28k|            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: 11.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");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  535|      0|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (535:21): [True: 0, False: 0]
  ------------------
  536|      0|                    return false;
  537|       |
  538|      0|                return status;
  539|      0|            }
  540|      0|            else
  541|      0|            {
  542|       |                /* Repeated field */
  543|      0|                pb_size_t *size = (pb_size_t*)field->pSize;
  544|      0|                field->pData = (char*)field->pField + field->data_size * (*size);
  545|       |
  546|      0|                if ((*size)++ >= field->array_size)
  ------------------
  |  Branch (546:21): [True: 0, False: 0]
  ------------------
  547|      0|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  548|       |
  549|      0|                return decode_basic_field(stream, wire_type, field);
  550|      0|            }
  551|       |
  552|  6.21k|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  316|  6.21k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (552:9): [True: 6.21k, False: 5.62k]
  ------------------
  553|  6.21k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  329|  12.4k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  6.21k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  6.21k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  12.4k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 5.01k, False: 1.20k]
  |  |  ------------------
  |  |  330|  12.4k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  1.20k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  1.20k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  1.20k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 1.20k]
  |  |  ------------------
  ------------------
  554|  5.01k|                *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (554:17): [True: 1.73k, False: 3.27k]
  ------------------
  555|  1.73k|            {
  556|       |                /* We memset to zero so that any callbacks are set to NULL.
  557|       |                 * This is because the callbacks might otherwise have values
  558|       |                 * from some other union field.
  559|       |                 * If callbacks are needed inside oneof field, use .proto
  560|       |                 * option submsg_callback to have a separate callback function
  561|       |                 * that can set the fields before submessage is decoded.
  562|       |                 * pb_dec_submessage() will set any default values. */
  563|  1.73k|                memset(field->pData, 0, (size_t)field->data_size);
  564|       |
  565|       |                /* Set default values for the submessage fields. */
  566|  1.73k|                if (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (566:21): [True: 0, False: 1.73k]
  ------------------
  567|  1.73k|                    field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (567:21): [True: 0, False: 1.73k]
  ------------------
  568|  1.73k|                    field->submsg_desc->submsg_info[0] != NULL)
  ------------------
  |  Branch (568:21): [True: 0, False: 1.73k]
  ------------------
  569|      0|                {
  570|      0|                    pb_field_iter_t submsg_iter;
  571|      0|                    if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (571:25): [True: 0, False: 0]
  ------------------
  572|      0|                    {
  573|      0|                        if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (573:29): [True: 0, False: 0]
  ------------------
  574|      0|                            PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  575|      0|                    }
  576|      0|                }
  577|  1.73k|            }
  578|  6.21k|            *(pb_size_t*)field->pSize = field->tag;
  579|       |
  580|  6.21k|            return decode_basic_field(stream, wire_type, field);
  581|       |
  582|      0|        default:
  ------------------
  |  Branch (582:9): [True: 0, False: 11.8k]
  ------------------
  583|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  584|  11.8k|    }
  585|  11.8k|}
pb_decode.c:decode_basic_field:
  427|  46.6M|{
  428|  46.6M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  328|  46.6M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  46.6M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  429|  46.6M|    {
  430|  3.94M|        case PB_LTYPE_BOOL:
  ------------------
  |  |  268|  3.94M|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (430:9): [True: 3.94M, False: 42.6M]
  ------------------
  431|  3.94M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (431:17): [True: 3.53M, False: 410k]
  |  Branch (431:46): [True: 15, False: 3.53M]
  ------------------
  432|     15|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     15|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     15|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  433|       |
  434|  3.94M|            return pb_dec_bool(stream, field);
  435|       |
  436|  7.20M|        case PB_LTYPE_VARINT:
  ------------------
  |  |  269|  7.20M|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (436:9): [True: 7.20M, False: 39.4M]
  ------------------
  437|  8.48M|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  270|  8.48M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (437:9): [True: 1.27M, False: 45.3M]
  ------------------
  438|  13.6M|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  271|  13.6M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (438:9): [True: 5.21M, False: 41.4M]
  ------------------
  439|  13.6M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (439:17): [True: 12.3M, False: 1.31M]
  |  Branch (439:46): [True: 79, False: 12.3M]
  ------------------
  440|     79|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     79|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     79|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 79]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  441|       |
  442|  13.6M|            return pb_dec_varint(stream, field);
  443|       |
  444|   123k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  272|   123k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (444:9): [True: 123k, False: 46.5M]
  ------------------
  445|   123k|            if (wire_type != PB_WT_32BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (445:17): [True: 41.6k, False: 81.7k]
  |  Branch (445:45): [True: 16, False: 41.6k]
  ------------------
  446|     16|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     16|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     16|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  447|       |
  448|   123k|            return pb_decode_fixed32(stream, field->pData);
  449|       |
  450|  62.1k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  273|  62.1k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (450:9): [True: 62.1k, False: 46.5M]
  ------------------
  451|  62.1k|            if (wire_type != PB_WT_64BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (451:17): [True: 8.48k, False: 53.6k]
  |  Branch (451:45): [True: 15, False: 8.46k]
  ------------------
  452|     15|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     15|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     15|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|  62.1k|            return pb_decode_fixed64(stream, field->pData);
  465|      0|#endif
  466|       |
  467|  1.08M|        case PB_LTYPE_BYTES:
  ------------------
  |  |  280|  1.08M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (467:9): [True: 1.08M, False: 45.5M]
  ------------------
  468|  1.08M|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (468:17): [True: 19, False: 1.08M]
  ------------------
  469|     19|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     19|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     19|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 19]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  470|       |
  471|  1.08M|            return pb_dec_bytes(stream, field);
  472|       |
  473|   137k|        case PB_LTYPE_STRING:
  ------------------
  |  |  284|   137k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (473:9): [True: 137k, False: 46.4M]
  ------------------
  474|   137k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (474:17): [True: 15, False: 137k]
  ------------------
  475|     15|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     15|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     15|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  476|       |
  477|   137k|            return pb_dec_string(stream, field);
  478|       |
  479|   201k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  288|   201k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (479:9): [True: 201k, False: 46.4M]
  ------------------
  480|   201k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  293|   201k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (480:9): [True: 0, False: 46.6M]
  ------------------
  481|   201k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (481:17): [True: 20, False: 201k]
  ------------------
  482|     20|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     20|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     20|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  483|       |
  484|   201k|            return pb_dec_submessage(stream, field);
  485|       |
  486|  27.3M|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  303|  27.3M|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (486:9): [True: 27.3M, False: 19.2M]
  ------------------
  487|  27.3M|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (487:17): [True: 4, False: 27.3M]
  ------------------
  488|      4|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|      4|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      4|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  489|       |
  490|  27.3M|            return pb_dec_fixed_length_bytes(stream, field);
  491|       |
  492|      0|        default:
  ------------------
  |  Branch (492:9): [True: 0, False: 46.6M]
  ------------------
  493|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  494|  46.6M|    }
  495|  46.6M|}
pb_decode.c:pb_dec_bool:
 1477|  3.94M|{
 1478|  3.94M|    return pb_decode_bool(stream, (bool*)field->pData);
 1479|  3.94M|}
pb_decode.c:pb_dec_varint:
 1482|  13.6M|{
 1483|  13.6M|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  328|  13.6M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  13.6M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  270|  13.6M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (1483:9): [True: 1.27M, False: 12.4M]
  ------------------
 1484|  1.27M|    {
 1485|  1.27M|        pb_uint64_t value, clamped;
  ------------------
  |  |   57|  1.27M|#define pb_uint64_t uint64_t
  ------------------
 1486|  1.27M|        if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1486:13): [True: 40, False: 1.27M]
  ------------------
 1487|     40|            return false;
 1488|       |
 1489|       |        /* Cast to the proper field size, while checking for overflows */
 1490|  1.27M|        if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (1490:13): [True: 501k, False: 778k]
  ------------------
 1491|   501k|            clamped = *(pb_uint64_t*)field->pData = value;
 1492|   778k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (1492:18): [True: 749k, False: 28.8k]
  ------------------
 1493|   749k|            clamped = *(uint32_t*)field->pData = (uint32_t)value;
 1494|  28.8k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (1494:18): [True: 14.3k, False: 14.5k]
  ------------------
 1495|  14.3k|            clamped = *(uint_least16_t*)field->pData = (uint_least16_t)value;
 1496|  14.5k|        else if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (1496:18): [True: 14.5k, False: 0]
  ------------------
 1497|  14.5k|            clamped = *(uint_least8_t*)field->pData = (uint_least8_t)value;
 1498|      0|        else
 1499|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1500|       |
 1501|  1.27M|        if (clamped != value)
  ------------------
  |  Branch (1501:13): [True: 116, False: 1.27M]
  ------------------
 1502|    116|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  923|    116|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|    116|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 116]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1503|       |
 1504|  1.27M|        return true;
 1505|  1.27M|    }
 1506|  12.4M|    else
 1507|  12.4M|    {
 1508|  12.4M|        pb_uint64_t value;
  ------------------
  |  |   57|  12.4M|#define pb_uint64_t uint64_t
  ------------------
 1509|  12.4M|        pb_int64_t svalue;
  ------------------
  |  |   56|  12.4M|#define pb_int64_t int64_t
  ------------------
 1510|  12.4M|        pb_int64_t clamped;
  ------------------
  |  |   56|  12.4M|#define pb_int64_t int64_t
  ------------------
 1511|       |
 1512|  12.4M|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  328|  12.4M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  12.4M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  271|  12.4M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (1512:13): [True: 5.21M, False: 7.20M]
  ------------------
 1513|  5.21M|        {
 1514|  5.21M|            if (!pb_decode_svarint(stream, &svalue))
  ------------------
  |  Branch (1514:17): [True: 38, False: 5.21M]
  ------------------
 1515|     38|                return false;
 1516|  5.21M|        }
 1517|  7.20M|        else
 1518|  7.20M|        {
 1519|  7.20M|            if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1519:17): [True: 50, False: 7.20M]
  ------------------
 1520|     50|                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|  7.20M|            if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1528:17): [True: 1.00M, False: 6.19M]
  ------------------
 1529|  1.00M|                svalue = (pb_int64_t)value;
 1530|  6.19M|            else
 1531|  6.19M|                svalue = (int32_t)value;
 1532|  7.20M|        }
 1533|       |
 1534|       |        /* Cast to the proper field size, while checking for overflows */
 1535|  12.4M|        if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1535:13): [True: 6.13M, False: 6.27M]
  ------------------
 1536|  6.13M|            clamped = *(pb_int64_t*)field->pData = svalue;
 1537|  6.27M|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (1537:18): [True: 6.22M, False: 57.3k]
  ------------------
 1538|  6.22M|            clamped = *(int32_t*)field->pData = (int32_t)svalue;
 1539|  57.3k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (1539:18): [True: 28.6k, False: 28.7k]
  ------------------
 1540|  28.6k|            clamped = *(int_least16_t*)field->pData = (int_least16_t)svalue;
 1541|  28.7k|        else if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (1541:18): [True: 28.7k, False: 0]
  ------------------
 1542|  28.7k|            clamped = *(int_least8_t*)field->pData = (int_least8_t)svalue;
 1543|      0|        else
 1544|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1545|       |
 1546|  12.4M|        if (clamped != svalue)
  ------------------
  |  Branch (1546:13): [True: 90, False: 12.4M]
  ------------------
 1547|     90|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  923|     90|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     90|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 90]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1548|       |
 1549|  12.4M|        return true;
 1550|  12.4M|    }
 1551|  13.6M|}
pb_decode.c:pb_dec_bytes:
 1554|  1.08M|{
 1555|  1.08M|    uint32_t size;
 1556|  1.08M|    size_t alloc_size;
 1557|  1.08M|    pb_bytes_array_t *dest;
 1558|       |    
 1559|  1.08M|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1559:9): [True: 25, False: 1.08M]
  ------------------
 1560|     25|        return false;
 1561|       |    
 1562|  1.08M|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  342|  1.08M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1562:9): [True: 29, False: 1.08M]
  ------------------
 1563|     29|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  923|     29|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     29|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 29]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1564|       |    
 1565|  1.08M|    alloc_size = PB_BYTES_ARRAY_T_ALLOCSIZE(size);
  ------------------
  |  |  406|  1.08M|#define PB_BYTES_ARRAY_T_ALLOCSIZE(n) ((size_t)n + offsetof(pb_bytes_array_t, bytes))
  ------------------
 1566|  1.08M|    if (size > alloc_size)
  ------------------
  |  Branch (1566:9): [True: 0, False: 1.08M]
  ------------------
 1567|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1568|       |    
 1569|  1.08M|    if (PB_ATYPE(field->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(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  1.08M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1569:9): [True: 1.08M, False: 0]
  ------------------
 1570|  1.08M|    {
 1571|       |#ifndef PB_ENABLE_MALLOC
 1572|       |        PB_RETURN_ERROR(stream, "no malloc support");
 1573|       |#else
 1574|  1.08M|        if (stream->bytes_left < size)
  ------------------
  |  Branch (1574:13): [True: 31, False: 1.08M]
  ------------------
 1575|     31|            PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  923|     31|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     31|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 31]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1576|       |
 1577|  1.08M|        if (!allocate_field(stream, field->pData, alloc_size, 1))
  ------------------
  |  Branch (1577:13): [True: 0, False: 1.08M]
  ------------------
 1578|      0|            return false;
 1579|  1.08M|        dest = *(pb_bytes_array_t**)field->pData;
 1580|  1.08M|#endif
 1581|  1.08M|    }
 1582|      0|    else
 1583|      0|    {
 1584|      0|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1584:13): [True: 0, False: 0]
  ------------------
 1585|      0|            PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1586|      0|        dest = (pb_bytes_array_t*)field->pData;
 1587|      0|    }
 1588|       |
 1589|  1.08M|    dest->size = (pb_size_t)size;
 1590|  1.08M|    return pb_read(stream, dest->bytes, (size_t)size);
 1591|  1.08M|}
pb_decode.c:allocate_field:
  593|  33.1M|{    
  594|  33.1M|    void *ptr = *(void**)pData;
  595|       |    
  596|  33.1M|    if (data_size == 0 || array_size == 0)
  ------------------
  |  Branch (596:9): [True: 0, False: 33.1M]
  |  Branch (596:27): [True: 0, False: 33.1M]
  ------------------
  597|      0|        PB_RETURN_ERROR(stream, "invalid size");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  598|       |    
  599|       |#ifdef __AVR__
  600|       |    /* Workaround for AVR libc bug 53284: http://savannah.nongnu.org/bugs/?53284
  601|       |     * Realloc to size of 1 byte can cause corruption of the malloc structures.
  602|       |     */
  603|       |    if (data_size == 1 && array_size == 1)
  604|       |    {
  605|       |        data_size = 2;
  606|       |    }
  607|       |#endif
  608|       |
  609|       |    /* Check for multiplication overflows.
  610|       |     * This code avoids the costly division if the sizes are small enough.
  611|       |     * Multiplication is safe as long as only half of bits are set
  612|       |     * in either multiplicand.
  613|       |     */
  614|  33.1M|    {
  615|  33.1M|        const size_t check_limit = (size_t)1 << (sizeof(size_t) * 4);
  616|  33.1M|        if (data_size >= check_limit || array_size >= check_limit)
  ------------------
  |  Branch (616:13): [True: 0, False: 33.1M]
  |  Branch (616:41): [True: 0, False: 33.1M]
  ------------------
  617|      0|        {
  618|      0|            const size_t size_max = (size_t)-1;
  619|      0|            if (size_max / array_size < data_size)
  ------------------
  |  Branch (619:17): [True: 0, False: 0]
  ------------------
  620|      0|            {
  621|      0|                PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  622|      0|            }
  623|      0|        }
  624|  33.1M|    }
  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.1M|    ptr = pb_realloc(ptr, array_size * data_size);
  ------------------
  |  |    3|  33.1M|#define pb_realloc(ptr,size) realloc_with_check(ptr,size)
  ------------------
  630|  33.1M|    if (ptr == NULL)
  ------------------
  |  Branch (630:9): [True: 0, False: 33.1M]
  ------------------
  631|      0|        PB_RETURN_ERROR(stream, "realloc failed");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  632|       |    
  633|  33.1M|    *(void**)pData = ptr;
  634|       |    return true;
  635|  33.1M|}
pb_decode.c:pb_dec_string:
 1594|   137k|{
 1595|   137k|    uint32_t size;
 1596|   137k|    size_t alloc_size;
 1597|   137k|    pb_byte_t *dest = (pb_byte_t*)field->pData;
 1598|       |
 1599|   137k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1599:9): [True: 24, False: 137k]
  ------------------
 1600|     24|        return false;
 1601|       |
 1602|   137k|    if (size == (uint32_t)-1)
  ------------------
  |  Branch (1602:9): [True: 3, False: 137k]
  ------------------
 1603|      3|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  923|      3|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      3|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1604|       |
 1605|       |    /* Space for null terminator */
 1606|   137k|    alloc_size = (size_t)(size + 1);
 1607|       |
 1608|   137k|    if (alloc_size < size)
  ------------------
  |  Branch (1608:9): [True: 0, False: 137k]
  ------------------
 1609|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1610|       |
 1611|   137k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   137k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   137k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   137k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1611:9): [True: 136k, False: 1.26k]
  ------------------
 1612|   136k|    {
 1613|       |#ifndef PB_ENABLE_MALLOC
 1614|       |        PB_RETURN_ERROR(stream, "no malloc support");
 1615|       |#else
 1616|   136k|        if (stream->bytes_left < size)
  ------------------
  |  Branch (1616:13): [True: 65, False: 136k]
  ------------------
 1617|     65|            PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  923|     65|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     65|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 65]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1618|       |
 1619|   136k|        if (!allocate_field(stream, field->pData, alloc_size, 1))
  ------------------
  |  Branch (1619:13): [True: 0, False: 136k]
  ------------------
 1620|      0|            return false;
 1621|   136k|        dest = *(pb_byte_t**)field->pData;
 1622|   136k|#endif
 1623|   136k|    }
 1624|  1.26k|    else
 1625|  1.26k|    {
 1626|  1.26k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1626:13): [True: 50, False: 1.21k]
  ------------------
 1627|     50|            PB_RETURN_ERROR(stream, "string overflow");
  ------------------
  |  |  923|     50|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     50|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 50]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1628|  1.26k|    }
 1629|       |    
 1630|   137k|    dest[size] = 0;
 1631|       |
 1632|   137k|    if (!pb_read(stream, dest, (size_t)size))
  ------------------
  |  Branch (1632:9): [True: 5, False: 137k]
  ------------------
 1633|      5|        return false;
 1634|       |
 1635|       |#ifdef PB_VALIDATE_UTF8
 1636|       |    if (!pb_validate_utf8((const char*)dest))
 1637|       |        PB_RETURN_ERROR(stream, "invalid utf8");
 1638|       |#endif
 1639|       |
 1640|   137k|    return true;
 1641|   137k|}
pb_decode.c:pb_dec_submessage:
 1644|   201k|{
 1645|   201k|    bool status = true;
 1646|   201k|    bool submsg_consumed = false;
 1647|   201k|    pb_istream_t substream;
 1648|       |
 1649|   201k|    if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1649:9): [True: 141, False: 201k]
  ------------------
 1650|    141|        return false;
 1651|       |    
 1652|   201k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (1652:9): [True: 0, False: 201k]
  ------------------
 1653|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1654|       |    
 1655|       |    /* Submessages can have a separate message-level callback that is called
 1656|       |     * before decoding the message. Typically it is used to set callback fields
 1657|       |     * inside oneofs. */
 1658|   201k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  328|   201k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   201k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  293|   402k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (1658:9): [True: 0, False: 201k]
  |  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|   201k|    if (status && !submsg_consumed)
  ------------------
  |  Branch (1674:9): [True: 201k, False: 0]
  |  Branch (1674:19): [True: 201k, False: 0]
  ------------------
 1675|   201k|    {
 1676|   201k|        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|   201k|        if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  326|   201k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   201k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  321|   402k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1680:13): [True: 9.30k, False: 191k]
  ------------------
 1681|  9.30k|            PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  327|  9.30k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  9.30k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  314|  9.30k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1681:13): [True: 9.30k, False: 0]
  ------------------
 1682|  9.30k|        {
 1683|  9.30k|            flags = PB_DECODE_NOINIT;
  ------------------
  |  |  122|  9.30k|#define PB_DECODE_NOINIT          0x01U
  ------------------
 1684|  9.30k|        }
 1685|       |
 1686|   201k|        status = pb_decode_inner(&substream, field->submsg_desc, field->pData, flags);
 1687|   201k|    }
 1688|       |    
 1689|   201k|    if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1689:9): [True: 0, False: 201k]
  ------------------
 1690|      0|        return false;
 1691|       |
 1692|   201k|    return status;
 1693|   201k|}
pb_decode.c:pb_dec_fixed_length_bytes:
 1696|  27.3M|{
 1697|  27.3M|    uint32_t size;
 1698|       |
 1699|  27.3M|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1699:9): [True: 3, False: 27.3M]
  ------------------
 1700|      3|        return false;
 1701|       |
 1702|  27.3M|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  342|  27.3M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1702:9): [True: 32, False: 27.3M]
  ------------------
 1703|     32|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  923|     32|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     32|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1704|       |
 1705|  27.3M|    if (size == 0)
  ------------------
  |  Branch (1705:9): [True: 26.3M, False: 1.02M]
  ------------------
 1706|  26.3M|    {
 1707|       |        /* As a special case, treat empty bytes string as all zeros for fixed_length_bytes. */
 1708|  26.3M|        memset(field->pData, 0, (size_t)field->data_size);
 1709|  26.3M|        return true;
 1710|  26.3M|    }
 1711|       |
 1712|  1.02M|    if (size != field->data_size)
  ------------------
  |  Branch (1712:9): [True: 48, False: 1.02M]
  ------------------
 1713|     48|        PB_RETURN_ERROR(stream, "incorrect fixed length bytes size");
  ------------------
  |  |  923|     48|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     48|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 48]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1714|       |
 1715|  1.02M|    return pb_read(stream, (pb_byte_t*)field->pData, (size_t)field->data_size);
 1716|  1.02M|}
pb_decode.c:decode_pointer_field:
  655|  30.7M|{
  656|       |#ifndef PB_ENABLE_MALLOC
  657|       |    PB_UNUSED(wire_type);
  658|       |    PB_UNUSED(field);
  659|       |    PB_RETURN_ERROR(stream, "no malloc support");
  660|       |#else
  661|  30.7M|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  327|  30.7M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  30.7M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  662|  30.7M|    {
  663|  2.04M|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  311|  2.04M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (663:9): [True: 2.04M, False: 28.7M]
  ------------------
  664|  2.06M|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  312|  2.06M|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (664:9): [True: 21.0k, False: 30.7M]
  ------------------
  665|  2.07M|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  316|  2.07M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (665:9): [True: 9.67k, False: 30.7M]
  ------------------
  666|  2.07M|            if (PB_LTYPE_IS_SUBMSG(field->type) && *(void**)field->pField != NULL)
  ------------------
  |  |  329|  4.15M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  2.07M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  2.07M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  4.15M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 89.1k, False: 1.98M]
  |  |  ------------------
  |  |  330|  4.15M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  1.98M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  1.98M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  1.98M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 1.98M]
  |  |  ------------------
  ------------------
  |  Branch (666:52): [True: 53.7k, False: 35.4k]
  ------------------
  667|  53.7k|            {
  668|       |                /* Duplicate field, have to release the old allocation first. */
  669|       |                /* FIXME: Does this work correctly for oneofs? */
  670|  53.7k|                pb_release_single_field(field);
  671|  53.7k|            }
  672|       |        
  673|  2.07M|            if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  2.07M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  2.07M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  2.07M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (673:17): [True: 9.67k, False: 2.06M]
  ------------------
  674|  9.67k|            {
  675|  9.67k|                *(pb_size_t*)field->pSize = field->tag;
  676|  9.67k|            }
  677|       |
  678|  2.07M|            if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  328|  2.07M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  2.07M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  284|  4.15M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (678:17): [True: 107k, False: 1.96M]
  ------------------
  679|  1.96M|                PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  328|  1.96M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.96M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  280|  1.96M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (679:17): [True: 18.3k, False: 1.95M]
  ------------------
  680|   126k|            {
  681|       |                /* pb_dec_string and pb_dec_bytes handle allocation themselves */
  682|   126k|                field->pData = field->pField;
  683|   126k|                return decode_basic_field(stream, wire_type, field);
  684|   126k|            }
  685|  1.95M|            else
  686|  1.95M|            {
  687|  1.95M|                if (!allocate_field(stream, field->pField, field->data_size, 1))
  ------------------
  |  Branch (687:21): [True: 0, False: 1.95M]
  ------------------
  688|      0|                    return false;
  689|       |                
  690|  1.95M|                field->pData = *(void**)field->pField;
  691|  1.95M|                initialize_pointer_field(field->pData, field);
  692|  1.95M|                return decode_basic_field(stream, wire_type, field);
  693|  1.95M|            }
  694|       |    
  695|  28.6M|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  314|  28.6M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (695:9): [True: 28.6M, False: 2.07M]
  ------------------
  696|  28.6M|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (696:17): [True: 28.6M, False: 11.4k]
  ------------------
  697|  28.6M|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  328|  28.6M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  28.6M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  276|  28.6M|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (697:20): [True: 129k, False: 28.5M]
  ------------------
  698|   129k|            {
  699|       |                /* Packed array, multiple items come in at once. */
  700|   129k|                bool status = true;
  701|   129k|                pb_size_t *size = (pb_size_t*)field->pSize;
  702|   129k|                size_t allocated_size = *size;
  703|   129k|                pb_istream_t substream;
  704|       |                
  705|   129k|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (705:21): [True: 59, False: 129k]
  ------------------
  706|     59|                    return false;
  707|       |                
  708|  16.0M|                while (substream.bytes_left)
  ------------------
  |  Branch (708:24): [True: 15.9M, False: 129k]
  ------------------
  709|  15.9M|                {
  710|  15.9M|                    if (*size == PB_SIZE_MAX)
  ------------------
  |  |  342|  15.9M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (710:25): [True: 8, False: 15.9M]
  ------------------
  711|      8|                    {
  712|      8|#ifndef PB_NO_ERRMSG
  713|      8|                        stream->errmsg = "too many array entries";
  714|      8|#endif
  715|      8|                        status = false;
  716|      8|                        break;
  717|      8|                    }
  718|       |
  719|  15.9M|                    if ((size_t)*size + 1 > allocated_size)
  ------------------
  |  Branch (719:25): [True: 1.40M, False: 14.5M]
  ------------------
  720|  1.40M|                    {
  721|       |                        /* Allocate more storage. This tries to guess the
  722|       |                         * number of remaining entries. Round the division
  723|       |                         * upwards. */
  724|  1.40M|                        size_t remain = (substream.bytes_left - 1) / field->data_size + 1;
  725|  1.40M|                        if (remain < PB_SIZE_MAX - allocated_size)
  ------------------
  |  |  342|  1.40M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (725:29): [True: 373k, False: 1.03M]
  ------------------
  726|   373k|                            allocated_size += remain;
  727|  1.03M|                        else
  728|  1.03M|                            allocated_size += 1;
  729|       |                        
  730|  1.40M|                        if (!allocate_field(&substream, field->pField, field->data_size, allocated_size))
  ------------------
  |  Branch (730:29): [True: 0, False: 1.40M]
  ------------------
  731|      0|                        {
  732|      0|                            status = false;
  733|      0|                            break;
  734|      0|                        }
  735|  1.40M|                    }
  736|       |
  737|       |                    /* Decode the array entry */
  738|  15.9M|                    field->pData = *(char**)field->pField + field->data_size * (*size);
  739|  15.9M|                    if (field->pData == NULL)
  ------------------
  |  Branch (739:25): [True: 0, False: 15.9M]
  ------------------
  740|      0|                    {
  741|       |                        /* Shouldn't happen, but satisfies static analyzers */
  742|      0|                        status = false;
  743|      0|                        break;
  744|      0|                    }
  745|  15.9M|                    initialize_pointer_field(field->pData, field);
  746|  15.9M|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (746:25): [True: 87, False: 15.9M]
  ------------------
  747|     87|                    {
  748|     87|                        status = false;
  749|     87|                        break;
  750|     87|                    }
  751|       |                    
  752|  15.9M|                    (*size)++;
  753|  15.9M|                }
  754|   129k|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (754:21): [True: 0, False: 129k]
  ------------------
  755|      0|                    return false;
  756|       |                
  757|   129k|                return status;
  758|   129k|            }
  759|  28.5M|            else
  760|  28.5M|            {
  761|       |                /* Normal repeated field, i.e. only one item at a time. */
  762|  28.5M|                pb_size_t *size = (pb_size_t*)field->pSize;
  763|       |
  764|  28.5M|                if (*size == PB_SIZE_MAX)
  ------------------
  |  |  342|  28.5M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (764:21): [True: 1, False: 28.5M]
  ------------------
  765|      1|                    PB_RETURN_ERROR(stream, "too many array entries");
  ------------------
  |  |  923|      1|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      1|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  766|       |                
  767|  28.5M|                if (!allocate_field(stream, field->pField, field->data_size, (size_t)(*size + 1)))
  ------------------
  |  Branch (767:21): [True: 0, False: 28.5M]
  ------------------
  768|      0|                    return false;
  769|       |            
  770|  28.5M|                field->pData = *(char**)field->pField + field->data_size * (*size);
  771|  28.5M|                (*size)++;
  772|  28.5M|                initialize_pointer_field(field->pData, field);
  773|  28.5M|                return decode_basic_field(stream, wire_type, field);
  774|  28.5M|            }
  775|       |
  776|      0|        default:
  ------------------
  |  Branch (776:9): [True: 0, False: 30.7M]
  ------------------
  777|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  778|  30.7M|    }
  779|  30.7M|#endif
  780|  30.7M|}
pb_decode.c:initialize_pointer_field:
  639|  46.4M|{
  640|  46.4M|    if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  328|  46.4M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  46.4M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  284|  92.9M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (640:9): [True: 28.8k, False: 46.4M]
  ------------------
  641|  46.4M|        PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  328|  46.4M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  46.4M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  280|  46.4M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (641:9): [True: 1.06M, False: 45.3M]
  ------------------
  642|  1.09M|    {
  643|  1.09M|        *(void**)pItem = NULL;
  644|  1.09M|    }
  645|  45.3M|    else if (PB_LTYPE_IS_SUBMSG(field->type))
  ------------------
  |  |  329|  45.3M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  45.3M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  45.3M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  90.7M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 192k, False: 45.2M]
  |  |  ------------------
  |  |  330|  45.3M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  45.2M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  45.2M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  45.2M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 45.2M]
  |  |  ------------------
  ------------------
  646|   192k|    {
  647|       |        /* We memset to zero so that any callbacks are set to NULL.
  648|       |         * Default values will be set by pb_dec_submessage(). */
  649|   192k|        memset(pItem, 0, field->data_size);
  650|   192k|    }
  651|  46.4M|}
pb_decode.c:decode_callback_field:
  783|  9.89k|{
  784|       |    /* Clear any data that may have been decoded for another oneof field
  785|       |     * that has come before this callback field.
  786|       |     */
  787|  9.89k|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  9.89k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  9.89k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  9.89k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (787:9): [True: 9.89k, False: 0]
  ------------------
  788|  9.89k|    {
  789|  9.89k|        if (*(pb_size_t*)field->pSize != 0 && *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (789:13): [True: 9.35k, False: 549]
  |  Branch (789:47): [True: 1.84k, False: 7.50k]
  ------------------
  790|  1.84k|        {
  791|  1.84k|            memset(field->pData, 0, (size_t)field->data_size);
  792|  1.84k|        }
  793|  9.89k|        *(pb_size_t*)field->pSize = field->tag;
  794|  9.89k|    }
  795|       |
  796|  9.89k|    if (!field->descriptor->field_callback)
  ------------------
  |  Branch (796:9): [True: 0, False: 9.89k]
  ------------------
  797|      0|        return pb_skip_field(stream, wire_type);
  798|       |
  799|  9.89k|    if (wire_type == PB_WT_STRING)
  ------------------
  |  Branch (799:9): [True: 2.68k, False: 7.21k]
  ------------------
  800|  2.68k|    {
  801|  2.68k|        pb_istream_t substream;
  802|  2.68k|        size_t prev_bytes_left;
  803|       |        
  804|  2.68k|        if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (804:13): [True: 44, False: 2.64k]
  ------------------
  805|     44|            return false;
  806|       |
  807|       |        /* If the callback field is inside a submsg, first call the submsg_callback which
  808|       |         * should set the decoder for the callback field. */
  809|  2.64k|        if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  328|  2.64k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  2.64k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  293|  5.28k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (809:13): [True: 0, False: 2.64k]
  |  Branch (809:62): [True: 0, False: 0]
  ------------------
  810|      0|            pb_callback_t* callback;
  811|      0|            *(pb_size_t*)field->pSize = field->tag;
  812|      0|            callback = (pb_callback_t*)field->pSize - 1;
  813|       |
  814|      0|            if (callback->funcs.decode)
  ------------------
  |  Branch (814:17): [True: 0, False: 0]
  ------------------
  815|      0|            {
  816|      0|                if (!callback->funcs.decode(&substream, field, &callback->arg)) {
  ------------------
  |  Branch (816:21): [True: 0, False: 0]
  ------------------
  817|      0|                    PB_SET_ERROR(stream, substream.errmsg ? substream.errmsg : "submsg callback failed");
  ------------------
  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  ------------------
  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  Branch (919:92): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  818|      0|                    return false;
  819|      0|                }
  820|      0|            }
  821|      0|        }
  822|       |        
  823|  2.64k|        do
  824|  2.64k|        {
  825|  2.64k|            prev_bytes_left = substream.bytes_left;
  826|  2.64k|            if (!field->descriptor->field_callback(&substream, NULL, field))
  ------------------
  |  Branch (826:17): [True: 0, False: 2.64k]
  ------------------
  827|      0|            {
  828|      0|                PB_SET_ERROR(stream, substream.errmsg ? substream.errmsg : "callback failed");
  ------------------
  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  ------------------
  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  Branch (919:92): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  829|      0|                return false;
  830|      0|            }
  831|  2.64k|        } while (substream.bytes_left > 0 && substream.bytes_left < prev_bytes_left);
  ------------------
  |  Branch (831:18): [True: 596, False: 2.04k]
  |  Branch (831:46): [True: 0, False: 596]
  ------------------
  832|       |        
  833|  2.64k|        if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (833:13): [True: 0, False: 2.64k]
  ------------------
  834|      0|            return false;
  835|       |
  836|  2.64k|        return true;
  837|  2.64k|    }
  838|  7.21k|    else
  839|  7.21k|    {
  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|  7.21k|        pb_istream_t substream;
  845|  7.21k|        pb_byte_t buffer[10];
  846|  7.21k|        size_t size = sizeof(buffer);
  847|       |        
  848|  7.21k|        if (!read_raw_value(stream, wire_type, buffer, &size))
  ------------------
  |  Branch (848:13): [True: 47, False: 7.16k]
  ------------------
  849|     47|            return false;
  850|  7.16k|        substream = pb_istream_from_buffer(buffer, size);
  851|       |        
  852|       |        return field->descriptor->field_callback(&substream, NULL, field);
  853|  7.21k|    }
  854|  9.89k|}
pb_decode.c:read_raw_value:
  342|  7.21k|{
  343|  7.21k|    size_t max_size = *size;
  344|  7.21k|    switch (wire_type)
  345|  7.21k|    {
  346|  2.73k|        case PB_WT_VARINT:
  ------------------
  |  Branch (346:9): [True: 2.73k, False: 4.47k]
  ------------------
  347|  2.73k|            *size = 0;
  348|  2.73k|            do
  349|  6.30k|            {
  350|  6.30k|                (*size)++;
  351|  6.30k|                if (*size > max_size)
  ------------------
  |  Branch (351:21): [True: 3, False: 6.29k]
  ------------------
  352|      3|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  923|      3|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      3|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  353|       |
  354|  6.29k|                if (!pb_read(stream, buf, 1))
  ------------------
  |  Branch (354:21): [True: 29, False: 6.27k]
  ------------------
  355|     29|                    return false;
  356|  6.29k|            } while (*buf++ & 0x80);
  ------------------
  |  Branch (356:22): [True: 3.56k, False: 2.70k]
  ------------------
  357|  2.70k|            return true;
  358|       |            
  359|  2.01k|        case PB_WT_64BIT:
  ------------------
  |  Branch (359:9): [True: 2.01k, False: 5.20k]
  ------------------
  360|  2.01k|            *size = 8;
  361|  2.01k|            return pb_read(stream, buf, 8);
  362|       |        
  363|  2.46k|        case PB_WT_32BIT:
  ------------------
  |  Branch (363:9): [True: 2.46k, False: 4.74k]
  ------------------
  364|  2.46k|            *size = 4;
  365|  2.46k|            return pb_read(stream, buf, 4);
  366|       |        
  367|      0|        case PB_WT_STRING:
  ------------------
  |  Branch (367:9): [True: 0, False: 7.21k]
  ------------------
  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: 7.21k]
  ------------------
  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|      2|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  923|      2|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      2|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (379:9): [True: 2, False: 7.21k]
  ------------------
  380|  7.21k|    }
  381|  7.21k|}
pb_decode.c:pb_release_single_field:
 1286|  1.20M|{
 1287|  1.20M|    pb_type_t type;
 1288|  1.20M|    type = field->type;
 1289|       |
 1290|  1.20M|    if (PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  1.20M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  1.20M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  1.20M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (1290:9): [True: 74.4k, False: 1.13M]
  ------------------
 1291|  74.4k|    {
 1292|  74.4k|        if (*(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (1292:13): [True: 59.8k, False: 14.6k]
  ------------------
 1293|  59.8k|            return; /* This is not the current field in the union */
 1294|  74.4k|    }
 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.14M|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  1.14M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.14M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  1.14M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1299:9): [True: 8.79k, False: 1.13M]
  ------------------
 1300|  8.79k|    {
 1301|       |        /* Release fields from all extensions in the linked list */
 1302|  8.79k|        pb_extension_t *ext = *(pb_extension_t**)field->pData;
 1303|  15.9k|        while (ext != NULL)
  ------------------
  |  Branch (1303:16): [True: 7.17k, False: 8.79k]
  ------------------
 1304|  7.17k|        {
 1305|  7.17k|            pb_field_iter_t ext_iter;
 1306|  7.17k|            if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (1306:17): [True: 7.17k, False: 0]
  ------------------
 1307|  7.17k|            {
 1308|  7.17k|                pb_release_single_field(&ext_iter);
 1309|  7.17k|            }
 1310|  7.17k|            ext = ext->next;
 1311|  7.17k|        }
 1312|  8.79k|    }
 1313|  1.13M|    else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  329|  2.27M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  1.13M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  1.13M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  2.27M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 146k, False: 992k]
  |  |  ------------------
  |  |  330|  2.27M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|   992k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|   992k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|   992k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 992k]
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  326|   146k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   146k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|   146k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (1313:42): [True: 144k, False: 1.75k]
  ------------------
 1314|   144k|    {
 1315|       |        /* Release fields in submessage or submsg array */
 1316|   144k|        pb_size_t count = 1;
 1317|       |        
 1318|   144k|        if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   144k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   144k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   144k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1318:13): [True: 136k, False: 8.92k]
  ------------------
 1319|   136k|        {
 1320|   136k|            field->pData = *(void**)field->pField;
 1321|   136k|        }
 1322|  8.92k|        else
 1323|  8.92k|        {
 1324|  8.92k|            field->pData = field->pField;
 1325|  8.92k|        }
 1326|       |        
 1327|   144k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|   144k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   144k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|   144k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1327:13): [True: 17.5k, False: 127k]
  ------------------
 1328|  17.5k|        {
 1329|  17.5k|            count = *(pb_size_t*)field->pSize;
 1330|       |
 1331|  17.5k|            if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > field->array_size)
  ------------------
  |  |  326|  17.5k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  17.5k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > field->array_size)
  ------------------
  |  |  321|  35.1k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1331:17): [True: 0, False: 17.5k]
  |  Branch (1331:54): [True: 0, False: 0]
  ------------------
 1332|      0|            {
 1333|       |                /* Protect against corrupted _count fields */
 1334|      0|                count = field->array_size;
 1335|      0|            }
 1336|  17.5k|        }
 1337|       |        
 1338|   144k|        if (field->pData)
  ------------------
  |  Branch (1338:13): [True: 100k, False: 44.4k]
  ------------------
 1339|   100k|        {
 1340|   301k|            for (; count > 0; count--)
  ------------------
  |  Branch (1340:20): [True: 200k, False: 100k]
  ------------------
 1341|   200k|            {
 1342|   200k|                pb_release(field->submsg_desc, field->pData);
 1343|   200k|                field->pData = (char*)field->pData + field->data_size;
 1344|   200k|            }
 1345|   100k|        }
 1346|   144k|    }
 1347|       |    
 1348|  1.14M|    if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  1.14M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  1.14M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  1.14M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1348:9): [True: 1.12M, False: 28.0k]
  ------------------
 1349|  1.12M|    {
 1350|  1.12M|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  327|  1.12M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  1.12M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  314|  2.24M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1350:13): [True: 184k, False: 935k]
  ------------------
 1351|   184k|            (PB_LTYPE(type) == PB_LTYPE_STRING ||
  ------------------
  |  |  328|   184k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   184k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          (PB_LTYPE(type) == PB_LTYPE_STRING ||
  ------------------
  |  |  284|   369k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (1351:14): [True: 8.79k, False: 175k]
  ------------------
 1352|   175k|             PB_LTYPE(type) == PB_LTYPE_BYTES))
  ------------------
  |  |  328|   175k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   175k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                           PB_LTYPE(type) == PB_LTYPE_BYTES))
  ------------------
  |  |  280|   175k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (1352:14): [True: 8.79k, False: 167k]
  ------------------
 1353|  17.5k|        {
 1354|       |            /* Release entries in repeated string or bytes array */
 1355|  17.5k|            void **pItem = *(void***)field->pField;
 1356|  17.5k|            pb_size_t count = *(pb_size_t*)field->pSize;
 1357|  1.10M|            for (; count > 0; count--)
  ------------------
  |  Branch (1357:20): [True: 1.09M, False: 17.5k]
  ------------------
 1358|  1.09M|            {
 1359|  1.09M|                pb_free(*pItem);
  ------------------
  |  |    4|  1.09M|#define pb_free(ptr) free_with_check(ptr)
  ------------------
 1360|  1.09M|                *pItem++ = NULL;
 1361|  1.09M|            }
 1362|  17.5k|        }
 1363|       |        
 1364|  1.12M|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|  1.12M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  1.12M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|  1.12M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1364:13): [True: 184k, False: 935k]
  ------------------
 1365|   184k|        {
 1366|       |            /* We are going to release the array, so set the size to 0 */
 1367|   184k|            *(pb_size_t*)field->pSize = 0;
 1368|   184k|        }
 1369|       |        
 1370|       |        /* Release main pointer */
 1371|  1.12M|        pb_free(*(void**)field->pField);
  ------------------
  |  |    4|  1.12M|#define pb_free(ptr) free_with_check(ptr)
  ------------------
 1372|       |        *(void**)field->pField = NULL;
 1373|  1.12M|    }
 1374|  1.14M|}

pb_ostream_from_buffer:
   73|  3.01k|{
   74|  3.01k|    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.01k|    stream.callback = &buf_write;
   83|  3.01k|#endif
   84|  3.01k|    stream.state = buf;
   85|  3.01k|    stream.max_size = bufsize;
   86|  3.01k|    stream.bytes_written = 0;
   87|  3.01k|#ifndef PB_NO_ERRMSG
   88|       |    stream.errmsg = NULL;
   89|  3.01k|#endif
   90|  3.01k|    return stream;
   91|  3.01k|}
pb_write:
   94|  42.4M|{
   95|  42.4M|    if (count > 0 && stream->callback != NULL)
  ------------------
  |  Branch (95:9): [True: 41.9M, False: 472k]
  |  Branch (95:22): [True: 36.1M, False: 5.83M]
  ------------------
   96|  36.1M|    {
   97|  36.1M|        if (stream->bytes_written + count < stream->bytes_written ||
  ------------------
  |  Branch (97:13): [True: 0, False: 36.1M]
  ------------------
   98|  36.1M|            stream->bytes_written + count > stream->max_size)
  ------------------
  |  Branch (98:13): [True: 182, False: 36.1M]
  ------------------
   99|    182|        {
  100|    182|            PB_RETURN_ERROR(stream, "stream full");
  ------------------
  |  |  923|    182|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|    182|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 182]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  101|    182|        }
  102|       |
  103|       |#ifdef PB_BUFFER_ONLY
  104|       |        if (!buf_write(stream, buf, count))
  105|       |            PB_RETURN_ERROR(stream, "io error");
  106|       |#else        
  107|  36.1M|        if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (107:13): [True: 0, False: 36.1M]
  ------------------
  108|      0|            PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  109|  36.1M|#endif
  110|  36.1M|    }
  111|       |    
  112|  42.4M|    stream->bytes_written += count;
  113|       |    return true;
  114|  42.4M|}
pb_encode:
  522|   127k|{
  523|   127k|    pb_field_iter_t iter;
  524|   127k|    if (!pb_field_iter_begin_const(&iter, fields, src_struct))
  ------------------
  |  Branch (524:9): [True: 43.2k, False: 84.0k]
  ------------------
  525|  43.2k|        return true; /* Empty message type */
  526|       |    
  527|   503k|    do {
  528|   503k|        if (PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|   503k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   503k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|   503k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (528:13): [True: 2.86k, False: 500k]
  ------------------
  529|  2.86k|        {
  530|       |            /* Special case for the extension field placeholder */
  531|  2.86k|            if (!encode_extension_field(stream, &iter))
  ------------------
  |  Branch (531:17): [True: 39, False: 2.82k]
  ------------------
  532|     39|                return false;
  533|  2.86k|        }
  534|   500k|        else
  535|   500k|        {
  536|       |            /* Regular field */
  537|   500k|            if (!encode_field(stream, &iter))
  ------------------
  |  Branch (537:17): [True: 191, False: 500k]
  ------------------
  538|    191|                return false;
  539|   500k|        }
  540|   503k|    } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (540:14): [True: 419k, False: 83.8k]
  ------------------
  541|       |    
  542|  83.8k|    return true;
  543|  84.0k|}
pb_encode_varint:
  617|  32.1M|{
  618|  32.1M|    if (value <= 0x7F)
  ------------------
  |  Branch (618:9): [True: 18.7M, False: 13.4M]
  ------------------
  619|  18.7M|    {
  620|       |        /* Fast path: single byte */
  621|  18.7M|        pb_byte_t byte = (pb_byte_t)value;
  622|  18.7M|        return pb_write(stream, &byte, 1);
  623|  18.7M|    }
  624|  13.4M|    else
  625|  13.4M|    {
  626|       |#ifdef PB_WITHOUT_64BIT
  627|       |        return pb_encode_varint_32(stream, value, 0);
  628|       |#else
  629|  13.4M|        return pb_encode_varint_32(stream, (uint32_t)value, (uint32_t)(value >> 32));
  630|  13.4M|#endif
  631|  13.4M|    }
  632|  32.1M|}
pb_encode_svarint:
  635|  4.29M|{
  636|  4.29M|    pb_uint64_t zigzagged;
  ------------------
  |  |   46|  4.29M|#define pb_uint64_t uint64_t
  ------------------
  637|  4.29M|    pb_uint64_t mask = ((pb_uint64_t)-1) >> 1; /* Satisfy clang -fsanitize=integer */
  ------------------
  |  |   46|  4.29M|#define pb_uint64_t uint64_t
  ------------------
  638|  4.29M|    if (value < 0)
  ------------------
  |  Branch (638:9): [True: 474k, False: 3.82M]
  ------------------
  639|   474k|        zigzagged = ~(((pb_uint64_t)value & mask) << 1);
  640|  3.82M|    else
  641|  3.82M|        zigzagged = (pb_uint64_t)value << 1;
  642|       |    
  643|  4.29M|    return pb_encode_varint(stream, zigzagged);
  644|  4.29M|}
pb_encode_fixed32:
  647|  22.6k|{
  648|  22.6k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
  649|       |    /* Fast path if we know that we're on little endian */
  650|  22.6k|    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|  22.6k|}
pb_encode_fixed64:
  664|  13.2k|{
  665|  13.2k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
  666|       |    /* Fast path if we know that we're on little endian */
  667|  13.2k|    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|  13.2k|}
pb_encode_tag:
  685|  10.5M|{
  686|  10.5M|    pb_uint64_t tag = ((pb_uint64_t)field_number << 3) | wiretype;
  ------------------
  |  |   46|  10.5M|#define pb_uint64_t uint64_t
  ------------------
  687|  10.5M|    return pb_encode_varint(stream, tag);
  688|  10.5M|}
pb_encode_tag_for_field:
  691|  10.5M|{
  692|  10.5M|    pb_wire_type_t wiretype;
  693|  10.5M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  328|  10.5M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  10.5M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  694|  10.5M|    {
  695|  3.12k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  268|  3.12k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (695:9): [True: 3.12k, False: 10.5M]
  ------------------
  696|   133k|        case PB_LTYPE_VARINT:
  ------------------
  |  |  269|   133k|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (696:9): [True: 130k, False: 10.3M]
  ------------------
  697|   177k|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  270|   177k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (697:9): [True: 44.0k, False: 10.4M]
  ------------------
  698|   195k|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  271|   195k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (698:9): [True: 17.8k, False: 10.5M]
  ------------------
  699|   195k|            wiretype = PB_WT_VARINT;
  700|   195k|            break;
  701|       |        
  702|  17.3k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  272|  17.3k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (702:9): [True: 17.3k, False: 10.5M]
  ------------------
  703|  17.3k|            wiretype = PB_WT_32BIT;
  704|  17.3k|            break;
  705|       |        
  706|  9.34k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  273|  9.34k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (706:9): [True: 9.34k, False: 10.5M]
  ------------------
  707|  9.34k|            wiretype = PB_WT_64BIT;
  708|  9.34k|            break;
  709|       |        
  710|   413k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  280|   413k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (710:9): [True: 413k, False: 10.1M]
  ------------------
  711|   488k|        case PB_LTYPE_STRING:
  ------------------
  |  |  284|   488k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (711:9): [True: 75.2k, False: 10.4M]
  ------------------
  712|   550k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  288|   550k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (712:9): [True: 62.2k, False: 10.4M]
  ------------------
  713|   550k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  293|   550k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (713:9): [True: 0, False: 10.5M]
  ------------------
  714|  10.2M|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  303|  10.2M|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (714:9): [True: 9.74M, False: 772k]
  ------------------
  715|  10.2M|            wiretype = PB_WT_STRING;
  716|  10.2M|            break;
  717|       |        
  718|      0|        default:
  ------------------
  |  Branch (718:9): [True: 0, False: 10.5M]
  ------------------
  719|      0|            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  720|  10.5M|    }
  721|       |    
  722|  10.5M|    return pb_encode_tag(stream, wiretype, field->tag);
  723|  10.5M|}
pb_encode_string:
  726|  10.2M|{
  727|  10.2M|    if (!pb_encode_varint(stream, (pb_uint64_t)size))
  ------------------
  |  Branch (727:9): [True: 9, False: 10.2M]
  ------------------
  728|      9|        return false;
  729|       |    
  730|  10.2M|    return pb_write(stream, buffer, size);
  731|  10.2M|}
pb_encode_submessage:
  734|  62.1k|{
  735|       |    /* First calculate the message size using a non-writing substream. */
  736|  62.1k|    pb_ostream_t substream = PB_OSTREAM_SIZING;
  ------------------
  |  |  126|  62.1k|#define PB_OSTREAM_SIZING {0,0,0,0,0}
  ------------------
  737|  62.1k|#if !defined(PB_NO_ENCODE_SIZE_CHECK) || PB_NO_ENCODE_SIZE_CHECK == 0
  738|  62.1k|    bool status;
  739|  62.1k|    size_t size;
  740|  62.1k|#endif
  741|       |    
  742|  62.1k|    if (!pb_encode(&substream, fields, src_struct))
  ------------------
  |  Branch (742:9): [True: 0, False: 62.1k]
  ------------------
  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|  62.1k|    if (!pb_encode_varint(stream, (pb_uint64_t)substream.bytes_written))
  ------------------
  |  Branch (750:9): [True: 21, False: 62.1k]
  ------------------
  751|     21|        return false;
  752|       |    
  753|  62.1k|    if (stream->callback == NULL)
  ------------------
  |  Branch (753:9): [True: 0, False: 62.1k]
  ------------------
  754|      0|        return pb_write(stream, NULL, substream.bytes_written); /* Just sizing */
  755|       |    
  756|  62.1k|    if (stream->bytes_written + substream.bytes_written > stream->max_size)
  ------------------
  |  Branch (756:9): [True: 48, False: 62.1k]
  ------------------
  757|     48|        PB_RETURN_ERROR(stream, "stream full");
  ------------------
  |  |  923|     48|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     48|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 48]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|  62.1k|    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|  62.1k|    substream.callback = stream->callback;
  766|  62.1k|    substream.state = stream->state;
  767|  62.1k|    substream.max_size = size;
  768|  62.1k|    substream.bytes_written = 0;
  769|  62.1k|#ifndef PB_NO_ERRMSG
  770|  62.1k|    substream.errmsg = NULL;
  771|  62.1k|#endif
  772|       |    
  773|  62.1k|    status = pb_encode(&substream, fields, src_struct);
  774|       |    
  775|  62.1k|    stream->bytes_written += substream.bytes_written;
  776|  62.1k|    stream->state = substream.state;
  777|  62.1k|#ifndef PB_NO_ERRMSG
  778|  62.1k|    stream->errmsg = substream.errmsg;
  779|  62.1k|#endif
  780|       |    
  781|  62.1k|    if (substream.bytes_written != size)
  ------------------
  |  Branch (781:9): [True: 0, False: 62.1k]
  ------------------
  782|      0|        PB_RETURN_ERROR(stream, "submsg size changed");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  783|       |
  784|  62.1k|    return status;
  785|  62.1k|#endif
  786|  62.1k|}
pb_encode.c:buf_write:
   54|  36.1M|{
   55|  36.1M|    pb_byte_t *dest = (pb_byte_t*)stream->state;
   56|  36.1M|    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|  36.1M|    if (buf != NULL)
  ------------------
  |  Branch (64:9): [True: 36.1M, False: 0]
  ------------------
   65|  36.1M|    {
   66|  36.1M|        memcpy(dest, buf, count * sizeof(pb_byte_t));
   67|  36.1M|    }
   68|       |
   69|       |    return true;
   70|  36.1M|}
pb_encode.c:encode_extension_field:
  497|  2.86k|{
  498|  2.86k|    const pb_extension_t *extension = *(const pb_extension_t* const *)field->pData;
  499|       |
  500|  5.69k|    while (extension)
  ------------------
  |  Branch (500:12): [True: 2.86k, False: 2.82k]
  ------------------
  501|  2.86k|    {
  502|  2.86k|        bool status;
  503|  2.86k|        if (extension->type->encode)
  ------------------
  |  Branch (503:13): [True: 0, False: 2.86k]
  ------------------
  504|      0|            status = extension->type->encode(stream, extension);
  505|  2.86k|        else
  506|  2.86k|            status = default_extension_encoder(stream, extension);
  507|       |
  508|  2.86k|        if (!status)
  ------------------
  |  Branch (508:13): [True: 39, False: 2.82k]
  ------------------
  509|     39|            return false;
  510|       |        
  511|  2.82k|        extension = extension->next;
  512|  2.82k|    }
  513|       |    
  514|  2.82k|    return true;
  515|  2.86k|}
pb_encode.c:default_extension_encoder:
  484|  2.86k|{
  485|  2.86k|    pb_field_iter_t iter;
  486|       |
  487|  2.86k|    if (!pb_field_iter_begin_extension_const(&iter, extension))
  ------------------
  |  Branch (487:9): [True: 0, False: 2.86k]
  ------------------
  488|      0|        PB_RETURN_ERROR(stream, "invalid extension");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  489|       |
  490|  2.86k|    return encode_field(stream, &iter);
  491|  2.86k|}
pb_encode.c:encode_field:
  428|   503k|{
  429|       |    /* Check field presence */
  430|   503k|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|   503k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   503k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|   503k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (430:9): [True: 20.4k, False: 483k]
  ------------------
  431|  20.4k|    {
  432|  20.4k|        if (*(const pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (432:13): [True: 19.9k, False: 578]
  ------------------
  433|  19.9k|        {
  434|       |            /* Different type oneof field */
  435|  19.9k|            return true;
  436|  19.9k|        }
  437|  20.4k|    }
  438|   483k|    else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL)
  ------------------
  |  |  327|   483k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   483k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL)
  ------------------
  |  |  312|   483k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (438:14): [True: 122k, False: 360k]
  ------------------
  439|   122k|    {
  440|   122k|        if (field->pSize)
  ------------------
  |  Branch (440:13): [True: 5.67k, False: 117k]
  ------------------
  441|  5.67k|        {
  442|  5.67k|            if (safe_read_bool(field->pSize) == false)
  ------------------
  |  Branch (442:17): [True: 5.45k, False: 215]
  ------------------
  443|  5.45k|            {
  444|       |                /* Missing optional field */
  445|  5.45k|                return true;
  446|  5.45k|            }
  447|  5.67k|        }
  448|   117k|        else if (PB_ATYPE(field->type) == PB_ATYPE_STATIC)
  ------------------
  |  |  326|   117k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   117k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      else if (PB_ATYPE(field->type) == PB_ATYPE_STATIC)
  ------------------
  |  |  321|   117k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (448:18): [True: 0, False: 117k]
  ------------------
  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|   122k|    }
  455|       |
  456|   478k|    if (!field->pData)
  ------------------
  |  Branch (456:9): [True: 163k, False: 314k]
  ------------------
  457|   163k|    {
  458|   163k|        if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED)
  ------------------
  |  |  327|   163k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   163k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED)
  ------------------
  |  |  311|   163k|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (458:13): [True: 0, False: 163k]
  ------------------
  459|      0|            PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  460|       |
  461|       |        /* Pointer field set to NULL */
  462|   163k|        return true;
  463|   163k|    }
  464|       |
  465|       |    /* Then encode field contents */
  466|   314k|    if (PB_ATYPE(field->type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  326|   314k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   314k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|   314k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (466:9): [True: 122, False: 314k]
  ------------------
  467|    122|    {
  468|    122|        return encode_callback_field(stream, field);
  469|    122|    }
  470|   314k|    else if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|   314k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   314k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|   314k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (470:14): [True: 6.07k, False: 308k]
  ------------------
  471|  6.07k|    {
  472|  6.07k|        return encode_array(stream, field);
  473|  6.07k|    }
  474|   308k|    else
  475|   308k|    {
  476|   308k|        return encode_basic_field(stream, field);
  477|   308k|    }
  478|   314k|}
pb_encode.c:safe_read_bool:
  125|  8.80k|{
  126|  8.80k|    const char *p = (const char *)pSize;
  127|  8.80k|    size_t i;
  128|  15.9k|    for (i = 0; i < sizeof(bool); i++)
  ------------------
  |  Branch (128:17): [True: 8.80k, False: 7.12k]
  ------------------
  129|  8.80k|    {
  130|  8.80k|        if (p[i] != 0)
  ------------------
  |  Branch (130:13): [True: 1.67k, False: 7.12k]
  ------------------
  131|  1.67k|            return true;
  132|  8.80k|    }
  133|  7.12k|    return false;
  134|  8.80k|}
pb_encode.c:encode_callback_field:
  417|    122|{
  418|    122|    if (field->descriptor->field_callback != NULL)
  ------------------
  |  Branch (418:9): [True: 122, False: 0]
  ------------------
  419|    122|    {
  420|    122|        if (!field->descriptor->field_callback(NULL, stream, field))
  ------------------
  |  Branch (420:13): [True: 0, False: 122]
  ------------------
  421|      0|            PB_RETURN_ERROR(stream, "callback error");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  422|    122|    }
  423|    122|    return true;
  424|    122|}
pb_encode.c:encode_array:
  138|  6.07k|{
  139|  6.07k|    pb_size_t i;
  140|  6.07k|    pb_size_t count;
  141|  6.07k|#ifndef PB_ENCODE_ARRAYS_UNPACKED
  142|  6.07k|    size_t size;
  143|  6.07k|#endif
  144|       |
  145|  6.07k|    count = *(pb_size_t*)field->pSize;
  146|       |
  147|  6.07k|    if (count == 0)
  ------------------
  |  Branch (147:9): [True: 0, False: 6.07k]
  ------------------
  148|      0|        return true;
  149|       |
  150|  6.07k|    if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size)
  ------------------
  |  |  326|  6.07k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  6.07k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size)
  ------------------
  |  |  322|  12.1k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (150:9): [True: 0, False: 6.07k]
  |  Branch (150:54): [True: 0, False: 0]
  ------------------
  151|      0|        PB_RETURN_ERROR(stream, "array max size exceeded");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  152|       |    
  153|  6.07k|#ifndef PB_ENCODE_ARRAYS_UNPACKED
  154|       |    /* We always pack arrays if the datatype allows it. */
  155|  6.07k|    if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  328|  6.07k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  6.07k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  276|  6.07k|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (155:9): [True: 2.83k, False: 3.24k]
  ------------------
  156|  2.83k|    {
  157|  2.83k|        if (!pb_encode_tag(stream, PB_WT_STRING, field->tag))
  ------------------
  |  Branch (157:13): [True: 2, False: 2.83k]
  ------------------
  158|      2|            return false;
  159|       |        
  160|       |        /* Determine the total size of packed array. */
  161|  2.83k|        if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32)
  ------------------
  |  |  328|  2.83k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  2.83k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32)
  ------------------
  |  |  272|  2.83k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (161:13): [True: 443, False: 2.38k]
  ------------------
  162|    443|        {
  163|    443|            size = 4 * (size_t)count;
  164|    443|        }
  165|  2.38k|        else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  328|  2.38k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  2.38k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  273|  2.38k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (165:18): [True: 235, False: 2.15k]
  ------------------
  166|    235|        {
  167|    235|            size = 8 * (size_t)count;
  168|    235|        }
  169|  2.15k|        else
  170|  2.15k|        { 
  171|  2.15k|            pb_ostream_t sizestream = PB_OSTREAM_SIZING;
  ------------------
  |  |  126|  2.15k|#define PB_OSTREAM_SIZING {0,0,0,0,0}
  ------------------
  172|  2.15k|            void *pData_orig = field->pData;
  173|  5.59M|            for (i = 0; i < count; i++)
  ------------------
  |  Branch (173:25): [True: 5.59M, False: 2.15k]
  ------------------
  174|  5.59M|            {
  175|  5.59M|                if (!pb_enc_varint(&sizestream, field))
  ------------------
  |  Branch (175:21): [True: 0, False: 5.59M]
  ------------------
  176|      0|                    PB_RETURN_ERROR(stream, PB_GET_ERROR(&sizestream));
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  |  Branch (919:92): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  177|  5.59M|                field->pData = (char*)field->pData + field->data_size;
  178|  5.59M|            }
  179|  2.15k|            field->pData = pData_orig;
  180|  2.15k|            size = sizestream.bytes_written;
  181|  2.15k|        }
  182|       |        
  183|  2.83k|        if (!pb_encode_varint(stream, (pb_uint64_t)size))
  ------------------
  |  Branch (183:13): [True: 2, False: 2.82k]
  ------------------
  184|      2|            return false;
  185|       |        
  186|  2.82k|        if (stream->callback == NULL)
  ------------------
  |  Branch (186:13): [True: 0, False: 2.82k]
  ------------------
  187|      0|            return pb_write(stream, NULL, size); /* Just sizing.. */
  188|       |        
  189|       |        /* Write the data */
  190|  5.59M|        for (i = 0; i < count; i++)
  ------------------
  |  Branch (190:21): [True: 5.58M, False: 2.82k]
  ------------------
  191|  5.58M|        {
  192|  5.58M|            if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  328|  5.58M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  5.58M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  272|  11.1M|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  328|  5.58M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  5.58M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  273|  5.58M|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (192:17): [True: 5.22k, False: 5.58M]
  |  Branch (192:62): [True: 3.86k, False: 5.57M]
  ------------------
  193|  9.08k|            {
  194|  9.08k|                if (!pb_enc_fixed(stream, field))
  ------------------
  |  Branch (194:21): [True: 2, False: 9.08k]
  ------------------
  195|      2|                    return false;
  196|  9.08k|            }
  197|  5.57M|            else
  198|  5.57M|            {
  199|  5.57M|                if (!pb_enc_varint(stream, field))
  ------------------
  |  Branch (199:21): [True: 5, False: 5.57M]
  ------------------
  200|      5|                    return false;
  201|  5.57M|            }
  202|       |
  203|  5.58M|            field->pData = (char*)field->pData + field->data_size;
  204|  5.58M|        }
  205|  2.82k|    }
  206|  3.24k|    else /* Unpacked fields */
  207|  3.24k|#endif
  208|  3.24k|    {
  209|  10.2M|        for (i = 0; i < count; i++)
  ------------------
  |  Branch (209:21): [True: 10.2M, False: 3.20k]
  ------------------
  210|  10.2M|        {
  211|       |            /* Normally the data is stored directly in the array entries, but
  212|       |             * for pointer-type string and bytes fields, the array entries are
  213|       |             * actually pointers themselves also. So we have to dereference once
  214|       |             * more to get to the actual data. */
  215|  10.2M|            if (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  326|  10.2M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  10.2M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  322|  20.4M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (215:17): [True: 10.2M, False: 0]
  ------------------
  216|  10.2M|                (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  328|  10.2M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  10.2M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  284|  20.4M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (216:18): [True: 13.8k, False: 10.1M]
  ------------------
  217|  10.1M|                 PB_LTYPE(field->type) == PB_LTYPE_BYTES))
  ------------------
  |  |  328|  10.1M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  10.1M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                               PB_LTYPE(field->type) == PB_LTYPE_BYTES))
  ------------------
  |  |  280|  10.1M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (217:18): [True: 409k, False: 9.78M]
  ------------------
  218|   423k|            {
  219|   423k|                bool status;
  220|   423k|                void *pData_orig = field->pData;
  221|   423k|                field->pData = *(void* const*)field->pData;
  222|       |
  223|   423k|                if (!field->pData)
  ------------------
  |  Branch (223:21): [True: 0, False: 423k]
  ------------------
  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|   423k|                else
  230|   423k|                {
  231|   423k|                    status = encode_basic_field(stream, field);
  232|   423k|                }
  233|       |
  234|   423k|                field->pData = pData_orig;
  235|       |
  236|   423k|                if (!status)
  ------------------
  |  Branch (236:21): [True: 15, False: 423k]
  ------------------
  237|     15|                    return false;
  238|   423k|            }
  239|  9.78M|            else
  240|  9.78M|            {
  241|  9.78M|                if (!encode_basic_field(stream, field))
  ------------------
  |  Branch (241:21): [True: 25, False: 9.78M]
  ------------------
  242|     25|                    return false;
  243|  9.78M|            }
  244|  10.2M|            field->pData = (char*)field->pData + field->data_size;
  245|  10.2M|        }
  246|  3.24k|    }
  247|       |    
  248|  6.02k|    return true;
  249|  6.07k|}
pb_encode.c:pb_enc_varint:
  798|  11.3M|{
  799|  11.3M|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  328|  11.3M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  11.3M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  270|  11.3M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (799:9): [True: 1.05M, False: 10.3M]
  ------------------
  800|  1.05M|    {
  801|       |        /* Perform unsigned integer extension */
  802|  1.05M|        pb_uint64_t value = 0;
  ------------------
  |  |   46|  1.05M|#define pb_uint64_t uint64_t
  ------------------
  803|       |
  804|  1.05M|        if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (804:13): [True: 5.82k, False: 1.04M]
  ------------------
  805|  5.82k|            value = *(const uint_least8_t*)field->pData;
  806|  1.04M|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (806:18): [True: 5.82k, False: 1.04M]
  ------------------
  807|  5.82k|            value = *(const uint_least16_t*)field->pData;
  808|  1.04M|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (808:18): [True: 690k, False: 349k]
  ------------------
  809|   690k|            value = *(const uint32_t*)field->pData;
  810|   349k|        else if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (810:18): [True: 349k, False: 0]
  ------------------
  811|   349k|            value = *(const pb_uint64_t*)field->pData;
  812|      0|        else
  813|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  814|       |
  815|  1.05M|        return pb_encode_varint(stream, value);
  816|  1.05M|    }
  817|  10.3M|    else
  818|  10.3M|    {
  819|       |        /* Perform signed integer extension */
  820|  10.3M|        pb_int64_t value = 0;
  ------------------
  |  |   45|  10.3M|#define pb_int64_t int64_t
  ------------------
  821|       |
  822|  10.3M|        if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (822:13): [True: 1.61M, False: 8.70M]
  ------------------
  823|  1.61M|            value = *(const int_least8_t*)field->pData;
  824|  8.70M|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (824:18): [True: 11.6k, False: 8.68M]
  ------------------
  825|  11.6k|            value = *(const int_least16_t*)field->pData;
  826|  8.68M|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (826:18): [True: 3.89M, False: 4.79M]
  ------------------
  827|  3.89M|            value = *(const int32_t*)field->pData;
  828|  4.79M|        else if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (828:18): [True: 4.79M, False: 0]
  ------------------
  829|  4.79M|            value = *(const pb_int64_t*)field->pData;
  830|      0|        else
  831|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  832|       |
  833|  10.3M|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  328|  10.3M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  10.3M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  271|  10.3M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (833:13): [True: 4.29M, False: 6.01M]
  ------------------
  834|  4.29M|            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|  6.01M|        else
  840|  6.01M|            return pb_encode_varint(stream, (pb_uint64_t)value);
  841|       |
  842|  10.3M|    }
  843|  11.3M|}
pb_encode.c:pb_enc_fixed:
  846|  35.8k|{
  847|       |#ifdef PB_CONVERT_DOUBLE_FLOAT
  848|       |    if (field->data_size == sizeof(float) && PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  849|       |    {
  850|       |        return pb_encode_float_as_double(stream, *(float*)field->pData);
  851|       |    }
  852|       |#endif
  853|       |
  854|  35.8k|    if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (854:9): [True: 22.6k, False: 13.2k]
  ------------------
  855|  22.6k|    {
  856|  22.6k|        return pb_encode_fixed32(stream, field->pData);
  857|  22.6k|    }
  858|  13.2k|#ifndef PB_WITHOUT_64BIT
  859|  13.2k|    else if (field->data_size == sizeof(uint64_t))
  ------------------
  |  Branch (859:14): [True: 13.2k, False: 0]
  ------------------
  860|  13.2k|    {
  861|  13.2k|        return pb_encode_fixed64(stream, field->pData);
  862|  13.2k|    }
  863|      0|#endif
  864|      0|    else
  865|      0|    {
  866|       |        PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  867|      0|    }
  868|  35.8k|}
pb_encode.c:encode_basic_field:
  372|  10.5M|{
  373|  10.5M|    if (!field->pData)
  ------------------
  |  Branch (373:9): [True: 0, False: 10.5M]
  ------------------
  374|      0|    {
  375|       |        /* Missing pointer field */
  376|      0|        return true;
  377|      0|    }
  378|       |
  379|  10.5M|    if (!pb_encode_tag_for_field(stream, field))
  ------------------
  |  Branch (379:9): [True: 67, False: 10.5M]
  ------------------
  380|     67|        return false;
  381|       |
  382|  10.5M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  328|  10.5M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  10.5M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  383|  10.5M|    {
  384|  3.12k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  268|  3.12k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (384:9): [True: 3.12k, False: 10.5M]
  ------------------
  385|  3.12k|            return pb_enc_bool(stream, field);
  386|       |
  387|   130k|        case PB_LTYPE_VARINT:
  ------------------
  |  |  269|   130k|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (387:9): [True: 130k, False: 10.3M]
  ------------------
  388|   174k|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  270|   174k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (388:9): [True: 44.0k, False: 10.4M]
  ------------------
  389|   192k|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  271|   192k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (389:9): [True: 17.8k, False: 10.5M]
  ------------------
  390|   192k|            return pb_enc_varint(stream, field);
  391|       |
  392|  17.3k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  272|  17.3k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (392:9): [True: 17.3k, False: 10.5M]
  ------------------
  393|  26.7k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  273|  26.7k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (393:9): [True: 9.34k, False: 10.5M]
  ------------------
  394|  26.7k|            return pb_enc_fixed(stream, field);
  395|       |
  396|   413k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  280|   413k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (396:9): [True: 413k, False: 10.1M]
  ------------------
  397|   413k|            return pb_enc_bytes(stream, field);
  398|       |
  399|  75.2k|        case PB_LTYPE_STRING:
  ------------------
  |  |  284|  75.2k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (399:9): [True: 75.2k, False: 10.4M]
  ------------------
  400|  75.2k|            return pb_enc_string(stream, field);
  401|       |
  402|  62.1k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  288|  62.1k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (402:9): [True: 62.1k, False: 10.4M]
  ------------------
  403|  62.1k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  293|  62.1k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (403:9): [True: 0, False: 10.5M]
  ------------------
  404|  62.1k|            return pb_enc_submessage(stream, field);
  405|       |
  406|  9.74M|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  303|  9.74M|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (406:9): [True: 9.74M, False: 772k]
  ------------------
  407|  9.74M|            return pb_enc_fixed_length_bytes(stream, field);
  408|       |
  409|      0|        default:
  ------------------
  |  Branch (409:9): [True: 0, False: 10.5M]
  ------------------
  410|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  411|  10.5M|    }
  412|  10.5M|}
pb_encode.c:pb_enc_bool:
  791|  3.12k|{
  792|  3.12k|    uint32_t value = safe_read_bool(field->pData) ? 1 : 0;
  ------------------
  |  Branch (792:22): [True: 1.45k, False: 1.67k]
  ------------------
  793|  3.12k|    PB_UNUSED(field);
  ------------------
  |  |  172|  3.12k|#define PB_UNUSED(x) (void)(x)
  ------------------
  794|  3.12k|    return pb_encode_varint(stream, value);
  795|  3.12k|}
pb_encode.c:pb_enc_bytes:
  871|   413k|{
  872|   413k|    const pb_bytes_array_t *bytes = NULL;
  873|       |
  874|   413k|    bytes = (const pb_bytes_array_t*)field->pData;
  875|       |    
  876|   413k|    if (bytes == NULL)
  ------------------
  |  Branch (876:9): [True: 0, False: 413k]
  ------------------
  877|      0|    {
  878|       |        /* Treat null pointer as an empty bytes field */
  879|      0|        return pb_encode_string(stream, NULL, 0);
  880|      0|    }
  881|       |    
  882|   413k|    if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  326|   413k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   413k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  321|   826k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (882:9): [True: 0, False: 413k]
  ------------------
  883|      0|        bytes->size > field->data_size - offsetof(pb_bytes_array_t, bytes))
  ------------------
  |  Branch (883:9): [True: 0, False: 0]
  ------------------
  884|      0|    {
  885|      0|        PB_RETURN_ERROR(stream, "bytes size exceeded");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  886|      0|    }
  887|       |    
  888|   413k|    return pb_encode_string(stream, bytes->bytes, (size_t)bytes->size);
  889|   413k|}
pb_encode.c:pb_enc_string:
  892|  75.2k|{
  893|  75.2k|    size_t size = 0;
  894|  75.2k|    size_t max_size = (size_t)field->data_size;
  895|  75.2k|    const char *str = (const char*)field->pData;
  896|       |    
  897|  75.2k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  75.2k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  75.2k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  75.2k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (897:9): [True: 75.0k, False: 215]
  ------------------
  898|  75.0k|    {
  899|  75.0k|        max_size = (size_t)-1;
  900|  75.0k|    }
  901|    215|    else
  902|    215|    {
  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|    215|        if (max_size == 0)
  ------------------
  |  Branch (908:13): [True: 0, False: 215]
  ------------------
  909|      0|            PB_RETURN_ERROR(stream, "zero-length string");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  910|       |
  911|    215|        max_size -= 1;
  912|    215|    }
  913|       |
  914|       |
  915|  75.2k|    if (str == NULL)
  ------------------
  |  Branch (915:9): [True: 0, False: 75.2k]
  ------------------
  916|      0|    {
  917|      0|        size = 0; /* Treat null pointer as an empty string */
  918|      0|    }
  919|  75.2k|    else
  920|  75.2k|    {
  921|  75.2k|        const char *p = str;
  922|       |
  923|       |        /* strnlen() is not always available, so just use a loop */
  924|   315k|        while (size < max_size && *p != '\0')
  ------------------
  |  Branch (924:16): [True: 315k, False: 24]
  |  Branch (924:35): [True: 240k, False: 75.1k]
  ------------------
  925|   240k|        {
  926|   240k|            size++;
  927|   240k|            p++;
  928|   240k|        }
  929|       |
  930|  75.2k|        if (*p != '\0')
  ------------------
  |  Branch (930:13): [True: 0, False: 75.2k]
  ------------------
  931|      0|        {
  932|      0|            PB_RETURN_ERROR(stream, "unterminated string");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  933|      0|        }
  934|  75.2k|    }
  935|       |
  936|       |#ifdef PB_VALIDATE_UTF8
  937|       |    if (!pb_validate_utf8(str))
  938|       |        PB_RETURN_ERROR(stream, "invalid utf8");
  939|       |#endif
  940|       |
  941|  75.2k|    return pb_encode_string(stream, (const pb_byte_t*)str, size);
  942|  75.2k|}
pb_encode.c:pb_enc_submessage:
  945|  62.1k|{
  946|  62.1k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (946:9): [True: 0, False: 62.1k]
  ------------------
  947|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  948|       |
  949|  62.1k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  328|  62.1k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  62.1k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  293|   124k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (949:9): [True: 0, False: 62.1k]
  |  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|  62.1k|    return pb_encode_submessage(stream, field->submsg_desc, field->pData);
  961|  62.1k|}
pb_encode.c:pb_enc_fixed_length_bytes:
  964|  9.74M|{
  965|  9.74M|    return pb_encode_string(stream, (const pb_byte_t*)field->pData, (size_t)field->data_size);
  966|  9.74M|}
pb_encode.c:pb_encode_varint_32:
  583|  13.4M|{
  584|  13.4M|    size_t i = 0;
  585|  13.4M|    pb_byte_t buffer[10];
  586|  13.4M|    pb_byte_t byte = (pb_byte_t)(low & 0x7F);
  587|  13.4M|    low >>= 7;
  588|       |
  589|  30.8M|    while (i < 4 && (low != 0 || high != 0))
  ------------------
  |  Branch (589:12): [True: 29.7M, False: 1.15M]
  |  Branch (589:22): [True: 17.3M, False: 12.3M]
  |  Branch (589:34): [True: 5.18k, False: 12.3M]
  ------------------
  590|  17.4M|    {
  591|  17.4M|        byte |= 0x80;
  592|  17.4M|        buffer[i++] = byte;
  593|  17.4M|        byte = (pb_byte_t)(low & 0x7F);
  594|  17.4M|        low >>= 7;
  595|  17.4M|    }
  596|       |
  597|  13.4M|    if (high)
  ------------------
  |  Branch (597:9): [True: 1.10M, False: 12.3M]
  ------------------
  598|  1.10M|    {
  599|  1.10M|        byte = (pb_byte_t)(byte | ((high & 0x07) << 4));
  600|  1.10M|        high >>= 3;
  601|       |
  602|  6.21M|        while (high)
  ------------------
  |  Branch (602:16): [True: 5.10M, False: 1.10M]
  ------------------
  603|  5.10M|        {
  604|  5.10M|            byte |= 0x80;
  605|  5.10M|            buffer[i++] = byte;
  606|  5.10M|            byte = (pb_byte_t)(high & 0x7F);
  607|  5.10M|            high >>= 7;
  608|  5.10M|        }
  609|  1.10M|    }
  610|       |
  611|  13.4M|    buffer[i++] = byte;
  612|       |
  613|  13.4M|    return pb_write(stream, buffer, i);
  614|  13.4M|}

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

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

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

validate_static:
    7|  18.7k|{
    8|  18.7k|    pb_size_t count = 1;
    9|  18.7k|    pb_size_t i;
   10|  18.7k|    bool truebool = true;
   11|  18.7k|    bool falsebool = false;
   12|       |
   13|  18.7k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  327|  18.7k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  18.7k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  314|  37.5k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (13:9): [True: 0, False: 18.7k]
  |  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|  18.7k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  327|  18.7k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  18.7k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  312|  37.5k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (19:14): [True: 0, False: 18.7k]
  |  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|  18.7k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  18.7k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  18.7k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  18.7k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (25:14): [True: 18.7k, False: 0]
  ------------------
   26|  18.7k|    {
   27|  18.7k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (27:13): [True: 18.3k, False: 389]
  ------------------
   28|  18.3k|        {
   29|       |            /* Some different field in oneof */
   30|  18.3k|            return;
   31|  18.3k|        }
   32|  18.7k|    }
   33|       |
   34|    778|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (34:17): [True: 389, False: 389]
  ------------------
   35|    389|    {
   36|    389|        void *pData = (char*)iter->pData + iter->data_size * i;
   37|       |
   38|    389|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  328|    389|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|    389|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  284|    389|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (38:13): [True: 0, False: 389]
  ------------------
   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|    389|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  328|    389|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|    389|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  280|    389|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (43:18): [True: 0, False: 389]
  ------------------
   44|      0|        {
   45|       |            /* Bytes length must be at most statically allocated size */
   46|      0|            pb_bytes_array_t *bytes = pData;
   47|      0|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= iter->data_size);
  ------------------
  |  Branch (47:13): [True: 0, False: 0]
  |  Branch (47:13): [True: 0, False: 0]
  ------------------
   48|      0|        }
   49|    389|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  328|    389|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|    389|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  268|    389|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (49:18): [True: 0, False: 389]
  ------------------
   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|    389|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  329|    389|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|    389|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|    389|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|    778|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 322, False: 67]
  |  |  ------------------
  |  |  330|    389|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|     67|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|     67|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|     67|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 67]
  |  |  ------------------
  ------------------
   56|    322|        {
   57|    322|            validate_message(pData, 0, iter->submsg_desc);
   58|    322|        }
   59|    389|    }
   60|    389|}
validate_pointer:
   63|   728k|{
   64|   728k|    pb_size_t count = 1;
   65|   728k|    pb_size_t i;
   66|   728k|    bool truebool = true;
   67|   728k|    bool falsebool = false;
   68|       |
   69|   728k|    if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|   728k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   728k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|   728k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (69:9): [True: 12.5k, False: 715k]
  ------------------
   70|  12.5k|    {
   71|  12.5k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (71:13): [True: 11.9k, False: 590]
  ------------------
   72|  11.9k|        {
   73|       |            /* Some different field in oneof */
   74|  11.9k|            return;
   75|  11.9k|        }
   76|  12.5k|    }
   77|   715k|    else if (!iter->pData)
  ------------------
  |  Branch (77:14): [True: 295k, False: 420k]
  ------------------
   78|   295k|    {
   79|       |        /* Nothing allocated */
   80|   295k|        if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize != &iter->array_size)
  ------------------
  |  |  327|   295k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   295k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize != &iter->array_size)
  ------------------
  |  |  314|   590k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (80:13): [True: 118k, False: 177k]
  |  Branch (80:58): [True: 106k, False: 11.9k]
  ------------------
   81|   106k|        {
   82|   106k|            assert(*(pb_size_t*)iter->pSize == 0);
  ------------------
  |  Branch (82:13): [True: 0, False: 106k]
  |  Branch (82:13): [True: 106k, False: 0]
  ------------------
   83|   106k|        }
   84|   295k|        return;
   85|   295k|    }
   86|       |
   87|   420k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|   420k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   420k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|   420k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (87:9): [True: 13.4k, False: 407k]
  ------------------
   88|  13.4k|    {
   89|       |        /* Check that enough memory has been allocated for array */
   90|  13.4k|        size_t allocated_size = get_allocation_size(iter->pData);
   91|  13.4k|        count = *(pb_size_t*)iter->pSize;
   92|  13.4k|        assert(allocated_size >= count * iter->data_size);
  ------------------
  |  Branch (92:9): [True: 0, False: 13.4k]
  |  Branch (92:9): [True: 13.4k, False: 0]
  ------------------
   93|  13.4k|    }
   94|   407k|    else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  328|   407k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   407k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  284|   814k|#define PB_LTYPE_STRING 0x07U
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  328|   335k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   335k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  280|   335k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (94:14): [True: 335k, False: 72.1k]
  |  Branch (94:57): [True: 328k, False: 6.97k]
  ------------------
   95|   328k|    {
   96|   328k|        size_t allocated_size = get_allocation_size(iter->pData);
   97|   328k|        assert(allocated_size >= iter->data_size);
  ------------------
  |  Branch (97:9): [True: 0, False: 328k]
  |  Branch (97:9): [True: 328k, False: 0]
  ------------------
   98|   328k|    }
   99|       |
  100|  42.0M|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (100:17): [True: 41.5M, False: 420k]
  ------------------
  101|  41.5M|    {
  102|  41.5M|        void *pData = (char*)iter->pData + iter->data_size * i;
  103|       |
  104|  41.5M|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  328|  41.5M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  41.5M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  284|  41.5M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (104:13): [True: 100k, False: 41.4M]
  ------------------
  105|   100k|        {
  106|       |            /* Check that enough memory is allocated for string and that
  107|       |               the string is properly terminated. */
  108|   100k|            const char *str = pData;
  109|       |
  110|   100k|            if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|   100k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   100k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|   100k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (110:17): [True: 28.6k, False: 72.1k]
  ------------------
  111|  28.6k|            {
  112|       |                /* String arrays are stored as array of pointers */
  113|  28.6k|                str = ((const char**)iter->pData)[i];
  114|  28.6k|            }
  115|       |
  116|   100k|            assert(strlen(str) + 1 <= get_allocation_size(str));
  ------------------
  |  Branch (116:13): [True: 0, False: 100k]
  |  Branch (116:13): [True: 100k, False: 0]
  ------------------
  117|   100k|        }
  118|  41.4M|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  328|  41.4M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  41.4M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  280|  41.4M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (118:18): [True: 1.00M, False: 40.4M]
  ------------------
  119|  1.00M|        {
  120|       |            /* Bytes length must be at most statically allocated size */
  121|  1.00M|            const pb_bytes_array_t *bytes = pData;
  122|       |
  123|  1.00M|            if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|  1.00M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  1.00M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|  1.00M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (123:17): [True: 997k, False: 6.97k]
  ------------------
  124|   997k|            {
  125|       |                /* Bytes arrays are stored as array of pointers */
  126|   997k|                bytes = ((const pb_bytes_array_t**)iter->pData)[i];
  127|   997k|            }
  128|       |
  129|  1.00M|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= get_allocation_size(bytes));
  ------------------
  |  Branch (129:13): [True: 0, False: 1.00M]
  |  Branch (129:13): [True: 1.00M, False: 0]
  ------------------
  130|  1.00M|        }
  131|  40.4M|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  328|  40.4M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  40.4M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  268|  40.4M|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (131:18): [True: 1.61M, False: 38.8M]
  ------------------
  132|  1.61M|        {
  133|       |            /* Bool fields must have valid value */
  134|  1.61M|            assert(memcmp(pData, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (134:13): [True: 1.61M, False: 0]
  |  Branch (134:13): [True: 0, False: 0]
  |  Branch (134:13): [True: 185k, False: 1.42M]
  |  Branch (134:13): [True: 1.42M, False: 0]
  ------------------
  135|  1.61M|                   memcmp(pData, &falsebool, sizeof(bool)) == 0);
  136|  1.61M|        }
  137|  38.8M|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  329|  38.8M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  38.8M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  38.8M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  77.7M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 129k, False: 38.7M]
  |  |  ------------------
  |  |  330|  38.8M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  38.7M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  38.7M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  38.7M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 38.7M]
  |  |  ------------------
  ------------------
  138|   129k|        {
  139|   129k|            validate_message(pData, 0, iter->submsg_desc);
  140|   129k|        }
  141|  41.5M|    }
  142|   420k|}
validate_message:
  145|   135k|{
  146|   135k|    pb_field_iter_t iter;
  147|       |
  148|   135k|    if (pb_field_iter_begin_const(&iter, msgtype, msg))
  ------------------
  |  Branch (148:9): [True: 90.4k, False: 45.1k]
  ------------------
  149|  90.4k|    {
  150|  90.4k|        do
  151|   765k|        {
  152|   765k|            if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  326|   765k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   765k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  321|   765k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (152:17): [True: 18.7k, False: 746k]
  ------------------
  153|  18.7k|            {
  154|  18.7k|                validate_static(&iter);
  155|  18.7k|            }
  156|   746k|            else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   746k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   746k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   746k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (156:22): [True: 728k, False: 18.7k]
  ------------------
  157|   728k|            {
  158|   728k|                validate_pointer(&iter);
  159|   728k|            }
  160|   765k|        } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (160:18): [True: 675k, False: 90.4k]
  ------------------
  161|  90.4k|    }
  162|   135k|}

