pb_field_iter_begin:
  157|   587k|{
  158|   587k|    memset(iter, 0, sizeof(*iter));
  159|       |
  160|   587k|    iter->descriptor = desc;
  161|   587k|    iter->message = message;
  162|       |
  163|   587k|    return load_descriptor_values(iter);
  164|   587k|}
pb_field_iter_begin_extension:
  167|   140k|{
  168|   140k|    const pb_msgdesc_t *msg = (const pb_msgdesc_t*)extension->type->arg;
  169|   140k|    bool status;
  170|       |
  171|   140k|    uint32_t word0 = PB_PROGMEM_READU32(msg->field_info[0]);
  ------------------
  |  |  184|   140k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  172|   140k|    if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   140k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   140k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   140k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (172:9): [True: 0, False: 140k]
  ------------------
  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|   140k|    else
  180|   140k|    {
  181|   140k|        status = pb_field_iter_begin(iter, msg, extension->dest);
  182|   140k|    }
  183|       |
  184|   140k|    iter->pSize = &extension->found;
  185|   140k|    return status;
  186|   140k|}
pb_field_iter_next:
  189|  1.79M|{
  190|  1.79M|    advance_iterator(iter);
  191|  1.79M|    (void)load_descriptor_values(iter);
  192|  1.79M|    return iter->index != 0;
  193|  1.79M|}
pb_field_iter_find:
  196|  7.18M|{
  197|  7.18M|    if (iter->tag == tag)
  ------------------
  |  Branch (197:9): [True: 4.39M, False: 2.78M]
  ------------------
  198|  4.39M|    {
  199|  4.39M|        return true; /* Nothing to do, correct field already. */
  200|  4.39M|    }
  201|  2.78M|    else if (tag > iter->descriptor->largest_tag)
  ------------------
  |  Branch (201:14): [True: 831k, False: 1.95M]
  ------------------
  202|   831k|    {
  203|   831k|        return false;
  204|   831k|    }
  205|  1.95M|    else
  206|  1.95M|    {
  207|  1.95M|        pb_size_t start = iter->index;
  208|  1.95M|        uint32_t fieldinfo;
  209|       |
  210|  1.95M|        if (tag < iter->tag)
  ------------------
  |  Branch (210:13): [True: 551k, False: 1.40M]
  ------------------
  211|   551k|        {
  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|   551k|            iter->index = iter->descriptor->field_count;
  216|   551k|        }
  217|       |
  218|  1.95M|        do
  219|  27.3M|        {
  220|       |            /* Advance iterator but don't load values yet */
  221|  27.3M|            advance_iterator(iter);
  222|       |
  223|       |            /* Do fast check for tag number match */
  224|  27.3M|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  184|  27.3M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  225|       |
  226|  27.3M|            if (((fieldinfo >> 2) & 0x3F) == (tag & 0x3F))
  ------------------
  |  Branch (226:17): [True: 2.03M, False: 25.3M]
  ------------------
  227|  2.03M|            {
  228|       |                /* Good candidate, check further */
  229|  2.03M|                (void)load_descriptor_values(iter);
  230|       |
  231|  2.03M|                if (iter->tag == tag &&
  ------------------
  |  Branch (231:21): [True: 1.86M, False: 171k]
  ------------------
  232|  1.86M|                    PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  1.86M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.86M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                                  PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  1.86M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (232:21): [True: 1.83M, False: 23.8k]
  ------------------
  233|  1.83M|                {
  234|       |                    /* Found it */
  235|  1.83M|                    return true;
  236|  1.83M|                }
  237|  2.03M|            }
  238|  27.3M|        } while (iter->index != start);
  ------------------
  |  Branch (238:18): [True: 25.4M, False: 119k]
  ------------------
  239|       |
  240|       |        /* Searched all the way back to start, and found nothing. */
  241|   119k|        (void)load_descriptor_values(iter);
  242|       |        return false;
  243|  1.95M|    }
  244|  7.18M|}
pb_field_iter_find_extension:
  247|  27.8k|{
  248|  27.8k|    if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  27.8k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  27.8k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  27.8k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (248:9): [True: 0, False: 27.8k]
  ------------------
  249|      0|    {
  250|      0|        return true;
  251|      0|    }
  252|  27.8k|    else
  253|  27.8k|    {
  254|  27.8k|        pb_size_t start = iter->index;
  255|  27.8k|        uint32_t fieldinfo;
  256|       |
  257|  27.8k|        do
  258|   158k|        {
  259|       |            /* Advance iterator but don't load values yet */
  260|   158k|            advance_iterator(iter);
  261|       |
  262|       |            /* Do fast check for field type */
  263|   158k|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  184|   158k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  264|       |
  265|   158k|            if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|   158k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   158k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|   158k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (265:17): [True: 3.48k, False: 155k]
  ------------------
  266|  3.48k|            {
  267|  3.48k|                return load_descriptor_values(iter);
  268|  3.48k|            }
  269|   158k|        } while (iter->index != start);
  ------------------
  |  Branch (269:18): [True: 131k, False: 24.3k]
  ------------------
  270|       |
  271|       |        /* Searched all the way back to start, and found nothing. */
  272|  24.3k|        (void)load_descriptor_values(iter);
  273|       |        return false;
  274|  27.8k|    }
  275|  27.8k|}
pb_field_iter_begin_const:
  291|  89.5k|{
  292|  89.5k|    return pb_field_iter_begin(iter, desc, pb_const_cast(message));
  293|  89.5k|}
pb_field_iter_begin_extension_const:
  296|  2.62k|{
  297|  2.62k|    return pb_field_iter_begin_extension(iter, (pb_extension_t*)pb_const_cast(extension));
  298|  2.62k|}
pb_default_field_callback:
  301|  75.3k|{
  302|  75.3k|    if (field->data_size == sizeof(pb_callback_t))
  ------------------
  |  Branch (302:9): [True: 75.3k, False: 0]
  ------------------
  303|  75.3k|    {
  304|  75.3k|        pb_callback_t *pCallback = (pb_callback_t*)field->pData;
  305|       |
  306|  75.3k|        if (pCallback != NULL)
  ------------------
  |  Branch (306:13): [True: 75.3k, False: 0]
  ------------------
  307|  75.3k|        {
  308|  75.3k|            if (istream != NULL && pCallback->funcs.decode != NULL)
  ------------------
  |  Branch (308:17): [True: 75.2k, False: 105]
  |  Branch (308:36): [True: 5.47k, False: 69.7k]
  ------------------
  309|  5.47k|            {
  310|  5.47k|                return pCallback->funcs.decode(istream, field, &pCallback->arg);
  311|  5.47k|            }
  312|       |
  313|  69.8k|            if (ostream != NULL && pCallback->funcs.encode != NULL)
  ------------------
  |  Branch (313:17): [True: 105, False: 69.7k]
  |  Branch (313:36): [True: 0, False: 105]
  ------------------
  314|      0|            {
  315|      0|                return pCallback->funcs.encode(ostream, field, &pCallback->arg);
  316|      0|            }
  317|  69.8k|        }
  318|  75.3k|    }
  319|       |
  320|  69.8k|    return true; /* Success, but didn't do anything */
  321|       |
  322|  75.3k|}
pb_common.c:load_descriptor_values:
    9|  4.56M|{
   10|  4.56M|    uint32_t word0;
   11|  4.56M|    uint32_t data_offset;
   12|  4.56M|    int_least8_t size_offset;
   13|       |
   14|  4.56M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (14:9): [True: 170k, False: 4.39M]
  ------------------
   15|   170k|        return false;
   16|       |
   17|  4.39M|    word0 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  184|  4.39M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   18|  4.39M|    iter->type = (pb_type_t)((word0 >> 8) & 0xFF);
   19|       |
   20|  4.39M|    switch(word0 & 3)
   21|  4.39M|    {
   22|   458k|        case 0: {
  ------------------
  |  Branch (22:9): [True: 458k, False: 3.93M]
  ------------------
   23|       |            /* 1-word format */
   24|   458k|            iter->array_size = 1;
   25|   458k|            iter->tag = (pb_size_t)((word0 >> 2) & 0x3F);
   26|   458k|            size_offset = (int_least8_t)((word0 >> 24) & 0x0F);
   27|   458k|            data_offset = (word0 >> 16) & 0xFF;
   28|   458k|            iter->data_size = (pb_size_t)((word0 >> 28) & 0x0F);
   29|   458k|            break;
   30|      0|        }
   31|       |
   32|  3.44M|        case 1: {
  ------------------
  |  Branch (32:9): [True: 3.44M, False: 941k]
  ------------------
   33|       |            /* 2-word format */
   34|  3.44M|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  184|  3.44M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   35|       |
   36|  3.44M|            iter->array_size = (pb_size_t)((word0 >> 16) & 0x0FFF);
   37|  3.44M|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 28) << 6));
   38|  3.44M|            size_offset = (int_least8_t)((word0 >> 28) & 0x0F);
   39|  3.44M|            data_offset = word1 & 0xFFFF;
   40|  3.44M|            iter->data_size = (pb_size_t)((word1 >> 16) & 0x0FFF);
   41|  3.44M|            break;
   42|      0|        }
   43|       |
   44|   417k|        case 2: {
  ------------------
  |  Branch (44:9): [True: 417k, False: 3.97M]
  ------------------
   45|       |            /* 4-word format */
   46|   417k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  184|   417k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   47|   417k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  184|   417k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   48|   417k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  184|   417k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   49|       |
   50|   417k|            iter->array_size = (pb_size_t)(word0 >> 16);
   51|   417k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   52|   417k|            size_offset = (int_least8_t)(word1 & 0xFF);
   53|   417k|            data_offset = word2;
   54|   417k|            iter->data_size = (pb_size_t)word3;
   55|   417k|            break;
   56|      0|        }
   57|       |
   58|  65.0k|        default: {
  ------------------
  |  Branch (58:9): [True: 65.0k, False: 4.32M]
  ------------------
   59|       |            /* 8-word format */
   60|  65.0k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  184|  65.0k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   61|  65.0k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  184|  65.0k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   62|  65.0k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  184|  65.0k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   63|  65.0k|            uint32_t word4 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 4]);
  ------------------
  |  |  184|  65.0k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   64|       |
   65|  65.0k|            iter->array_size = (pb_size_t)word4;
   66|  65.0k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   67|  65.0k|            size_offset = (int_least8_t)(word1 & 0xFF);
   68|  65.0k|            data_offset = word2;
   69|  65.0k|            iter->data_size = (pb_size_t)word3;
   70|  65.0k|            break;
   71|      0|        }
   72|  4.39M|    }
   73|       |
   74|  4.39M|    if (!iter->message)
  ------------------
  |  Branch (74:9): [True: 0, False: 4.39M]
  ------------------
   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.39M|    else
   81|  4.39M|    {
   82|  4.39M|        iter->pField = (char*)iter->message + data_offset;
   83|       |
   84|  4.39M|        if (size_offset)
  ------------------
  |  Branch (84:13): [True: 1.39M, False: 2.99M]
  ------------------
   85|  1.39M|        {
   86|  1.39M|            iter->pSize = (char*)iter->pField - size_offset;
   87|  1.39M|        }
   88|  2.99M|        else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  327|  2.99M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  2.99M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  314|  5.99M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (88:18): [True: 92.2k, False: 2.90M]
  ------------------
   89|  92.2k|                 (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  326|  92.2k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  92.2k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                               (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  321|   184k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (89:19): [True: 43.6k, False: 48.5k]
  ------------------
   90|  48.5k|                  PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  326|  48.5k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  48.5k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                                PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  322|  48.5k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (90:19): [True: 0, False: 48.5k]
  ------------------
   91|  43.6k|        {
   92|       |            /* Fixed count array */
   93|  43.6k|            iter->pSize = &iter->array_size;
   94|  43.6k|        }
   95|  2.95M|        else
   96|  2.95M|        {
   97|  2.95M|            iter->pSize = NULL;
   98|  2.95M|        }
   99|       |
  100|  4.39M|        if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  326|  4.39M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  4.39M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  322|  8.78M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (100:13): [True: 0, False: 4.39M]
  |  Branch (100:57): [True: 0, False: 0]
  ------------------
  101|      0|        {
  102|      0|            iter->pData = *(void**)iter->pField;
  103|      0|        }
  104|  4.39M|        else
  105|  4.39M|        {
  106|  4.39M|            iter->pData = iter->pField;
  107|  4.39M|        }
  108|  4.39M|    }
  109|       |
  110|  4.39M|    if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  329|  4.39M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  4.39M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  4.39M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  8.78M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 639k, False: 3.75M]
  |  |  ------------------
  |  |  330|  4.39M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  3.75M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  3.75M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  3.75M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 46.7k, False: 3.70M]
  |  |  ------------------
  ------------------
  111|   686k|    {
  112|   686k|        iter->submsg_desc = iter->descriptor->submsg_info[iter->submessage_index];
  113|   686k|    }
  114|  3.70M|    else
  115|  3.70M|    {
  116|  3.70M|        iter->submsg_desc = NULL;
  117|  3.70M|    }
  118|       |
  119|       |    return true;
  120|  4.39M|}
