pb_field_iter_begin:
  157|   666k|{
  158|   666k|    memset(iter, 0, sizeof(*iter));
  159|       |
  160|   666k|    iter->descriptor = desc;
  161|   666k|    iter->message = message;
  162|       |
  163|   666k|    return load_descriptor_values(iter);
  164|   666k|}
pb_field_iter_begin_extension:
  167|  98.1k|{
  168|  98.1k|    const pb_msgdesc_t *msg = (const pb_msgdesc_t*)extension->type->arg;
  169|  98.1k|    bool status;
  170|       |
  171|  98.1k|    uint32_t word0 = PB_PROGMEM_READU32(msg->field_info[0]);
  ------------------
  |  |  191|  98.1k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  172|  98.1k|    if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  333|  98.1k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|  98.1k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  329|  98.1k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (172:9): [True: 0, False: 98.1k]
  ------------------
  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|  98.1k|    else
  180|  98.1k|    {
  181|  98.1k|        status = pb_field_iter_begin(iter, msg, extension->dest);
  182|  98.1k|    }
  183|       |
  184|  98.1k|    iter->pSize = &extension->found;
  185|  98.1k|    return status;
  186|  98.1k|}
pb_field_iter_next:
  189|  3.16M|{
  190|  3.16M|    advance_iterator(iter);
  191|  3.16M|    (void)load_descriptor_values(iter);
  192|  3.16M|    return iter->index != 0;
  193|  3.16M|}
pb_field_iter_find:
  196|  32.0M|{
  197|  32.0M|    if (iter->tag == tag)
  ------------------
  |  Branch (197:9): [True: 30.6M, False: 1.42M]
  ------------------
  198|  30.6M|    {
  199|  30.6M|        return true; /* Nothing to do, correct field already. */
  200|  30.6M|    }
  201|  1.42M|    else if (tag > iter->descriptor->largest_tag)
  ------------------
  |  Branch (201:14): [True: 456k, False: 968k]
  ------------------
  202|   456k|    {
  203|   456k|        return false;
  204|   456k|    }
  205|   968k|    else
  206|   968k|    {
  207|   968k|        pb_size_t start = iter->index;
  208|   968k|        uint32_t fieldinfo;
  209|       |
  210|   968k|        if (tag < iter->tag)
  ------------------
  |  Branch (210:13): [True: 237k, False: 730k]
  ------------------
  211|   237k|        {
  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|   237k|            iter->index = iter->descriptor->field_count;
  216|   237k|        }
  217|       |
  218|   968k|        do
  219|  11.2M|        {
  220|       |            /* Advance iterator but don't load values yet */
  221|  11.2M|            advance_iterator(iter);
  222|       |
  223|       |            /* Do fast check for tag number match */
  224|  11.2M|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  191|  11.2M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  225|       |
  226|  11.2M|            if (((fieldinfo >> 2) & 0x3F) == (tag & 0x3F))
  ------------------
  |  Branch (226:17): [True: 1.00M, False: 10.2M]
  ------------------
  227|  1.00M|            {
  228|       |                /* Good candidate, check further */
  229|  1.00M|                (void)load_descriptor_values(iter);
  230|       |
  231|  1.00M|                if (iter->tag == tag &&
  ------------------
  |  Branch (231:21): [True: 909k, False: 99.8k]
  ------------------
  232|   909k|                    PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  335|   909k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   909k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                                  PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  304|   909k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (232:21): [True: 904k, False: 4.17k]
  ------------------
  233|   904k|                {
  234|       |                    /* Found it */
  235|   904k|                    return true;
  236|   904k|                }
  237|  1.00M|            }
  238|  11.2M|        } while (iter->index != start);
  ------------------
  |  Branch (238:18): [True: 10.2M, False: 63.5k]
  ------------------
  239|       |
  240|       |        /* Searched all the way back to start, and found nothing. */
  241|  63.5k|        (void)load_descriptor_values(iter);
  242|       |        return false;
  243|   968k|    }
  244|  32.0M|}
pb_field_iter_find_extension:
  247|  9.32k|{
  248|  9.32k|    if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  335|  9.32k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  9.32k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  304|  9.32k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (248:9): [True: 0, False: 9.32k]
  ------------------
  249|      0|    {
  250|      0|        return true;
  251|      0|    }
  252|  9.32k|    else
  253|  9.32k|    {
  254|  9.32k|        pb_size_t start = iter->index;
  255|  9.32k|        uint32_t fieldinfo;
  256|       |
  257|  9.32k|        do
  258|   131k|        {
  259|       |            /* Advance iterator but don't load values yet */
  260|   131k|            advance_iterator(iter);
  261|       |
  262|       |            /* Do fast check for field type */
  263|   131k|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  191|   131k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  264|       |
  265|   131k|            if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  335|   131k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   131k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  304|   131k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (265:17): [True: 3.94k, False: 127k]
  ------------------
  266|  3.94k|            {
  267|  3.94k|                return load_descriptor_values(iter);
  268|  3.94k|            }
  269|   131k|        } while (iter->index != start);
  ------------------
  |  Branch (269:18): [True: 122k, False: 5.37k]
  ------------------
  270|       |
  271|       |        /* Searched all the way back to start, and found nothing. */
  272|  5.37k|        (void)load_descriptor_values(iter);
  273|       |        return false;
  274|  9.32k|    }
  275|  9.32k|}
pb_field_iter_begin_const:
  291|   220k|{
  292|   220k|    return pb_field_iter_begin(iter, desc, pb_const_cast(message));
  293|   220k|}
pb_field_iter_begin_extension_const:
  296|  2.99k|{
  297|  2.99k|    return pb_field_iter_begin_extension(iter, (pb_extension_t*)pb_const_cast(extension));
  298|  2.99k|}
pb_default_field_callback:
  301|  7.82k|{
  302|  7.82k|    if (field->data_size == sizeof(pb_callback_t))
  ------------------
  |  Branch (302:9): [True: 7.82k, False: 0]
  ------------------
  303|  7.82k|    {
  304|  7.82k|        pb_callback_t *pCallback = (pb_callback_t*)field->pData;
  305|       |
  306|  7.82k|        if (pCallback != NULL)
  ------------------
  |  Branch (306:13): [True: 7.82k, False: 0]
  ------------------
  307|  7.82k|        {
  308|  7.82k|            if (istream != NULL && pCallback->funcs.decode != NULL)
  ------------------
  |  Branch (308:17): [True: 7.70k, False: 129]
  |  Branch (308:36): [True: 0, False: 7.70k]
  ------------------
  309|      0|            {
  310|      0|                return pCallback->funcs.decode(istream, field, &pCallback->arg);
  311|      0|            }
  312|       |
  313|  7.82k|            if (ostream != NULL && pCallback->funcs.encode != NULL)
  ------------------
  |  Branch (313:17): [True: 129, False: 7.70k]
  |  Branch (313:36): [True: 0, False: 129]
  ------------------
  314|      0|            {
  315|      0|                return pCallback->funcs.encode(ostream, field, &pCallback->arg);
  316|      0|            }
  317|  7.82k|        }
  318|  7.82k|    }
  319|       |
  320|  7.82k|    return true; /* Success, but didn't do anything */
  321|       |
  322|  7.82k|}
pb_common.c:load_descriptor_values:
    9|  4.90M|{
   10|  4.90M|    uint32_t word0;
   11|  4.90M|    uint32_t data_offset;
   12|  4.90M|    int_least8_t size_offset;
   13|       |
   14|  4.90M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (14:9): [True: 167k, False: 4.74M]
  ------------------
   15|   167k|        return false;
   16|       |
   17|  4.74M|    word0 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  191|  4.74M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   18|  4.74M|    iter->type = (pb_type_t)((word0 >> 8) & 0xFF);
   19|       |
   20|  4.74M|    switch(word0 & 3)
   21|  4.74M|    {
   22|   777k|        case 0: {
  ------------------
  |  Branch (22:9): [True: 777k, False: 3.96M]
  ------------------
   23|       |            /* 1-word format */
   24|   777k|            iter->array_size = 1;
   25|   777k|            iter->tag = (pb_size_t)((word0 >> 2) & 0x3F);
   26|   777k|            size_offset = (int_least8_t)((word0 >> 24) & 0x0F);
   27|   777k|            data_offset = (word0 >> 16) & 0xFF;
   28|   777k|            iter->data_size = (pb_size_t)((word0 >> 28) & 0x0F);
   29|   777k|            break;
   30|      0|        }
   31|       |
   32|  3.42M|        case 1: {
  ------------------
  |  Branch (32:9): [True: 3.42M, False: 1.31M]
  ------------------
   33|       |            /* 2-word format */
   34|  3.42M|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  191|  3.42M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   35|       |
   36|  3.42M|            iter->array_size = (pb_size_t)((word0 >> 16) & 0x0FFF);
   37|  3.42M|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 28) << 6));
   38|  3.42M|            size_offset = (int_least8_t)((word0 >> 28) & 0x0F);
   39|  3.42M|            data_offset = word1 & 0xFFFF;
   40|  3.42M|            iter->data_size = (pb_size_t)((word1 >> 16) & 0x0FFF);
   41|  3.42M|            break;
   42|      0|        }
   43|       |
   44|   419k|        case 2: {
  ------------------
  |  Branch (44:9): [True: 419k, False: 4.32M]
  ------------------
   45|       |            /* 4-word format */
   46|   419k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  191|   419k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   47|   419k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  191|   419k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   48|   419k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  191|   419k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   49|       |
   50|   419k|            iter->array_size = (pb_size_t)(word0 >> 16);
   51|   419k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   52|   419k|            size_offset = (int_least8_t)(word1 & 0xFF);
   53|   419k|            data_offset = word2;
   54|   419k|            iter->data_size = (pb_size_t)word3;
   55|   419k|            break;
   56|      0|        }
   57|       |
   58|   119k|        default: {
  ------------------
  |  Branch (58:9): [True: 119k, False: 4.62M]
  ------------------
   59|       |            /* 8-word format */
   60|   119k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  191|   119k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   61|   119k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  191|   119k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   62|   119k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  191|   119k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   63|   119k|            uint32_t word4 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 4]);
  ------------------
  |  |  191|   119k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   64|       |
   65|   119k|            iter->array_size = (pb_size_t)word4;
   66|   119k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   67|   119k|            size_offset = (int_least8_t)(word1 & 0xFF);
   68|   119k|            data_offset = word2;
   69|   119k|            iter->data_size = (pb_size_t)word3;
   70|   119k|            break;
   71|      0|        }
   72|  4.74M|    }
   73|       |
   74|  4.74M|    if (!iter->message)
  ------------------
  |  Branch (74:9): [True: 0, False: 4.74M]
  ------------------
   75|      0|    {
   76|       |        /* Avoid doing arithmetic on null pointers, it is undefined */
   77|      0|        iter->pField = NULL;
   78|      0|        iter->pSize = NULL;
   79|      0|    }
   80|  4.74M|    else
   81|  4.74M|    {
   82|  4.74M|        iter->pField = (char*)iter->message + data_offset;
   83|       |
   84|  4.74M|        if (size_offset)
  ------------------
  |  Branch (84:13): [True: 962k, False: 3.77M]
  ------------------
   85|   962k|        {
   86|   962k|            iter->pSize = (char*)iter->pField - size_offset;
   87|   962k|        }
   88|  3.77M|        else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  334|  3.77M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  3.77M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  321|  7.55M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (88:18): [True: 64.3k, False: 3.71M]
  ------------------
   89|  64.3k|                 (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  333|  64.3k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|  64.3k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                               (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  328|   128k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (89:19): [True: 0, False: 64.3k]
  ------------------
   90|  64.3k|                  PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  333|  64.3k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|  64.3k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                                PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  329|  64.3k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (90:19): [True: 64.3k, False: 0]
  ------------------
   91|  64.3k|        {
   92|       |            /* Fixed count array */
   93|  64.3k|            iter->pSize = &iter->array_size;
   94|  64.3k|        }
   95|  3.71M|        else
   96|  3.71M|        {
   97|  3.71M|            iter->pSize = NULL;
   98|  3.71M|        }
   99|       |
  100|  4.74M|        if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  333|  4.74M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|  4.74M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  329|  9.48M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (100:13): [True: 4.38M, False: 353k]
  |  Branch (100:57): [True: 4.38M, False: 0]
  ------------------
  101|  4.38M|        {
  102|  4.38M|            iter->pData = *(void**)iter->pField;
  103|  4.38M|        }
  104|   353k|        else
  105|   353k|        {
  106|   353k|            iter->pData = iter->pField;
  107|   353k|        }
  108|  4.74M|    }
  109|       |
  110|  4.74M|    if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  336|  4.74M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  335|  4.74M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|  4.74M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  295|  9.48M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (336:32): [True: 635k, False: 4.10M]
  |  |  ------------------
  |  |  337|  4.74M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  335|  4.10M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|  4.10M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  300|  4.10M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (337:32): [True: 0, False: 4.10M]
  |  |  ------------------
  ------------------
  111|   635k|    {
  112|   635k|        iter->submsg_desc = iter->descriptor->submsg_info[iter->submessage_index];
  113|   635k|    }
  114|  4.10M|    else
  115|  4.10M|    {
  116|  4.10M|        iter->submsg_desc = NULL;
  117|  4.10M|    }
  118|       |
  119|       |    return true;
  120|  4.74M|}
pb_common.c:advance_iterator:
  123|  14.5M|{
  124|  14.5M|    iter->index++;
  125|       |
  126|  14.5M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (126:9): [True: 656k, False: 13.8M]
  ------------------
  127|   656k|    {
  128|       |        /* Restart */
  129|   656k|        iter->index = 0;
  130|   656k|        iter->field_info_index = 0;
  131|   656k|        iter->submessage_index = 0;
  132|   656k|        iter->required_field_index = 0;
  133|   656k|    }
  134|  13.8M|    else
  135|  13.8M|    {
  136|       |        /* Increment indexes based on previous field type.
  137|       |         * All field info formats have the following fields:
  138|       |         * - lowest 2 bits tell the amount of words in the descriptor (2^n words)
  139|       |         * - bits 2..7 give the lowest bits of tag number.
  140|       |         * - bits 8..15 give the field type.
  141|       |         */
  142|  13.8M|        uint32_t prev_descriptor = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  191|  13.8M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  143|  13.8M|        pb_type_t prev_type = (prev_descriptor >> 8) & 0xFF;
  144|  13.8M|        pb_size_t descriptor_len = (pb_size_t)(1 << (prev_descriptor & 3));
  145|       |
  146|       |        /* Add to fields.
  147|       |         * The cast to pb_size_t is needed to avoid -Wconversion warning.
  148|       |         * Because the data is is constants from generator, there is no danger of overflow.
  149|       |         */
  150|  13.8M|        iter->field_info_index = (pb_size_t)(iter->field_info_index + descriptor_len);
  151|  13.8M|        iter->required_field_index = (pb_size_t)(iter->required_field_index + (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED));
  ------------------
  |  |  334|  13.8M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  13.8M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      iter->required_field_index = (pb_size_t)(iter->required_field_index + (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED));
  ------------------
  |  |  318|  13.8M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  152|  13.8M|        iter->submessage_index = (pb_size_t)(iter->submessage_index + PB_LTYPE_IS_SUBMSG(prev_type));
  ------------------
  |  |  336|  13.8M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  335|  13.8M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|  13.8M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  295|  27.7M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (336:32): [True: 2.00M, False: 11.8M]
  |  |  ------------------
  |  |  337|  13.8M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  335|  11.8M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|  11.8M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  300|  11.8M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (337:32): [True: 0, False: 11.8M]
  |  |  ------------------
  ------------------
  153|  13.8M|    }
  154|  14.5M|}
pb_common.c:pb_const_cast:
  278|   223k|{
  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|   223k|    union {
  283|   223k|        void *p1;
  284|   223k|        const void *p2;
  285|   223k|    } t;
  286|   223k|    t.p2 = p;
  287|   223k|    return t.p1;
  288|   223k|}

pb_read:
   83|  2.63M|{
   84|  2.63M|    if (count == 0)
  ------------------
  |  Branch (84:9): [True: 831k, False: 1.80M]
  ------------------
   85|   831k|        return true;
   86|       |
   87|  1.80M|#ifndef PB_BUFFER_ONLY
   88|  1.80M|	if (buf == NULL && stream->callback != buf_read)
  ------------------
  |  Branch (88:6): [True: 115k, False: 1.68M]
  |  Branch (88:21): [True: 38.2k, False: 77.4k]
  ------------------
   89|  38.2k|	{
   90|       |		/* Skip input bytes */
   91|  38.2k|		pb_byte_t tmp[16];
   92|   201k|		while (count > 16)
  ------------------
  |  Branch (92:10): [True: 163k, False: 38.2k]
  ------------------
   93|   163k|		{
   94|   163k|			if (!pb_read(stream, tmp, 16))
  ------------------
  |  Branch (94:8): [True: 0, False: 163k]
  ------------------
   95|      0|				return false;
   96|       |			
   97|   163k|			count -= 16;
   98|   163k|		}
   99|       |		
  100|  38.2k|		return pb_read(stream, tmp, count);
  101|  38.2k|	}
  102|  1.76M|#endif
  103|       |
  104|  1.76M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (104:9): [True: 263, False: 1.76M]
  ------------------
  105|    263|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  937|    263|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|    263|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 263]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  106|       |    
  107|  1.76M|#ifndef PB_BUFFER_ONLY
  108|  1.76M|    if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (108:9): [True: 0, False: 1.76M]
  ------------------
  109|      0|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  110|       |#else
  111|       |    if (!buf_read(stream, buf, count))
  112|       |        return false;
  113|       |#endif
  114|       |    
  115|  1.76M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (115:9): [True: 0, False: 1.76M]
  ------------------
  116|      0|        stream->bytes_left = 0;
  117|  1.76M|    else
  118|  1.76M|        stream->bytes_left -= count;
  119|       |
  120|       |    return true;
  121|  1.76M|}
pb_istream_from_buffer:
  144|  12.7k|{
  145|  12.7k|    pb_istream_t stream;
  146|       |    /* Cast away the const from buf without a compiler error.  We are
  147|       |     * careful to use it only in a const manner in the callbacks.
  148|       |     */
  149|  12.7k|    union {
  150|  12.7k|        void *state;
  151|  12.7k|        const void *c_state;
  152|  12.7k|    } state;
  153|       |#ifdef PB_BUFFER_ONLY
  154|       |    stream.callback = NULL;
  155|       |#else
  156|  12.7k|    stream.callback = &buf_read;
  157|  12.7k|#endif
  158|  12.7k|    state.c_state = buf;
  159|  12.7k|    stream.state = state.state;
  160|  12.7k|    stream.bytes_left = msglen;
  161|  12.7k|#ifndef PB_NO_ERRMSG
  162|  12.7k|    stream.errmsg = NULL;
  163|  12.7k|#endif
  164|       |#ifdef PB_MESSAGE_NESTING_MAX
  165|       |    stream.depth = 0;
  166|       |#endif
  167|  12.7k|    return stream;
  168|  12.7k|}
pb_decode_varint32:
  250|  33.3M|{
  251|       |    return pb_decode_varint32_eof(stream, dest, NULL);
  252|  33.3M|}
pb_decode_varint:
  256|  9.29M|{
  257|  9.29M|    pb_byte_t byte;
  258|  9.29M|    uint_fast8_t bitpos = 0;
  259|  9.29M|    uint64_t result = 0;
  260|       |    
  261|  9.29M|    do
  262|  14.7M|    {
  263|  14.7M|        if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (263:13): [True: 108, False: 14.7M]
  ------------------
  264|    108|            return false;
  265|       |
  266|  14.7M|        if (bitpos >= 63 && (byte & 0xFE) != 0)
  ------------------
  |  Branch (266:13): [True: 35.1k, False: 14.7M]
  |  Branch (266:29): [True: 35, False: 35.1k]
  ------------------
  267|     35|            PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  937|     35|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     35|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 35]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  268|       |
  269|  14.7M|        result |= (uint64_t)(byte & 0x7F) << bitpos;
  270|  14.7M|        bitpos = (uint_fast8_t)(bitpos + 7);
  271|  14.7M|    } while (byte & 0x80);
  ------------------
  |  Branch (271:14): [True: 5.48M, False: 9.29M]
  ------------------
  272|       |    
  273|  9.29M|    *dest = result;
  274|       |    return true;
  275|  9.29M|}
pb_decode_tag:
  304|  32.2M|{
  305|  32.2M|    uint32_t temp;
  306|  32.2M|    *eof = false;
  307|  32.2M|    *wire_type = (pb_wire_type_t) 0;
  308|  32.2M|    *tag = 0;
  309|       |
  310|  32.2M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (310:9): [True: 163k, False: 32.0M]
  ------------------
  311|   163k|    {
  312|   163k|        *eof = true;
  313|   163k|        return false;
  314|   163k|    }
  315|       |
  316|  32.0M|    if (!pb_decode_varint32_eof(stream, &temp, eof))
  ------------------
  |  Branch (316:9): [True: 1.78k, False: 32.0M]
  ------------------
  317|  1.78k|    {
  318|  1.78k|        return false;
  319|  1.78k|    }
  320|       |    
  321|  32.0M|    *tag = temp >> 3;
  322|  32.0M|    *wire_type = (pb_wire_type_t)(temp & 7);
  323|       |    return true;
  324|  32.0M|}