pb_common.c:advance_iterator:
  123|  29.3M|{
  124|  29.3M|    iter->index++;
  125|       |
  126|  29.3M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (126:9): [True: 866k, False: 28.4M]
  ------------------
  127|   866k|    {
  128|       |        /* Restart */
  129|   866k|        iter->index = 0;
  130|   866k|        iter->field_info_index = 0;
  131|   866k|        iter->submessage_index = 0;
  132|   866k|        iter->required_field_index = 0;
  133|   866k|    }
  134|  28.4M|    else
  135|  28.4M|    {
  136|       |        /* Increment indexes based on previous field type.
  137|       |         * All field info formats have the following fields:
  138|       |         * - lowest 2 bits tell the amount of words in the descriptor (2^n words)
  139|       |         * - bits 2..7 give the lowest bits of tag number.
  140|       |         * - bits 8..15 give the field type.
  141|       |         */
  142|  28.4M|        uint32_t prev_descriptor = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  184|  28.4M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  143|  28.4M|        pb_type_t prev_type = (prev_descriptor >> 8) & 0xFF;
  144|  28.4M|        pb_size_t descriptor_len = (pb_size_t)(1 << (prev_descriptor & 3));
  145|       |
  146|       |        /* Add to fields.
  147|       |         * The cast to pb_size_t is needed to avoid -Wconversion warning.
  148|       |         * Because the data is is constants from generator, there is no danger of overflow.
  149|       |         */
  150|  28.4M|        iter->field_info_index = (pb_size_t)(iter->field_info_index + descriptor_len);
  151|  28.4M|        iter->required_field_index = (pb_size_t)(iter->required_field_index + (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED));
  ------------------
  |  |  327|  28.4M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  28.4M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      iter->required_field_index = (pb_size_t)(iter->required_field_index + (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED));
  ------------------
  |  |  311|  28.4M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  152|  28.4M|        iter->submessage_index = (pb_size_t)(iter->submessage_index + PB_LTYPE_IS_SUBMSG(prev_type));
  ------------------
  |  |  329|  28.4M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  28.4M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  28.4M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  56.9M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 3.58M, False: 24.8M]
  |  |  ------------------
  |  |  330|  28.4M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  24.8M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  24.8M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  24.8M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 142k, False: 24.7M]
  |  |  ------------------
  ------------------
  153|  28.4M|    }
  154|  29.3M|}
pb_common.c:pb_const_cast:
  278|  92.1k|{
  279|       |    /* Note: this casts away const, in order to use the common field iterator
  280|       |     * logic for both encoding and decoding. The cast is done using union
  281|       |     * to avoid spurious compiler warnings. */
  282|  92.1k|    union {
  283|  92.1k|        void *p1;
  284|  92.1k|        const void *p2;
  285|  92.1k|    } t;
  286|  92.1k|    t.p2 = p;
  287|  92.1k|    return t.p1;
  288|  92.1k|}

pb_read:
   82|  2.55M|{
   83|  2.55M|    if (count == 0)
  ------------------
  |  Branch (83:9): [True: 174k, False: 2.37M]
  ------------------
   84|   174k|        return true;
   85|       |
   86|  2.37M|#ifndef PB_BUFFER_ONLY
   87|  2.37M|	if (buf == NULL && stream->callback != buf_read)
  ------------------
  |  Branch (87:6): [True: 298k, False: 2.08M]
  |  Branch (87:21): [True: 67.2k, False: 231k]
  ------------------
   88|  67.2k|	{
   89|       |		/* Skip input bytes */
   90|  67.2k|		pb_byte_t tmp[16];
   91|   558k|		while (count > 16)
  ------------------
  |  Branch (91:10): [True: 491k, False: 67.2k]
  ------------------
   92|   491k|		{
   93|   491k|			if (!pb_read(stream, tmp, 16))
  ------------------
  |  Branch (93:8): [True: 0, False: 491k]
  ------------------
   94|      0|				return false;
   95|       |			
   96|   491k|			count -= 16;
   97|   491k|		}
   98|       |		
   99|  67.2k|		return pb_read(stream, tmp, count);
  100|  67.2k|	}
  101|  2.31M|#endif
  102|       |
  103|  2.31M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (103:9): [True: 264, False: 2.31M]
  ------------------
  104|    264|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  930|    264|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|    264|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 264]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  105|       |    
  106|  2.31M|#ifndef PB_BUFFER_ONLY
  107|  2.31M|    if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (107:9): [True: 0, False: 2.31M]
  ------------------
  108|      0|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  109|       |#else
  110|       |    if (!buf_read(stream, buf, count))
  111|       |        return false;
  112|       |#endif
  113|       |    
  114|  2.31M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (114:9): [True: 0, False: 2.31M]
  ------------------
  115|      0|        stream->bytes_left = 0;
  116|  2.31M|    else
  117|  2.31M|        stream->bytes_left -= count;
  118|       |
  119|       |    return true;
  120|  2.31M|}
pb_istream_from_buffer:
  143|   119k|{
  144|   119k|    pb_istream_t stream;
  145|       |    /* Cast away the const from buf without a compiler error.  We are
  146|       |     * careful to use it only in a const manner in the callbacks.
  147|       |     */
  148|   119k|    union {
  149|   119k|        void *state;
  150|   119k|        const void *c_state;
  151|   119k|    } state;
  152|       |#ifdef PB_BUFFER_ONLY
  153|       |    stream.callback = NULL;
  154|       |#else
  155|   119k|    stream.callback = &buf_read;
  156|   119k|#endif
  157|   119k|    state.c_state = buf;
  158|   119k|    stream.state = state.state;
  159|   119k|    stream.bytes_left = msglen;
  160|   119k|#ifndef PB_NO_ERRMSG
  161|   119k|    stream.errmsg = NULL;
  162|   119k|#endif
  163|       |#ifdef PB_MESSAGE_NESTING_MAX
  164|       |    stream.depth = 0;
  165|       |#endif
  166|   119k|    return stream;
  167|   119k|}
pb_decode_varint32:
  175|  8.84M|{
  176|  8.84M|    pb_byte_t byte;
  177|  8.84M|    uint32_t result;
  178|       |    
  179|  8.84M|    if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (179:9): [True: 1.45k, False: 8.83M]
  ------------------
  180|  1.45k|    {
  181|  1.45k|        return false;
  182|  1.45k|    }
  183|       |    
  184|  8.83M|    if ((byte & 0x80) == 0)
  ------------------
  |  Branch (184:9): [True: 7.60M, False: 1.23M]
  ------------------
  185|  7.60M|    {
  186|       |        /* Quick case, 1 byte value */
  187|  7.60M|        result = byte;
  188|  7.60M|    }
  189|  1.23M|    else
  190|  1.23M|    {
  191|       |        /* Multibyte case */
  192|  1.23M|        uint_fast8_t bitpos = 7;
  193|  1.23M|        result = byte & 0x7F;
  194|       |        
  195|  1.23M|        do
  196|  1.54M|        {
  197|  1.54M|            if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (197:17): [True: 44, False: 1.54M]
  ------------------
  198|     44|                return false;
  199|       |            
  200|  1.54M|            if (bitpos >= 32)
  ------------------
  |  Branch (200:17): [True: 15.1k, False: 1.52M]
  ------------------
  201|  15.1k|            {
  202|       |                /* Note: The varint could have trailing 0x80 bytes, or 0xFF for negative. */
  203|  15.1k|                pb_byte_t sign_extension = (bitpos < 63) ? 0xFF : 0x01;
  ------------------
  |  Branch (203:44): [True: 14.7k, False: 488]
  ------------------
  204|  15.1k|                bool valid_extension = ((byte & 0x7F) == 0x00 ||
  ------------------
  |  Branch (204:41): [True: 3.96k, False: 11.2k]
  ------------------
  205|  11.2k|                         ((result >> 31) != 0 && byte == sign_extension));
  ------------------
  |  Branch (205:27): [True: 11.2k, False: 14]
  |  Branch (205:50): [True: 11.1k, False: 42]
  ------------------
  206|       |
  207|  15.1k|                if (bitpos >= 64 || !valid_extension)
  ------------------
  |  Branch (207:21): [True: 2, False: 15.1k]
  |  Branch (207:37): [True: 56, False: 15.1k]
  ------------------
  208|     58|                {
  209|     58|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  930|     58|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     58|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  210|     58|                }
  211|  15.1k|            }
  212|  1.52M|            else if (bitpos == 28)
  ------------------
  |  Branch (212:22): [True: 11.6k, False: 1.51M]
  ------------------
  213|  11.6k|            {
  214|  11.6k|                if ((byte & 0x70) != 0 && (byte & 0x78) != 0x78)
  ------------------
  |  Branch (214:21): [True: 3.97k, False: 7.65k]
  |  Branch (214:43): [True: 13, False: 3.96k]
  ------------------
  215|     13|                {
  216|     13|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  930|     13|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     13|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  217|     13|                }
  218|  11.6k|                result |= (uint32_t)(byte & 0x0F) << bitpos;
  219|  11.6k|            }
  220|  1.51M|            else
  221|  1.51M|            {
  222|  1.51M|                result |= (uint32_t)(byte & 0x7F) << bitpos;
  223|  1.51M|            }
  224|  1.54M|            bitpos = (uint_fast8_t)(bitpos + 7);
  225|  1.54M|        } while (byte & 0x80);
  ------------------
  |  Branch (225:18): [True: 312k, False: 1.22M]
  ------------------
  226|  1.23M|   }
  227|       |   
  228|  8.83M|   *dest = result;
  229|       |   return true;
  230|  8.83M|}
pb_decode_varint:
  234|  5.24M|{
  235|  5.24M|    pb_byte_t byte;
  236|  5.24M|    uint_fast8_t bitpos = 0;
  237|  5.24M|    uint64_t result = 0;
  238|       |    
  239|  5.24M|    do
  240|  6.40M|    {
  241|  6.40M|        if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (241:13): [True: 62, False: 6.40M]
  ------------------
  242|     62|            return false;
  243|       |
  244|  6.40M|        if (bitpos >= 63 && (byte & 0xFE) != 0)
  ------------------
  |  Branch (244:13): [True: 49.9k, False: 6.35M]
  |  Branch (244:29): [True: 21, False: 49.8k]
  ------------------
  245|     21|            PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  930|     21|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     21|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 21]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  246|       |
  247|  6.40M|        result |= (uint64_t)(byte & 0x7F) << bitpos;
  248|  6.40M|        bitpos = (uint_fast8_t)(bitpos + 7);
  249|  6.40M|    } while (byte & 0x80);
  ------------------
  |  Branch (249:14): [True: 1.16M, False: 5.24M]
  ------------------
  250|       |    
  251|  5.24M|    *dest = result;
  252|       |    return true;
  253|  5.24M|}