pb_skip_field:
  327|   517k|{
  328|   517k|    switch (wire_type)
  329|   517k|    {
  330|   161k|        case PB_WT_VARINT: return pb_skip_varint(stream);
  ------------------
  |  Branch (330:9): [True: 161k, False: 355k]
  ------------------
  331|  14.0k|        case PB_WT_64BIT: return pb_read(stream, NULL, 8);
  ------------------
  |  Branch (331:9): [True: 14.0k, False: 502k]
  ------------------
  332|   284k|        case PB_WT_STRING: return pb_skip_string(stream);
  ------------------
  |  Branch (332:9): [True: 284k, False: 232k]
  ------------------
  333|  56.6k|        case PB_WT_32BIT: return pb_read(stream, NULL, 4);
  ------------------
  |  Branch (333:9): [True: 56.6k, False: 460k]
  ------------------
  334|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (334:2): [True: 0, False: 517k]
  ------------------
  335|       |            /* Calling pb_skip_field with a PB_WT_PACKED is an error.
  336|       |             * Explicitly handle this case and fallthrough to default to avoid
  337|       |             * compiler warnings.
  338|       |             */
  339|     80|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  937|     80|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     80|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 80]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (339:9): [True: 80, False: 516k]
  ------------------
  340|   517k|    }
  341|   517k|}
pb_make_string_substream:
  392|   221k|{
  393|   221k|    uint32_t size;
  394|   221k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (394:9): [True: 142, False: 221k]
  ------------------
  395|    142|        return false;
  396|       |    
  397|   221k|    *substream = *stream;
  398|   221k|    if (substream->bytes_left < size)
  ------------------
  |  Branch (398:9): [True: 116, False: 221k]
  ------------------
  399|    116|        PB_RETURN_ERROR(stream, "parent stream too short");
  ------------------
  |  |  937|    116|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|    116|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 116]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  400|       |    
  401|       |#ifdef PB_MESSAGE_NESTING_MAX
  402|       |    substream->depth++;
  403|       |    if (substream->depth > PB_MESSAGE_NESTING_MAX)
  404|       |        PB_RETURN_ERROR(stream, "max depth");
  405|       |#endif
  406|       |
  407|   221k|    substream->bytes_left = (size_t)size;
  408|   221k|    stream->bytes_left -= (size_t)size;
  409|       |    return true;
  410|   221k|}
pb_close_string_substream:
  413|   221k|{
  414|   221k|    if (substream->bytes_left) {
  ------------------
  |  Branch (414:9): [True: 620, False: 220k]
  ------------------
  415|    620|        if (!pb_read(substream, NULL, substream->bytes_left))
  ------------------
  |  Branch (415:13): [True: 0, False: 620]
  ------------------
  416|      0|            return false;
  417|    620|    }
  418|       |
  419|   221k|    stream->state = substream->state;
  420|       |
  421|   221k|#ifndef PB_NO_ERRMSG
  422|   221k|    stream->errmsg = substream->errmsg;
  423|   221k|#endif
  424|       |    return true;
  425|   221k|}
pb_decode_ex:
 1332|  8.83k|{
 1333|  8.83k|    bool status;
 1334|       |
 1335|  8.83k|    if ((flags & PB_DECODE_DELIMITED) == 0)
  ------------------
  |  |  123|  8.83k|#define PB_DECODE_DELIMITED       0x02U
  ------------------
  |  Branch (1335:9): [True: 8.83k, False: 0]
  ------------------
 1336|  8.83k|    {
 1337|  8.83k|      status = pb_decode_inner(stream, fields, dest_struct, flags);
 1338|  8.83k|    }
 1339|      0|    else
 1340|      0|    {
 1341|      0|      pb_istream_t substream;
 1342|      0|      if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1342:11): [True: 0, False: 0]
  ------------------
 1343|      0|        return false;
 1344|       |
 1345|      0|      status = pb_decode_inner(&substream, fields, dest_struct, flags);
 1346|       |
 1347|      0|      if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1347:11): [True: 0, False: 0]
  ------------------
 1348|      0|        status = false;
 1349|      0|    }
 1350|       |    
 1351|  8.83k|#ifdef PB_ENABLE_MALLOC
 1352|  8.83k|    if (!status)
  ------------------
  |  Branch (1352:9): [True: 2.36k, False: 6.47k]
  ------------------
 1353|  2.36k|        pb_release(fields, dest_struct);
 1354|  8.83k|#endif
 1355|       |    
 1356|  8.83k|    return status;
 1357|  8.83k|}
pb_decode:
 1360|  3.12k|{
 1361|  3.12k|    return pb_decode_ex(stream, fields, dest_struct, 0);
 1362|  3.12k|}
pb_release:
 1495|   139k|{
 1496|   139k|    pb_field_iter_t iter;
 1497|       |    
 1498|   139k|    if (!dest_struct)
  ------------------
  |  Branch (1498:9): [True: 0, False: 139k]
  ------------------
 1499|      0|        return; /* Ignore NULL pointers, similar to free() */
 1500|       |
 1501|   139k|    if (!pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1501:9): [True: 38.8k, False: 100k]
  ------------------
 1502|  38.8k|        return; /* Empty message type */
 1503|       |    
 1504|   100k|    do
 1505|   972k|    {
 1506|   972k|        pb_release_single_field(&iter);
 1507|   972k|    } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (1507:14): [True: 872k, False: 100k]
  ------------------
 1508|   100k|}
pb_decode_bool:
 1521|  3.11M|{
 1522|  3.11M|    uint32_t value;
 1523|  3.11M|    if (!pb_decode_varint32(stream, &value))
  ------------------
  |  Branch (1523:9): [True: 70, False: 3.11M]
  ------------------
 1524|     70|        return false;
 1525|       |
 1526|  3.11M|    *(bool*)dest = (value != 0);
 1527|       |    return true;
 1528|  3.11M|}
pb_decode_svarint:
 1531|  3.82M|{
 1532|  3.82M|    pb_uint64_t value;
  ------------------
  |  |   58|  3.82M|#define pb_uint64_t uint64_t
  ------------------
 1533|  3.82M|    if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1533:9): [True: 43, False: 3.82M]
  ------------------
 1534|     43|        return false;
 1535|       |    
 1536|  3.82M|    if (value & 1)
  ------------------
  |  Branch (1536:9): [True: 620k, False: 3.20M]
  ------------------
 1537|   620k|        *dest = (pb_int64_t)(~(value >> 1));
 1538|  3.20M|    else
 1539|  3.20M|        *dest = (pb_int64_t)(value >> 1);
 1540|       |    
 1541|       |    return true;
 1542|  3.82M|}
pb_decode_fixed32:
 1545|   136k|{
 1546|   136k|    union {
 1547|   136k|        uint32_t fixed32;
 1548|   136k|        pb_byte_t bytes[4];
 1549|   136k|    } u;
 1550|       |
 1551|   136k|    if (!pb_read(stream, u.bytes, 4))
  ------------------
  |  Branch (1551:9): [True: 19, False: 136k]
  ------------------
 1552|     19|        return false;
 1553|       |
 1554|   136k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1555|       |    /* fast path - if we know that we're on little endian, assign directly */
 1556|   136k|    *(uint32_t*)dest = u.fixed32;
 1557|       |#else
 1558|       |    *(uint32_t*)dest = ((uint32_t)u.bytes[0] << 0) |
 1559|       |                       ((uint32_t)u.bytes[1] << 8) |
 1560|       |                       ((uint32_t)u.bytes[2] << 16) |
 1561|       |                       ((uint32_t)u.bytes[3] << 24);
 1562|       |#endif
 1563|       |    return true;
 1564|   136k|}
pb_decode_fixed64:
 1568|  63.8k|{
 1569|  63.8k|    union {
 1570|  63.8k|        uint64_t fixed64;
 1571|  63.8k|        pb_byte_t bytes[8];
 1572|  63.8k|    } u;
 1573|       |
 1574|  63.8k|    if (!pb_read(stream, u.bytes, 8))
  ------------------
  |  Branch (1574:9): [True: 21, False: 63.8k]
  ------------------
 1575|     21|        return false;
 1576|       |
 1577|  63.8k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1578|       |    /* fast path - if we know that we're on little endian, assign directly */
 1579|  63.8k|    *(uint64_t*)dest = u.fixed64;
 1580|       |#else
 1581|       |    *(uint64_t*)dest = ((uint64_t)u.bytes[0] << 0) |
 1582|       |                       ((uint64_t)u.bytes[1] << 8) |
 1583|       |                       ((uint64_t)u.bytes[2] << 16) |
 1584|       |                       ((uint64_t)u.bytes[3] << 24) |
 1585|       |                       ((uint64_t)u.bytes[4] << 32) |
 1586|       |                       ((uint64_t)u.bytes[5] << 40) |
 1587|       |                       ((uint64_t)u.bytes[6] << 48) |
 1588|       |                       ((uint64_t)u.bytes[7] << 56);
 1589|       |#endif
 1590|       |    return true;
 1591|  63.8k|}
pb_decode.c:buf_read:
   70|  78.6M|{
   71|  78.6M|    const pb_byte_t *source = (const pb_byte_t*)stream->state;
   72|  78.6M|    stream->state = (pb_byte_t*)stream->state + count;
   73|       |    
   74|  78.6M|    if (buf != NULL)
  ------------------
  |  Branch (74:9): [True: 78.5M, False: 77.3k]
  ------------------
   75|  78.5M|    {
   76|  78.5M|        memcpy(buf, source, count * sizeof(pb_byte_t));
   77|  78.5M|    }
   78|       |    
   79|       |    return true;
   80|  78.6M|}
pb_decode.c:pb_decode_varint32_eof:
  178|  65.4M|{
  179|  65.4M|    pb_byte_t byte;
  180|  65.4M|    uint32_t result;
  181|       |
  182|       |#ifdef PB_BUFFER_ONLY
  183|       |    (void)eof;
  184|       |#endif
  185|       |    
  186|  65.4M|    if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (186:9): [True: 1.93k, False: 65.4M]
  ------------------
  187|  1.93k|    {
  188|  1.93k|#ifndef PB_BUFFER_ONLY
  189|  1.93k|        if (eof != NULL && stream->callback != buf_read && stream->bytes_left == 0)
  ------------------
  |  Branch (189:13): [True: 1.67k, False: 261]
  |  Branch (189:28): [True: 1.67k, False: 0]
  |  Branch (189:60): [True: 1.67k, False: 0]
  ------------------
  190|  1.67k|        {
  191|  1.67k|#ifndef PB_NO_ERRMSG
  192|  1.67k|            if (strcmp(stream->errmsg, "io error") == 0)
  ------------------
  |  Branch (192:17): [True: 1.67k, False: 0]
  ------------------
  193|  1.67k|                stream->errmsg = NULL;
  194|  1.67k|#endif
  195|  1.67k|            *eof = true;
  196|  1.67k|        }
  197|  1.93k|#endif
  198|  1.93k|        return false;
  199|  1.93k|    }
  200|       |    
  201|  65.4M|    if ((byte & 0x80) == 0)
  ------------------
  |  Branch (201:9): [True: 35.0M, False: 30.4M]
  ------------------
  202|  35.0M|    {
  203|       |        /* Quick case, 1 byte value */
  204|  35.0M|        result = byte;
  205|  35.0M|    }
  206|  30.4M|    else
  207|  30.4M|    {
  208|       |        /* Multibyte case */
  209|  30.4M|        uint_fast8_t bitpos = 7;
  210|  30.4M|        result = byte & 0x7F;
  211|       |        
  212|  30.4M|        do
  213|  30.5M|        {
  214|  30.5M|            if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (214:17): [True: 60, False: 30.5M]
  ------------------
  215|     60|                return false;
  216|       |            
  217|  30.5M|            if (bitpos >= 32)
  ------------------
  |  Branch (217:17): [True: 8.40k, False: 30.5M]
  ------------------
  218|  8.40k|            {
  219|       |                /* Note: The varint could have trailing 0x80 bytes, or 0xFF for negative. */
  220|  8.40k|                pb_byte_t sign_extension = (bitpos < 63) ? 0xFF : 0x01;
  ------------------
  |  Branch (220:44): [True: 8.26k, False: 136]
  ------------------
  221|  8.40k|                bool valid_extension = ((byte & 0x7F) == 0x00 ||
  ------------------
  |  Branch (221:41): [True: 4.49k, False: 3.90k]
  ------------------
  222|  3.90k|                         ((result >> 31) != 0 && byte == sign_extension));
  ------------------
  |  Branch (222:27): [True: 3.89k, False: 10]
  |  Branch (222:50): [True: 3.83k, False: 66]
  ------------------
  223|       |
  224|  8.40k|                if (bitpos >= 64 || !valid_extension)
  ------------------
  |  Branch (224:21): [True: 2, False: 8.40k]
  |  Branch (224:37): [True: 76, False: 8.32k]
  ------------------
  225|     78|                {
  226|     78|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  937|     78|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     78|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 78]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  227|     78|                }
  228|  8.40k|            }
  229|  30.5M|            else if (bitpos == 28)
  ------------------
  |  Branch (229:22): [True: 11.9k, False: 30.5M]
  ------------------
  230|  11.9k|            {
  231|  11.9k|                if ((byte & 0x70) != 0 && (byte & 0x78) != 0x78)
  ------------------
  |  Branch (231:21): [True: 7.53k, False: 4.37k]
  |  Branch (231:43): [True: 30, False: 7.50k]
  ------------------
  232|     30|                {
  233|     30|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  937|     30|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     30|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 30]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  234|     30|                }
  235|  11.8k|                result |= (uint32_t)(byte & 0x0F) << bitpos;
  236|  11.8k|            }
  237|  30.5M|            else
  238|  30.5M|            {
  239|  30.5M|                result |= (uint32_t)(byte & 0x7F) << bitpos;
  240|  30.5M|            }
  241|  30.5M|            bitpos = (uint_fast8_t)(bitpos + 7);
  242|  30.5M|        } while (byte & 0x80);
  ------------------
  |  Branch (242:18): [True: 118k, False: 30.4M]
  ------------------
  243|  30.4M|   }
  244|       |   
  245|  65.4M|   *dest = result;
  246|       |   return true;
  247|  65.4M|}
pb_decode.c:pb_readbyte:
  126|   110M|{
  127|   110M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (127:9): [True: 429, False: 110M]
  ------------------
  128|    429|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  937|    429|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|    429|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 429]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  129|       |
  130|   110M|#ifndef PB_BUFFER_ONLY
  131|   110M|    if (!stream->callback(stream, buf, 1))
  ------------------
  |  Branch (131:9): [True: 1.67k, False: 110M]
  ------------------
  132|  1.67k|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  937|  1.67k|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|  1.67k|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 1.67k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  133|       |#else
  134|       |    *buf = *(const pb_byte_t*)stream->state;
  135|       |    stream->state = (pb_byte_t*)stream->state + 1;
  136|       |#endif
  137|       |
  138|   110M|    stream->bytes_left--;
  139|       |    
  140|       |    return true;    
  141|   110M|}
pb_decode.c:pb_skip_varint:
  279|   161k|{
  280|   161k|    pb_byte_t byte;
  281|   161k|    do
  282|   189k|    {
  283|   189k|        if (!pb_read(stream, &byte, 1))
  ------------------
  |  Branch (283:13): [True: 75, False: 189k]
  ------------------
  284|     75|            return false;
  285|   189k|    } while (byte & 0x80);
  ------------------
  |  Branch (285:14): [True: 28.0k, False: 161k]
  ------------------
  286|   161k|    return true;
  287|   161k|}
pb_decode.c:pb_skip_string:
  290|   284k|{
  291|   284k|    uint32_t length;
  292|   284k|    if (!pb_decode_varint32(stream, &length))
  ------------------
  |  Branch (292:9): [True: 59, False: 284k]
  ------------------
  293|     59|        return false;
  294|       |    
  295|   284k|    if ((size_t)length != length)
  ------------------
  |  Branch (295:9): [True: 0, False: 284k]
  ------------------
  296|      0|    {
  297|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  298|      0|    }
  299|       |
  300|   284k|    return pb_read(stream, NULL, (size_t)length);
  301|   284k|}
pb_decode.c:pb_decode_inner:
 1149|   167k|{
 1150|       |    /* If the message contains extension fields, the extension handlers
 1151|       |     * are called when tag number is >= extension_range_start. This precheck
 1152|       |     * is just for speed, and the handlers will check for precise match.
 1153|       |     */
 1154|   167k|    uint32_t extension_range_start = 0;
 1155|   167k|    pb_extension_t *extensions = NULL;
 1156|       |
 1157|       |    /* 'fixed_count_field' and 'fixed_count_size' track position of a repeated fixed
 1158|       |     * count field. This can only handle _one_ repeated fixed count field that
 1159|       |     * is unpacked and unordered among other (non repeated fixed count) fields.
 1160|       |     */
 1161|   167k|    pb_size_t fixed_count_field = PB_SIZE_MAX;
  ------------------
  |  |  349|   167k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
 1162|   167k|    pb_size_t fixed_count_size = 0;
 1163|   167k|    pb_size_t fixed_count_total_size = 0;
 1164|       |
 1165|       |    /* Tag and wire type of next field from the input stream */
 1166|   167k|    uint32_t tag;
 1167|   167k|    pb_wire_type_t wire_type;
 1168|   167k|    bool eof;
 1169|       |
 1170|       |    /* Track presence of required fields */
 1171|   167k|    pb_fields_seen_t fields_seen = {{0, 0}};
 1172|   167k|    const uint32_t allbits = ~(uint32_t)0;
 1173|       |
 1174|       |    /* Descriptor for the structure field matching the tag decoded from stream */
 1175|   167k|    pb_field_iter_t iter;
 1176|       |
 1177|   167k|    if (pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1177:9): [True: 118k, False: 48.7k]
  ------------------
 1178|   118k|    {
 1179|   118k|        if ((flags & PB_DECODE_NOINIT) == 0)
  ------------------
  |  |  122|   118k|#define PB_DECODE_NOINIT          0x01U
  ------------------
  |  Branch (1179:13): [True: 58.1k, False: 60.7k]
  ------------------
 1180|  58.1k|        {
 1181|  58.1k|            if (!pb_message_set_to_defaults(&iter))
  ------------------
  |  Branch (1181:17): [True: 0, False: 58.1k]
  ------------------
 1182|      0|                PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1183|  58.1k|        }
 1184|   118k|    }
 1185|       |
 1186|  32.2M|    while (decode_next_tag(stream, flags, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1186:12): [True: 32.0M, False: 165k]
  ------------------
 1187|  32.0M|    {
 1188|  32.0M|        if (tag == 0)
  ------------------
  |  Branch (1188:13): [True: 97, False: 32.0M]
  ------------------
 1189|     97|        {
 1190|     97|          if (flags & PB_DECODE_NULLTERMINATED)
  ------------------
  |  |  124|     97|#define PB_DECODE_NULLTERMINATED  0x04U
  ------------------
  |  Branch (1190:15): [True: 0, False: 97]
  ------------------
 1191|      0|          {
 1192|      0|            eof = true;
 1193|      0|            break;
 1194|      0|          }
 1195|     97|          else
 1196|     97|          {
 1197|     97|            PB_RETURN_ERROR(stream, "zero tag");
  ------------------
  |  |  937|     97|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     97|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 97]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1198|     97|          }
 1199|     97|        }
 1200|       |
 1201|  32.0M|        if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  335|  31.5M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  31.5M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  304|  31.5M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1201:13): [True: 519k, False: 31.5M]
  |  Branch (1201:48): [True: 1.06k, False: 31.5M]
  ------------------
 1202|   520k|        {
 1203|       |            /* No match found, check if it matches an extension. */
 1204|   520k|            if (extension_range_start == 0)
  ------------------
  |  Branch (1204:17): [True: 9.32k, False: 511k]
  ------------------
 1205|  9.32k|            {
 1206|  9.32k|                if (pb_field_iter_find_extension(&iter))
  ------------------
  |  Branch (1206:21): [True: 3.94k, False: 5.37k]
  ------------------
 1207|  3.94k|                {
 1208|  3.94k|                    extensions = *(pb_extension_t* const *)iter.pData;
 1209|  3.94k|                    extension_range_start = iter.tag;
 1210|  3.94k|                }
 1211|       |
 1212|  9.32k|                if (!extensions)
  ------------------
  |  Branch (1212:21): [True: 6.03k, False: 3.28k]
  ------------------
 1213|  6.03k|                {
 1214|  6.03k|                    extension_range_start = (uint32_t)-1;
 1215|  6.03k|                }
 1216|  9.32k|            }
 1217|       |
 1218|   520k|            if (tag >= extension_range_start)
  ------------------
  |  Branch (1218:17): [True: 80.5k, False: 440k]
  ------------------
 1219|  80.5k|            {
 1220|  80.5k|                size_t pos = stream->bytes_left;
 1221|       |
 1222|  80.5k|                if (!decode_extension(stream, tag, wire_type, extensions))
  ------------------
  |  Branch (1222:21): [True: 112, False: 80.4k]
  ------------------
 1223|    112|                    return false;
 1224|       |
 1225|  80.4k|                if (pos != stream->bytes_left)
  ------------------
  |  Branch (1225:21): [True: 3.55k, False: 76.9k]
  ------------------
 1226|  3.55k|                {
 1227|       |                    /* The field was handled */
 1228|  3.55k|                    continue;
 1229|  3.55k|                }
 1230|  80.4k|            }
 1231|       |
 1232|       |            /* No match found, skip data */
 1233|   517k|            if (!pb_skip_field(stream, wire_type))
  ------------------
  |  Branch (1233:17): [True: 308, False: 516k]
  ------------------
 1234|    308|                return false;
 1235|   516k|            continue;
 1236|   517k|        }
 1237|       |
 1238|       |        /* If a repeated fixed count field was found, get size from
 1239|       |         * 'fixed_count_field' as there is no counter contained in the struct.
 1240|       |         */
 1241|  31.5M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  334|  31.5M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  31.5M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  321|  63.1M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1241:13): [True: 29.7M, False: 1.76M]
  |  Branch (1241:57): [True: 5.56k, False: 29.7M]
  ------------------
 1242|  5.56k|        {
 1243|  5.56k|            if (fixed_count_field != iter.index) {
  ------------------
  |  Branch (1243:17): [True: 4.26k, False: 1.30k]
  ------------------
 1244|       |                /* If the new fixed count field does not match the previous one,
 1245|       |                 * check that the previous one is NULL or that it finished
 1246|       |                 * receiving all the expected data.
 1247|       |                 */
 1248|  4.26k|                if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  349|  8.52k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1248:21): [True: 3.65k, False: 603]
  ------------------
 1249|  3.65k|                    fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1249:21): [True: 31, False: 3.62k]
  ------------------
 1250|     31|                {
 1251|     31|                    PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  937|     31|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     31|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 31]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1252|     31|                }
 1253|       |
 1254|  4.23k|                fixed_count_field = iter.index;
 1255|  4.23k|                fixed_count_size = 0;
 1256|  4.23k|                fixed_count_total_size = iter.array_size;
 1257|       |
 1258|  4.23k|#ifdef PB_ENABLE_MALLOC
 1259|       |                /* Decoding restarts from the first entry. If the field was
 1260|       |                 * already decoded (it appeared before another fixed count
 1261|       |                 * field, or the message is being merged), release the old
 1262|       |                 * entries so that overwriting them does not leak memory. */
 1263|  4.23k|                {
 1264|  4.23k|                    pb_field_iter_t old_field = iter;
 1265|  4.23k|                    old_field.pSize = &old_field.array_size;
 1266|  4.23k|                    pb_release_single_field(&old_field);
 1267|  4.23k|                }
 1268|  4.23k|#endif
 1269|  4.23k|            }
 1270|       |
 1271|  5.53k|            iter.pSize = &fixed_count_size;
 1272|  5.53k|        }
 1273|       |
 1274|  31.5M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  334|  31.5M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  31.5M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  318|  63.1M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (1274:13): [True: 1.72M, False: 29.8M]
  ------------------
 1275|  1.72M|            && iter.required_field_index < PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  240|  1.72M|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1275:16): [True: 1.72M, False: 0]
  ------------------
 1276|  1.72M|        {
 1277|  1.72M|            uint32_t tmp = ((uint32_t)1 << (iter.required_field_index & 31));
 1278|  1.72M|            fields_seen.bitfield[iter.required_field_index >> 5] |= tmp;
 1279|  1.72M|        }
 1280|       |
 1281|  31.5M|        if (!decode_field(stream, wire_type, &iter))
  ------------------
  |  Branch (1281:13): [True: 1.51k, False: 31.5M]
  ------------------
 1282|  1.51k|            return false;
 1283|  31.5M|    }
 1284|       |
 1285|   165k|    if (!eof)
  ------------------
  |  Branch (1285:9): [True: 107, False: 165k]
  ------------------
 1286|    107|    {
 1287|       |        /* pb_decode_tag() returned error before end of stream */
 1288|    107|        return false;
 1289|    107|    }
 1290|       |
 1291|       |    /* Check that all elements of the last decoded fixed count field were present. */
 1292|   165k|    if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  349|   330k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1292:9): [True: 473, False: 164k]
  ------------------
 1293|    473|        fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1293:9): [True: 52, False: 421]
  ------------------
 1294|     52|    {
 1295|     52|        PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  937|     52|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     52|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 52]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1296|     52|    }
 1297|       |
 1298|       |    /* Check that all required fields were present. */
 1299|   165k|    {
 1300|   165k|        pb_size_t req_field_count = iter.descriptor->required_field_count;
 1301|       |
 1302|   165k|        if (req_field_count > 0)
  ------------------
  |  Branch (1302:13): [True: 109k, False: 55.7k]
  ------------------
 1303|   109k|        {
 1304|   109k|            pb_size_t i;
 1305|       |
 1306|   109k|            if (req_field_count > PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  240|   109k|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1306:17): [True: 0, False: 109k]
  ------------------
 1307|      0|                req_field_count = PB_MAX_REQUIRED_FIELDS;
  ------------------
  |  |  240|      0|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
 1308|       |
 1309|       |            /* Check the whole words */
 1310|   109k|            for (i = 0; i < (req_field_count >> 5); i++)
  ------------------
  |  Branch (1310:25): [True: 0, False: 109k]
  ------------------
 1311|      0|            {
 1312|      0|                if (fields_seen.bitfield[i] != allbits)
  ------------------
  |  Branch (1312:21): [True: 0, False: 0]
  ------------------
 1313|      0|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1314|      0|            }
 1315|       |
 1316|       |            /* Check the remaining bits (if any) */
 1317|   109k|            if ((req_field_count & 31) != 0)
  ------------------
  |  Branch (1317:17): [True: 109k, False: 0]
  ------------------
 1318|   109k|            {
 1319|   109k|                if (fields_seen.bitfield[req_field_count >> 5] !=
  ------------------
  |  Branch (1319:21): [True: 471, False: 109k]
  ------------------
 1320|   109k|                    (allbits >> (uint_least8_t)(32 - (req_field_count & 31))))
 1321|    471|                {
 1322|    471|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  937|    471|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|    471|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 471]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1323|    471|                }
 1324|   109k|            }
 1325|   109k|        }
 1326|   165k|    }
 1327|       |
 1328|   164k|    return true;
 1329|   165k|}
pb_decode.c:pb_message_set_to_defaults:
 1092|  94.2k|{
 1093|  94.2k|    pb_istream_t defstream = PB_ISTREAM_EMPTY;
  ------------------
  |  |   71|  94.2k|#  define PB_ISTREAM_EMPTY {0,0,0,0}
  ------------------
 1094|  94.2k|    uint32_t tag = 0;
 1095|  94.2k|    pb_wire_type_t wire_type = PB_WT_VARINT;
 1096|  94.2k|    bool eof;
 1097|       |
 1098|  94.2k|    if (iter->descriptor->default_value)
  ------------------
  |  Branch (1098:9): [True: 0, False: 94.2k]
  ------------------
 1099|      0|    {
 1100|      0|        defstream = pb_istream_from_buffer(iter->descriptor->default_value, (size_t)-1);
 1101|      0|        if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1101:13): [True: 0, False: 0]
  ------------------
 1102|      0|            return false;
 1103|      0|    }
 1104|       |
 1105|  94.2k|    do
 1106|   944k|    {
 1107|   944k|        if (!pb_field_set_to_default(iter))
  ------------------
  |  Branch (1107:13): [True: 0, False: 944k]
  ------------------
 1108|      0|            return false;
 1109|       |
 1110|   944k|        if (tag != 0 && iter->tag == tag)
  ------------------
  |  Branch (1110:13): [True: 0, False: 944k]
  |  Branch (1110:25): [True: 0, False: 0]
  ------------------
 1111|      0|        {
 1112|       |            /* We have a default value for this field in the defstream */
 1113|      0|            if (!decode_field(&defstream, wire_type, iter))
  ------------------
  |  Branch (1113:17): [True: 0, False: 0]
  ------------------
 1114|      0|                return false;
 1115|      0|            if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1115:17): [True: 0, False: 0]
  ------------------
 1116|      0|                return false;
 1117|       |
 1118|      0|            if (iter->pSize)
  ------------------
  |  Branch (1118:17): [True: 0, False: 0]
  ------------------
 1119|      0|                *(bool*)iter->pSize = false;
 1120|      0|        }
 1121|   944k|    } while (pb_field_iter_next(iter));
  ------------------
  |  Branch (1121:14): [True: 850k, False: 94.2k]
  ------------------
 1122|       |
 1123|  94.2k|    return true;
 1124|  94.2k|}
pb_decode.c:pb_field_set_to_default:
  988|   944k|{
  989|   944k|    pb_type_t type;
  990|   944k|    type = field->type;
  991|       |
  992|   944k|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  335|   944k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   944k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  304|   944k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (992:9): [True: 8.83k, False: 935k]
  ------------------
  993|  8.83k|    {
  994|  8.83k|        pb_extension_t *ext = *(pb_extension_t* const *)field->pData;
  995|  16.0k|        while (ext != NULL)
  ------------------
  |  Branch (995:16): [True: 7.16k, False: 8.83k]
  ------------------
  996|  7.16k|        {
  997|  7.16k|            pb_field_iter_t ext_iter;
  998|  7.16k|            if (ext->type->decode != NULL)
  ------------------
  |  Branch (998:17): [True: 0, False: 7.16k]
  ------------------
  999|      0|                ext->found = false; /* Custom type: arg is not a message descriptor */
 1000|  7.16k|            else if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (1000:22): [True: 7.16k, False: 0]
  ------------------
 1001|  7.16k|            {
 1002|  7.16k|                ext->found = false;
 1003|  7.16k|                if (!pb_message_set_to_defaults(&ext_iter))
  ------------------
  |  Branch (1003:21): [True: 0, False: 7.16k]
  ------------------
 1004|      0|                    return false;
 1005|  7.16k|            }
 1006|  7.16k|            ext = ext->next;
 1007|  7.16k|        }
 1008|  8.83k|    }
 1009|   935k|    else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  333|   935k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|   935k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  328|   935k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1009:14): [True: 33.6k, False: 901k]
  ------------------
 1010|  33.6k|    {
 1011|  33.6k|        bool init_data = true;
 1012|  33.6k|        if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  334|  33.6k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  33.6k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  319|  67.3k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (1012:13): [True: 0, False: 33.6k]
  |  Branch (1012:52): [True: 0, False: 0]
  ------------------
 1013|      0|        {
 1014|       |            /* Set has_field to false. Still initialize the optional field
 1015|       |             * itself also. */
 1016|      0|            *(bool*)field->pSize = false;
 1017|      0|        }
 1018|  33.6k|        else if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  334|  33.6k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  33.6k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  321|  67.3k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1018:18): [True: 0, False: 33.6k]
  ------------------
 1019|      0|                 field->pSize == &field->array_size &&
  ------------------
  |  Branch (1019:18): [True: 0, False: 0]
  ------------------
 1020|      0|                 PB_LTYPE_IS_SUBMSG(type))
  ------------------
  |  |  336|      0|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  335|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  295|      0|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (336:32): [True: 0, False: 0]
  |  |  ------------------
  |  |  337|      0|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  335|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  300|      0|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (337:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1021|      0|        {
 1022|       |            /* Fixed count array: there is no count field, so pb_release()
 1023|       |             * walks all array_size entries even if they were not decoded.
 1024|       |             * Initialize all submessages so that their pointers are valid. */
 1025|      0|            pb_size_t i;
 1026|      0|            for (i = 0; i < field->array_size; i++)
  ------------------
  |  Branch (1026:25): [True: 0, False: 0]
  ------------------
 1027|      0|            {
 1028|      0|                pb_field_iter_t submsg_iter;
 1029|      0|                if (pb_field_iter_begin(&submsg_iter, field->submsg_desc,
  ------------------
  |  Branch (1029:21): [True: 0, False: 0]
  ------------------
 1030|      0|                                        (char*)field->pData + field->data_size * i))
 1031|      0|                {
 1032|      0|                    if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (1032:25): [True: 0, False: 0]
  ------------------
 1033|      0|                        return false;
 1034|      0|                }
 1035|      0|            }
 1036|      0|            init_data = false;
 1037|      0|        }
 1038|  33.6k|        else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  334|  33.6k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  33.6k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  321|  67.3k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1038:18): [True: 0, False: 33.6k]
  ------------------
 1039|  33.6k|                 PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  334|  33.6k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  33.6k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                               PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  323|  33.6k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (1039:18): [True: 26.5k, False: 7.16k]
  ------------------
 1040|  26.5k|        {
 1041|       |            /* REPEATED: Set array count to 0, no need to initialize contents.
 1042|       |               ONEOF: Set which_field to 0. */
 1043|  26.5k|            *(pb_size_t*)field->pSize = 0;
 1044|  26.5k|            init_data = false;
 1045|  26.5k|        }
 1046|       |
 1047|  33.6k|        if (init_data)
  ------------------
  |  Branch (1047:13): [True: 7.16k, False: 26.5k]
  ------------------
 1048|  7.16k|        {
 1049|  7.16k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  336|  14.3k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  335|  7.16k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|  7.16k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  295|  14.3k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (336:32): [True: 7.16k, False: 0]
  |  |  ------------------
  |  |  337|  14.3k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  335|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  300|      0|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (337:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1050|  7.16k|                (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (1050:18): [True: 0, False: 7.16k]
  ------------------
 1051|  7.16k|                 field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (1051:18): [True: 0, False: 7.16k]
  ------------------
 1052|  7.16k|                 field->submsg_desc->submsg_info[0] != NULL))
  ------------------
  |  Branch (1052:18): [True: 0, False: 7.16k]
  ------------------
 1053|      0|            {
 1054|       |                /* Initialize submessage to defaults.
 1055|       |                 * Only needed if it has default values
 1056|       |                 * or callback/submessage fields. */
 1057|      0|                pb_field_iter_t submsg_iter;
 1058|      0|                if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (1058:21): [True: 0, False: 0]
  ------------------
 1059|      0|                {
 1060|      0|                    if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (1060:25): [True: 0, False: 0]
  ------------------
 1061|      0|                        return false;
 1062|      0|                }
 1063|      0|            }
 1064|  7.16k|            else
 1065|  7.16k|            {
 1066|       |                /* Initialize to zeros */
 1067|  7.16k|                memset(field->pData, 0, (size_t)field->data_size);
 1068|  7.16k|            }
 1069|  7.16k|        }
 1070|  33.6k|    }
 1071|   901k|    else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  333|   901k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|   901k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  329|   901k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1071:14): [True: 884k, False: 17.6k]
  ------------------
 1072|   884k|    {
 1073|       |        /* Initialize the pointer to NULL. */
 1074|   884k|        *(void**)field->pField = NULL;
 1075|       |
 1076|       |        /* Initialize array count to 0. */
 1077|   884k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  334|   884k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   884k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  321|  1.76M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1077:13): [True: 185k, False: 698k]
  ------------------
 1078|   698k|            PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  334|   698k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   698k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  323|   698k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (1078:13): [True: 17.6k, False: 681k]
  ------------------
 1079|   203k|        {
 1080|   203k|            *(pb_size_t*)field->pSize = 0;
 1081|   203k|        }
 1082|   884k|    }
 1083|  17.6k|    else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  333|  17.6k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|  17.6k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  330|  17.6k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (1083:14): [True: 17.6k, False: 0]
  ------------------
 1084|  17.6k|    {
 1085|       |        /* Don't overwrite callback */
 1086|  17.6k|    }
 1087|       |
 1088|   944k|    return true;
 1089|   944k|}
pb_decode.c:decode_next_tag:
 1132|  32.2M|{
 1133|       |    /* Length-delimited messages must consume their full advertised size. */
 1134|  32.2M|    bool delimited_not_done = (flags & PB_DECODE_DELIMITED) != 0 && stream->bytes_left > 0;
  ------------------
  |  |  123|  32.2M|#define PB_DECODE_DELIMITED       0x02U
  ------------------
  |  Branch (1134:31): [True: 904k, False: 31.3M]
  |  Branch (1134:69): [True: 746k, False: 158k]
  ------------------
 1135|       |
 1136|  32.2M|    if (pb_decode_tag(stream, wire_type, tag, eof))
  ------------------
  |  Branch (1136:9): [True: 32.0M, False: 165k]
  ------------------
 1137|  32.0M|        return true;
 1138|       |
 1139|   165k|    if (*eof && delimited_not_done)
  ------------------
  |  Branch (1139:9): [True: 165k, False: 107]
  |  Branch (1139:17): [True: 0, False: 165k]
  ------------------
 1140|      0|    {
 1141|      0|        *eof = false;
 1142|      0|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1143|      0|    }
 1144|       |
 1145|   165k|    return false;
 1146|   165k|}
pb_decode.c:decode_extension:
  966|  80.5k|{
  967|  80.5k|    size_t pos = stream->bytes_left;
  968|       |    
  969|   161k|    while (extension != NULL && pos == stream->bytes_left)
  ------------------
  |  Branch (969:12): [True: 80.5k, False: 80.4k]
  |  Branch (969:33): [True: 80.5k, False: 0]
  ------------------
  970|  80.5k|    {
  971|  80.5k|        bool status;
  972|  80.5k|        if (extension->type->decode)
  ------------------
  |  Branch (972:13): [True: 0, False: 80.5k]
  ------------------
  973|      0|            status = extension->type->decode(stream, extension, tag, wire_type);
  974|  80.5k|        else
  975|  80.5k|            status = default_extension_decoder(stream, extension, tag, wire_type);
  976|       |
  977|  80.5k|        if (!status)
  ------------------
  |  Branch (977:13): [True: 112, False: 80.4k]
  ------------------
  978|    112|            return false;
  979|       |        
  980|  80.4k|        extension = extension->next;
  981|  80.4k|    }
  982|       |    
  983|  80.4k|    return true;
  984|  80.5k|}
pb_decode.c:default_extension_decoder:
  949|  80.5k|{
  950|  80.5k|    pb_field_iter_t iter;
  951|       |
  952|  80.5k|    if (!pb_field_iter_begin_extension(&iter, extension))
  ------------------
  |  Branch (952:9): [True: 0, False: 80.5k]
  ------------------
  953|      0|        PB_RETURN_ERROR(stream, "invalid extension");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  954|       |
  955|  80.5k|    if (iter.tag != tag || !iter.message)
  ------------------
  |  Branch (955:9): [True: 76.9k, False: 3.66k]
  |  Branch (955:28): [True: 0, False: 3.66k]
  ------------------
  956|  76.9k|        return true;
  957|       |
  958|  3.66k|    extension->found = true;
  959|  3.66k|    return decode_field(stream, wire_type, &iter);
  960|  80.5k|}
pb_decode.c:decode_field:
  917|  31.5M|{
  918|  31.5M|#ifdef PB_ENABLE_MALLOC
  919|       |    /* When decoding an oneof field, check if there is old data that must be
  920|       |     * released first. */
  921|  31.5M|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  334|  31.5M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  31.5M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  323|  31.5M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (921:9): [True: 29.9k, False: 31.5M]
  ------------------
  922|  29.9k|    {
  923|  29.9k|        if (!pb_release_union_field(stream, field))
  ------------------
  |  Branch (923:13): [True: 0, False: 29.9k]
  ------------------
  924|      0|            return false;
  925|  29.9k|    }
  926|  31.5M|#endif
  927|       |
  928|  31.5M|    switch (PB_ATYPE(field->type))
  ------------------
  |  |  333|  31.5M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|  31.5M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
  929|  31.5M|    {
  930|  13.9k|        case PB_ATYPE_STATIC:
  ------------------
  |  |  328|  13.9k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (930:9): [True: 13.9k, False: 31.5M]
  ------------------
  931|  13.9k|            return decode_static_field(stream, wire_type, field);
  932|       |        
  933|  31.5M|        case PB_ATYPE_POINTER:
  ------------------
  |  |  329|  31.5M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (933:9): [True: 31.5M, False: 21.6k]
  ------------------
  934|  31.5M|            return decode_pointer_field(stream, wire_type, field);
  935|       |        
  936|  7.79k|        case PB_ATYPE_CALLBACK:
  ------------------
  |  |  330|  7.79k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (936:9): [True: 7.79k, False: 31.5M]
  ------------------
  937|  7.79k|            return decode_callback_field(stream, wire_type, field);
  938|       |        
  939|      0|        default:
  ------------------
  |  Branch (939:9): [True: 0, False: 31.5M]
  ------------------
  940|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  941|  31.5M|    }
  942|  31.5M|}