pb_decode_tag:
  282|  8.01M|{
  283|  8.01M|    uint32_t temp;
  284|  8.01M|    *eof = false;
  285|  8.01M|    *wire_type = (pb_wire_type_t) 0;
  286|  8.01M|    *tag = 0;
  287|       |
  288|  8.01M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (288:9): [True: 268k, False: 7.74M]
  ------------------
  289|   268k|    {
  290|   268k|        *eof = true;
  291|   268k|        return false;
  292|   268k|    }
  293|       |
  294|  7.74M|    if (!pb_decode_varint32(stream, &temp))
  ------------------
  |  Branch (294:9): [True: 1.40k, False: 7.74M]
  ------------------
  295|  1.40k|    {
  296|  1.40k|#ifndef PB_BUFFER_ONLY
  297|       |        /* Workaround for issue #1017
  298|       |         *
  299|       |         * Callback streams don't set bytes_left to 0 on eof until after being called by pb_decode_varint32,
  300|       |         * which results in "io error" being raised. This contrasts the behavior of buffer streams who raise
  301|       |         * no error on eof as bytes_left is already 0 on entry. This causes legitimate errors (e.g. missing
  302|       |         * required fields) to be incorrectly reported by callback streams.
  303|       |         */
  304|  1.40k|        if (stream->callback != buf_read && stream->bytes_left == 0)
  ------------------
  |  Branch (304:13): [True: 1.31k, False: 95]
  |  Branch (304:45): [True: 1.31k, False: 0]
  ------------------
  305|  1.31k|        {
  306|  1.31k|#ifndef PB_NO_ERRMSG
  307|  1.31k|            if (strcmp(stream->errmsg, "io error") == 0)
  ------------------
  |  Branch (307:17): [True: 1.31k, False: 0]
  ------------------
  308|  1.31k|                stream->errmsg = NULL;
  309|  1.31k|#endif
  310|  1.31k|            *eof = true;
  311|  1.31k|        }
  312|  1.40k|#endif
  313|  1.40k|        return false;
  314|  1.40k|    }
  315|       |    
  316|  7.74M|    *tag = temp >> 3;
  317|  7.74M|    *wire_type = (pb_wire_type_t)(temp & 7);
  318|       |    return true;
  319|  7.74M|}
pb_skip_field:
  322|   945k|{
  323|   945k|    switch (wire_type)
  324|   945k|    {
  325|   600k|        case PB_WT_VARINT: return pb_skip_varint(stream);
  ------------------
  |  Branch (325:9): [True: 600k, False: 344k]
  ------------------
  326|  73.3k|        case PB_WT_64BIT: return pb_read(stream, NULL, 8);
  ------------------
  |  Branch (326:9): [True: 73.3k, False: 871k]
  ------------------
  327|   152k|        case PB_WT_STRING: return pb_skip_string(stream);
  ------------------
  |  Branch (327:9): [True: 152k, False: 792k]
  ------------------
  328|   118k|        case PB_WT_32BIT: return pb_read(stream, NULL, 4);
  ------------------
  |  Branch (328:9): [True: 118k, False: 826k]
  ------------------
  329|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (329:2): [True: 0, False: 945k]
  ------------------
  330|       |            /* Calling pb_skip_field with a PB_WT_PACKED is an error.
  331|       |             * Explicitly handle this case and fallthrough to default to avoid
  332|       |             * compiler warnings.
  333|       |             */
  334|     93|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  930|     93|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     93|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 93]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (334:9): [True: 93, False: 945k]
  ------------------
  335|   945k|    }
  336|   945k|}
pb_make_string_substream:
  387|   359k|{
  388|   359k|    uint32_t size;
  389|   359k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (389:9): [True: 79, False: 359k]
  ------------------
  390|     79|        return false;
  391|       |    
  392|   359k|    *substream = *stream;
  393|   359k|    if (substream->bytes_left < size)
  ------------------
  |  Branch (393:9): [True: 126, False: 359k]
  ------------------
  394|    126|        PB_RETURN_ERROR(stream, "parent stream too short");
  ------------------
  |  |  930|    126|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|    126|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 126]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  395|       |    
  396|       |#ifdef PB_MESSAGE_NESTING_MAX
  397|       |    substream->depth++;
  398|       |    if (substream->depth > PB_MESSAGE_NESTING_MAX)
  399|       |        PB_RETURN_ERROR(stream, "max depth");
  400|       |#endif
  401|       |
  402|   359k|    substream->bytes_left = (size_t)size;
  403|   359k|    stream->bytes_left -= (size_t)size;
  404|       |    return true;
  405|   359k|}
pb_close_string_substream:
  408|   359k|{
  409|   359k|    if (substream->bytes_left) {
  ------------------
  |  Branch (409:9): [True: 24.7k, False: 334k]
  ------------------
  410|  24.7k|        if (!pb_read(substream, NULL, substream->bytes_left))
  ------------------
  |  Branch (410:13): [True: 0, False: 24.7k]
  ------------------
  411|      0|            return false;
  412|  24.7k|    }
  413|       |
  414|   359k|    stream->state = substream->state;
  415|       |
  416|   359k|#ifndef PB_NO_ERRMSG
  417|   359k|    stream->errmsg = substream->errmsg;
  418|   359k|#endif
  419|       |    return true;
  420|   359k|}
pb_decode_ex:
 1222|  8.41k|{
 1223|  8.41k|    bool status;
 1224|       |
 1225|  8.41k|    if ((flags & PB_DECODE_DELIMITED) == 0)
  ------------------
  |  |  123|  8.41k|#define PB_DECODE_DELIMITED       0x02U
  ------------------
  |  Branch (1225:9): [True: 8.41k, False: 0]
  ------------------
 1226|  8.41k|    {
 1227|  8.41k|      status = pb_decode_inner(stream, fields, dest_struct, flags);
 1228|  8.41k|    }
 1229|      0|    else
 1230|      0|    {
 1231|      0|      pb_istream_t substream;
 1232|      0|      if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1232:11): [True: 0, False: 0]
  ------------------
 1233|      0|        return false;
 1234|       |
 1235|      0|      status = pb_decode_inner(&substream, fields, dest_struct, flags);
 1236|       |
 1237|      0|      if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1237:11): [True: 0, False: 0]
  ------------------
 1238|      0|        status = false;
 1239|      0|    }
 1240|       |    
 1241|       |#ifdef PB_ENABLE_MALLOC
 1242|       |    if (!status)
 1243|       |        pb_release(fields, dest_struct);
 1244|       |#endif
 1245|       |    
 1246|  8.41k|    return status;
 1247|  8.41k|}
pb_decode:
 1250|  3.93k|{
 1251|  3.93k|    return pb_decode_ex(stream, fields, dest_struct, 0);
 1252|  3.93k|}
pb_release:
 1396|  6.56k|{
 1397|       |    /* Nothing to release without PB_ENABLE_MALLOC. */
 1398|  6.56k|    PB_UNUSED(fields);
  ------------------
  |  |  172|  6.56k|#define PB_UNUSED(x) (void)(x)
  ------------------
 1399|  6.56k|    PB_UNUSED(dest_struct);
  ------------------
  |  |  172|  6.56k|#define PB_UNUSED(x) (void)(x)
  ------------------
 1400|  6.56k|}
pb_decode_bool:
 1406|   309k|{
 1407|   309k|    uint32_t value;
 1408|   309k|    if (!pb_decode_varint32(stream, &value))
  ------------------
  |  Branch (1408:9): [True: 15, False: 309k]
  ------------------
 1409|     15|        return false;
 1410|       |
 1411|   309k|    *(bool*)dest = (value != 0);
 1412|       |    return true;
 1413|   309k|}
pb_decode_svarint:
 1416|   166k|{
 1417|   166k|    pb_uint64_t value;
  ------------------
  |  |   57|   166k|#define pb_uint64_t uint64_t
  ------------------
 1418|   166k|    if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1418:9): [True: 27, False: 166k]
  ------------------
 1419|     27|        return false;
 1420|       |    
 1421|   166k|    if (value & 1)
  ------------------
  |  Branch (1421:9): [True: 28.0k, False: 138k]
  ------------------
 1422|  28.0k|        *dest = (pb_int64_t)(~(value >> 1));
 1423|   138k|    else
 1424|   138k|        *dest = (pb_int64_t)(value >> 1);
 1425|       |    
 1426|       |    return true;
 1427|   166k|}
pb_decode_fixed32:
 1430|   283k|{
 1431|   283k|    union {
 1432|   283k|        uint32_t fixed32;
 1433|   283k|        pb_byte_t bytes[4];
 1434|   283k|    } u;
 1435|       |
 1436|   283k|    if (!pb_read(stream, u.bytes, 4))
  ------------------
  |  Branch (1436:9): [True: 16, False: 283k]
  ------------------
 1437|     16|        return false;
 1438|       |
 1439|   283k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1440|       |    /* fast path - if we know that we're on little endian, assign directly */
 1441|   283k|    *(uint32_t*)dest = u.fixed32;
 1442|       |#else
 1443|       |    *(uint32_t*)dest = ((uint32_t)u.bytes[0] << 0) |
 1444|       |                       ((uint32_t)u.bytes[1] << 8) |
 1445|       |                       ((uint32_t)u.bytes[2] << 16) |
 1446|       |                       ((uint32_t)u.bytes[3] << 24);
 1447|       |#endif
 1448|       |    return true;
 1449|   283k|}
pb_decode_fixed64:
 1453|   247k|{
 1454|   247k|    union {
 1455|   247k|        uint64_t fixed64;
 1456|   247k|        pb_byte_t bytes[8];
 1457|   247k|    } u;
 1458|       |
 1459|   247k|    if (!pb_read(stream, u.bytes, 8))
  ------------------
  |  Branch (1459:9): [True: 17, False: 247k]
  ------------------
 1460|     17|        return false;
 1461|       |
 1462|   247k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1463|       |    /* fast path - if we know that we're on little endian, assign directly */
 1464|   247k|    *(uint64_t*)dest = u.fixed64;
 1465|       |#else
 1466|       |    *(uint64_t*)dest = ((uint64_t)u.bytes[0] << 0) |
 1467|       |                       ((uint64_t)u.bytes[1] << 8) |
 1468|       |                       ((uint64_t)u.bytes[2] << 16) |
 1469|       |                       ((uint64_t)u.bytes[3] << 24) |
 1470|       |                       ((uint64_t)u.bytes[4] << 32) |
 1471|       |                       ((uint64_t)u.bytes[5] << 40) |
 1472|       |                       ((uint64_t)u.bytes[6] << 48) |
 1473|       |                       ((uint64_t)u.bytes[7] << 56);
 1474|       |#endif
 1475|       |    return true;
 1476|   247k|}
pb_decode.c:buf_read:
   69|  14.5M|{
   70|  14.5M|    const pb_byte_t *source = (const pb_byte_t*)stream->state;
   71|  14.5M|    stream->state = (pb_byte_t*)stream->state + count;
   72|       |    
   73|  14.5M|    if (buf != NULL)
  ------------------
  |  Branch (73:9): [True: 14.3M, False: 231k]
  ------------------
   74|  14.3M|    {
   75|  14.3M|        memcpy(buf, source, count * sizeof(pb_byte_t));
   76|  14.3M|    }
   77|       |    
   78|       |    return true;
   79|  14.5M|}
pb_decode.c:pb_readbyte:
  125|  16.7M|{
  126|  16.7M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (126:9): [True: 249, False: 16.7M]
  ------------------
  127|    249|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  930|    249|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|    249|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 249]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  128|       |
  129|  16.7M|#ifndef PB_BUFFER_ONLY
  130|  16.7M|    if (!stream->callback(stream, buf, 1))
  ------------------
  |  Branch (130:9): [True: 1.31k, False: 16.7M]
  ------------------
  131|  1.31k|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  930|  1.31k|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|  1.31k|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 1.31k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  132|       |#else
  133|       |    *buf = *(const pb_byte_t*)stream->state;
  134|       |    stream->state = (pb_byte_t*)stream->state + 1;
  135|       |#endif
  136|       |
  137|  16.7M|    stream->bytes_left--;
  138|       |    
  139|       |    return true;    
  140|  16.7M|}