pb_decode.c:pb_release_union_field:
 1368|  29.9k|{
 1369|  29.9k|    pb_field_iter_t old_field = *field;
 1370|  29.9k|    pb_size_t old_tag = *(pb_size_t*)field->pSize; /* Previous which_ value */
 1371|  29.9k|    pb_size_t new_tag = field->tag; /* New which_ value */
 1372|       |
 1373|  29.9k|    if (old_tag == 0)
  ------------------
  |  Branch (1373:9): [True: 1.86k, False: 28.0k]
  ------------------
 1374|  1.86k|        return true; /* Ok, no old data in union */
 1375|       |
 1376|  28.0k|    if (old_tag == new_tag)
  ------------------
  |  Branch (1376:9): [True: 9.03k, False: 19.0k]
  ------------------
 1377|  9.03k|        return true; /* Ok, old data is of same type => merge */
 1378|       |
 1379|       |    /* Release old data. The find can fail if the message struct contains
 1380|       |     * invalid data. */
 1381|  19.0k|    if (!pb_field_iter_find(&old_field, old_tag))
  ------------------
  |  Branch (1381:9): [True: 0, False: 19.0k]
  ------------------
 1382|      0|        PB_RETURN_ERROR(stream, "invalid union tag");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1383|       |
 1384|  19.0k|    pb_release_single_field(&old_field);
 1385|       |
 1386|  19.0k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  333|  19.0k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|  19.0k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  329|  19.0k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1386:9): [True: 7.87k, False: 11.1k]
  ------------------
 1387|  7.87k|    {
 1388|       |        /* Initialize the pointer to NULL to make sure it is valid
 1389|       |         * even in case of error return. */
 1390|  7.87k|        *(void**)field->pField = NULL;
 1391|  7.87k|        field->pData = NULL;
 1392|  7.87k|    }
 1393|       |
 1394|       |    return true;
 1395|  19.0k|}
pb_decode.c:decode_static_field:
  503|  13.9k|{
  504|  13.9k|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  334|  13.9k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  13.9k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  505|  13.9k|    {
  506|  3.66k|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  318|  3.66k|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (506:9): [True: 3.66k, False: 10.2k]
  ------------------
  507|  3.66k|            return decode_basic_field(stream, wire_type, field);
  508|       |            
  509|  1.31k|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  319|  1.31k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (509:9): [True: 1.31k, False: 12.5k]
  ------------------
  510|  1.31k|            if (field->pSize != NULL)
  ------------------
  |  Branch (510:17): [True: 1.31k, False: 0]
  ------------------
  511|  1.31k|                *(bool*)field->pSize = true;
  512|  1.31k|            return decode_basic_field(stream, wire_type, field);
  513|       |    
  514|      0|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  321|      0|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (514:9): [True: 0, False: 13.9k]
  ------------------
  515|      0|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (515:17): [True: 0, False: 0]
  ------------------
  516|      0|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  335|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  283|      0|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (516:20): [True: 0, False: 0]
  ------------------
  517|      0|            {
  518|       |                /* Packed array */
  519|      0|                bool status = true;
  520|      0|                pb_istream_t substream;
  521|      0|                pb_size_t *size = (pb_size_t*)field->pSize;
  522|      0|                field->pData = (char*)field->pField + field->data_size * (*size);
  523|       |
  524|      0|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (524:21): [True: 0, False: 0]
  ------------------
  525|      0|                    return false;
  526|       |
  527|      0|                while (substream.bytes_left > 0 && *size < field->array_size)
  ------------------
  |  Branch (527:24): [True: 0, False: 0]
  |  Branch (527:52): [True: 0, False: 0]
  ------------------
  528|      0|                {
  529|      0|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (529:25): [True: 0, False: 0]
  ------------------
  530|      0|                    {
  531|      0|                        status = false;
  532|      0|                        break;
  533|      0|                    }
  534|      0|                    (*size)++;
  535|      0|                    field->pData = (char*)field->pData + field->data_size;
  536|      0|                }
  537|       |
  538|      0|                if (substream.bytes_left != 0)
  ------------------
  |  Branch (538:21): [True: 0, False: 0]
  ------------------
  539|      0|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  540|      0|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (540:21): [True: 0, False: 0]
  ------------------
  541|      0|                    return false;
  542|       |
  543|      0|                return status;
  544|      0|            }
  545|      0|            else
  546|      0|            {
  547|       |                /* Repeated field */
  548|      0|                pb_size_t *size = (pb_size_t*)field->pSize;
  549|      0|                field->pData = (char*)field->pField + field->data_size * (*size);
  550|       |
  551|      0|                if ((*size)++ >= field->array_size)
  ------------------
  |  Branch (551:21): [True: 0, False: 0]
  ------------------
  552|      0|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  553|       |
  554|      0|                if (PB_LTYPE_IS_SUBMSG(field->type))
  ------------------
  |  |  336|      0|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  335|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  295|      0|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (336:32): [True: 0, False: 0]
  |  |  ------------------
  |  |  337|      0|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  335|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  300|      0|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (337:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  555|      0|                {
  556|       |                    /* The entry is now counted, so pb_release() will walk it
  557|       |                     * even if decoding fails before pb_dec_submessage().
  558|       |                     * Set defaults here so that its pointers are valid. */
  559|      0|                    pb_field_iter_t submsg_iter;
  560|      0|                    if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (560:25): [True: 0, False: 0]
  ------------------
  561|      0|                    {
  562|      0|                        if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (562:29): [True: 0, False: 0]
  ------------------
  563|      0|                            PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  564|      0|                    }
  565|      0|                }
  566|       |
  567|      0|                return decode_basic_field(stream, wire_type, field);
  568|      0|            }
  569|       |
  570|  8.92k|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  323|  8.92k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (570:9): [True: 8.92k, False: 4.97k]
  ------------------
  571|  8.92k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  336|  17.8k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  335|  8.92k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|  8.92k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  295|  17.8k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (336:32): [True: 7.19k, False: 1.72k]
  |  |  ------------------
  |  |  337|  17.8k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  335|  1.72k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|  1.72k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  300|  1.72k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (337:32): [True: 0, False: 1.72k]
  |  |  ------------------
  ------------------
  572|  7.19k|                *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (572:17): [True: 5.46k, False: 1.73k]
  ------------------
  573|  5.46k|            {
  574|       |                /* We memset to zero so that any callbacks are set to NULL.
  575|       |                 * This is because the callbacks might otherwise have values
  576|       |                 * from some other union field.
  577|       |                 * If callbacks are needed inside oneof field, use .proto
  578|       |                 * option submsg_callback to have a separate callback function
  579|       |                 * that can set the fields before submessage is decoded.
  580|       |                 * pb_dec_submessage() will set any default values. */
  581|  5.46k|                memset(field->pData, 0, (size_t)field->data_size);
  582|       |
  583|       |                /* Set default values for the submessage fields. */
  584|  5.46k|                if (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (584:21): [True: 0, False: 5.46k]
  ------------------
  585|  5.46k|                    field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (585:21): [True: 0, False: 5.46k]
  ------------------
  586|  5.46k|                    field->submsg_desc->submsg_info[0] != NULL)
  ------------------
  |  Branch (586:21): [True: 0, False: 5.46k]
  ------------------
  587|      0|                {
  588|      0|                    pb_field_iter_t submsg_iter;
  589|      0|                    if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (589:25): [True: 0, False: 0]
  ------------------
  590|      0|                    {
  591|      0|                        if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (591:29): [True: 0, False: 0]
  ------------------
  592|      0|                            PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  593|      0|                    }
  594|      0|                }
  595|  5.46k|            }
  596|  8.92k|            *(pb_size_t*)field->pSize = field->tag;
  597|       |
  598|  8.92k|            return decode_basic_field(stream, wire_type, field);
  599|       |
  600|      0|        default:
  ------------------
  |  Branch (600:9): [True: 0, False: 13.9k]
  ------------------
  601|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  602|  13.9k|    }
  603|  13.9k|}
pb_decode.c:decode_basic_field:
  432|  42.5M|{
  433|  42.5M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  335|  42.5M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  42.5M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  434|  42.5M|    {
  435|  3.11M|        case PB_LTYPE_BOOL:
  ------------------
  |  |  275|  3.11M|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (435:9): [True: 3.11M, False: 39.3M]
  ------------------
  436|  3.11M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (436:17): [True: 2.67M, False: 449k]
  |  Branch (436:46): [True: 14, False: 2.67M]
  ------------------
  437|     14|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  937|     14|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     14|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  438|       |
  439|  3.11M|            return pb_dec_bool(stream, field);
  440|       |
  441|  4.29M|        case PB_LTYPE_VARINT:
  ------------------
  |  |  276|  4.29M|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (441:9): [True: 4.29M, False: 38.2M]
  ------------------
  442|  5.46M|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  277|  5.46M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (442:9): [True: 1.16M, False: 41.3M]
  ------------------
  443|  9.29M|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  278|  9.29M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (443:9): [True: 3.82M, False: 38.6M]
  ------------------
  444|  9.29M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (444:17): [True: 8.29M, False: 997k]
  |  Branch (444:46): [True: 71, False: 8.29M]
  ------------------
  445|     71|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  937|     71|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     71|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 71]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  446|       |
  447|  9.29M|            return pb_dec_varint(stream, field);
  448|       |
  449|   136k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  279|   136k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (449:9): [True: 136k, False: 42.3M]
  ------------------
  450|   136k|            if (wire_type != PB_WT_32BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (450:17): [True: 46.6k, False: 89.4k]
  |  Branch (450:45): [True: 18, False: 46.6k]
  ------------------
  451|     18|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  937|     18|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     18|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  452|       |
  453|   136k|            return pb_decode_fixed32(stream, field->pData);
  454|       |
  455|  63.8k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  280|  63.8k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (455:9): [True: 63.8k, False: 42.4M]
  ------------------
  456|  63.8k|            if (wire_type != PB_WT_64BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (456:17): [True: 15.4k, False: 48.4k]
  |  Branch (456:45): [True: 13, False: 15.4k]
  ------------------
  457|     13|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  937|     13|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     13|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  458|       |
  459|       |#ifdef PB_CONVERT_DOUBLE_FLOAT
  460|       |            if (field->data_size == sizeof(float))
  461|       |            {
  462|       |                return pb_decode_double_as_float(stream, (float*)field->pData);
  463|       |            }
  464|       |#endif
  465|       |
  466|       |#ifdef PB_WITHOUT_64BIT
  467|       |            PB_RETURN_ERROR(stream, "invalid data_size");
  468|       |#else
  469|  63.8k|            return pb_decode_fixed64(stream, field->pData);
  470|      0|#endif
  471|       |
  472|   510k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  287|   510k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (472:9): [True: 510k, False: 42.0M]
  ------------------
  473|   510k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (473:17): [True: 14, False: 510k]
  ------------------
  474|     14|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  937|     14|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     14|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  475|       |
  476|   510k|            return pb_dec_bytes(stream, field);
  477|       |
  478|   111k|        case PB_LTYPE_STRING:
  ------------------
  |  |  291|   111k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (478:9): [True: 111k, False: 42.4M]
  ------------------
  479|   111k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (479:17): [True: 15, False: 111k]
  ------------------
  480|     15|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  937|     15|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     15|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  481|       |
  482|   111k|            return pb_dec_string(stream, field);
  483|       |
  484|   158k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  295|   158k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (484:9): [True: 158k, False: 42.3M]
  ------------------
  485|   158k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  300|   158k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (485:9): [True: 0, False: 42.5M]
  ------------------
  486|   158k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (486:17): [True: 32, False: 158k]
  ------------------
  487|     32|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  937|     32|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     32|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  488|       |
  489|   158k|            return pb_dec_submessage(stream, field);
  490|       |
  491|  29.1M|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  310|  29.1M|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (491:9): [True: 29.1M, False: 13.3M]
  ------------------
  492|  29.1M|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (492:17): [True: 4, False: 29.1M]
  ------------------
  493|      4|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  937|      4|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      4|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  494|       |
  495|  29.1M|            return pb_dec_fixed_length_bytes(stream, field);
  496|       |
  497|      0|        default:
  ------------------
  |  Branch (497:9): [True: 0, False: 42.5M]
  ------------------
  498|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  499|  42.5M|    }
  500|  42.5M|}
pb_decode.c:pb_dec_bool:
 1595|  3.11M|{
 1596|  3.11M|    return pb_decode_bool(stream, (bool*)field->pData);
 1597|  3.11M|}
pb_decode.c:pb_dec_varint:
 1600|  9.29M|{
 1601|  9.29M|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  335|  9.29M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  9.29M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  277|  9.29M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (1601:9): [True: 1.16M, False: 8.12M]
  ------------------
 1602|  1.16M|    {
 1603|  1.16M|        pb_uint64_t value, clamped;
  ------------------
  |  |   58|  1.16M|#define pb_uint64_t uint64_t
  ------------------
 1604|  1.16M|        if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1604:13): [True: 36, False: 1.16M]
  ------------------
 1605|     36|            return false;
 1606|       |
 1607|       |        /* Cast to the proper field size, while checking for overflows */
 1608|  1.16M|        if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (1608:13): [True: 551k, False: 614k]
  ------------------
 1609|   551k|            clamped = *(pb_uint64_t*)field->pData = value;
 1610|   614k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (1610:18): [True: 592k, False: 21.8k]
  ------------------
 1611|   592k|            clamped = *(uint32_t*)field->pData = (uint32_t)value;
 1612|  21.8k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (1612:18): [True: 10.8k, False: 10.9k]
  ------------------
 1613|  10.8k|            clamped = *(uint_least16_t*)field->pData = (uint_least16_t)value;
 1614|  10.9k|        else if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (1614:18): [True: 10.9k, False: 0]
  ------------------
 1615|  10.9k|            clamped = *(uint_least8_t*)field->pData = (uint_least8_t)value;
 1616|      0|        else
 1617|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1618|       |
 1619|  1.16M|        if (clamped != value)
  ------------------
  |  Branch (1619:13): [True: 113, False: 1.16M]
  ------------------
 1620|    113|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  937|    113|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|    113|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 113]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1621|       |
 1622|  1.16M|        return true;
 1623|  1.16M|    }
 1624|  8.12M|    else
 1625|  8.12M|    {
 1626|  8.12M|        pb_uint64_t value;
  ------------------
  |  |   58|  8.12M|#define pb_uint64_t uint64_t
  ------------------
 1627|  8.12M|        pb_int64_t svalue;
  ------------------
  |  |   57|  8.12M|#define pb_int64_t int64_t
  ------------------
 1628|  8.12M|        pb_int64_t clamped;
  ------------------
  |  |   57|  8.12M|#define pb_int64_t int64_t
  ------------------
 1629|       |
 1630|  8.12M|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  335|  8.12M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  8.12M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  278|  8.12M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (1630:13): [True: 3.82M, False: 4.29M]
  ------------------
 1631|  3.82M|        {
 1632|  3.82M|            if (!pb_decode_svarint(stream, &svalue))
  ------------------
  |  Branch (1632:17): [True: 43, False: 3.82M]
  ------------------
 1633|     43|                return false;
 1634|  3.82M|        }
 1635|  4.29M|        else
 1636|  4.29M|        {
 1637|  4.29M|            if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1637:17): [True: 64, False: 4.29M]
  ------------------
 1638|     64|                return false;
 1639|       |
 1640|       |            /* See issue 97: Google's C++ protobuf allows negative varint values to
 1641|       |            * be cast as int32_t, instead of the int64_t that should be used when
 1642|       |            * encoding. Nanopb versions before 0.2.5 had a bug in encoding. In order to
 1643|       |            * not break decoding of such messages, we cast <=32 bit fields to
 1644|       |            * int32_t first to get the sign correct.
 1645|       |            */
 1646|  4.29M|            if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1646:17): [True: 677k, False: 3.62M]
  ------------------
 1647|   677k|                svalue = (pb_int64_t)value;
 1648|  3.62M|            else
 1649|  3.62M|                svalue = (int32_t)value;
 1650|  4.29M|        }
 1651|       |
 1652|       |        /* Cast to the proper field size, while checking for overflows */
 1653|  8.12M|        if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1653:13): [True: 4.40M, False: 3.72M]
  ------------------
 1654|  4.40M|            clamped = *(pb_int64_t*)field->pData = svalue;
 1655|  3.72M|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (1655:18): [True: 3.68M, False: 43.1k]
  ------------------
 1656|  3.68M|            clamped = *(int32_t*)field->pData = (int32_t)svalue;
 1657|  43.1k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (1657:18): [True: 21.5k, False: 21.6k]
  ------------------
 1658|  21.5k|            clamped = *(int_least16_t*)field->pData = (int_least16_t)svalue;
 1659|  21.6k|        else if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (1659:18): [True: 21.6k, False: 0]
  ------------------
 1660|  21.6k|            clamped = *(int_least8_t*)field->pData = (int_least8_t)svalue;
 1661|      0|        else
 1662|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1663|       |
 1664|  8.12M|        if (clamped != svalue)
  ------------------
  |  Branch (1664:13): [True: 90, False: 8.12M]
  ------------------
 1665|     90|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  937|     90|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     90|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 90]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1666|       |
 1667|  8.12M|        return true;
 1668|  8.12M|    }
 1669|  9.29M|}
pb_decode.c:pb_dec_bytes:
 1672|   510k|{
 1673|   510k|    uint32_t size;
 1674|   510k|    size_t alloc_size;
 1675|   510k|    pb_bytes_array_t *dest;
 1676|       |    
 1677|   510k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1677:9): [True: 19, False: 510k]
  ------------------
 1678|     19|        return false;
 1679|       |    
 1680|   510k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  349|   510k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1680:9): [True: 32, False: 510k]
  ------------------
 1681|     32|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  937|     32|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     32|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1682|       |    
 1683|   510k|    alloc_size = PB_BYTES_ARRAY_T_ALLOCSIZE(size);
  ------------------
  |  |  418|   510k|    (((size_t)(n) + offsetof(pb_bytes_array_t, bytes)) < sizeof(pb_bytes_array_t) \
  |  |  ------------------
  |  |  |  Branch (418:6): [True: 499k, False: 10.4k]
  |  |  ------------------
  |  |  419|   510k|        ? sizeof(pb_bytes_array_t) \
  |  |  420|   510k|        : ((size_t)(n) + offsetof(pb_bytes_array_t, bytes)))
  ------------------
 1684|   510k|    if (size > alloc_size)
  ------------------
  |  Branch (1684:9): [True: 0, False: 510k]
  ------------------
 1685|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1686|       |    
 1687|   510k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  333|   510k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|   510k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  329|   510k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1687:9): [True: 510k, False: 0]
  ------------------
 1688|   510k|    {
 1689|       |#ifndef PB_ENABLE_MALLOC
 1690|       |        PB_RETURN_ERROR(stream, "no malloc support");
 1691|       |#else
 1692|   510k|        if (stream->bytes_left < size)
  ------------------
  |  Branch (1692:13): [True: 52, False: 510k]
  ------------------
 1693|     52|            PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  937|     52|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     52|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 52]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1694|       |
 1695|   510k|        if (!allocate_field(stream, field->pData, alloc_size, 1))
  ------------------
  |  Branch (1695:13): [True: 0, False: 510k]
  ------------------
 1696|      0|            return false;
 1697|   510k|        dest = *(pb_bytes_array_t**)field->pData;
 1698|   510k|#endif
 1699|   510k|    }
 1700|      0|    else
 1701|      0|    {
 1702|      0|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1702:13): [True: 0, False: 0]
  ------------------
 1703|      0|            PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1704|      0|        dest = (pb_bytes_array_t*)field->pData;
 1705|      0|    }
 1706|       |
 1707|   510k|    dest->size = (pb_size_t)size;
 1708|   510k|    return pb_read(stream, dest->bytes, (size_t)size);
 1709|   510k|}
pb_decode.c:allocate_field:
  611|  32.8M|{    
  612|  32.8M|    void *ptr = *(void**)pData;
  613|       |    
  614|  32.8M|    if (data_size == 0 || array_size == 0)
  ------------------
  |  Branch (614:9): [True: 0, False: 32.8M]
  |  Branch (614:27): [True: 0, False: 32.8M]
  ------------------
  615|      0|        PB_RETURN_ERROR(stream, "invalid size");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  616|       |    
  617|       |#ifdef __AVR__
  618|       |    /* Workaround for AVR libc bug 53284: http://savannah.nongnu.org/bugs/?53284
  619|       |     * Realloc to size of 1 byte can cause corruption of the malloc structures.
  620|       |     */
  621|       |    if (data_size == 1 && array_size == 1)
  622|       |    {
  623|       |        data_size = 2;
  624|       |    }
  625|       |#endif
  626|       |
  627|       |    /* Check for multiplication overflows.
  628|       |     * This code avoids the costly division if the sizes are small enough.
  629|       |     * Multiplication is safe as long as only half of bits are set
  630|       |     * in either multiplicand.
  631|       |     */
  632|  32.8M|    {
  633|  32.8M|        const size_t check_limit = (size_t)1 << (sizeof(size_t) * 4);
  634|  32.8M|        if (data_size >= check_limit || array_size >= check_limit)
  ------------------
  |  Branch (634:13): [True: 0, False: 32.8M]
  |  Branch (634:41): [True: 0, False: 32.8M]
  ------------------
  635|      0|        {
  636|      0|            const size_t size_max = (size_t)-1;
  637|      0|            if (size_max / array_size < data_size)
  ------------------
  |  Branch (637:17): [True: 0, False: 0]
  ------------------
  638|      0|            {
  639|      0|                PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  640|      0|            }
  641|      0|        }
  642|  32.8M|    }
  643|       |    
  644|       |    /* Allocate new or expand previous allocation */
  645|       |    /* Note: on failure the old pointer will remain in the structure,
  646|       |     * the message must be freed by caller also on error return. */
  647|  32.8M|    ptr = pb_realloc(ptr, array_size * data_size);
  ------------------
  |  |    3|  32.8M|#define pb_realloc(ptr,size) realloc_with_check(ptr,size)
  ------------------
  648|  32.8M|    if (ptr == NULL)
  ------------------
  |  Branch (648:9): [True: 0, False: 32.8M]
  ------------------
  649|      0|        PB_RETURN_ERROR(stream, "realloc failed");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  650|       |    
  651|  32.8M|    *(void**)pData = ptr;
  652|       |    return true;
  653|  32.8M|}
pb_decode.c:pb_dec_string:
 1712|   111k|{
 1713|   111k|    uint32_t size;
 1714|   111k|    size_t alloc_size;
 1715|   111k|    pb_byte_t *dest = (pb_byte_t*)field->pData;
 1716|       |
 1717|   111k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1717:9): [True: 29, False: 111k]
  ------------------
 1718|     29|        return false;
 1719|       |
 1720|   111k|    if (size == (uint32_t)-1)
  ------------------
  |  Branch (1720:9): [True: 2, False: 111k]
  ------------------
 1721|      2|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  937|      2|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      2|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1722|       |
 1723|       |    /* Space for null terminator */
 1724|   111k|    alloc_size = (size_t)(size + 1);
 1725|       |
 1726|   111k|    if (alloc_size < size)
  ------------------
  |  Branch (1726:9): [True: 0, False: 111k]
  ------------------
 1727|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1728|       |
 1729|   111k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  333|   111k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|   111k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  329|   111k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1729:9): [True: 109k, False: 1.29k]
  ------------------
 1730|   109k|    {
 1731|       |#ifndef PB_ENABLE_MALLOC
 1732|       |        PB_RETURN_ERROR(stream, "no malloc support");
 1733|       |#else
 1734|   109k|        if (stream->bytes_left < size)
  ------------------
  |  Branch (1734:13): [True: 64, False: 109k]
  ------------------
 1735|     64|            PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  937|     64|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     64|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 64]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1736|       |
 1737|   109k|        if (!allocate_field(stream, field->pData, alloc_size, 1))
  ------------------
  |  Branch (1737:13): [True: 0, False: 109k]
  ------------------
 1738|      0|            return false;
 1739|   109k|        dest = *(pb_byte_t**)field->pData;
 1740|   109k|#endif
 1741|   109k|    }
 1742|  1.29k|    else
 1743|  1.29k|    {
 1744|  1.29k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1744:13): [True: 42, False: 1.25k]
  ------------------
 1745|     42|            PB_RETURN_ERROR(stream, "string overflow");
  ------------------
  |  |  937|     42|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     42|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 42]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1746|  1.29k|    }
 1747|       |    
 1748|   111k|    dest[size] = 0;
 1749|       |
 1750|   111k|    if (!pb_read(stream, dest, (size_t)size))
  ------------------
  |  Branch (1750:9): [True: 3, False: 111k]
  ------------------
 1751|      3|        return false;
 1752|       |
 1753|       |#ifdef PB_VALIDATE_UTF8
 1754|       |    if (!pb_validate_utf8((const char*)dest))
 1755|       |        PB_RETURN_ERROR(stream, "invalid utf8");
 1756|       |#endif
 1757|       |
 1758|   111k|    return true;
 1759|   111k|}
pb_decode.c:pb_dec_submessage:
 1762|   158k|{
 1763|   158k|    bool status = true;
 1764|   158k|    bool submsg_consumed = false;
 1765|   158k|    pb_istream_t substream;
 1766|       |
 1767|   158k|    if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1767:9): [True: 155, False: 158k]
  ------------------
 1768|    155|        return false;
 1769|       |    
 1770|   158k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (1770:9): [True: 0, False: 158k]
  ------------------
 1771|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1772|       |    
 1773|       |    /* Submessages can have a separate message-level callback that is called
 1774|       |     * before decoding the message. Typically it is used to set callback fields
 1775|       |     * inside oneofs. Required fields have no callback slot. Extension fields
 1776|       |     * are always required, and for them pSize points to extension->found. */
 1777|   158k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL &&
  ------------------
  |  |  335|   158k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   158k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL &&
  ------------------
  |  |  300|   317k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (1777:9): [True: 0, False: 158k]
  |  Branch (1777:58): [True: 0, False: 0]
  ------------------
 1778|      0|        PB_HTYPE(field->type) != PB_HTYPE_REQUIRED)
  ------------------
  |  |  334|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      PB_HTYPE(field->type) != PB_HTYPE_REQUIRED)
  ------------------
  |  |  318|      0|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (1778:9): [True: 0, False: 0]
  ------------------
 1779|      0|    {
 1780|       |        /* Message callback is stored right before pSize. */
 1781|      0|        pb_callback_t *callback = (pb_callback_t*)field->pSize - 1;
 1782|      0|        if (callback->funcs.decode)
  ------------------
  |  Branch (1782:13): [True: 0, False: 0]
  ------------------
 1783|      0|        {
 1784|      0|            status = callback->funcs.decode(&substream, field, &callback->arg);
 1785|       |
 1786|      0|            if (substream.bytes_left == 0)
  ------------------
  |  Branch (1786:17): [True: 0, False: 0]
  ------------------
 1787|      0|            {
 1788|      0|                submsg_consumed = true;
 1789|      0|            }
 1790|      0|        }
 1791|      0|    }
 1792|       |
 1793|       |    /* Now decode the submessage contents */
 1794|   158k|    if (status && !submsg_consumed)
  ------------------
  |  Branch (1794:9): [True: 158k, False: 0]
  |  Branch (1794:19): [True: 158k, False: 0]
  ------------------
 1795|   158k|    {
 1796|   158k|        unsigned int flags = PB_DECODE_DELIMITED;
  ------------------
  |  |  123|   158k|#define PB_DECODE_DELIMITED       0x02U
  ------------------
 1797|       |
 1798|       |        /* Static required/optional fields are already initialized by top-level
 1799|       |         * pb_decode() and repeated/oneof fields by decode_static_field(), no
 1800|       |         * need to initialize them again. Single pointer submessages are
 1801|       |         * initialized by decode_pointer_field() when they are allocated, and
 1802|       |         * must not be cleared when the field occurs again and is merged. */
 1803|   158k|        if (PB_ATYPE(field->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  333|   158k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|   158k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(field->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  328|   317k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1803:13): [True: 10.8k, False: 147k]
  ------------------
 1804|   147k|            (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  333|   147k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|   147k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  329|   295k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1804:14): [True: 147k, False: 0]
  ------------------
 1805|   147k|             PB_HTYPE(field->type) != PB_HTYPE_REPEATED))
  ------------------
  |  |  334|   147k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   147k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                           PB_HTYPE(field->type) != PB_HTYPE_REPEATED))
  ------------------
  |  |  321|   147k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1805:14): [True: 72.7k, False: 75.2k]
  ------------------
 1806|  83.5k|        {
 1807|  83.5k|            flags |= PB_DECODE_NOINIT;
  ------------------
  |  |  122|  83.5k|#define PB_DECODE_NOINIT          0x01U
  ------------------
 1808|  83.5k|        }
 1809|       |
 1810|   158k|        status = pb_decode_inner(&substream, field->submsg_desc, field->pData, flags);
 1811|   158k|    }
 1812|       |    
 1813|   158k|    if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1813:9): [True: 0, False: 158k]
  ------------------
 1814|      0|        return false;
 1815|       |
 1816|   158k|    return status;
 1817|   158k|}
pb_decode.c:pb_dec_fixed_length_bytes:
 1820|  29.1M|{
 1821|  29.1M|    uint32_t size;
 1822|       |
 1823|  29.1M|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1823:9): [True: 3, False: 29.1M]
  ------------------
 1824|      3|        return false;
 1825|       |
 1826|  29.1M|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  349|  29.1M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1826:9): [True: 29, False: 29.1M]
  ------------------
 1827|     29|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  937|     29|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     29|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 29]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1828|       |
 1829|  29.1M|    if (size == 0)
  ------------------
  |  Branch (1829:9): [True: 28.0M, False: 1.05M]
  ------------------
 1830|  28.0M|    {
 1831|       |        /* As a special case, treat empty bytes string as all zeros for fixed_length_bytes. */
 1832|  28.0M|        memset(field->pData, 0, (size_t)field->data_size);
 1833|  28.0M|        return true;
 1834|  28.0M|    }
 1835|       |
 1836|  1.05M|    if (size != field->data_size)
  ------------------
  |  Branch (1836:9): [True: 46, False: 1.05M]
  ------------------
 1837|     46|        PB_RETURN_ERROR(stream, "incorrect fixed length bytes size");
  ------------------
  |  |  937|     46|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     46|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 46]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1838|       |
 1839|  1.05M|    return pb_read(stream, (pb_byte_t*)field->pData, (size_t)field->data_size);
 1840|  1.05M|}
pb_decode.c:decode_pointer_field:
  673|  31.5M|{
  674|       |#ifndef PB_ENABLE_MALLOC
  675|       |    PB_UNUSED(wire_type);
  676|       |    PB_UNUSED(field);
  677|       |    PB_RETURN_ERROR(stream, "no malloc support");
  678|       |#else
  679|  31.5M|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  334|  31.5M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  31.5M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  680|  31.5M|    {
  681|  1.72M|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  318|  1.72M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (681:9): [True: 1.72M, False: 29.8M]
  ------------------
  682|  1.73M|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  319|  1.73M|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (682:9): [True: 16.8k, False: 31.5M]
  ------------------
  683|  1.75M|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  323|  1.75M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (683:9): [True: 13.1k, False: 31.5M]
  ------------------
  684|  1.75M|            if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  334|  1.75M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  1.75M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  323|  1.75M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (684:17): [True: 13.1k, False: 1.73M]
  ------------------
  685|  13.1k|            {
  686|  13.1k|                *(pb_size_t*)field->pSize = field->tag;
  687|  13.1k|            }
  688|       |
  689|  1.75M|            if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  335|  1.75M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  1.75M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  291|  3.50M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (689:17): [True: 83.7k, False: 1.66M]
  ------------------
  690|  1.66M|                PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  335|  1.66M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  1.66M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  287|  1.66M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (690:17): [True: 15.8k, False: 1.65M]
  ------------------
  691|  99.6k|            {
  692|       |                /* pb_dec_string and pb_dec_bytes handle allocation themselves */
  693|  99.6k|                field->pData = field->pField;
  694|  99.6k|                return decode_basic_field(stream, wire_type, field);
  695|  99.6k|            }
  696|  1.65M|            else if (PB_LTYPE_IS_SUBMSG(field->type) && *(void**)field->pField != NULL)
  ------------------
  |  |  336|  3.30M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  335|  1.65M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|  1.65M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  295|  3.30M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (336:32): [True: 72.8k, False: 1.57M]
  |  |  ------------------
  |  |  337|  3.30M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  335|  1.57M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|  1.57M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  300|  1.57M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (337:32): [True: 0, False: 1.57M]
  |  |  ------------------
  ------------------
  |  Branch (696:57): [True: 30.9k, False: 41.8k]
  ------------------
  697|  30.9k|            {
  698|       |                /* The submessage already occurred earlier in the stream.
  699|       |                 * Merge the new data into it, like for static submessages.
  700|       |                 * If a different oneof member was set before, it has already
  701|       |                 * been released by pb_release_union_field(). */
  702|  30.9k|                field->pData = *(void**)field->pField;
  703|  30.9k|                return decode_basic_field(stream, wire_type, field);
  704|  30.9k|            }
  705|  1.61M|            else
  706|  1.61M|            {
  707|  1.61M|                if (!allocate_field(stream, field->pField, field->data_size, 1))
  ------------------
  |  Branch (707:21): [True: 0, False: 1.61M]
  ------------------
  708|      0|                    return false;
  709|       |                
  710|  1.61M|                field->pData = *(void**)field->pField;
  711|  1.61M|                initialize_pointer_field(field->pData, field);
  712|       |
  713|  1.61M|                if (PB_LTYPE_IS_SUBMSG(field->type))
  ------------------
  |  |  336|  1.61M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  335|  1.61M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|  1.61M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  295|  3.23M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (336:32): [True: 41.8k, False: 1.57M]
  |  |  ------------------
  |  |  337|  1.61M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  335|  1.57M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|  1.57M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  300|  1.57M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (337:32): [True: 0, False: 1.57M]
  |  |  ------------------
  ------------------
  714|  41.8k|                {
  715|       |                    /* pb_dec_submessage() decodes single pointer submessages
  716|       |                     * with PB_DECODE_NOINIT so that a later occurrence can be
  717|       |                     * merged into them. Set the defaults here instead. */
  718|  41.8k|                    pb_field_iter_t submsg_iter;
  719|  41.8k|                    if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (719:25): [True: 28.9k, False: 12.8k]
  ------------------
  720|  28.9k|                    {
  721|  28.9k|                        if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (721:29): [True: 0, False: 28.9k]
  ------------------
  722|      0|                            PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  723|  28.9k|                    }
  724|  41.8k|                }
  725|       |
  726|  1.61M|                return decode_basic_field(stream, wire_type, field);
  727|  1.61M|            }
  728|       |    
  729|  29.7M|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  321|  29.7M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (729:9): [True: 29.7M, False: 1.75M]
  ------------------
  730|  29.7M|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (730:17): [True: 29.7M, False: 15.7k]
  ------------------
  731|  29.7M|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  335|  29.7M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  29.7M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  283|  29.7M|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (731:20): [True: 60.6k, False: 29.7M]
  ------------------
  732|  60.6k|            {
  733|       |                /* Packed array, multiple items come in at once. */
  734|  60.6k|                bool status = true;
  735|  60.6k|                pb_size_t *size = (pb_size_t*)field->pSize;
  736|  60.6k|                size_t allocated_size = *size;
  737|  60.6k|                pb_istream_t substream;
  738|       |                
  739|  60.6k|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (739:21): [True: 60, False: 60.6k]
  ------------------
  740|     60|                    return false;
  741|       |                
  742|  11.0M|                while (substream.bytes_left)
  ------------------
  |  Branch (742:24): [True: 11.0M, False: 60.5k]
  ------------------
  743|  11.0M|                {
  744|  11.0M|                    if (*size == PB_SIZE_MAX)
  ------------------
  |  |  349|  11.0M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (744:25): [True: 5, False: 11.0M]
  ------------------
  745|      5|                    {
  746|      5|#ifndef PB_NO_ERRMSG
  747|      5|                        stream->errmsg = "too many array entries";
  748|      5|#endif
  749|      5|                        status = false;
  750|      5|                        break;
  751|      5|                    }
  752|       |
  753|  11.0M|                    if ((size_t)*size + 1 > allocated_size)
  ------------------
  |  Branch (753:25): [True: 897k, False: 10.1M]
  ------------------
  754|   897k|                    {
  755|       |                        /* Allocate more storage. This tries to guess the
  756|       |                         * number of remaining entries. Round the division
  757|       |                         * upwards. */
  758|   897k|                        size_t remain = (substream.bytes_left - 1) / field->data_size + 1;
  759|   897k|                        if (remain < PB_SIZE_MAX - allocated_size)
  ------------------
  |  |  349|   897k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (759:29): [True: 187k, False: 710k]
  ------------------
  760|   187k|                            allocated_size += remain;
  761|   710k|                        else
  762|   710k|                            allocated_size += 1;
  763|       |                        
  764|   897k|                        if (!allocate_field(&substream, field->pField, field->data_size, allocated_size))
  ------------------
  |  Branch (764:29): [True: 0, False: 897k]
  ------------------
  765|      0|                        {
  766|      0|                            status = false;
  767|      0|                            break;
  768|      0|                        }
  769|   897k|                    }
  770|       |
  771|       |                    /* Decode the array entry */
  772|  11.0M|                    field->pData = *(char**)field->pField + field->data_size * (*size);
  773|  11.0M|                    if (field->pData == NULL)
  ------------------
  |  Branch (773:25): [True: 0, False: 11.0M]
  ------------------
  774|      0|                    {
  775|       |                        /* Shouldn't happen, but satisfies static analyzers */
  776|      0|                        status = false;
  777|      0|                        break;
  778|      0|                    }
  779|  11.0M|                    initialize_pointer_field(field->pData, field);
  780|  11.0M|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (780:25): [True: 87, False: 11.0M]
  ------------------
  781|     87|                    {
  782|     87|                        status = false;
  783|     87|                        break;
  784|     87|                    }
  785|       |                    
  786|  11.0M|                    (*size)++;
  787|  11.0M|                }
  788|  60.6k|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (788:21): [True: 0, False: 60.6k]
  ------------------
  789|      0|                    return false;
  790|       |                
  791|  60.6k|                return status;
  792|  60.6k|            }
  793|  29.7M|            else
  794|  29.7M|            {
  795|       |                /* Normal repeated field, i.e. only one item at a time. */
  796|  29.7M|                pb_size_t *size = (pb_size_t*)field->pSize;
  797|       |
  798|  29.7M|                if (*size == PB_SIZE_MAX)
  ------------------
  |  |  349|  29.7M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (798:21): [True: 2, False: 29.7M]
  ------------------
  799|      2|                    PB_RETURN_ERROR(stream, "too many array entries");
  ------------------
  |  |  937|      2|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      2|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  800|       |                
  801|  29.7M|                if (field->array_size > 1)
  ------------------
  |  Branch (801:21): [True: 5.45k, False: 29.7M]
  ------------------
  802|  5.45k|                {
  803|       |                    /* Fixed count array (array_size is 1 for other pointer arrays).
  804|       |                     * There is no count field, so pb_release() frees all array_size
  805|       |                     * entries. Allocate and initialize the whole array at once. */
  806|  5.45k|                    bool new_array = (*(void**)field->pField == NULL);
  807|       |
  808|  5.45k|                    if (*size >= field->array_size)
  ------------------
  |  Branch (808:25): [True: 18, False: 5.43k]
  ------------------
  809|     18|                        PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  937|     18|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     18|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  810|       |
  811|  5.43k|                    if (!allocate_field(stream, field->pField, field->data_size, field->array_size))
  ------------------
  |  Branch (811:25): [True: 0, False: 5.43k]
  ------------------
  812|      0|                        return false;
  813|       |
  814|  5.43k|                    if (new_array)
  ------------------
  |  Branch (814:25): [True: 1.10k, False: 4.33k]
  ------------------
  815|  1.10k|                    {
  816|  1.10k|                        pb_size_t i;
  817|  6.61k|                        for (i = 0; i < field->array_size; i++)
  ------------------
  |  Branch (817:37): [True: 5.51k, False: 1.10k]
  ------------------
  818|  5.51k|                            initialize_pointer_field(*(char**)field->pField + field->data_size * i, field);
  819|  1.10k|                    }
  820|  5.43k|                }
  821|  29.7M|                else if (!allocate_field(stream, field->pField, field->data_size, (size_t)(*size + 1)))
  ------------------
  |  Branch (821:26): [True: 0, False: 29.7M]
  ------------------
  822|      0|                    return false;
  823|       |            
  824|  29.7M|                field->pData = *(char**)field->pField + field->data_size * (*size);
  825|  29.7M|                (*size)++;
  826|  29.7M|                initialize_pointer_field(field->pData, field);
  827|  29.7M|                return decode_basic_field(stream, wire_type, field);
  828|  29.7M|            }
  829|       |
  830|      0|        default:
  ------------------
  |  Branch (830:9): [True: 0, False: 31.5M]
  ------------------
  831|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  832|  31.5M|    }
  833|  31.5M|#endif
  834|  31.5M|}
pb_decode.c:initialize_pointer_field:
  657|  42.3M|{
  658|  42.3M|    if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  335|  42.3M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  42.3M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  291|  84.7M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (658:9): [True: 26.1k, False: 42.3M]
  ------------------
  659|  42.3M|        PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  335|  42.3M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  42.3M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  287|  42.3M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (659:9): [True: 494k, False: 41.8M]
  ------------------
  660|   520k|    {
  661|   520k|        *(void**)pItem = NULL;
  662|   520k|    }
  663|  41.8M|    else if (PB_LTYPE_IS_SUBMSG(field->type))
  ------------------
  |  |  336|  41.8M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  335|  41.8M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|  41.8M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  295|  83.7M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (336:32): [True: 117k, False: 41.7M]
  |  |  ------------------
  |  |  337|  41.8M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  335|  41.7M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|  41.7M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  300|  41.7M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (337:32): [True: 0, False: 41.7M]
  |  |  ------------------
  ------------------
  664|   117k|    {
  665|       |        /* We memset to zero so that any callbacks are set to NULL.
  666|       |         * Default values will be set by pb_dec_submessage(). */
  667|   117k|        memset(pItem, 0, field->data_size);
  668|   117k|    }
  669|  42.3M|}