pb_decode.c:pb_skip_varint:
  257|   600k|{
  258|   600k|    pb_byte_t byte;
  259|   600k|    do
  260|   800k|    {
  261|   800k|        if (!pb_read(stream, &byte, 1))
  ------------------
  |  Branch (261:13): [True: 48, False: 800k]
  ------------------
  262|     48|            return false;
  263|   800k|    } while (byte & 0x80);
  ------------------
  |  Branch (263:14): [True: 199k, False: 600k]
  ------------------
  264|   600k|    return true;
  265|   600k|}
pb_decode.c:pb_skip_string:
  268|   152k|{
  269|   152k|    uint32_t length;
  270|   152k|    if (!pb_decode_varint32(stream, &length))
  ------------------
  |  Branch (270:9): [True: 56, False: 152k]
  ------------------
  271|     56|        return false;
  272|       |    
  273|   152k|    if ((size_t)length != length)
  ------------------
  |  Branch (273:9): [True: 0, False: 152k]
  ------------------
  274|      0|    {
  275|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  276|      0|    }
  277|       |
  278|   152k|    return pb_read(stream, NULL, (size_t)length);
  279|   152k|}
pb_decode.c:pb_decode_inner:
 1051|   271k|{
 1052|       |    /* If the message contains extension fields, the extension handlers
 1053|       |     * are called when tag number is >= extension_range_start. This precheck
 1054|       |     * is just for speed, and the handlers will check for precise match.
 1055|       |     */
 1056|   271k|    uint32_t extension_range_start = 0;
 1057|   271k|    pb_extension_t *extensions = NULL;
 1058|       |
 1059|       |    /* 'fixed_count_field' and 'fixed_count_size' track position of a repeated fixed
 1060|       |     * count field. This can only handle _one_ repeated fixed count field that
 1061|       |     * is unpacked and unordered among other (non repeated fixed count) fields.
 1062|       |     */
 1063|   271k|    pb_size_t fixed_count_field = PB_SIZE_MAX;
  ------------------
  |  |  342|   271k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
 1064|   271k|    pb_size_t fixed_count_size = 0;
 1065|   271k|    pb_size_t fixed_count_total_size = 0;
 1066|       |
 1067|       |    /* Tag and wire type of next field from the input stream */
 1068|   271k|    uint32_t tag;
 1069|   271k|    pb_wire_type_t wire_type;
 1070|   271k|    bool eof;
 1071|       |
 1072|       |    /* Track presence of required fields */
 1073|   271k|    pb_fields_seen_t fields_seen = {{0, 0}};
 1074|   271k|    const uint32_t allbits = ~(uint32_t)0;
 1075|       |
 1076|       |    /* Descriptor for the structure field matching the tag decoded from stream */
 1077|   271k|    pb_field_iter_t iter;
 1078|       |
 1079|   271k|    if (pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1079:9): [True: 144k, False: 127k]
  ------------------
 1080|   144k|    {
 1081|   144k|        if ((flags & PB_DECODE_NOINIT) == 0)
  ------------------
  |  |  122|   144k|#define PB_DECODE_NOINIT          0x01U
  ------------------
  |  Branch (1081:13): [True: 12.3k, False: 132k]
  ------------------
 1082|  12.3k|        {
 1083|  12.3k|            if (!pb_message_set_to_defaults(&iter))
  ------------------
  |  Branch (1083:17): [True: 0, False: 12.3k]
  ------------------
 1084|      0|                PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1085|  12.3k|        }
 1086|   144k|    }
 1087|       |
 1088|  7.45M|    while (pb_decode_tag(stream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1088:12): [True: 7.18M, False: 270k]
  ------------------
 1089|  7.18M|    {
 1090|  7.18M|        if (tag == 0)
  ------------------
  |  Branch (1090:13): [True: 59, False: 7.18M]
  ------------------
 1091|     59|        {
 1092|     59|          if (flags & PB_DECODE_NULLTERMINATED)
  ------------------
  |  |  124|     59|#define PB_DECODE_NULLTERMINATED  0x04U
  ------------------
  |  Branch (1092:15): [True: 0, False: 59]
  ------------------
 1093|      0|          {
 1094|      0|            eof = true;
 1095|      0|            break;
 1096|      0|          }
 1097|     59|          else
 1098|     59|          {
 1099|     59|            PB_RETURN_ERROR(stream, "zero tag");
  ------------------
  |  |  930|     59|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     59|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 59]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1100|     59|          }
 1101|     59|        }
 1102|       |
 1103|  7.18M|        if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  6.23M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  6.23M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  6.23M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1103:13): [True: 950k, False: 6.23M]
  |  Branch (1103:48): [True: 403, False: 6.22M]
  ------------------
 1104|   950k|        {
 1105|       |            /* No match found, check if it matches an extension. */
 1106|   950k|            if (extension_range_start == 0)
  ------------------
  |  Branch (1106:17): [True: 27.8k, False: 922k]
  ------------------
 1107|  27.8k|            {
 1108|  27.8k|                if (pb_field_iter_find_extension(&iter))
  ------------------
  |  Branch (1108:21): [True: 3.48k, False: 24.3k]
  ------------------
 1109|  3.48k|                {
 1110|  3.48k|                    extensions = *(pb_extension_t* const *)iter.pData;
 1111|  3.48k|                    extension_range_start = iter.tag;
 1112|  3.48k|                }
 1113|       |
 1114|  27.8k|                if (!extensions)
  ------------------
  |  Branch (1114:21): [True: 25.1k, False: 2.62k]
  ------------------
 1115|  25.1k|                {
 1116|  25.1k|                    extension_range_start = (uint32_t)-1;
 1117|  25.1k|                }
 1118|  27.8k|            }
 1119|       |
 1120|   950k|            if (tag >= extension_range_start)
  ------------------
  |  Branch (1120:17): [True: 132k, False: 818k]
  ------------------
 1121|   132k|            {
 1122|   132k|                size_t pos = stream->bytes_left;
 1123|       |
 1124|   132k|                if (!decode_extension(stream, tag, wire_type, extensions))
  ------------------
  |  Branch (1124:21): [True: 43, False: 132k]
  ------------------
 1125|     43|                    return false;
 1126|       |
 1127|   132k|                if (pos != stream->bytes_left)
  ------------------
  |  Branch (1127:21): [True: 5.53k, False: 126k]
  ------------------
 1128|  5.53k|                {
 1129|       |                    /* The field was handled */
 1130|  5.53k|                    continue;
 1131|  5.53k|                }
 1132|   132k|            }
 1133|       |
 1134|       |            /* No match found, skip data */
 1135|   945k|            if (!pb_skip_field(stream, wire_type))
  ------------------
  |  Branch (1135:17): [True: 322, False: 944k]
  ------------------
 1136|    322|                return false;
 1137|   944k|            continue;
 1138|   945k|        }
 1139|       |
 1140|       |        /* If a repeated fixed count field was found, get size from
 1141|       |         * 'fixed_count_field' as there is no counter contained in the struct.
 1142|       |         */
 1143|  6.22M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  327|  6.22M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  6.22M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  314|  12.4M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1143:13): [True: 36.3k, False: 6.19M]
  |  Branch (1143:57): [True: 3.53k, False: 32.7k]
  ------------------
 1144|  3.53k|        {
 1145|  3.53k|            if (fixed_count_field != iter.index) {
  ------------------
  |  Branch (1145:17): [True: 3.25k, False: 278]
  ------------------
 1146|       |                /* If the new fixed count field does not match the previous one,
 1147|       |                 * check that the previous one is NULL or that it finished
 1148|       |                 * receiving all the expected data.
 1149|       |                 */
 1150|  3.25k|                if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  342|  6.51k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1150:21): [True: 1.65k, False: 1.59k]
  ------------------
 1151|  1.65k|                    fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1151:21): [True: 4, False: 1.65k]
  ------------------
 1152|      4|                {
 1153|      4|                    PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  930|      4|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      4|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1154|      4|                }
 1155|       |
 1156|  3.25k|                fixed_count_field = iter.index;
 1157|  3.25k|                fixed_count_size = 0;
 1158|  3.25k|                fixed_count_total_size = iter.array_size;
 1159|  3.25k|            }
 1160|       |
 1161|  3.53k|            iter.pSize = &fixed_count_size;
 1162|  3.53k|        }
 1163|       |
 1164|  6.22M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  327|  6.22M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  6.22M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  311|  12.4M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (1164:13): [True: 5.71M, False: 514k]
  ------------------
 1165|  5.71M|            && iter.required_field_index < PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  233|  5.71M|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1165:16): [True: 5.71M, False: 0]
  ------------------
 1166|  5.71M|        {
 1167|  5.71M|            uint32_t tmp = ((uint32_t)1 << (iter.required_field_index & 31));
 1168|  5.71M|            fields_seen.bitfield[iter.required_field_index >> 5] |= tmp;
 1169|  5.71M|        }
 1170|       |
 1171|  6.22M|        if (!decode_field(stream, wire_type, &iter))
  ------------------
  |  Branch (1171:13): [True: 1.26k, False: 6.22M]
  ------------------
 1172|  1.26k|            return false;
 1173|  6.22M|    }
 1174|       |
 1175|   270k|    if (!eof)
  ------------------
  |  Branch (1175:9): [True: 95, False: 270k]
  ------------------
 1176|     95|    {
 1177|       |        /* pb_decode_tag() returned error before end of stream */
 1178|     95|        return false;
 1179|     95|    }
 1180|       |
 1181|       |    /* Check that all elements of the last decoded fixed count field were present. */
 1182|   270k|    if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  342|   540k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1182:9): [True: 1.54k, False: 268k]
  ------------------
 1183|  1.54k|        fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1183:9): [True: 11, False: 1.53k]
  ------------------
 1184|     11|    {
 1185|     11|        PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  930|     11|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     11|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1186|     11|    }
 1187|       |
 1188|       |    /* Check that all required fields were present. */
 1189|   270k|    {
 1190|   270k|        pb_size_t req_field_count = iter.descriptor->required_field_count;
 1191|       |
 1192|   270k|        if (req_field_count > 0)
  ------------------
  |  Branch (1192:13): [True: 136k, False: 133k]
  ------------------
 1193|   136k|        {
 1194|   136k|            pb_size_t i;
 1195|       |
 1196|   136k|            if (req_field_count > PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  233|   136k|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1196:17): [True: 0, False: 136k]
  ------------------
 1197|      0|                req_field_count = PB_MAX_REQUIRED_FIELDS;
  ------------------
  |  |  233|      0|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
 1198|       |
 1199|       |            /* Check the whole words */
 1200|   136k|            for (i = 0; i < (req_field_count >> 5); i++)
  ------------------
  |  Branch (1200:25): [True: 0, False: 136k]
  ------------------
 1201|      0|            {
 1202|      0|                if (fields_seen.bitfield[i] != allbits)
  ------------------
  |  Branch (1202:21): [True: 0, False: 0]
  ------------------
 1203|      0|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1204|      0|            }
 1205|       |
 1206|       |            /* Check the remaining bits (if any) */
 1207|   136k|            if ((req_field_count & 31) != 0)
  ------------------
  |  Branch (1207:17): [True: 136k, False: 0]
  ------------------
 1208|   136k|            {
 1209|   136k|                if (fields_seen.bitfield[req_field_count >> 5] !=
  ------------------
  |  Branch (1209:21): [True: 330, False: 136k]
  ------------------
 1210|   136k|                    (allbits >> (uint_least8_t)(32 - (req_field_count & 31))))
 1211|    330|                {
 1212|    330|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  930|    330|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|    330|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 330]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1213|    330|                }
 1214|   136k|            }
 1215|   136k|        }
 1216|   270k|    }
 1217|       |
 1218|   269k|    return true;
 1219|   270k|}