pb_decode.c:decode_callback_field:
  837|  7.79k|{
  838|       |    /* Clear any data that may have been decoded for another oneof field
  839|       |     * that has come before this callback field.
  840|       |     */
  841|  7.79k|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  334|  7.79k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  7.79k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  323|  7.79k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (841:9): [True: 7.79k, False: 0]
  ------------------
  842|  7.79k|    {
  843|  7.79k|        bool clear_data = (*(pb_size_t*)field->pSize != field->tag);
  844|       |
  845|       |#ifdef PB_ENABLE_UNSAFE_DECODE_ONEOF_CALLBACKS
  846|       |        if (*(pb_size_t*)field->pSize == 0) clear_data = false;
  847|       |#endif
  848|       |
  849|  7.79k|        if (clear_data)
  ------------------
  |  Branch (849:13): [True: 5.38k, False: 2.41k]
  ------------------
  850|  5.38k|        {
  851|  5.38k|            memset(field->pData, 0, (size_t)field->data_size);
  852|  5.38k|        }
  853|  7.79k|        *(pb_size_t*)field->pSize = field->tag;
  854|  7.79k|    }
  855|       |
  856|  7.79k|    if (!field->descriptor->field_callback)
  ------------------
  |  Branch (856:9): [True: 0, False: 7.79k]
  ------------------
  857|      0|        return pb_skip_field(stream, wire_type);
  858|       |
  859|  7.79k|    if (wire_type == PB_WT_STRING)
  ------------------
  |  Branch (859:9): [True: 2.13k, False: 5.65k]
  ------------------
  860|  2.13k|    {
  861|  2.13k|        pb_istream_t substream;
  862|  2.13k|        size_t prev_bytes_left;
  863|       |        
  864|  2.13k|        if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (864:13): [True: 43, False: 2.09k]
  ------------------
  865|     43|            return false;
  866|       |
  867|       |        /* If the callback field is inside a submsg, first call the submsg_callback which
  868|       |         * should set the decoder for the callback field. */
  869|  2.09k|        if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  335|  2.09k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  2.09k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  300|  4.18k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (869:13): [True: 0, False: 2.09k]
  |  Branch (869:62): [True: 0, False: 0]
  ------------------
  870|      0|            pb_callback_t* callback;
  871|      0|            *(pb_size_t*)field->pSize = field->tag;
  872|      0|            callback = (pb_callback_t*)field->pSize - 1;
  873|       |
  874|      0|            if (callback->funcs.decode)
  ------------------
  |  Branch (874:17): [True: 0, False: 0]
  ------------------
  875|      0|            {
  876|      0|                if (!callback->funcs.decode(&substream, field, &callback->arg)) {
  ------------------
  |  Branch (876:21): [True: 0, False: 0]
  ------------------
  877|      0|                    PB_SET_ERROR(stream, substream.errmsg ? substream.errmsg : "submsg callback failed");
  ------------------
  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  ------------------
  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  Branch (933:92): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  878|      0|                    return false;
  879|      0|                }
  880|      0|            }
  881|      0|        }
  882|       |        
  883|  2.09k|        do
  884|  2.09k|        {
  885|  2.09k|            prev_bytes_left = substream.bytes_left;
  886|  2.09k|            if (!field->descriptor->field_callback(&substream, NULL, field))
  ------------------
  |  Branch (886:17): [True: 0, False: 2.09k]
  ------------------
  887|      0|            {
  888|      0|                PB_SET_ERROR(stream, substream.errmsg ? substream.errmsg : "callback failed");
  ------------------
  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  ------------------
  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  Branch (933:92): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  889|      0|                return false;
  890|      0|            }
  891|  2.09k|        } while (substream.bytes_left > 0 && substream.bytes_left < prev_bytes_left);
  ------------------
  |  Branch (891:18): [True: 503, False: 1.58k]
  |  Branch (891:46): [True: 0, False: 503]
  ------------------
  892|       |        
  893|  2.09k|        if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (893:13): [True: 0, False: 2.09k]
  ------------------
  894|      0|            return false;
  895|       |
  896|  2.09k|        return true;
  897|  2.09k|    }
  898|  5.65k|    else
  899|  5.65k|    {
  900|       |        /* Copy the single scalar value to stack.
  901|       |         * This is required so that we can limit the stream length,
  902|       |         * which in turn allows to use same callback for packed and
  903|       |         * not-packed fields. */
  904|  5.65k|        pb_istream_t substream;
  905|  5.65k|        pb_byte_t buffer[10];
  906|  5.65k|        size_t size = sizeof(buffer);
  907|       |        
  908|  5.65k|        if (!read_raw_value(stream, wire_type, buffer, &size))
  ------------------
  |  Branch (908:13): [True: 51, False: 5.60k]
  ------------------
  909|     51|            return false;
  910|  5.60k|        substream = pb_istream_from_buffer(buffer, size);
  911|       |        
  912|       |        return field->descriptor->field_callback(&substream, NULL, field);
  913|  5.65k|    }
  914|  7.79k|}
pb_decode.c:read_raw_value:
  347|  5.65k|{
  348|  5.65k|    size_t max_size = *size;
  349|  5.65k|    switch (wire_type)
  350|  5.65k|    {
  351|  4.20k|        case PB_WT_VARINT:
  ------------------
  |  Branch (351:9): [True: 4.20k, False: 1.45k]
  ------------------
  352|  4.20k|            *size = 0;
  353|  4.20k|            do
  354|  5.54k|            {
  355|  5.54k|                (*size)++;
  356|  5.54k|                if (*size > max_size)
  ------------------
  |  Branch (356:21): [True: 4, False: 5.54k]
  ------------------
  357|      4|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  937|      4|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      4|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  358|       |
  359|  5.54k|                if (!pb_read(stream, buf, 1))
  ------------------
  |  Branch (359:21): [True: 34, False: 5.50k]
  ------------------
  360|     34|                    return false;
  361|  5.54k|            } while (*buf++ & 0x80);
  ------------------
  |  Branch (361:22): [True: 1.33k, False: 4.17k]
  ------------------
  362|  4.17k|            return true;
  363|       |            
  364|    742|        case PB_WT_64BIT:
  ------------------
  |  Branch (364:9): [True: 742, False: 4.91k]
  ------------------
  365|    742|            *size = 8;
  366|    742|            return pb_read(stream, buf, 8);
  367|       |        
  368|    707|        case PB_WT_32BIT:
  ------------------
  |  Branch (368:9): [True: 707, False: 4.95k]
  ------------------
  369|    707|            *size = 4;
  370|    707|            return pb_read(stream, buf, 4);
  371|       |        
  372|      0|        case PB_WT_STRING:
  ------------------
  |  Branch (372:9): [True: 0, False: 5.65k]
  ------------------
  373|       |            /* Calling read_raw_value with a PB_WT_STRING is an error.
  374|       |             * Explicitly handle this case and fallthrough to default to avoid
  375|       |             * compiler warnings.
  376|       |             */
  377|       |
  378|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (378:2): [True: 0, False: 5.65k]
  ------------------
  379|       |            /* Calling read_raw_value with a PB_WT_PACKED is an error.
  380|       |             * Explicitly handle this case and fallthrough to default to avoid
  381|       |             * compiler warnings.
  382|       |             */
  383|       |
  384|      2|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  937|      2|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      2|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (384:9): [True: 2, False: 5.65k]
  ------------------
  385|  5.65k|    }
  386|  5.65k|}
pb_decode.c:pb_release_single_field:
 1398|  1.00M|{
 1399|  1.00M|    pb_type_t type;
 1400|  1.00M|    type = field->type;
 1401|       |
 1402|  1.00M|    if (PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  334|  1.00M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  1.00M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  323|  1.00M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (1402:9): [True: 82.5k, False: 920k]
  ------------------
 1403|  82.5k|    {
 1404|  82.5k|        if (*(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (1404:13): [True: 61.6k, False: 20.9k]
  ------------------
 1405|  61.6k|            return; /* This is not the current field in the union */
 1406|  82.5k|    }
 1407|       |
 1408|       |    /* Release anything contained inside an extension or submsg.
 1409|       |     * This has to be done even if the submsg itself is statically
 1410|       |     * allocated. */
 1411|   941k|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  335|   941k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   941k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  304|   941k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1411:9): [True: 9.07k, False: 932k]
  ------------------
 1412|  9.07k|    {
 1413|       |        /* Release fields from all extensions in the linked list */
 1414|  9.07k|        pb_extension_t *ext = *(pb_extension_t**)field->pData;
 1415|  16.4k|        while (ext != NULL)
  ------------------
  |  Branch (1415:16): [True: 7.39k, False: 9.07k]
  ------------------
 1416|  7.39k|        {
 1417|  7.39k|            pb_field_iter_t ext_iter;
 1418|  7.39k|            if (ext->type->decode == NULL &&
  ------------------
  |  Branch (1418:17): [True: 7.39k, False: 0]
  ------------------
 1419|  7.39k|                pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (1419:17): [True: 7.39k, False: 0]
  ------------------
 1420|  7.39k|            {
 1421|  7.39k|                pb_release_single_field(&ext_iter);
 1422|  7.39k|            }
 1423|  7.39k|            ext = ext->next;
 1424|  7.39k|        }
 1425|  9.07k|    }
 1426|   932k|    else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  336|  1.86M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  335|   932k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|   932k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  295|  1.86M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (336:32): [True: 106k, False: 825k]
  |  |  ------------------
  |  |  337|  1.86M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  335|   825k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|   825k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  300|   825k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (337:32): [True: 0, False: 825k]
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  333|   106k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|   106k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  330|   106k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (1426:42): [True: 103k, False: 3.53k]
  ------------------
 1427|   103k|    {
 1428|       |        /* Release fields in submessage or submsg array */
 1429|   103k|        pb_size_t count = 1;
 1430|       |        
 1431|   103k|        if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  333|   103k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|   103k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  329|   103k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1431:13): [True: 90.3k, False: 12.8k]
  ------------------
 1432|  90.3k|        {
 1433|  90.3k|            field->pData = *(void**)field->pField;
 1434|  90.3k|        }
 1435|  12.8k|        else
 1436|  12.8k|        {
 1437|  12.8k|            field->pData = field->pField;
 1438|  12.8k|        }
 1439|       |        
 1440|   103k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  334|   103k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   103k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  321|   103k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1440:13): [True: 18.1k, False: 85.0k]
  ------------------
 1441|  18.1k|        {
 1442|  18.1k|            count = *(pb_size_t*)field->pSize;
 1443|       |
 1444|  18.1k|            if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > field->array_size)
  ------------------
  |  |  333|  18.1k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|  18.1k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > field->array_size)
  ------------------
  |  |  328|  36.2k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1444:17): [True: 0, False: 18.1k]
  |  Branch (1444:54): [True: 0, False: 0]
  ------------------
 1445|      0|            {
 1446|       |                /* Protect against corrupted _count fields */
 1447|      0|                count = field->array_size;
 1448|      0|            }
 1449|  18.1k|        }
 1450|       |        
 1451|   103k|        if (field->pData)
  ------------------
  |  Branch (1451:13): [True: 57.0k, False: 46.1k]
  ------------------
 1452|  57.0k|        {
 1453|   186k|            for (; count > 0; count--)
  ------------------
  |  Branch (1453:20): [True: 129k, False: 57.0k]
  ------------------
 1454|   129k|            {
 1455|   129k|                pb_release(field->submsg_desc, field->pData);
 1456|   129k|                field->pData = (char*)field->pData + field->data_size;
 1457|   129k|            }
 1458|  57.0k|        }
 1459|   103k|    }
 1460|       |    
 1461|   941k|    if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  333|   941k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|   941k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  329|   941k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1461:9): [True: 905k, False: 36.1k]
  ------------------
 1462|   905k|    {
 1463|   905k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  334|   905k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   905k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  321|  1.81M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1463:13): [True: 194k, False: 710k]
  ------------------
 1464|   194k|            (PB_LTYPE(type) == PB_LTYPE_STRING ||
  ------------------
  |  |  335|   194k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   194k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          (PB_LTYPE(type) == PB_LTYPE_STRING ||
  ------------------
  |  |  291|   389k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (1464:14): [True: 9.07k, False: 185k]
  ------------------
 1465|   185k|             PB_LTYPE(type) == PB_LTYPE_BYTES))
  ------------------
  |  |  335|   185k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   185k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                           PB_LTYPE(type) == PB_LTYPE_BYTES))
  ------------------
  |  |  287|   185k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (1465:14): [True: 9.07k, False: 176k]
  ------------------
 1466|  18.1k|        {
 1467|       |            /* Release entries in repeated string or bytes array */
 1468|  18.1k|            void **pItem = *(void***)field->pField;
 1469|  18.1k|            pb_size_t count = *(pb_size_t*)field->pSize;
 1470|       |
 1471|       |            /* Fixed count arrays report array_size even if never allocated */
 1472|  18.1k|            if (pItem == NULL)
  ------------------
  |  Branch (1472:17): [True: 15.8k, False: 2.29k]
  ------------------
 1473|  15.8k|                count = 0;
 1474|       |
 1475|   538k|            for (; count > 0; count--)
  ------------------
  |  Branch (1475:20): [True: 520k, False: 18.1k]
  ------------------
 1476|   520k|            {
 1477|   520k|                pb_free(*pItem);
  ------------------
  |  |    4|   520k|#define pb_free(ptr) free_with_check(ptr)
  ------------------
 1478|   520k|                *pItem++ = NULL;
 1479|   520k|            }
 1480|  18.1k|        }
 1481|       |        
 1482|   905k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  334|   905k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   905k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  321|   905k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1482:13): [True: 194k, False: 710k]
  ------------------
 1483|   194k|        {
 1484|       |            /* We are going to release the array, so set the size to 0 */
 1485|   194k|            *(pb_size_t*)field->pSize = 0;
 1486|   194k|        }
 1487|       |        
 1488|       |        /* Release main pointer */
 1489|   905k|        pb_free(*(void**)field->pField);
  ------------------
  |  |    4|   905k|#define pb_free(ptr) free_with_check(ptr)
  ------------------
 1490|       |        *(void**)field->pField = NULL;
 1491|   905k|    }
 1492|   941k|}

pb_ostream_from_buffer:
   73|  3.12k|{
   74|  3.12k|    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.12k|    stream.callback = &buf_write;
   83|  3.12k|#endif
   84|  3.12k|    stream.state = buf;
   85|  3.12k|    stream.max_size = bufsize;
   86|  3.12k|    stream.bytes_written = 0;
   87|  3.12k|#ifndef PB_NO_ERRMSG
   88|       |    stream.errmsg = NULL;
   89|  3.12k|#endif
   90|  3.12k|    return stream;
   91|  3.12k|}
pb_write:
   94|  38.9M|{
   95|  38.9M|    if (count > 0 && stream->callback != NULL)
  ------------------
  |  Branch (95:9): [True: 38.8M, False: 135k]
  |  Branch (95:22): [True: 35.1M, False: 3.70M]
  ------------------
   96|  35.1M|    {
   97|  35.1M|        if (stream->bytes_written + count < stream->bytes_written ||
  ------------------
  |  Branch (97:13): [True: 0, False: 35.1M]
  ------------------
   98|  35.1M|            stream->bytes_written + count > stream->max_size)
  ------------------
  |  Branch (98:13): [True: 190, False: 35.1M]
  ------------------
   99|    190|        {
  100|    190|            PB_RETURN_ERROR(stream, "stream full");
  ------------------
  |  |  937|    190|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|    190|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 190]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  101|    190|        }
  102|       |
  103|       |#ifdef PB_BUFFER_ONLY
  104|       |        if (!buf_write(stream, buf, count))
  105|       |            PB_RETURN_ERROR(stream, "io error");
  106|       |#else        
  107|  35.1M|        if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (107:13): [True: 0, False: 35.1M]
  ------------------
  108|      0|            PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  109|  35.1M|#endif
  110|  35.1M|    }
  111|       |    
  112|  38.9M|    stream->bytes_written += count;
  113|       |    return true;
  114|  38.9M|}
pb_encode:
  522|   105k|{
  523|   105k|    pb_field_iter_t iter;
  524|   105k|    if (!pb_field_iter_begin_const(&iter, fields, src_struct))
  ------------------
  |  Branch (524:9): [True: 30.4k, False: 75.5k]
  ------------------
  525|  30.4k|        return true; /* Empty message type */
  526|       |    
  527|   487k|    do {
  528|   487k|        if (PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  335|   487k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   487k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  304|   487k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (528:13): [True: 2.99k, False: 484k]
  ------------------
  529|  2.99k|        {
  530|       |            /* Special case for the extension field placeholder */
  531|  2.99k|            if (!encode_extension_field(stream, &iter))
  ------------------
  |  Branch (531:17): [True: 41, False: 2.94k]
  ------------------
  532|     41|                return false;
  533|  2.99k|        }
  534|   484k|        else
  535|   484k|        {
  536|       |            /* Regular field */
  537|   484k|            if (!encode_field(stream, &iter))
  ------------------
  |  Branch (537:17): [True: 192, False: 484k]
  ------------------
  538|    192|                return false;
  539|   484k|        }
  540|   487k|    } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (540:14): [True: 412k, False: 75.3k]
  ------------------
  541|       |    
  542|  75.3k|    return true;
  543|  75.5k|}
pb_encode_varint:
  617|  28.4M|{
  618|  28.4M|    if (value <= 0x7F)
  ------------------
  |  Branch (618:9): [True: 16.0M, False: 12.3M]
  ------------------
  619|  16.0M|    {
  620|       |        /* Fast path: single byte */
  621|  16.0M|        pb_byte_t byte = (pb_byte_t)value;
  622|  16.0M|        return pb_write(stream, &byte, 1);
  623|  16.0M|    }
  624|  12.3M|    else
  625|  12.3M|    {
  626|       |#ifdef PB_WITHOUT_64BIT
  627|       |        return pb_encode_varint_32(stream, value, 0);
  628|       |#else
  629|  12.3M|        return pb_encode_varint_32(stream, (uint32_t)value, (uint32_t)(value >> 32));
  630|  12.3M|#endif
  631|  12.3M|    }
  632|  28.4M|}
pb_encode_svarint:
  635|  2.98M|{
  636|  2.98M|    pb_uint64_t zigzagged;
  ------------------
  |  |   46|  2.98M|#define pb_uint64_t uint64_t
  ------------------
  637|  2.98M|    pb_uint64_t mask = ((pb_uint64_t)-1) >> 1; /* Satisfy clang -fsanitize=integer */
  ------------------
  |  |   46|  2.98M|#define pb_uint64_t uint64_t
  ------------------
  638|  2.98M|    if (value < 0)
  ------------------
  |  Branch (638:9): [True: 367k, False: 2.61M]
  ------------------
  639|   367k|        zigzagged = ~(((pb_uint64_t)value & mask) << 1);
  640|  2.61M|    else
  641|  2.61M|        zigzagged = (pb_uint64_t)value << 1;
  642|       |    
  643|  2.98M|    return pb_encode_varint(stream, zigzagged);
  644|  2.98M|}
pb_encode_fixed32:
  647|  21.8k|{
  648|  21.8k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
  649|       |    /* Fast path if we know that we're on little endian */
  650|  21.8k|    return pb_write(stream, (const pb_byte_t*)value, 4);
  651|       |#else
  652|       |    uint32_t val = *(const uint32_t*)value;
  653|       |    pb_byte_t bytes[4];
  654|       |    bytes[0] = (pb_byte_t)(val & 0xFF);
  655|       |    bytes[1] = (pb_byte_t)((val >> 8) & 0xFF);
  656|       |    bytes[2] = (pb_byte_t)((val >> 16) & 0xFF);
  657|       |    bytes[3] = (pb_byte_t)((val >> 24) & 0xFF);
  658|       |    return pb_write(stream, bytes, 4);
  659|       |#endif
  660|  21.8k|}
pb_encode_fixed64:
  664|  16.4k|{
  665|  16.4k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
  666|       |    /* Fast path if we know that we're on little endian */
  667|  16.4k|    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|  16.4k|}
pb_encode_tag:
  685|  10.7M|{
  686|  10.7M|    pb_uint64_t tag = ((pb_uint64_t)field_number << 3) | wiretype;
  ------------------
  |  |   46|  10.7M|#define pb_uint64_t uint64_t
  ------------------
  687|  10.7M|    return pb_encode_varint(stream, tag);
  688|  10.7M|}
pb_encode_tag_for_field:
  691|  10.7M|{
  692|  10.7M|    pb_wire_type_t wiretype;
  693|  10.7M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  335|  10.7M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  10.7M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  694|  10.7M|    {
  695|  3.19k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  275|  3.19k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (695:9): [True: 3.19k, False: 10.7M]
  ------------------
  696|   127k|        case PB_LTYPE_VARINT:
  ------------------
  |  |  276|   127k|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (696:9): [True: 123k, False: 10.6M]
  ------------------
  697|   172k|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  277|   172k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (697:9): [True: 45.7k, False: 10.7M]
  ------------------
  698|   191k|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  278|   191k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (698:9): [True: 18.5k, False: 10.7M]
  ------------------
  699|   191k|            wiretype = PB_WT_VARINT;
  700|   191k|            break;
  701|       |        
  702|  17.0k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  279|  17.0k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (702:9): [True: 17.0k, False: 10.7M]
  ------------------
  703|  17.0k|            wiretype = PB_WT_32BIT;
  704|  17.0k|            break;
  705|       |        
  706|  9.63k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  280|  9.63k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (706:9): [True: 9.63k, False: 10.7M]
  ------------------
  707|  9.63k|            wiretype = PB_WT_64BIT;
  708|  9.63k|            break;
  709|       |        
  710|  84.9k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  287|  84.9k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (710:9): [True: 84.9k, False: 10.6M]
  ------------------
  711|   148k|        case PB_LTYPE_STRING:
  ------------------
  |  |  291|   148k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (711:9): [True: 63.6k, False: 10.6M]
  ------------------
  712|   200k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  295|   200k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (712:9): [True: 51.4k, False: 10.7M]
  ------------------
  713|   200k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  300|   200k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (713:9): [True: 0, False: 10.7M]
  ------------------
  714|  10.5M|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  310|  10.5M|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (714:9): [True: 10.3M, False: 418k]
  ------------------
  715|  10.5M|            wiretype = PB_WT_STRING;
  716|  10.5M|            break;
  717|       |        
  718|      0|        default:
  ------------------
  |  Branch (718:9): [True: 0, False: 10.7M]
  ------------------
  719|      0|            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  720|  10.7M|    }
  721|       |    
  722|  10.7M|    return pb_encode_tag(stream, wiretype, field->tag);
  723|  10.7M|}
pb_encode_string:
  726|  10.4M|{
  727|  10.4M|    if (!pb_encode_varint(stream, (pb_uint64_t)size))
  ------------------
  |  Branch (727:9): [True: 7, False: 10.4M]
  ------------------
  728|      7|        return false;
  729|       |    
  730|  10.4M|    return pb_write(stream, buffer, size);
  731|  10.4M|}
pb_encode_submessage:
  734|  51.4k|{
  735|       |    /* First calculate the message size using a non-writing substream. */
  736|  51.4k|    pb_ostream_t substream = PB_OSTREAM_SIZING;
  ------------------
  |  |  126|  51.4k|#define PB_OSTREAM_SIZING {0,0,0,0,0}
  ------------------
  737|  51.4k|#if !defined(PB_NO_ENCODE_SIZE_CHECK) || PB_NO_ENCODE_SIZE_CHECK == 0
  738|  51.4k|    bool status;
  739|  51.4k|    size_t size;
  740|  51.4k|#endif
  741|       |    
  742|  51.4k|    if (!pb_encode(&substream, fields, src_struct))
  ------------------
  |  Branch (742:9): [True: 0, False: 51.4k]
  ------------------
  743|      0|    {
  744|      0|#ifndef PB_NO_ERRMSG
  745|      0|        stream->errmsg = substream.errmsg;
  746|      0|#endif
  747|      0|        return false;
  748|      0|    }
  749|       |    
  750|  51.4k|    if (!pb_encode_varint(stream, (pb_uint64_t)substream.bytes_written))
  ------------------
  |  Branch (750:9): [True: 25, False: 51.4k]
  ------------------
  751|     25|        return false;
  752|       |    
  753|  51.4k|    if (stream->callback == NULL)
  ------------------
  |  Branch (753:9): [True: 0, False: 51.4k]
  ------------------
  754|      0|        return pb_write(stream, NULL, substream.bytes_written); /* Just sizing */
  755|       |    
  756|  51.4k|    if (stream->bytes_written + substream.bytes_written > stream->max_size)
  ------------------
  |  Branch (756:9): [True: 43, False: 51.3k]
  ------------------
  757|     43|        PB_RETURN_ERROR(stream, "stream full");
  ------------------
  |  |  937|     43|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     43|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 43]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|  51.3k|    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|  51.3k|    substream.callback = stream->callback;
  766|  51.3k|    substream.state = stream->state;
  767|  51.3k|    substream.max_size = size;
  768|  51.3k|    substream.bytes_written = 0;
  769|  51.3k|#ifndef PB_NO_ERRMSG
  770|  51.3k|    substream.errmsg = NULL;
  771|  51.3k|#endif
  772|       |    
  773|  51.3k|    status = pb_encode(&substream, fields, src_struct);
  774|       |    
  775|  51.3k|    stream->bytes_written += substream.bytes_written;
  776|  51.3k|    stream->state = substream.state;
  777|  51.3k|#ifndef PB_NO_ERRMSG
  778|  51.3k|    stream->errmsg = substream.errmsg;
  779|  51.3k|#endif
  780|       |    
  781|  51.3k|    if (substream.bytes_written != size)
  ------------------
  |  Branch (781:9): [True: 0, False: 51.3k]
  ------------------
  782|      0|        PB_RETURN_ERROR(stream, "submsg size changed");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  783|       |
  784|  51.3k|    return status;
  785|  51.3k|#endif
  786|  51.3k|}
pb_encode.c:buf_write:
   54|  35.1M|{
   55|  35.1M|    pb_byte_t *dest = (pb_byte_t*)stream->state;
   56|  35.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|  35.1M|    if (buf != NULL)
  ------------------
  |  Branch (64:9): [True: 35.1M, False: 0]
  ------------------
   65|  35.1M|    {
   66|  35.1M|        memcpy(dest, buf, count * sizeof(pb_byte_t));
   67|  35.1M|    }
   68|       |
   69|       |    return true;
   70|  35.1M|}
pb_encode.c:encode_extension_field:
  497|  2.99k|{
  498|  2.99k|    const pb_extension_t *extension = *(const pb_extension_t* const *)field->pData;
  499|       |
  500|  5.93k|    while (extension)
  ------------------
  |  Branch (500:12): [True: 2.99k, False: 2.94k]
  ------------------
  501|  2.99k|    {
  502|  2.99k|        bool status;
  503|  2.99k|        if (extension->type->encode)
  ------------------
  |  Branch (503:13): [True: 0, False: 2.99k]
  ------------------
  504|      0|            status = extension->type->encode(stream, extension);
  505|  2.99k|        else
  506|  2.99k|            status = default_extension_encoder(stream, extension);
  507|       |
  508|  2.99k|        if (!status)
  ------------------
  |  Branch (508:13): [True: 41, False: 2.94k]
  ------------------
  509|     41|            return false;
  510|       |        
  511|  2.94k|        extension = extension->next;
  512|  2.94k|    }
  513|       |    
  514|  2.94k|    return true;
  515|  2.99k|}
pb_encode.c:default_extension_encoder:
  484|  2.99k|{
  485|  2.99k|    pb_field_iter_t iter;
  486|       |
  487|  2.99k|    if (!pb_field_iter_begin_extension_const(&iter, extension))
  ------------------
  |  Branch (487:9): [True: 0, False: 2.99k]
  ------------------
  488|      0|        PB_RETURN_ERROR(stream, "invalid extension");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  489|       |
  490|  2.99k|    return encode_field(stream, &iter);
  491|  2.99k|}
pb_encode.c:encode_field:
  428|   487k|{
  429|       |    /* Check field presence */
  430|   487k|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  334|   487k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   487k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  323|   487k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (430:9): [True: 21.3k, False: 466k]
  ------------------
  431|  21.3k|    {
  432|  21.3k|        if (*(const pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (432:13): [True: 20.6k, False: 658]
  ------------------
  433|  20.6k|        {
  434|       |            /* Different type oneof field */
  435|  20.6k|            return true;
  436|  20.6k|        }
  437|  21.3k|    }
  438|   466k|    else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL)
  ------------------
  |  |  334|   466k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   466k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL)
  ------------------
  |  |  319|   466k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (438:14): [True: 115k, False: 350k]
  ------------------
  439|   115k|    {
  440|   115k|        if (field->pSize)
  ------------------
  |  Branch (440:13): [True: 5.92k, False: 109k]
  ------------------
  441|  5.92k|        {
  442|  5.92k|            if (safe_read_bool(field->pSize) == false)
  ------------------
  |  Branch (442:17): [True: 5.70k, False: 217]
  ------------------
  443|  5.70k|            {
  444|       |                /* Missing optional field */
  445|  5.70k|                return true;
  446|  5.70k|            }
  447|  5.92k|        }
  448|   109k|        else if (PB_ATYPE(field->type) == PB_ATYPE_STATIC)
  ------------------
  |  |  333|   109k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|   109k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      else if (PB_ATYPE(field->type) == PB_ATYPE_STATIC)
  ------------------
  |  |  328|   109k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (448:18): [True: 0, False: 109k]
  ------------------
  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|   115k|    }
  455|       |
  456|   461k|    if (!field->pData)
  ------------------
  |  Branch (456:9): [True: 160k, False: 300k]
  ------------------
  457|   160k|    {
  458|   160k|        if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED)
  ------------------
  |  |  334|   160k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   160k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED)
  ------------------
  |  |  318|   160k|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (458:13): [True: 0, False: 160k]
  ------------------
  459|      0|            PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  460|       |
  461|       |        /* Pointer field set to NULL */
  462|   160k|        return true;
  463|   160k|    }
  464|       |
  465|       |    /* Then encode field contents */
  466|   300k|    if (PB_ATYPE(field->type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  333|   300k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|   300k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  330|   300k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (466:9): [True: 129, False: 300k]
  ------------------
  467|    129|    {
  468|    129|        return encode_callback_field(stream, field);
  469|    129|    }
  470|   300k|    else if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  334|   300k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   300k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  321|   300k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (470:14): [True: 5.27k, False: 295k]
  ------------------
  471|  5.27k|    {
  472|  5.27k|        return encode_array(stream, field);
  473|  5.27k|    }
  474|   295k|    else
  475|   295k|    {
  476|   295k|        return encode_basic_field(stream, field);
  477|   295k|    }
  478|   300k|}
pb_encode.c:safe_read_bool:
  125|  9.12k|{
  126|  9.12k|    const char *p = (const char *)pSize;
  127|  9.12k|    size_t i;
  128|  16.5k|    for (i = 0; i < sizeof(bool); i++)
  ------------------
  |  Branch (128:17): [True: 9.12k, False: 7.40k]
  ------------------
  129|  9.12k|    {
  130|  9.12k|        if (p[i] != 0)
  ------------------
  |  Branch (130:13): [True: 1.72k, False: 7.40k]
  ------------------
  131|  1.72k|            return true;
  132|  9.12k|    }
  133|  7.40k|    return false;
  134|  9.12k|}
pb_encode.c:encode_callback_field:
  417|    129|{
  418|    129|    if (field->descriptor->field_callback != NULL)
  ------------------
  |  Branch (418:9): [True: 129, False: 0]
  ------------------
  419|    129|    {
  420|    129|        if (!field->descriptor->field_callback(NULL, stream, field))
  ------------------
  |  Branch (420:13): [True: 0, False: 129]
  ------------------
  421|      0|            PB_RETURN_ERROR(stream, "callback error");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  422|    129|    }
  423|    129|    return true;
  424|    129|}
pb_encode.c:encode_array:
  138|  5.27k|{
  139|  5.27k|    pb_size_t i;
  140|  5.27k|    pb_size_t count;
  141|  5.27k|#ifndef PB_ENCODE_ARRAYS_UNPACKED
  142|  5.27k|    size_t size;
  143|  5.27k|#endif
  144|       |
  145|  5.27k|    count = *(pb_size_t*)field->pSize;
  146|       |
  147|  5.27k|    if (count == 0)
  ------------------
  |  Branch (147:9): [True: 0, False: 5.27k]
  ------------------
  148|      0|        return true;
  149|       |
  150|  5.27k|    if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size)
  ------------------
  |  |  333|  5.27k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|  5.27k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size)
  ------------------
  |  |  329|  10.5k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (150:9): [True: 0, False: 5.27k]
  |  Branch (150:54): [True: 0, False: 0]
  ------------------
  151|      0|        PB_RETURN_ERROR(stream, "array max size exceeded");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  152|       |    
  153|  5.27k|#ifndef PB_ENCODE_ARRAYS_UNPACKED
  154|       |    /* We always pack arrays if the datatype allows it. */
  155|  5.27k|    if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  335|  5.27k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  5.27k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  283|  5.27k|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (155:9): [True: 2.26k, False: 3.00k]
  ------------------
  156|  2.26k|    {
  157|  2.26k|        if (!pb_encode_tag(stream, PB_WT_STRING, field->tag))
  ------------------
  |  Branch (157:13): [True: 2, False: 2.26k]
  ------------------
  158|      2|            return false;
  159|       |        
  160|       |        /* Determine the total size of packed array. */
  161|  2.26k|        if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32)
  ------------------
  |  |  335|  2.26k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  2.26k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32)
  ------------------
  |  |  279|  2.26k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (161:13): [True: 371, False: 1.89k]
  ------------------
  162|    371|        {
  163|    371|            size = 4 * (size_t)count;
  164|    371|        }
  165|  1.89k|        else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  335|  1.89k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  1.89k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  280|  1.89k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (165:18): [True: 206, False: 1.68k]
  ------------------
  166|    206|        {
  167|    206|            size = 8 * (size_t)count;
  168|    206|        }
  169|  1.68k|        else
  170|  1.68k|        { 
  171|  1.68k|            pb_ostream_t sizestream = PB_OSTREAM_SIZING;
  ------------------
  |  |  126|  1.68k|#define PB_OSTREAM_SIZING {0,0,0,0,0}
  ------------------
  172|  1.68k|            void *pData_orig = field->pData;
  173|  3.48M|            for (i = 0; i < count; i++)
  ------------------
  |  Branch (173:25): [True: 3.48M, False: 1.68k]
  ------------------
  174|  3.48M|            {
  175|  3.48M|                if (!pb_enc_varint(&sizestream, field))
  ------------------
  |  Branch (175:21): [True: 0, False: 3.48M]
  ------------------
  176|      0|                    PB_RETURN_ERROR(stream, PB_GET_ERROR(&sizestream));
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  |  Branch (933:92): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  177|  3.48M|                field->pData = (char*)field->pData + field->data_size;
  178|  3.48M|            }
  179|  1.68k|            field->pData = pData_orig;
  180|  1.68k|            size = sizestream.bytes_written;
  181|  1.68k|        }
  182|       |        
  183|  2.26k|        if (!pb_encode_varint(stream, (pb_uint64_t)size))
  ------------------
  |  Branch (183:13): [True: 3, False: 2.26k]
  ------------------
  184|      3|            return false;
  185|       |        
  186|  2.26k|        if (stream->callback == NULL)
  ------------------
  |  Branch (186:13): [True: 0, False: 2.26k]
  ------------------
  187|      0|            return pb_write(stream, NULL, size); /* Just sizing.. */
  188|       |        
  189|       |        /* Write the data */
  190|  3.47M|        for (i = 0; i < count; i++)
  ------------------
  |  Branch (190:21): [True: 3.46M, False: 2.25k]
  ------------------
  191|  3.46M|        {
  192|  3.46M|            if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  335|  3.46M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  3.46M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  279|  6.93M|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  335|  3.46M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  3.46M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  280|  3.46M|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (192:17): [True: 4.78k, False: 3.46M]
  |  Branch (192:62): [True: 6.78k, False: 3.45M]
  ------------------
  193|  11.5k|            {
  194|  11.5k|                if (!pb_enc_fixed(stream, field))
  ------------------
  |  Branch (194:21): [True: 2, False: 11.5k]
  ------------------
  195|      2|                    return false;
  196|  11.5k|            }
  197|  3.45M|            else
  198|  3.45M|            {
  199|  3.45M|                if (!pb_enc_varint(stream, field))
  ------------------
  |  Branch (199:21): [True: 10, False: 3.45M]
  ------------------
  200|     10|                    return false;
  201|  3.45M|            }
  202|       |
  203|  3.46M|            field->pData = (char*)field->pData + field->data_size;
  204|  3.46M|        }
  205|  2.26k|    }
  206|  3.00k|    else /* Unpacked fields */
  207|  3.00k|#endif
  208|  3.00k|    {
  209|  10.4M|        for (i = 0; i < count; i++)
  ------------------
  |  Branch (209:21): [True: 10.4M, False: 2.98k]
  ------------------
  210|  10.4M|        {
  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.4M|            if (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  333|  10.4M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|  10.4M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  329|  20.9M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (215:17): [True: 10.4M, False: 0]
  ------------------
  216|  10.4M|                (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  335|  10.4M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  10.4M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  291|  20.9M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (216:18): [True: 11.9k, False: 10.4M]
  ------------------
  217|  10.4M|                 PB_LTYPE(field->type) == PB_LTYPE_BYTES))
  ------------------
  |  |  335|  10.4M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  10.4M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                               PB_LTYPE(field->type) == PB_LTYPE_BYTES))
  ------------------
  |  |  287|  10.4M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (217:18): [True: 81.4k, False: 10.3M]
  ------------------
  218|  93.4k|            {
  219|  93.4k|                bool status;
  220|  93.4k|                void *pData_orig = field->pData;
  221|  93.4k|                field->pData = *(void* const*)field->pData;
  222|       |
  223|  93.4k|                if (!field->pData)
  ------------------
  |  Branch (223:21): [True: 0, False: 93.4k]
  ------------------
  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|  93.4k|                else
  230|  93.4k|                {
  231|  93.4k|                    status = encode_basic_field(stream, field);
  232|  93.4k|                }
  233|       |
  234|  93.4k|                field->pData = pData_orig;
  235|       |
  236|  93.4k|                if (!status)
  ------------------
  |  Branch (236:21): [True: 3, False: 93.4k]
  ------------------
  237|      3|                    return false;
  238|  93.4k|            }
  239|  10.3M|            else
  240|  10.3M|            {
  241|  10.3M|                if (!encode_basic_field(stream, field))
  ------------------
  |  Branch (241:21): [True: 13, False: 10.3M]
  ------------------
  242|     13|                    return false;
  243|  10.3M|            }
  244|  10.4M|            field->pData = (char*)field->pData + field->data_size;
  245|  10.4M|        }
  246|  3.00k|    }
  247|       |    
  248|  5.23k|    return true;
  249|  5.27k|}
pb_encode.c:pb_enc_varint:
  798|  7.12M|{
  799|  7.12M|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  335|  7.12M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  7.12M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  277|  7.12M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (799:9): [True: 905k, False: 6.22M]
  ------------------
  800|   905k|    {
  801|       |        /* Perform unsigned integer extension */
  802|   905k|        pb_uint64_t value = 0;
  ------------------
  |  |   46|   905k|#define pb_uint64_t uint64_t
  ------------------
  803|       |
  804|   905k|        if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (804:13): [True: 6.07k, False: 899k]
  ------------------
  805|  6.07k|            value = *(const uint_least8_t*)field->pData;
  806|   899k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (806:18): [True: 6.07k, False: 893k]
  ------------------
  807|  6.07k|            value = *(const uint_least16_t*)field->pData;
  808|   893k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (808:18): [True: 489k, False: 403k]
  ------------------
  809|   489k|            value = *(const uint32_t*)field->pData;
  810|   403k|        else if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (810:18): [True: 403k, False: 0]
  ------------------
  811|   403k|            value = *(const pb_uint64_t*)field->pData;
  812|      0|        else
  813|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  814|       |
  815|   905k|        return pb_encode_varint(stream, value);
  816|   905k|    }
  817|  6.22M|    else
  818|  6.22M|    {
  819|       |        /* Perform signed integer extension */
  820|  6.22M|        pb_int64_t value = 0;
  ------------------
  |  |   45|  6.22M|#define pb_int64_t int64_t
  ------------------
  821|       |
  822|  6.22M|        if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (822:13): [True: 822k, False: 5.40M]
  ------------------
  823|   822k|            value = *(const int_least8_t*)field->pData;
  824|  5.40M|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (824:18): [True: 12.1k, False: 5.38M]
  ------------------
  825|  12.1k|            value = *(const int_least16_t*)field->pData;
  826|  5.38M|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (826:18): [True: 2.27M, False: 3.10M]
  ------------------
  827|  2.27M|            value = *(const int32_t*)field->pData;
  828|  3.10M|        else if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (828:18): [True: 3.10M, False: 0]
  ------------------
  829|  3.10M|            value = *(const pb_int64_t*)field->pData;
  830|      0|        else
  831|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  832|       |
  833|  6.22M|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  335|  6.22M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  6.22M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  278|  6.22M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (833:13): [True: 2.98M, False: 3.23M]
  ------------------
  834|  2.98M|            return pb_encode_svarint(stream, value);
  835|       |#ifdef PB_WITHOUT_64BIT
  836|       |        else if (value < 0)
  837|       |            return pb_encode_varint_32(stream, (uint32_t)value, (uint32_t)-1);
  838|       |#endif
  839|  3.23M|        else
  840|  3.23M|            return pb_encode_varint(stream, (pb_uint64_t)value);
  841|       |
  842|  6.22M|    }
  843|  7.12M|}