pb_decode.c:pb_message_set_to_defaults:
 1012|   103k|{
 1013|   103k|    pb_istream_t defstream = PB_ISTREAM_EMPTY;
  ------------------
  |  |   71|   103k|#  define PB_ISTREAM_EMPTY {0,0,0,0}
  ------------------
 1014|   103k|    uint32_t tag = 0;
 1015|   103k|    pb_wire_type_t wire_type = PB_WT_VARINT;
 1016|   103k|    bool eof;
 1017|       |
 1018|   103k|    if (iter->descriptor->default_value)
  ------------------
  |  Branch (1018:9): [True: 97.6k, False: 5.78k]
  ------------------
 1019|  97.6k|    {
 1020|  97.6k|        defstream = pb_istream_from_buffer(iter->descriptor->default_value, (size_t)-1);
 1021|  97.6k|        if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1021:13): [True: 0, False: 97.6k]
  ------------------
 1022|      0|            return false;
 1023|  97.6k|    }
 1024|       |
 1025|   103k|    do
 1026|   946k|    {
 1027|   946k|        if (!pb_field_set_to_default(iter))
  ------------------
  |  Branch (1027:13): [True: 0, False: 946k]
  ------------------
 1028|      0|            return false;
 1029|       |
 1030|   946k|        if (tag != 0 && iter->tag == tag)
  ------------------
  |  Branch (1030:13): [True: 848k, False: 98.3k]
  |  Branch (1030:25): [True: 464k, False: 383k]
  ------------------
 1031|   464k|        {
 1032|       |            /* We have a default value for this field in the defstream */
 1033|   464k|            if (!decode_field(&defstream, wire_type, iter))
  ------------------
  |  Branch (1033:17): [True: 0, False: 464k]
  ------------------
 1034|      0|                return false;
 1035|   464k|            if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1035:17): [True: 0, False: 464k]
  ------------------
 1036|      0|                return false;
 1037|       |
 1038|   464k|            if (iter->pSize)
  ------------------
  |  Branch (1038:17): [True: 228k, False: 236k]
  ------------------
 1039|   228k|                *(bool*)iter->pSize = false;
 1040|   464k|        }
 1041|   946k|    } while (pb_field_iter_next(iter));
  ------------------
  |  Branch (1041:14): [True: 843k, False: 103k]
  ------------------
 1042|       |
 1043|   103k|    return true;
 1044|   103k|}
pb_decode.c:pb_field_set_to_default:
  928|   946k|{
  929|   946k|    pb_type_t type;
  930|   946k|    type = field->type;
  931|       |
  932|   946k|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|   946k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   946k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|   946k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (932:9): [True: 8.41k, False: 938k]
  ------------------
  933|  8.41k|    {
  934|  8.41k|        pb_extension_t *ext = *(pb_extension_t* const *)field->pData;
  935|  14.2k|        while (ext != NULL)
  ------------------
  |  Branch (935:16): [True: 5.78k, False: 8.41k]
  ------------------
  936|  5.78k|        {
  937|  5.78k|            pb_field_iter_t ext_iter;
  938|  5.78k|            if (ext->type->decode != NULL)
  ------------------
  |  Branch (938:17): [True: 0, False: 5.78k]
  ------------------
  939|      0|                ext->found = false; /* Custom type: arg is not a message descriptor */
  940|  5.78k|            else if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (940:22): [True: 5.78k, False: 0]
  ------------------
  941|  5.78k|            {
  942|  5.78k|                ext->found = false;
  943|  5.78k|                if (!pb_message_set_to_defaults(&ext_iter))
  ------------------
  |  Branch (943:21): [True: 0, False: 5.78k]
  ------------------
  944|      0|                    return false;
  945|  5.78k|            }
  946|  5.78k|            ext = ext->next;
  947|  5.78k|        }
  948|  8.41k|    }
  949|   938k|    else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  326|   938k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   938k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  321|   938k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (949:14): [True: 867k, False: 70.2k]
  ------------------
  950|   867k|    {
  951|   867k|        bool init_data = true;
  952|   867k|        if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  327|   867k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   867k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  312|  1.73M|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (952:13): [True: 245k, False: 622k]
  |  Branch (952:52): [True: 245k, False: 0]
  ------------------
  953|   245k|        {
  954|       |            /* Set has_field to false. Still initialize the optional field
  955|       |             * itself also. */
  956|   245k|            *(bool*)field->pSize = false;
  957|   245k|        }
  958|   622k|        else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  327|   622k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   622k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  314|  1.24M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (958:18): [True: 149k, False: 473k]
  ------------------
  959|   473k|                 PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|   473k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   473k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                               PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|   473k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (959:18): [True: 42.0k, False: 431k]
  ------------------
  960|   191k|        {
  961|       |            /* REPEATED: Set array count to 0, no need to initialize contents.
  962|       |               ONEOF: Set which_field to 0. */
  963|   191k|            *(pb_size_t*)field->pSize = 0;
  964|   191k|            init_data = false;
  965|   191k|        }
  966|       |
  967|   867k|        if (init_data)
  ------------------
  |  Branch (967:13): [True: 676k, False: 191k]
  ------------------
  968|   676k|        {
  969|   676k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  329|  1.35M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|   676k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|   676k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  1.35M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 64.6k, False: 611k]
  |  |  ------------------
  |  |  330|  1.35M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|   611k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|   611k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|   611k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 611k]
  |  |  ------------------
  ------------------
  970|  64.6k|                (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (970:18): [True: 25.2k, False: 39.4k]
  ------------------
  971|  39.4k|                 field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (971:18): [True: 0, False: 39.4k]
  ------------------
  972|  39.4k|                 field->submsg_desc->submsg_info[0] != NULL))
  ------------------
  |  Branch (972:18): [True: 0, False: 39.4k]
  ------------------
  973|  25.2k|            {
  974|       |                /* Initialize submessage to defaults.
  975|       |                 * Only needed if it has default values
  976|       |                 * or callback/submessage fields. */
  977|  25.2k|                pb_field_iter_t submsg_iter;
  978|  25.2k|                if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (978:21): [True: 25.2k, False: 0]
  ------------------
  979|  25.2k|                {
  980|  25.2k|                    if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (980:25): [True: 0, False: 25.2k]
  ------------------
  981|      0|                        return false;
  982|  25.2k|                }
  983|  25.2k|            }
  984|   651k|            else
  985|   651k|            {
  986|       |                /* Initialize to zeros */
  987|   651k|                memset(field->pData, 0, (size_t)field->data_size);
  988|   651k|            }
  989|   676k|        }
  990|   867k|    }
  991|  70.2k|    else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  70.2k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  70.2k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  70.2k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (991:14): [True: 0, False: 70.2k]
  ------------------
  992|      0|    {
  993|       |        /* Initialize the pointer to NULL. */
  994|      0|        *(void**)field->pField = NULL;
  995|       |
  996|       |        /* Initialize array count to 0. */
  997|      0|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  327|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  314|      0|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (997:13): [True: 0, False: 0]
  ------------------
  998|      0|            PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|      0|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (998:13): [True: 0, False: 0]
  ------------------
  999|      0|        {
 1000|      0|            *(pb_size_t*)field->pSize = 0;
 1001|      0|        }
 1002|      0|    }
 1003|  70.2k|    else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  326|  70.2k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  70.2k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|  70.2k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (1003:14): [True: 70.2k, False: 0]
  ------------------
 1004|  70.2k|    {
 1005|       |        /* Don't overwrite callback */
 1006|  70.2k|    }
 1007|       |
 1008|   946k|    return true;
 1009|   946k|}
pb_decode.c:decode_extension:
  906|   132k|{
  907|   132k|    size_t pos = stream->bytes_left;
  908|       |    
  909|   264k|    while (extension != NULL && pos == stream->bytes_left)
  ------------------
  |  Branch (909:12): [True: 132k, False: 132k]
  |  Branch (909:33): [True: 132k, False: 0]
  ------------------
  910|   132k|    {
  911|   132k|        bool status;
  912|   132k|        if (extension->type->decode)
  ------------------
  |  Branch (912:13): [True: 0, False: 132k]
  ------------------
  913|      0|            status = extension->type->decode(stream, extension, tag, wire_type);
  914|   132k|        else
  915|   132k|            status = default_extension_decoder(stream, extension, tag, wire_type);
  916|       |
  917|   132k|        if (!status)
  ------------------
  |  Branch (917:13): [True: 43, False: 132k]
  ------------------
  918|     43|            return false;
  919|       |        
  920|   132k|        extension = extension->next;
  921|   132k|    }
  922|       |    
  923|   132k|    return true;
  924|   132k|}
pb_decode.c:default_extension_decoder:
  889|   132k|{
  890|   132k|    pb_field_iter_t iter;
  891|       |
  892|   132k|    if (!pb_field_iter_begin_extension(&iter, extension))
  ------------------
  |  Branch (892:9): [True: 0, False: 132k]
  ------------------
  893|      0|        PB_RETURN_ERROR(stream, "invalid extension");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  894|       |
  895|   132k|    if (iter.tag != tag || !iter.message)
  ------------------
  |  Branch (895:9): [True: 126k, False: 5.57k]
  |  Branch (895:28): [True: 0, False: 5.57k]
  ------------------
  896|   126k|        return true;
  897|       |
  898|  5.57k|    extension->found = true;
  899|  5.57k|    return decode_field(stream, wire_type, &iter);
  900|   132k|}
pb_decode.c:decode_field:
  857|  6.69M|{
  858|       |#ifdef PB_ENABLE_MALLOC
  859|       |    /* When decoding an oneof field, check if there is old data that must be
  860|       |     * released first. */
  861|       |    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  862|       |    {
  863|       |        if (!pb_release_union_field(stream, field))
  864|       |            return false;
  865|       |    }
  866|       |#endif
  867|       |
  868|  6.69M|    switch (PB_ATYPE(field->type))
  ------------------
  |  |  326|  6.69M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  6.69M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
  869|  6.69M|    {
  870|  6.62M|        case PB_ATYPE_STATIC:
  ------------------
  |  |  321|  6.62M|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (870:9): [True: 6.62M, False: 75.3k]
  ------------------
  871|  6.62M|            return decode_static_field(stream, wire_type, field);
  872|       |        
  873|      0|        case PB_ATYPE_POINTER:
  ------------------
  |  |  322|      0|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (873:9): [True: 0, False: 6.69M]
  ------------------
  874|      0|            return decode_pointer_field(stream, wire_type, field);
  875|       |        
  876|  75.3k|        case PB_ATYPE_CALLBACK:
  ------------------
  |  |  323|  75.3k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (876:9): [True: 75.3k, False: 6.62M]
  ------------------
  877|  75.3k|            return decode_callback_field(stream, wire_type, field);
  878|       |        
  879|      0|        default:
  ------------------
  |  Branch (879:9): [True: 0, False: 6.69M]
  ------------------
  880|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  881|  6.69M|    }
  882|  6.69M|}
pb_decode.c:decode_static_field:
  498|  6.62M|{
  499|  6.62M|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  327|  6.62M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  6.62M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  500|  6.62M|    {
  501|  5.91M|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  311|  5.91M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (501:9): [True: 5.91M, False: 712k]
  ------------------
  502|  5.91M|            return decode_basic_field(stream, wire_type, field);
  503|       |            
  504|   494k|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  312|   494k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (504:9): [True: 494k, False: 6.13M]
  ------------------
  505|   494k|            if (field->pSize != NULL)
  ------------------
  |  Branch (505:17): [True: 494k, False: 0]
  ------------------
  506|   494k|                *(bool*)field->pSize = true;
  507|   494k|            return decode_basic_field(stream, wire_type, field);
  508|       |    
  509|  29.2k|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  314|  29.2k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (509:9): [True: 29.2k, False: 6.59M]
  ------------------
  510|  29.2k|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (510:17): [True: 21.4k, False: 7.86k]
  ------------------
  511|  21.4k|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  328|  21.4k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  21.4k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  276|  21.4k|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (511:20): [True: 10.0k, False: 11.3k]
  ------------------
  512|  10.0k|            {
  513|       |                /* Packed array */
  514|  10.0k|                bool status = true;
  515|  10.0k|                pb_istream_t substream;
  516|  10.0k|                pb_size_t *size = (pb_size_t*)field->pSize;
  517|  10.0k|                field->pData = (char*)field->pField + field->data_size * (*size);
  518|       |
  519|  10.0k|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (519:21): [True: 64, False: 9.96k]
  ------------------
  520|     64|                    return false;
  521|       |
  522|  44.1k|                while (substream.bytes_left > 0 && *size < field->array_size)
  ------------------
  |  Branch (522:24): [True: 34.2k, False: 9.91k]
  |  Branch (522:52): [True: 34.1k, False: 27]
  ------------------
  523|  34.1k|                {
  524|  34.1k|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (524:25): [True: 25, False: 34.1k]
  ------------------
  525|     25|                    {
  526|     25|                        status = false;
  527|     25|                        break;
  528|     25|                    }
  529|  34.1k|                    (*size)++;
  530|  34.1k|                    field->pData = (char*)field->pData + field->data_size;
  531|  34.1k|                }
  532|       |
  533|  9.96k|                if (substream.bytes_left != 0)
  ------------------
  |  Branch (533:21): [True: 47, False: 9.92k]
  ------------------
  534|     47|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  930|     47|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     47|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  535|  9.92k|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (535:21): [True: 0, False: 9.92k]
  ------------------
  536|      0|                    return false;
  537|       |
  538|  9.92k|                return status;
  539|  9.92k|            }
  540|  19.2k|            else
  541|  19.2k|            {
  542|       |                /* Repeated field */
  543|  19.2k|                pb_size_t *size = (pb_size_t*)field->pSize;
  544|  19.2k|                field->pData = (char*)field->pField + field->data_size * (*size);
  545|       |
  546|  19.2k|                if ((*size)++ >= field->array_size)
  ------------------
  |  Branch (546:21): [True: 3, False: 19.2k]
  ------------------
  547|      3|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  930|      3|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      3|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  548|       |
  549|  19.2k|                return decode_basic_field(stream, wire_type, field);
  550|  19.2k|            }
  551|       |
  552|   189k|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  316|   189k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (552:9): [True: 189k, False: 6.43M]
  ------------------
  553|   189k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  329|   378k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|   189k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|   189k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|   378k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 145k, False: 44.0k]
  |  |  ------------------
  |  |  330|   378k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  44.0k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  44.0k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  44.0k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 43.7k, False: 316]
  |  |  ------------------
  ------------------
  554|   188k|                *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (554:17): [True: 107k, False: 81.6k]
  ------------------
  555|   107k|            {
  556|       |                /* We memset to zero so that any callbacks are set to NULL.
  557|       |                 * This is because the callbacks might otherwise have values
  558|       |                 * from some other union field.
  559|       |                 * If callbacks are needed inside oneof field, use .proto
  560|       |                 * option submsg_callback to have a separate callback function
  561|       |                 * that can set the fields before submessage is decoded.
  562|       |                 * pb_dec_submessage() will set any default values. */
  563|   107k|                memset(field->pData, 0, (size_t)field->data_size);
  564|       |
  565|       |                /* Set default values for the submessage fields. */
  566|   107k|                if (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (566:21): [True: 60.0k, False: 47.1k]
  ------------------
  567|  47.1k|                    field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (567:21): [True: 0, False: 47.1k]
  ------------------
  568|  47.1k|                    field->submsg_desc->submsg_info[0] != NULL)
  ------------------
  |  Branch (568:21): [True: 0, False: 47.1k]
  ------------------
  569|  60.0k|                {
  570|  60.0k|                    pb_field_iter_t submsg_iter;
  571|  60.0k|                    if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (571:25): [True: 60.0k, False: 0]
  ------------------
  572|  60.0k|                    {
  573|  60.0k|                        if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (573:29): [True: 0, False: 60.0k]
  ------------------
  574|      0|                            PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  575|  60.0k|                    }
  576|  60.0k|                }
  577|   107k|            }
  578|   189k|            *(pb_size_t*)field->pSize = field->tag;
  579|       |
  580|   189k|            return decode_basic_field(stream, wire_type, field);
  581|       |
  582|      0|        default:
  ------------------
  |  Branch (582:9): [True: 0, False: 6.62M]
  ------------------
  583|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  584|  6.62M|    }
  585|  6.62M|}
pb_decode.c:decode_basic_field:
  427|  6.64M|{
  428|  6.64M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  328|  6.64M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  6.64M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  429|  6.64M|    {
  430|   309k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  268|   309k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (430:9): [True: 309k, False: 6.33M]
  ------------------
  431|   309k|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (431:17): [True: 1.57k, False: 307k]
  |  Branch (431:46): [True: 7, False: 1.56k]
  ------------------
  432|      7|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|      7|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      7|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  433|       |
  434|   309k|            return pb_dec_bool(stream, field);
  435|       |
  436|  4.72M|        case PB_LTYPE_VARINT:
  ------------------
  |  |  269|  4.72M|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (436:9): [True: 4.72M, False: 1.92M]
  ------------------
  437|  5.07M|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  270|  5.07M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (437:9): [True: 349k, False: 6.29M]
  ------------------
  438|  5.24M|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  271|  5.24M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (438:9): [True: 166k, False: 6.48M]
  ------------------
  439|  5.24M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (439:17): [True: 22.8k, False: 5.22M]
  |  Branch (439:46): [True: 44, False: 22.7k]
  ------------------
  440|     44|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     44|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     44|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 44]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  441|       |
  442|  5.24M|            return pb_dec_varint(stream, field);
  443|       |
  444|   283k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  272|   283k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (444:9): [True: 283k, False: 6.36M]
  ------------------
  445|   283k|            if (wire_type != PB_WT_32BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (445:17): [True: 5.58k, False: 277k]
  |  Branch (445:45): [True: 21, False: 5.56k]
  ------------------
  446|     21|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     21|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     21|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 21]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  447|       |
  448|   283k|            return pb_decode_fixed32(stream, field->pData);
  449|       |
  450|   247k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  273|   247k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (450:9): [True: 247k, False: 6.40M]
  ------------------
  451|   247k|            if (wire_type != PB_WT_64BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (451:17): [True: 4.30k, False: 243k]
  |  Branch (451:45): [True: 10, False: 4.29k]
  ------------------
  452|     10|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     10|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     10|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  453|       |
  454|       |#ifdef PB_CONVERT_DOUBLE_FLOAT
  455|       |            if (field->data_size == sizeof(float))
  456|       |            {
  457|       |                return pb_decode_double_as_float(stream, (float*)field->pData);
  458|       |            }
  459|       |#endif
  460|       |
  461|       |#ifdef PB_WITHOUT_64BIT
  462|       |            PB_RETURN_ERROR(stream, "invalid data_size");
  463|       |#else
  464|   247k|            return pb_decode_fixed64(stream, field->pData);
  465|      0|#endif
  466|       |
  467|  47.5k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  280|  47.5k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (467:9): [True: 47.5k, False: 6.60M]
  ------------------
  468|  47.5k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (468:17): [True: 11, False: 47.5k]
  ------------------
  469|     11|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     11|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     11|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  470|       |
  471|  47.5k|            return pb_dec_bytes(stream, field);
  472|       |
  473|   202k|        case PB_LTYPE_STRING:
  ------------------
  |  |  284|   202k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (473:9): [True: 202k, False: 6.44M]
  ------------------
  474|   202k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (474:17): [True: 17, False: 202k]
  ------------------
  475|     17|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     17|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     17|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  476|       |
  477|   202k|            return pb_dec_string(stream, field);
  478|       |
  479|   245k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  288|   245k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (479:9): [True: 245k, False: 6.40M]
  ------------------
  480|   288k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  293|   288k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (480:9): [True: 43.7k, False: 6.60M]
  ------------------
  481|   288k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (481:17): [True: 18, False: 288k]
  ------------------
  482|     18|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     18|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     18|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  483|       |
  484|   288k|            return pb_dec_submessage(stream, field);
  485|       |
  486|  26.0k|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  303|  26.0k|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (486:9): [True: 26.0k, False: 6.62M]
  ------------------
  487|  26.0k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (487:17): [True: 2, False: 26.0k]
  ------------------
  488|      2|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|      2|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      2|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  489|       |
  490|  26.0k|            return pb_dec_fixed_length_bytes(stream, field);
  491|       |
  492|      0|        default:
  ------------------
  |  Branch (492:9): [True: 0, False: 6.64M]
  ------------------
  493|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  494|  6.64M|    }
  495|  6.64M|}
pb_decode.c:pb_dec_bool:
 1480|   309k|{
 1481|   309k|    return pb_decode_bool(stream, (bool*)field->pData);
 1482|   309k|}
pb_decode.c:pb_dec_varint:
 1485|  5.24M|{
 1486|  5.24M|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  328|  5.24M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  5.24M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  270|  5.24M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (1486:9): [True: 349k, False: 4.89M]
  ------------------
 1487|   349k|    {
 1488|   349k|        pb_uint64_t value, clamped;
  ------------------
  |  |   57|   349k|#define pb_uint64_t uint64_t
  ------------------
 1489|   349k|        if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1489:13): [True: 22, False: 349k]
  ------------------
 1490|     22|            return false;
 1491|       |
 1492|       |        /* Cast to the proper field size, while checking for overflows */
 1493|   349k|        if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (1493:13): [True: 157k, False: 191k]
  ------------------
 1494|   157k|            clamped = *(pb_uint64_t*)field->pData = value;
 1495|   191k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (1495:18): [True: 168k, False: 23.0k]
  ------------------
 1496|   168k|            clamped = *(uint32_t*)field->pData = (uint32_t)value;
 1497|  23.0k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (1497:18): [True: 11.4k, False: 11.5k]
  ------------------
 1498|  11.4k|            clamped = *(uint_least16_t*)field->pData = (uint_least16_t)value;
 1499|  11.5k|        else if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (1499:18): [True: 11.5k, False: 0]
  ------------------
 1500|  11.5k|            clamped = *(uint_least8_t*)field->pData = (uint_least8_t)value;
 1501|      0|        else
 1502|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1503|       |
 1504|   349k|        if (clamped != value)
  ------------------
  |  Branch (1504:13): [True: 117, False: 348k]
  ------------------
 1505|    117|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  930|    117|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|    117|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 117]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1506|       |
 1507|   348k|        return true;
 1508|   349k|    }
 1509|  4.89M|    else
 1510|  4.89M|    {
 1511|  4.89M|        pb_uint64_t value;
  ------------------
  |  |   57|  4.89M|#define pb_uint64_t uint64_t
  ------------------
 1512|  4.89M|        pb_int64_t svalue;
  ------------------
  |  |   56|  4.89M|#define pb_int64_t int64_t
  ------------------
 1513|  4.89M|        pb_int64_t clamped;
  ------------------
  |  |   56|  4.89M|#define pb_int64_t int64_t
  ------------------
 1514|       |
 1515|  4.89M|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  328|  4.89M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  4.89M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  271|  4.89M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (1515:13): [True: 166k, False: 4.72M]
  ------------------
 1516|   166k|        {
 1517|   166k|            if (!pb_decode_svarint(stream, &svalue))
  ------------------
  |  Branch (1517:17): [True: 27, False: 166k]
  ------------------
 1518|     27|                return false;
 1519|   166k|        }
 1520|  4.72M|        else
 1521|  4.72M|        {
 1522|  4.72M|            if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1522:17): [True: 34, False: 4.72M]
  ------------------
 1523|     34|                return false;
 1524|       |
 1525|       |            /* See issue 97: Google's C++ protobuf allows negative varint values to
 1526|       |            * be cast as int32_t, instead of the int64_t that should be used when
 1527|       |            * encoding. Nanopb versions before 0.2.5 had a bug in encoding. In order to
 1528|       |            * not break decoding of such messages, we cast <=32 bit fields to
 1529|       |            * int32_t first to get the sign correct.
 1530|       |            */
 1531|  4.72M|            if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1531:17): [True: 151k, False: 4.57M]
  ------------------
 1532|   151k|                svalue = (pb_int64_t)value;
 1533|  4.57M|            else
 1534|  4.57M|                svalue = (int32_t)value;
 1535|  4.72M|        }
 1536|       |
 1537|       |        /* Cast to the proper field size, while checking for overflows */
 1538|  4.89M|        if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1538:13): [True: 226k, False: 4.66M]
  ------------------
 1539|   226k|            clamped = *(pb_int64_t*)field->pData = svalue;
 1540|  4.66M|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (1540:18): [True: 4.62M, False: 45.5k]
  ------------------
 1541|  4.62M|            clamped = *(int32_t*)field->pData = (int32_t)svalue;
 1542|  45.5k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (1542:18): [True: 22.7k, False: 22.8k]
  ------------------
 1543|  22.7k|            clamped = *(int_least16_t*)field->pData = (int_least16_t)svalue;
 1544|  22.8k|        else if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (1544:18): [True: 22.8k, False: 0]
  ------------------
 1545|  22.8k|            clamped = *(int_least8_t*)field->pData = (int_least8_t)svalue;
 1546|      0|        else
 1547|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1548|       |
 1549|  4.89M|        if (clamped != svalue)
  ------------------
  |  Branch (1549:13): [True: 86, False: 4.89M]
  ------------------
 1550|     86|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  930|     86|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     86|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 86]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1551|       |
 1552|  4.89M|        return true;
 1553|  4.89M|    }
 1554|  5.24M|}