pb_encode.c:pb_enc_fixed:
  846|  38.2k|{
  847|       |#ifdef PB_CONVERT_DOUBLE_FLOAT
  848|       |    if (field->data_size == sizeof(float) && PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  849|       |    {
  850|       |        return pb_encode_float_as_double(stream, *(float*)field->pData);
  851|       |    }
  852|       |#endif
  853|       |
  854|  38.2k|    if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (854:9): [True: 21.8k, False: 16.4k]
  ------------------
  855|  21.8k|    {
  856|  21.8k|        return pb_encode_fixed32(stream, field->pData);
  857|  21.8k|    }
  858|  16.4k|#ifndef PB_WITHOUT_64BIT
  859|  16.4k|    else if (field->data_size == sizeof(uint64_t))
  ------------------
  |  Branch (859:14): [True: 16.4k, False: 0]
  ------------------
  860|  16.4k|    {
  861|  16.4k|        return pb_encode_fixed64(stream, field->pData);
  862|  16.4k|    }
  863|      0|#endif
  864|      0|    else
  865|      0|    {
  866|       |        PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  867|      0|    }
  868|  38.2k|}
pb_encode.c:encode_basic_field:
  372|  10.7M|{
  373|  10.7M|    if (!field->pData)
  ------------------
  |  Branch (373:9): [True: 0, False: 10.7M]
  ------------------
  374|      0|    {
  375|       |        /* Missing pointer field */
  376|      0|        return true;
  377|      0|    }
  378|       |
  379|  10.7M|    if (!pb_encode_tag_for_field(stream, field))
  ------------------
  |  Branch (379:9): [True: 75, False: 10.7M]
  ------------------
  380|     75|        return false;
  381|       |
  382|  10.7M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  335|  10.7M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  10.7M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  383|  10.7M|    {
  384|  3.19k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  275|  3.19k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (384:9): [True: 3.19k, False: 10.7M]
  ------------------
  385|  3.19k|            return pb_enc_bool(stream, field);
  386|       |
  387|   123k|        case PB_LTYPE_VARINT:
  ------------------
  |  |  276|   123k|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (387:9): [True: 123k, False: 10.6M]
  ------------------
  388|   169k|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  277|   169k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (388:9): [True: 45.7k, False: 10.7M]
  ------------------
  389|   188k|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  278|   188k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (389:9): [True: 18.5k, False: 10.7M]
  ------------------
  390|   188k|            return pb_enc_varint(stream, field);
  391|       |
  392|  17.0k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  279|  17.0k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (392:9): [True: 17.0k, False: 10.7M]
  ------------------
  393|  26.7k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  280|  26.7k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (393:9): [True: 9.63k, False: 10.7M]
  ------------------
  394|  26.7k|            return pb_enc_fixed(stream, field);
  395|       |
  396|  84.9k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  287|  84.9k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (396:9): [True: 84.9k, False: 10.6M]
  ------------------
  397|  84.9k|            return pb_enc_bytes(stream, field);
  398|       |
  399|  63.6k|        case PB_LTYPE_STRING:
  ------------------
  |  |  291|  63.6k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (399:9): [True: 63.6k, False: 10.6M]
  ------------------
  400|  63.6k|            return pb_enc_string(stream, field);
  401|       |
  402|  51.4k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  295|  51.4k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (402:9): [True: 51.4k, False: 10.7M]
  ------------------
  403|  51.4k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  300|  51.4k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (403:9): [True: 0, False: 10.7M]
  ------------------
  404|  51.4k|            return pb_enc_submessage(stream, field);
  405|       |
  406|  10.3M|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  310|  10.3M|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (406:9): [True: 10.3M, False: 417k]
  ------------------
  407|  10.3M|            return pb_enc_fixed_length_bytes(stream, field);
  408|       |
  409|      0|        default:
  ------------------
  |  Branch (409:9): [True: 0, False: 10.7M]
  ------------------
  410|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  411|  10.7M|    }
  412|  10.7M|}
pb_encode.c:pb_enc_bool:
  791|  3.19k|{
  792|  3.19k|    uint32_t value = safe_read_bool(field->pData) ? 1 : 0;
  ------------------
  |  Branch (792:22): [True: 1.50k, False: 1.69k]
  ------------------
  793|  3.19k|    PB_UNUSED(field);
  ------------------
  |  |  179|  3.19k|#define PB_UNUSED(x) (void)(x)
  ------------------
  794|  3.19k|    return pb_encode_varint(stream, value);
  795|  3.19k|}
pb_encode.c:pb_enc_bytes:
  871|  84.9k|{
  872|  84.9k|    const pb_bytes_array_t *bytes = NULL;
  873|       |
  874|  84.9k|    bytes = (const pb_bytes_array_t*)field->pData;
  875|       |    
  876|  84.9k|    if (bytes == NULL)
  ------------------
  |  Branch (876:9): [True: 0, False: 84.9k]
  ------------------
  877|      0|    {
  878|       |        /* Treat null pointer as an empty bytes field */
  879|      0|        return pb_encode_string(stream, NULL, 0);
  880|      0|    }
  881|       |    
  882|  84.9k|    if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  333|  84.9k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|  84.9k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  328|   169k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (882:9): [True: 0, False: 84.9k]
  ------------------
  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");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  886|      0|    }
  887|       |    
  888|  84.9k|    return pb_encode_string(stream, bytes->bytes, (size_t)bytes->size);
  889|  84.9k|}
pb_encode.c:pb_enc_string:
  892|  63.6k|{
  893|  63.6k|    size_t size = 0;
  894|  63.6k|    size_t max_size = (size_t)field->data_size;
  895|  63.6k|    const char *str = (const char*)field->pData;
  896|       |    
  897|  63.6k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  333|  63.6k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|  63.6k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  329|  63.6k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (897:9): [True: 63.3k, False: 217]
  ------------------
  898|  63.3k|    {
  899|  63.3k|        max_size = (size_t)-1;
  900|  63.3k|    }
  901|    217|    else
  902|    217|    {
  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|    217|        if (max_size == 0)
  ------------------
  |  Branch (908:13): [True: 0, False: 217]
  ------------------
  909|      0|            PB_RETURN_ERROR(stream, "zero-length string");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  910|       |
  911|    217|        max_size -= 1;
  912|    217|    }
  913|       |
  914|       |
  915|  63.6k|    if (str == NULL)
  ------------------
  |  Branch (915:9): [True: 0, False: 63.6k]
  ------------------
  916|      0|    {
  917|      0|        size = 0; /* Treat null pointer as an empty string */
  918|      0|    }
  919|  63.6k|    else
  920|  63.6k|    {
  921|  63.6k|        const char *p = str;
  922|       |
  923|       |        /* strnlen() is not always available, so just use a loop */
  924|   286k|        while (size < max_size && *p != '\0')
  ------------------
  |  Branch (924:16): [True: 286k, False: 20]
  |  Branch (924:35): [True: 222k, False: 63.5k]
  ------------------
  925|   222k|        {
  926|   222k|            size++;
  927|   222k|            p++;
  928|   222k|        }
  929|       |
  930|  63.6k|        if (*p != '\0')
  ------------------
  |  Branch (930:13): [True: 0, False: 63.6k]
  ------------------
  931|      0|        {
  932|      0|            PB_RETURN_ERROR(stream, "unterminated string");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  933|      0|        }
  934|  63.6k|    }
  935|       |
  936|       |#ifdef PB_VALIDATE_UTF8
  937|       |    if (!pb_validate_utf8(str))
  938|       |        PB_RETURN_ERROR(stream, "invalid utf8");
  939|       |#endif
  940|       |
  941|  63.6k|    return pb_encode_string(stream, (const pb_byte_t*)str, size);
  942|  63.6k|}
pb_encode.c:pb_enc_submessage:
  945|  51.4k|{
  946|  51.4k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (946:9): [True: 0, False: 51.4k]
  ------------------
  947|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  948|       |
  949|       |    /* Required fields have no callback slot. Extension fields are always
  950|       |     * required, and for them pSize points to extension->found. */
  951|  51.4k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL &&
  ------------------
  |  |  335|  51.4k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  51.4k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL &&
  ------------------
  |  |  300|   102k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (951:9): [True: 0, False: 51.4k]
  |  Branch (951:58): [True: 0, False: 0]
  ------------------
  952|      0|        PB_HTYPE(field->type) != PB_HTYPE_REQUIRED)
  ------------------
  |  |  334|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      PB_HTYPE(field->type) != PB_HTYPE_REQUIRED)
  ------------------
  |  |  318|      0|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (952:9): [True: 0, False: 0]
  ------------------
  953|      0|    {
  954|       |        /* Message callback is stored right before pSize. */
  955|      0|        pb_callback_t *callback = (pb_callback_t*)field->pSize - 1;
  956|      0|        if (callback->funcs.encode)
  ------------------
  |  Branch (956:13): [True: 0, False: 0]
  ------------------
  957|      0|        {
  958|      0|            if (!callback->funcs.encode(stream, field, &callback->arg))
  ------------------
  |  Branch (958:17): [True: 0, False: 0]
  ------------------
  959|      0|                return false;
  960|      0|        }
  961|      0|    }
  962|       |    
  963|  51.4k|    return pb_encode_submessage(stream, field->submsg_desc, field->pData);
  964|  51.4k|}
pb_encode.c:pb_enc_fixed_length_bytes:
  967|  10.3M|{
  968|  10.3M|    return pb_encode_string(stream, (const pb_byte_t*)field->pData, (size_t)field->data_size);
  969|  10.3M|}
pb_encode.c:pb_encode_varint_32:
  583|  12.3M|{
  584|  12.3M|    size_t i = 0;
  585|  12.3M|    pb_byte_t buffer[10];
  586|  12.3M|    pb_byte_t byte = (pb_byte_t)(low & 0x7F);
  587|  12.3M|    low >>= 7;
  588|       |
  589|  26.6M|    while (i < 4 && (low != 0 || high != 0))
  ------------------
  |  Branch (589:12): [True: 26.0M, False: 555k]
  |  Branch (589:22): [True: 14.2M, False: 11.8M]
  |  Branch (589:34): [True: 4.61k, False: 11.8M]
  ------------------
  590|  14.2M|    {
  591|  14.2M|        byte |= 0x80;
  592|  14.2M|        buffer[i++] = byte;
  593|  14.2M|        byte = (pb_byte_t)(low & 0x7F);
  594|  14.2M|        low >>= 7;
  595|  14.2M|    }
  596|       |
  597|  12.3M|    if (high)
  ------------------
  |  Branch (597:9): [True: 522k, False: 11.8M]
  ------------------
  598|   522k|    {
  599|   522k|        byte = (pb_byte_t)(byte | ((high & 0x07) << 4));
  600|   522k|        high >>= 3;
  601|       |
  602|  2.68M|        while (high)
  ------------------
  |  Branch (602:16): [True: 2.15M, False: 522k]
  ------------------
  603|  2.15M|        {
  604|  2.15M|            byte |= 0x80;
  605|  2.15M|            buffer[i++] = byte;
  606|  2.15M|            byte = (pb_byte_t)(high & 0x7F);
  607|  2.15M|            high >>= 7;
  608|  2.15M|        }
  609|   522k|    }
  610|       |
  611|  12.3M|    buffer[i++] = byte;
  612|       |
  613|  12.3M|    return pb_write(stream, buffer, i);
  614|  12.3M|}

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

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

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

validate_static:
    7|  19.4k|{
    8|  19.4k|    pb_size_t count = 1;
    9|  19.4k|    pb_size_t i;
   10|  19.4k|    bool truebool = true;
   11|  19.4k|    bool falsebool = false;
   12|       |
   13|  19.4k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  334|  19.4k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  19.4k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  321|  38.8k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (13:9): [True: 0, False: 19.4k]
  |  Branch (13:54): [True: 0, False: 0]
  ------------------
   14|      0|    {
   15|       |        /* Array count must be between 0 and statically allocated size */
   16|      0|        count = *(pb_size_t*)iter->pSize;
   17|      0|        assert(count <= iter->array_size);
  ------------------
  |  Branch (17:9): [True: 0, False: 0]
  |  Branch (17:9): [True: 0, False: 0]
  ------------------
   18|      0|    }
   19|  19.4k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  334|  19.4k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  19.4k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  319|  38.8k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (19:14): [True: 0, False: 19.4k]
  |  Branch (19:59): [True: 0, False: 0]
  ------------------
   20|      0|    {
   21|       |        /* Boolean has_ field must have a valid value */
   22|      0|        assert(memcmp(iter->pSize, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (22:9): [True: 0, False: 0]
  |  Branch (22:9): [True: 0, False: 0]
  |  Branch (22:9): [True: 0, False: 0]
  |  Branch (22:9): [True: 0, False: 0]
  ------------------
   23|      0|               memcmp(iter->pSize, &falsebool, sizeof(bool)) == 0);
   24|      0|    }
   25|  19.4k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  334|  19.4k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  19.4k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  323|  19.4k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (25:14): [True: 19.4k, False: 0]
  ------------------
   26|  19.4k|    {
   27|  19.4k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (27:13): [True: 18.9k, False: 522]
  ------------------
   28|  18.9k|        {
   29|       |            /* Some different field in oneof */
   30|  18.9k|            return;
   31|  18.9k|        }
   32|  19.4k|    }
   33|       |
   34|  1.04k|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (34:17): [True: 522, False: 522]
  ------------------
   35|    522|    {
   36|    522|        void *pData = (char*)iter->pData + iter->data_size * i;
   37|       |
   38|    522|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  335|    522|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|    522|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  291|    522|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (38:13): [True: 0, False: 522]
  ------------------
   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|    522|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  335|    522|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|    522|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  287|    522|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (43:18): [True: 0, False: 522]
  ------------------
   44|      0|        {
   45|       |            /* Bytes length must be at most statically allocated size */
   46|      0|            pb_bytes_array_t *bytes = pData;
   47|      0|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= iter->data_size);
  ------------------
  |  Branch (47:13): [True: 0, False: 0]
  |  Branch (47:13): [True: 0, False: 0]
  |  Branch (47:13): [True: 0, False: 0]
  |  Branch (47:13): [True: 0, False: 0]
  ------------------
   48|      0|        }
   49|    522|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  335|    522|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|    522|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  275|    522|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (49:18): [True: 0, False: 522]
  ------------------
   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|    522|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  336|    522|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  335|    522|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|    522|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  295|  1.04k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (336:32): [True: 451, False: 71]
  |  |  ------------------
  |  |  337|    522|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  335|     71|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|     71|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  300|     71|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (337:32): [True: 0, False: 71]
  |  |  ------------------
  ------------------
   56|    451|        {
   57|    451|            validate_message(pData, 0, iter->submsg_desc);
   58|    451|        }
   59|    522|    }
   60|    522|}
validate_pointer:
   63|   717k|{
   64|   717k|    pb_size_t count = 1;
   65|   717k|    pb_size_t i;
   66|   717k|    bool truebool = true;
   67|   717k|    bool falsebool = false;
   68|       |
   69|   717k|    if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  334|   717k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   717k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  323|   717k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (69:9): [True: 12.9k, False: 704k]
  ------------------
   70|  12.9k|    {
   71|  12.9k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (71:13): [True: 12.3k, False: 574]
  ------------------
   72|  12.3k|        {
   73|       |            /* Some different field in oneof */
   74|  12.3k|            return;
   75|  12.3k|        }
   76|  12.9k|    }
   77|   704k|    else if (!iter->pData)
  ------------------
  |  Branch (77:14): [True: 297k, False: 406k]
  ------------------
   78|   297k|    {
   79|       |        /* Nothing allocated */
   80|   297k|        if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize != &iter->array_size)
  ------------------
  |  |  334|   297k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   297k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize != &iter->array_size)
  ------------------
  |  |  321|   594k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (80:13): [True: 124k, False: 173k]
  |  Branch (80:58): [True: 111k, False: 12.3k]
  ------------------
   81|   111k|        {
   82|   111k|            assert(*(pb_size_t*)iter->pSize == 0);
  ------------------
  |  Branch (82:13): [True: 0, False: 111k]
  |  Branch (82:13): [True: 111k, False: 0]
  ------------------
   83|   111k|        }
   84|   297k|        return;
   85|   297k|    }
   86|       |
   87|   407k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  334|   407k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   407k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  321|   407k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (87:9): [True: 11.6k, False: 395k]
  ------------------
   88|  11.6k|    {
   89|       |        /* Check that enough memory has been allocated for array */
   90|  11.6k|        size_t allocated_size = get_allocation_size(iter->pData);
   91|  11.6k|        count = *(pb_size_t*)iter->pSize;
   92|  11.6k|        assert(allocated_size >= count * iter->data_size);
  ------------------
  |  Branch (92:9): [True: 0, False: 11.6k]
  |  Branch (92:9): [True: 11.6k, False: 0]
  ------------------
   93|  11.6k|    }
   94|   395k|    else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  335|   395k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   395k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  291|   791k|#define PB_LTYPE_STRING 0x07U
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  335|   333k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   333k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  287|   333k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (94:14): [True: 333k, False: 62.3k]
  |  Branch (94:57): [True: 326k, False: 7.18k]
  ------------------
   95|   326k|    {
   96|   326k|        size_t allocated_size = get_allocation_size(iter->pData);
   97|   326k|        assert(allocated_size >= iter->data_size);
  ------------------
  |  Branch (97:9): [True: 0, False: 326k]
  |  Branch (97:9): [True: 326k, False: 0]
  ------------------
   98|   326k|    }
   99|       |
  100|  37.9M|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (100:17): [True: 37.5M, False: 407k]
  ------------------
  101|  37.5M|    {
  102|  37.5M|        void *pData = (char*)iter->pData + iter->data_size * i;
  103|       |
  104|  37.5M|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  335|  37.5M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  37.5M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  291|  37.5M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (104:13): [True: 87.9k, False: 37.4M]
  ------------------
  105|  87.9k|        {
  106|       |            /* Check that enough memory is allocated for string and that
  107|       |               the string is properly terminated. */
  108|  87.9k|            const char *str = pData;
  109|       |
  110|  87.9k|            if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  334|  87.9k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  87.9k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  321|  87.9k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (110:17): [True: 25.6k, False: 62.3k]
  ------------------
  111|  25.6k|            {
  112|       |                /* String arrays are stored as array of pointers */
  113|  25.6k|                str = ((const char**)iter->pData)[i];
  114|  25.6k|            }
  115|       |
  116|  87.9k|            assert(strlen(str) + 1 <= get_allocation_size(str));
  ------------------
  |  Branch (116:13): [True: 0, False: 87.9k]
  |  Branch (116:13): [True: 87.9k, False: 0]
  ------------------
  117|  87.9k|        }
  118|  37.4M|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  335|  37.4M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  37.4M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  287|  37.4M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (118:18): [True: 242k, False: 37.2M]
  ------------------
  119|   242k|        {
  120|       |            /* Bytes length must be at most statically allocated size */
  121|   242k|            const pb_bytes_array_t *bytes = pData;
  122|       |
  123|   242k|            if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  334|   242k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   242k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  321|   242k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (123:17): [True: 235k, False: 7.18k]
  ------------------
  124|   235k|            {
  125|       |                /* Bytes arrays are stored as array of pointers */
  126|   235k|                bytes = ((const pb_bytes_array_t**)iter->pData)[i];
  127|   235k|            }
  128|       |
  129|   242k|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= get_allocation_size(bytes));
  ------------------
  |  Branch (129:13): [True: 0, False: 242k]
  |  Branch (129:13): [True: 0, False: 242k]
  |  Branch (129:13): [True: 234k, False: 8.31k]
  |  Branch (129:13): [True: 242k, False: 0]
  ------------------
  130|   242k|        }
  131|  37.2M|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  335|  37.2M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  37.2M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  275|  37.2M|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (131:18): [True: 820k, False: 36.4M]
  ------------------
  132|   820k|        {
  133|       |            /* Bool fields must have valid value */
  134|   820k|            assert(memcmp(pData, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (134:13): [True: 820k, False: 0]
  |  Branch (134:13): [True: 0, False: 0]
  |  Branch (134:13): [True: 267k, False: 552k]
  |  Branch (134:13): [True: 552k, False: 0]
  ------------------
  135|   820k|                   memcmp(pData, &falsebool, sizeof(bool)) == 0);
  136|   820k|        }
  137|  36.4M|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  336|  36.4M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  335|  36.4M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|  36.4M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  295|  72.8M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (336:32): [True: 107k, False: 36.3M]
  |  |  ------------------
  |  |  337|  36.4M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  335|  36.3M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|  36.3M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  300|  36.3M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (337:32): [True: 0, False: 36.3M]
  |  |  ------------------
  ------------------
  138|   107k|        {
  139|   107k|            validate_message(pData, 0, iter->submsg_desc);
  140|   107k|        }
  141|  37.5M|    }
  142|   407k|}
validate_message:
  145|   114k|{
  146|   114k|    pb_field_iter_t iter;
  147|       |
  148|   114k|    if (pb_field_iter_begin_const(&iter, msgtype, msg))
  ------------------
  |  Branch (148:9): [True: 81.6k, False: 32.5k]
  ------------------
  149|  81.6k|    {
  150|  81.6k|        do
  151|   755k|        {
  152|   755k|            if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  333|   755k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|   755k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  328|   755k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (152:17): [True: 19.4k, False: 736k]
  ------------------
  153|  19.4k|            {
  154|  19.4k|                validate_static(&iter);
  155|  19.4k|            }
  156|   736k|            else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  333|   736k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|   736k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  329|   736k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (156:22): [True: 717k, False: 19.4k]
  ------------------
  157|   717k|            {
  158|   717k|                validate_pointer(&iter);
  159|   717k|            }
  160|   755k|        } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (160:18): [True: 674k, False: 81.6k]
  ------------------
  161|  81.6k|    }
  162|   114k|}