pb_decode.c:pb_dec_bytes:
 1557|  47.5k|{
 1558|  47.5k|    uint32_t size;
 1559|  47.5k|    size_t alloc_size;
 1560|  47.5k|    pb_bytes_array_t *dest;
 1561|       |    
 1562|  47.5k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1562:9): [True: 1, False: 47.5k]
  ------------------
 1563|      1|        return false;
 1564|       |    
 1565|  47.5k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  342|  47.5k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1565:9): [True: 31, False: 47.5k]
  ------------------
 1566|     31|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  930|     31|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     31|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 31]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1567|       |    
 1568|  47.5k|    alloc_size = PB_BYTES_ARRAY_T_ALLOCSIZE(size);
  ------------------
  |  |  411|  47.5k|    (((size_t)(n) + offsetof(pb_bytes_array_t, bytes)) < sizeof(pb_bytes_array_t) \
  |  |  ------------------
  |  |  |  Branch (411:6): [True: 21.6k, False: 25.9k]
  |  |  ------------------
  |  |  412|  47.5k|        ? sizeof(pb_bytes_array_t) \
  |  |  413|  47.5k|        : ((size_t)(n) + offsetof(pb_bytes_array_t, bytes)))
  ------------------
 1569|  47.5k|    if (size > alloc_size)
  ------------------
  |  Branch (1569:9): [True: 0, False: 47.5k]
  ------------------
 1570|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1571|       |    
 1572|  47.5k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  47.5k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  47.5k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  47.5k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1572:9): [True: 0, False: 47.5k]
  ------------------
 1573|      0|    {
 1574|      0|#ifndef PB_ENABLE_MALLOC
 1575|      0|        PB_RETURN_ERROR(stream, "no malloc support");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1576|       |#else
 1577|       |        if (stream->bytes_left < size)
 1578|       |            PB_RETURN_ERROR(stream, "end-of-stream");
 1579|       |
 1580|       |        if (!allocate_field(stream, field->pData, alloc_size, 1))
 1581|       |            return false;
 1582|       |        dest = *(pb_bytes_array_t**)field->pData;
 1583|       |#endif
 1584|      0|    }
 1585|  47.5k|    else
 1586|  47.5k|    {
 1587|  47.5k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1587:13): [True: 58, False: 47.4k]
  ------------------
 1588|     58|            PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  930|     58|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     58|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1589|  47.4k|        dest = (pb_bytes_array_t*)field->pData;
 1590|  47.4k|    }
 1591|       |
 1592|  47.4k|    dest->size = (pb_size_t)size;
 1593|  47.4k|    return pb_read(stream, dest->bytes, (size_t)size);
 1594|  47.5k|}
pb_decode.c:pb_dec_string:
 1597|   202k|{
 1598|   202k|    uint32_t size;
 1599|   202k|    size_t alloc_size;
 1600|   202k|    pb_byte_t *dest = (pb_byte_t*)field->pData;
 1601|       |
 1602|   202k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1602:9): [True: 5, False: 202k]
  ------------------
 1603|      5|        return false;
 1604|       |
 1605|   202k|    if (size == (uint32_t)-1)
  ------------------
  |  Branch (1605:9): [True: 3, False: 202k]
  ------------------
 1606|      3|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  930|      3|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      3|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1607|       |
 1608|       |    /* Space for null terminator */
 1609|   202k|    alloc_size = (size_t)(size + 1);
 1610|       |
 1611|   202k|    if (alloc_size < size)
  ------------------
  |  Branch (1611:9): [True: 0, False: 202k]
  ------------------
 1612|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1613|       |
 1614|   202k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   202k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   202k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   202k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1614:9): [True: 0, False: 202k]
  ------------------
 1615|      0|    {
 1616|      0|#ifndef PB_ENABLE_MALLOC
 1617|      0|        PB_RETURN_ERROR(stream, "no malloc support");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1618|       |#else
 1619|       |        if (stream->bytes_left < size)
 1620|       |            PB_RETURN_ERROR(stream, "end-of-stream");
 1621|       |
 1622|       |        if (!allocate_field(stream, field->pData, alloc_size, 1))
 1623|       |            return false;
 1624|       |        dest = *(pb_byte_t**)field->pData;
 1625|       |#endif
 1626|      0|    }
 1627|   202k|    else
 1628|   202k|    {
 1629|   202k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1629:13): [True: 89, False: 202k]
  ------------------
 1630|     89|            PB_RETURN_ERROR(stream, "string overflow");
  ------------------
  |  |  930|     89|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     89|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 89]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1631|   202k|    }
 1632|       |    
 1633|   202k|    dest[size] = 0;
 1634|       |
 1635|   202k|    if (!pb_read(stream, dest, (size_t)size))
  ------------------
  |  Branch (1635:9): [True: 8, False: 202k]
  ------------------
 1636|      8|        return false;
 1637|       |
 1638|       |#ifdef PB_VALIDATE_UTF8
 1639|       |    if (!pb_validate_utf8((const char*)dest))
 1640|       |        PB_RETURN_ERROR(stream, "invalid utf8");
 1641|       |#endif
 1642|       |
 1643|   202k|    return true;
 1644|   202k|}
pb_decode.c:pb_dec_submessage:
 1647|   288k|{
 1648|   288k|    bool status = true;
 1649|   288k|    bool submsg_consumed = false;
 1650|   288k|    pb_istream_t substream;
 1651|       |
 1652|   288k|    if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1652:9): [True: 93, False: 288k]
  ------------------
 1653|     93|        return false;
 1654|       |    
 1655|   288k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (1655:9): [True: 0, False: 288k]
  ------------------
 1656|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1657|       |    
 1658|       |    /* Submessages can have a separate message-level callback that is called
 1659|       |     * before decoding the message. Typically it is used to set callback fields
 1660|       |     * inside oneofs. */
 1661|   288k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  328|   288k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   288k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  293|   577k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (1661:9): [True: 43.7k, False: 245k]
  |  Branch (1661:58): [True: 43.7k, False: 0]
  ------------------
 1662|  43.7k|    {
 1663|       |        /* Message callback is stored right before pSize. */
 1664|  43.7k|        pb_callback_t *callback = (pb_callback_t*)field->pSize - 1;
 1665|  43.7k|        if (callback->funcs.decode)
  ------------------
  |  Branch (1665:13): [True: 43.7k, False: 0]
  ------------------
 1666|  43.7k|        {
 1667|  43.7k|            status = callback->funcs.decode(&substream, field, &callback->arg);
 1668|       |
 1669|  43.7k|            if (substream.bytes_left == 0)
  ------------------
  |  Branch (1669:17): [True: 25.4k, False: 18.2k]
  ------------------
 1670|  25.4k|            {
 1671|  25.4k|                submsg_consumed = true;
 1672|  25.4k|            }
 1673|  43.7k|        }
 1674|  43.7k|    }
 1675|       |
 1676|       |    /* Now decode the submessage contents */
 1677|   288k|    if (status && !submsg_consumed)
  ------------------
  |  Branch (1677:9): [True: 288k, False: 0]
  |  Branch (1677:19): [True: 263k, False: 25.4k]
  ------------------
 1678|   263k|    {
 1679|   263k|        unsigned int flags = 0;
 1680|       |
 1681|       |        /* Static required/optional fields are already initialized by top-level
 1682|       |         * pb_decode(), no need to initialize them again. */
 1683|   263k|        if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  326|   263k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   263k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  321|   526k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1683:13): [True: 263k, False: 0]
  ------------------
 1684|   263k|            PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  327|   263k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   263k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  314|   263k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1684:13): [True: 258k, False: 4.97k]
  ------------------
 1685|   258k|        {
 1686|   258k|            flags = PB_DECODE_NOINIT;
  ------------------
  |  |  122|   258k|#define PB_DECODE_NOINIT          0x01U
  ------------------
 1687|   258k|        }
 1688|       |
 1689|   263k|        status = pb_decode_inner(&substream, field->submsg_desc, field->pData, flags);
 1690|   263k|    }
 1691|       |    
 1692|   288k|    if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1692:9): [True: 0, False: 288k]
  ------------------
 1693|      0|        return false;
 1694|       |
 1695|   288k|    return status;
 1696|   288k|}
pb_decode.c:pb_dec_fixed_length_bytes:
 1699|  26.0k|{
 1700|  26.0k|    uint32_t size;
 1701|       |
 1702|  26.0k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1702:9): [True: 7, False: 25.9k]
  ------------------
 1703|      7|        return false;
 1704|       |
 1705|  25.9k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  342|  25.9k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1705:9): [True: 30, False: 25.9k]
  ------------------
 1706|     30|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  930|     30|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     30|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 30]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1707|       |
 1708|  25.9k|    if (size == 0)
  ------------------
  |  Branch (1708:9): [True: 14.4k, False: 11.5k]
  ------------------
 1709|  14.4k|    {
 1710|       |        /* As a special case, treat empty bytes string as all zeros for fixed_length_bytes. */
 1711|  14.4k|        memset(field->pData, 0, (size_t)field->data_size);
 1712|  14.4k|        return true;
 1713|  14.4k|    }
 1714|       |
 1715|  11.5k|    if (size != field->data_size)
  ------------------
  |  Branch (1715:9): [True: 41, False: 11.4k]
  ------------------
 1716|     41|        PB_RETURN_ERROR(stream, "incorrect fixed length bytes size");
  ------------------
  |  |  930|     41|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     41|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 41]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1717|       |
 1718|  11.4k|    return pb_read(stream, (pb_byte_t*)field->pData, (size_t)field->data_size);
 1719|  11.5k|}
pb_decode.c:decode_callback_field:
  783|  75.3k|{
  784|       |    /* Clear any data that may have been decoded for another oneof field
  785|       |     * that has come before this callback field.
  786|       |     */
  787|  75.3k|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  75.3k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  75.3k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  75.3k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (787:9): [True: 10.3k, False: 64.9k]
  ------------------
  788|  10.3k|    {
  789|  10.3k|        if (*(pb_size_t*)field->pSize != 0 && *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (789:13): [True: 9.91k, False: 480]
  |  Branch (789:47): [True: 1.81k, False: 8.10k]
  ------------------
  790|  1.81k|        {
  791|  1.81k|            memset(field->pData, 0, (size_t)field->data_size);
  792|  1.81k|        }
  793|  10.3k|        *(pb_size_t*)field->pSize = field->tag;
  794|  10.3k|    }
  795|       |
  796|  75.3k|    if (!field->descriptor->field_callback)
  ------------------
  |  Branch (796:9): [True: 0, False: 75.3k]
  ------------------
  797|      0|        return pb_skip_field(stream, wire_type);
  798|       |
  799|  75.3k|    if (wire_type == PB_WT_STRING)
  ------------------
  |  Branch (799:9): [True: 60.3k, False: 15.0k]
  ------------------
  800|  60.3k|    {
  801|  60.3k|        pb_istream_t substream;
  802|  60.3k|        size_t prev_bytes_left;
  803|       |        
  804|  60.3k|        if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (804:13): [True: 48, False: 60.2k]
  ------------------
  805|     48|            return false;
  806|       |
  807|       |        /* If the callback field is inside a submsg, first call the submsg_callback which
  808|       |         * should set the decoder for the callback field. */
  809|  60.2k|        if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  328|  60.2k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  60.2k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  293|   120k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (809:13): [True: 0, False: 60.2k]
  |  Branch (809:62): [True: 0, False: 0]
  ------------------
  810|      0|            pb_callback_t* callback;
  811|      0|            *(pb_size_t*)field->pSize = field->tag;
  812|      0|            callback = (pb_callback_t*)field->pSize - 1;
  813|       |
  814|      0|            if (callback->funcs.decode)
  ------------------
  |  Branch (814:17): [True: 0, False: 0]
  ------------------
  815|      0|            {
  816|      0|                if (!callback->funcs.decode(&substream, field, &callback->arg)) {
  ------------------
  |  Branch (816:21): [True: 0, False: 0]
  ------------------
  817|      0|                    PB_SET_ERROR(stream, substream.errmsg ? substream.errmsg : "submsg callback failed");
  ------------------
  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  ------------------
  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  Branch (926:92): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  818|      0|                    return false;
  819|      0|                }
  820|      0|            }
  821|      0|        }
  822|       |        
  823|  60.2k|        do
  824|  60.2k|        {
  825|  60.2k|            prev_bytes_left = substream.bytes_left;
  826|  60.2k|            if (!field->descriptor->field_callback(&substream, NULL, field))
  ------------------
  |  Branch (826:17): [True: 0, False: 60.2k]
  ------------------
  827|      0|            {
  828|      0|                PB_SET_ERROR(stream, substream.errmsg ? substream.errmsg : "callback failed");
  ------------------
  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  ------------------
  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  Branch (926:92): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  829|      0|                return false;
  830|      0|            }
  831|  60.2k|        } while (substream.bytes_left > 0 && substream.bytes_left < prev_bytes_left);
  ------------------
  |  Branch (831:18): [True: 24.7k, False: 35.5k]
  |  Branch (831:46): [True: 0, False: 24.7k]
  ------------------
  832|       |        
  833|  60.2k|        if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (833:13): [True: 0, False: 60.2k]
  ------------------
  834|      0|            return false;
  835|       |
  836|  60.2k|        return true;
  837|  60.2k|    }
  838|  15.0k|    else
  839|  15.0k|    {
  840|       |        /* Copy the single scalar value to stack.
  841|       |         * This is required so that we can limit the stream length,
  842|       |         * which in turn allows to use same callback for packed and
  843|       |         * not-packed fields. */
  844|  15.0k|        pb_istream_t substream;
  845|  15.0k|        pb_byte_t buffer[10];
  846|  15.0k|        size_t size = sizeof(buffer);
  847|       |        
  848|  15.0k|        if (!read_raw_value(stream, wire_type, buffer, &size))
  ------------------
  |  Branch (848:13): [True: 41, False: 15.0k]
  ------------------
  849|     41|            return false;
  850|  15.0k|        substream = pb_istream_from_buffer(buffer, size);
  851|       |        
  852|       |        return field->descriptor->field_callback(&substream, NULL, field);
  853|  15.0k|    }
  854|  75.3k|}
pb_decode.c:read_raw_value:
  342|  15.0k|{
  343|  15.0k|    size_t max_size = *size;
  344|  15.0k|    switch (wire_type)
  345|  15.0k|    {
  346|  9.68k|        case PB_WT_VARINT:
  ------------------
  |  Branch (346:9): [True: 9.68k, False: 5.36k]
  ------------------
  347|  9.68k|            *size = 0;
  348|  9.68k|            do
  349|  22.7k|            {
  350|  22.7k|                (*size)++;
  351|  22.7k|                if (*size > max_size)
  ------------------
  |  Branch (351:21): [True: 8, False: 22.7k]
  ------------------
  352|      8|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  930|      8|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      8|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  353|       |
  354|  22.7k|                if (!pb_read(stream, buf, 1))
  ------------------
  |  Branch (354:21): [True: 21, False: 22.7k]
  ------------------
  355|     21|                    return false;
  356|  22.7k|            } while (*buf++ & 0x80);
  ------------------
  |  Branch (356:22): [True: 13.1k, False: 9.65k]
  ------------------
  357|  9.65k|            return true;
  358|       |            
  359|  4.51k|        case PB_WT_64BIT:
  ------------------
  |  Branch (359:9): [True: 4.51k, False: 10.5k]
  ------------------
  360|  4.51k|            *size = 8;
  361|  4.51k|            return pb_read(stream, buf, 8);
  362|       |        
  363|    843|        case PB_WT_32BIT:
  ------------------
  |  Branch (363:9): [True: 843, False: 14.2k]
  ------------------
  364|    843|            *size = 4;
  365|    843|            return pb_read(stream, buf, 4);
  366|       |        
  367|      0|        case PB_WT_STRING:
  ------------------
  |  Branch (367:9): [True: 0, False: 15.0k]
  ------------------
  368|       |            /* Calling read_raw_value with a PB_WT_STRING is an error.
  369|       |             * Explicitly handle this case and fallthrough to default to avoid
  370|       |             * compiler warnings.
  371|       |             */
  372|       |
  373|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (373:2): [True: 0, False: 15.0k]
  ------------------
  374|       |            /* Calling read_raw_value with a PB_WT_PACKED is an error.
  375|       |             * Explicitly handle this case and fallthrough to default to avoid
  376|       |             * compiler warnings.
  377|       |             */
  378|       |
  379|      2|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  930|      2|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      2|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (379:9): [True: 2, False: 15.0k]
  ------------------
  380|  15.0k|    }
  381|  15.0k|}

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

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

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

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

validate_static:
    7|   506k|{
    8|   506k|    pb_size_t count = 1;
    9|   506k|    pb_size_t i;
   10|   506k|    bool truebool = true;
   11|   506k|    bool falsebool = false;
   12|       |
   13|   506k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  327|   506k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   506k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  314|  1.01M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (13:9): [True: 110k, False: 396k]
  |  Branch (13:54): [True: 110k, False: 0]
  ------------------
   14|   110k|    {
   15|       |        /* Array count must be between 0 and statically allocated size */
   16|   110k|        count = *(pb_size_t*)iter->pSize;
   17|   110k|        assert(count <= iter->array_size);
  ------------------
  |  Branch (17:9): [True: 0, False: 110k]
  |  Branch (17:9): [True: 110k, False: 0]
  ------------------
   18|   110k|    }
   19|   396k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  327|   396k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   396k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  312|   792k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (19:14): [True: 119k, False: 276k]
  |  Branch (19:59): [True: 119k, False: 0]
  ------------------
   20|   119k|    {
   21|       |        /* Boolean has_ field must have a valid value */
   22|   119k|        assert(memcmp(iter->pSize, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (22:9): [True: 119k, False: 0]
  |  Branch (22:9): [True: 0, False: 0]
  |  Branch (22:9): [True: 11.0k, False: 108k]
  |  Branch (22:9): [True: 108k, False: 0]
  ------------------
   23|   119k|               memcmp(iter->pSize, &falsebool, sizeof(bool)) == 0);
   24|   119k|    }
   25|   276k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|   276k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   276k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|   276k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (25:14): [True: 26.2k, False: 250k]
  ------------------
   26|  26.2k|    {
   27|  26.2k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (27:13): [True: 24.8k, False: 1.40k]
  ------------------
   28|  24.8k|        {
   29|       |            /* Some different field in oneof */
   30|  24.8k|            return;
   31|  24.8k|        }
   32|  26.2k|    }
   33|       |
   34|   933k|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (34:17): [True: 452k, False: 481k]
  ------------------
   35|   452k|    {
   36|   452k|        void *pData = (char*)iter->pData + iter->data_size * i;
   37|       |
   38|   452k|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  328|   452k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   452k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  284|   452k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (38:13): [True: 27.5k, False: 424k]
  ------------------
   39|  27.5k|        {
   40|       |            /* String length must be at most statically allocated size */
   41|  27.5k|            assert(strlen(pData) + 1 <= iter->data_size);
  ------------------
  |  Branch (41:13): [True: 0, False: 27.5k]
  |  Branch (41:13): [True: 27.5k, False: 0]
  ------------------
   42|  27.5k|        }
   43|   424k|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  328|   424k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   424k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  280|   424k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (43:18): [True: 12.2k, False: 412k]
  ------------------
   44|  12.2k|        {
   45|       |            /* Bytes length must be at most statically allocated size */
   46|  12.2k|            pb_bytes_array_t *bytes = pData;
   47|  12.2k|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= iter->data_size);
  ------------------
  |  Branch (47:13): [True: 0, False: 12.2k]
  |  Branch (47:13): [True: 0, False: 12.2k]
  |  Branch (47:13): [True: 5.90k, False: 6.34k]
  |  Branch (47:13): [True: 12.2k, False: 0]
  ------------------
   48|  12.2k|        }
   49|   412k|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  328|   412k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   412k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  268|   412k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (49:18): [True: 12.0k, False: 400k]
  ------------------
   50|  12.0k|        {
   51|       |            /* Bool fields must have valid value */
   52|  12.0k|            assert(memcmp(pData, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (52:13): [True: 12.0k, False: 0]
  |  Branch (52:13): [True: 0, False: 0]
  |  Branch (52:13): [True: 5.16k, False: 6.90k]
  |  Branch (52:13): [True: 6.90k, False: 0]
  ------------------
   53|  12.0k|                   memcmp(pData, &falsebool, sizeof(bool)) == 0);
   54|  12.0k|        }
   55|   400k|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  329|   400k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|   400k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|   400k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|   800k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 42.9k, False: 357k]
  |  |  ------------------
  |  |  330|   400k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|   357k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|   357k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|   357k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 357k]
  |  |  ------------------
  ------------------
   56|  42.9k|        {
   57|  42.9k|            validate_message(pData, 0, iter->submsg_desc);
   58|  42.9k|        }
   59|   452k|    }
   60|   481k|}
validate_message:
  145|  48.2k|{
  146|  48.2k|    pb_field_iter_t iter;
  147|       |
  148|  48.2k|    if (pb_field_iter_begin_const(&iter, msgtype, msg))
  ------------------
  |  Branch (148:9): [True: 35.8k, False: 12.3k]
  ------------------
  149|  35.8k|    {
  150|  35.8k|        do
  151|   522k|        {
  152|   522k|            if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  326|   522k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   522k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  321|   522k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (152:17): [True: 506k, False: 15.7k]
  ------------------
  153|   506k|            {
  154|   506k|                validate_static(&iter);
  155|   506k|            }
  156|  15.7k|            else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  15.7k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  15.7k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  15.7k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (156:22): [True: 0, False: 15.7k]
  ------------------
  157|      0|            {
  158|      0|                validate_pointer(&iter);
  159|      0|            }
  160|   522k|        } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (160:18): [True: 486k, False: 35.8k]
  ------------------
  161|  35.8k|    }
  162|  48.2k|}

