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

pb_read:
   82|  2.91M|{
   83|  2.91M|    if (count == 0)
  ------------------
  |  Branch (83:9): [True: 200k, False: 2.71M]
  ------------------
   84|   200k|        return true;
   85|       |
   86|  2.71M|#ifndef PB_BUFFER_ONLY
   87|  2.71M|	if (buf == NULL && stream->callback != buf_read)
  ------------------
  |  Branch (87:6): [True: 345k, False: 2.36M]
  |  Branch (87:21): [True: 78.7k, False: 266k]
  ------------------
   88|  78.7k|	{
   89|       |		/* Skip input bytes */
   90|  78.7k|		pb_byte_t tmp[16];
   91|   571k|		while (count > 16)
  ------------------
  |  Branch (91:10): [True: 492k, False: 78.7k]
  ------------------
   92|   492k|		{
   93|   492k|			if (!pb_read(stream, tmp, 16))
  ------------------
  |  Branch (93:8): [True: 0, False: 492k]
  ------------------
   94|      0|				return false;
   95|       |			
   96|   492k|			count -= 16;
   97|   492k|		}
   98|       |		
   99|  78.7k|		return pb_read(stream, tmp, count);
  100|  78.7k|	}
  101|  2.63M|#endif
  102|       |
  103|  2.63M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (103:9): [True: 264, False: 2.63M]
  ------------------
  104|    264|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  923|    264|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|    264|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 264]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  105|       |    
  106|  2.63M|#ifndef PB_BUFFER_ONLY
  107|  2.63M|    if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (107:9): [True: 0, False: 2.63M]
  ------------------
  108|      0|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  109|       |#else
  110|       |    if (!buf_read(stream, buf, count))
  111|       |        return false;
  112|       |#endif
  113|       |    
  114|  2.63M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (114:9): [True: 0, False: 2.63M]
  ------------------
  115|      0|        stream->bytes_left = 0;
  116|  2.63M|    else
  117|  2.63M|        stream->bytes_left -= count;
  118|       |
  119|       |    return true;
  120|  2.63M|}
pb_istream_from_buffer:
  143|   132k|{
  144|   132k|    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|   132k|    union {
  149|   132k|        void *state;
  150|   132k|        const void *c_state;
  151|   132k|    } state;
  152|       |#ifdef PB_BUFFER_ONLY
  153|       |    stream.callback = NULL;
  154|       |#else
  155|   132k|    stream.callback = &buf_read;
  156|   132k|#endif
  157|   132k|    state.c_state = buf;
  158|   132k|    stream.state = state.state;
  159|   132k|    stream.bytes_left = msglen;
  160|   132k|#ifndef PB_NO_ERRMSG
  161|   132k|    stream.errmsg = NULL;
  162|   132k|#endif
  163|       |#ifdef PB_MESSAGE_NESTING_MAX
  164|       |    stream.depth = 0;
  165|       |#endif
  166|   132k|    return stream;
  167|   132k|}
pb_decode_varint32:
  175|  9.78M|{
  176|  9.78M|    pb_byte_t byte;
  177|  9.78M|    uint32_t result;
  178|       |    
  179|  9.78M|    if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (179:9): [True: 1.47k, False: 9.78M]
  ------------------
  180|  1.47k|    {
  181|  1.47k|        return false;
  182|  1.47k|    }
  183|       |    
  184|  9.78M|    if ((byte & 0x80) == 0)
  ------------------
  |  Branch (184:9): [True: 8.43M, False: 1.34M]
  ------------------
  185|  8.43M|    {
  186|       |        /* Quick case, 1 byte value */
  187|  8.43M|        result = byte;
  188|  8.43M|    }
  189|  1.34M|    else
  190|  1.34M|    {
  191|       |        /* Multibyte case */
  192|  1.34M|        uint_fast8_t bitpos = 7;
  193|  1.34M|        result = byte & 0x7F;
  194|       |        
  195|  1.34M|        do
  196|  1.69M|        {
  197|  1.69M|            if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (197:17): [True: 47, False: 1.69M]
  ------------------
  198|     47|                return false;
  199|       |            
  200|  1.69M|            if (bitpos >= 32)
  ------------------
  |  Branch (200:17): [True: 18.6k, False: 1.67M]
  ------------------
  201|  18.6k|            {
  202|       |                /* Note: The varint could have trailing 0x80 bytes, or 0xFF for negative. */
  203|  18.6k|                pb_byte_t sign_extension = (bitpos < 63) ? 0xFF : 0x01;
  ------------------
  |  Branch (203:44): [True: 18.1k, False: 542]
  ------------------
  204|  18.6k|                bool valid_extension = ((byte & 0x7F) == 0x00 ||
  ------------------
  |  Branch (204:41): [True: 4.68k, False: 13.9k]
  ------------------
  205|  13.9k|                         ((result >> 31) != 0 && byte == sign_extension));
  ------------------
  |  Branch (205:27): [True: 13.9k, False: 14]
  |  Branch (205:50): [True: 13.9k, False: 55]
  ------------------
  206|       |
  207|  18.6k|                if (bitpos >= 64 || !valid_extension)
  ------------------
  |  Branch (207:21): [True: 3, False: 18.6k]
  |  Branch (207:37): [True: 68, False: 18.5k]
  ------------------
  208|     71|                {
  209|     71|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  923|     71|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     71|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 71]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  210|     71|                }
  211|  18.6k|            }
  212|  1.67M|            else if (bitpos == 28)
  ------------------
  |  Branch (212:22): [True: 11.9k, False: 1.66M]
  ------------------
  213|  11.9k|            {
  214|  11.9k|                if ((byte & 0x70) != 0 && (byte & 0x78) != 0x78)
  ------------------
  |  Branch (214:21): [True: 4.87k, False: 7.04k]
  |  Branch (214:43): [True: 15, False: 4.85k]
  ------------------
  215|     15|                {
  216|     15|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  923|     15|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     15|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  217|     15|                }
  218|  11.9k|                result |= (uint32_t)(byte & 0x0F) << bitpos;
  219|  11.9k|            }
  220|  1.66M|            else
  221|  1.66M|            {
  222|  1.66M|                result |= (uint32_t)(byte & 0x7F) << bitpos;
  223|  1.66M|            }
  224|  1.69M|            bitpos = (uint_fast8_t)(bitpos + 7);
  225|  1.69M|        } while (byte & 0x80);
  ------------------
  |  Branch (225:18): [True: 343k, False: 1.34M]
  ------------------
  226|  1.34M|   }
  227|       |   
  228|  9.78M|   *dest = result;
  229|       |   return true;
  230|  9.78M|}
pb_decode_varint:
  234|  5.65M|{
  235|  5.65M|    pb_byte_t byte;
  236|  5.65M|    uint_fast8_t bitpos = 0;
  237|  5.65M|    uint64_t result = 0;
  238|       |    
  239|  5.65M|    do
  240|  6.94M|    {
  241|  6.94M|        if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (241:13): [True: 56, False: 6.94M]
  ------------------
  242|     56|            return false;
  243|       |
  244|  6.94M|        if (bitpos >= 63 && (byte & 0xFE) != 0)
  ------------------
  |  Branch (244:13): [True: 55.2k, False: 6.89M]
  |  Branch (244:29): [True: 31, False: 55.2k]
  ------------------
  245|     31|            PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  923|     31|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     31|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 31]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  246|       |
  247|  6.94M|        result |= (uint64_t)(byte & 0x7F) << bitpos;
  248|  6.94M|        bitpos = (uint_fast8_t)(bitpos + 7);
  249|  6.94M|    } while (byte & 0x80);
  ------------------
  |  Branch (249:14): [True: 1.29M, False: 5.65M]
  ------------------
  250|       |    
  251|  5.65M|    *dest = result;
  252|       |    return true;
  253|  5.65M|}
pb_decode_tag:
  282|  8.86M|{
  283|  8.86M|    uint32_t temp;
  284|  8.86M|    *eof = false;
  285|  8.86M|    *wire_type = (pb_wire_type_t) 0;
  286|  8.86M|    *tag = 0;
  287|       |
  288|  8.86M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (288:9): [True: 298k, False: 8.56M]
  ------------------
  289|   298k|    {
  290|   298k|        *eof = true;
  291|   298k|        return false;
  292|   298k|    }
  293|       |
  294|  8.56M|    if (!pb_decode_varint32(stream, &temp))
  ------------------
  |  Branch (294:9): [True: 1.44k, False: 8.56M]
  ------------------
  295|  1.44k|    {
  296|  1.44k|#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.44k|        if (stream->callback != buf_read && stream->bytes_left == 0)
  ------------------
  |  Branch (304:13): [True: 1.32k, False: 114]
  |  Branch (304:45): [True: 1.32k, False: 0]
  ------------------
  305|  1.32k|        {
  306|  1.32k|#ifndef PB_NO_ERRMSG
  307|  1.32k|            if (strcmp(stream->errmsg, "io error") == 0)
  ------------------
  |  Branch (307:17): [True: 1.32k, False: 0]
  ------------------
  308|  1.32k|                stream->errmsg = NULL;
  309|  1.32k|#endif
  310|  1.32k|            *eof = true;
  311|  1.32k|        }
  312|  1.44k|#endif
  313|  1.44k|        return false;
  314|  1.44k|    }
  315|       |    
  316|  8.56M|    *tag = temp >> 3;
  317|  8.56M|    *wire_type = (pb_wire_type_t)(temp & 7);
  318|       |    return true;
  319|  8.56M|}
pb_skip_field:
  322|  1.20M|{
  323|  1.20M|    switch (wire_type)
  324|  1.20M|    {
  325|   797k|        case PB_WT_VARINT: return pb_skip_varint(stream);
  ------------------
  |  Branch (325:9): [True: 797k, False: 405k]
  ------------------
  326|  83.3k|        case PB_WT_64BIT: return pb_read(stream, NULL, 8);
  ------------------
  |  Branch (326:9): [True: 83.3k, False: 1.11M]
  ------------------
  327|   185k|        case PB_WT_STRING: return pb_skip_string(stream);
  ------------------
  |  Branch (327:9): [True: 185k, False: 1.01M]
  ------------------
  328|   136k|        case PB_WT_32BIT: return pb_read(stream, NULL, 4);
  ------------------
  |  Branch (328:9): [True: 136k, False: 1.06M]
  ------------------
  329|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (329:2): [True: 0, False: 1.20M]
  ------------------
  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|     95|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  923|     95|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     95|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 95]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (334:9): [True: 95, False: 1.20M]
  ------------------
  335|  1.20M|    }
  336|  1.20M|}
pb_make_string_substream:
  387|   395k|{
  388|   395k|    uint32_t size;
  389|   395k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (389:9): [True: 76, False: 395k]
  ------------------
  390|     76|        return false;
  391|       |    
  392|   395k|    *substream = *stream;
  393|   395k|    if (substream->bytes_left < size)
  ------------------
  |  Branch (393:9): [True: 128, False: 395k]
  ------------------
  394|    128|        PB_RETURN_ERROR(stream, "parent stream too short");
  ------------------
  |  |  923|    128|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|    128|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 128]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|   395k|    substream->bytes_left = (size_t)size;
  403|   395k|    stream->bytes_left -= (size_t)size;
  404|       |    return true;
  405|   395k|}
pb_close_string_substream:
  408|   395k|{
  409|   395k|    if (substream->bytes_left) {
  ------------------
  |  Branch (409:9): [True: 24.8k, False: 370k]
  ------------------
  410|  24.8k|        if (!pb_read(substream, NULL, substream->bytes_left))
  ------------------
  |  Branch (410:13): [True: 0, False: 24.8k]
  ------------------
  411|      0|            return false;
  412|  24.8k|    }
  413|       |
  414|   395k|    stream->state = substream->state;
  415|       |
  416|   395k|#ifndef PB_NO_ERRMSG
  417|   395k|    stream->errmsg = substream->errmsg;
  418|   395k|#endif
  419|       |    return true;
  420|   395k|}
pb_decode_ex:
 1220|  8.54k|{
 1221|  8.54k|    bool status;
 1222|       |
 1223|  8.54k|    if ((flags & PB_DECODE_DELIMITED) == 0)
  ------------------
  |  |  123|  8.54k|#define PB_DECODE_DELIMITED       0x02U
  ------------------
  |  Branch (1223:9): [True: 8.54k, False: 0]
  ------------------
 1224|  8.54k|    {
 1225|  8.54k|      status = pb_decode_inner(stream, fields, dest_struct, flags);
 1226|  8.54k|    }
 1227|      0|    else
 1228|      0|    {
 1229|      0|      pb_istream_t substream;
 1230|      0|      if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1230:11): [True: 0, False: 0]
  ------------------
 1231|      0|        return false;
 1232|       |
 1233|      0|      status = pb_decode_inner(&substream, fields, dest_struct, flags);
 1234|       |
 1235|      0|      if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1235:11): [True: 0, False: 0]
  ------------------
 1236|      0|        status = false;
 1237|      0|    }
 1238|       |    
 1239|       |#ifdef PB_ENABLE_MALLOC
 1240|       |    if (!status)
 1241|       |        pb_release(fields, dest_struct);
 1242|       |#endif
 1243|       |    
 1244|  8.54k|    return status;
 1245|  8.54k|}
pb_decode:
 1248|  3.98k|{
 1249|  3.98k|    return pb_decode_ex(stream, fields, dest_struct, 0);
 1250|  3.98k|}
pb_release:
 1393|  6.64k|{
 1394|       |    /* Nothing to release without PB_ENABLE_MALLOC. */
 1395|  6.64k|    PB_UNUSED(fields);
  ------------------
  |  |  172|  6.64k|#define PB_UNUSED(x) (void)(x)
  ------------------
 1396|  6.64k|    PB_UNUSED(dest_struct);
  ------------------
  |  |  172|  6.64k|#define PB_UNUSED(x) (void)(x)
  ------------------
 1397|  6.64k|}
pb_decode_bool:
 1403|   342k|{
 1404|   342k|    uint32_t value;
 1405|   342k|    if (!pb_decode_varint32(stream, &value))
  ------------------
  |  Branch (1405:9): [True: 17, False: 342k]
  ------------------
 1406|     17|        return false;
 1407|       |
 1408|   342k|    *(bool*)dest = (value != 0);
 1409|       |    return true;
 1410|   342k|}
pb_decode_svarint:
 1413|   178k|{
 1414|   178k|    pb_uint64_t value;
  ------------------
  |  |   57|   178k|#define pb_uint64_t uint64_t
  ------------------
 1415|   178k|    if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1415:9): [True: 23, False: 178k]
  ------------------
 1416|     23|        return false;
 1417|       |    
 1418|   178k|    if (value & 1)
  ------------------
  |  Branch (1418:9): [True: 30.0k, False: 148k]
  ------------------
 1419|  30.0k|        *dest = (pb_int64_t)(~(value >> 1));
 1420|   148k|    else
 1421|   148k|        *dest = (pb_int64_t)(value >> 1);
 1422|       |    
 1423|       |    return true;
 1424|   178k|}
pb_decode_fixed32:
 1427|   317k|{
 1428|   317k|    union {
 1429|   317k|        uint32_t fixed32;
 1430|   317k|        pb_byte_t bytes[4];
 1431|   317k|    } u;
 1432|       |
 1433|   317k|    if (!pb_read(stream, u.bytes, 4))
  ------------------
  |  Branch (1433:9): [True: 13, False: 317k]
  ------------------
 1434|     13|        return false;
 1435|       |
 1436|   317k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1437|       |    /* fast path - if we know that we're on little endian, assign directly */
 1438|   317k|    *(uint32_t*)dest = u.fixed32;
 1439|       |#else
 1440|       |    *(uint32_t*)dest = ((uint32_t)u.bytes[0] << 0) |
 1441|       |                       ((uint32_t)u.bytes[1] << 8) |
 1442|       |                       ((uint32_t)u.bytes[2] << 16) |
 1443|       |                       ((uint32_t)u.bytes[3] << 24);
 1444|       |#endif
 1445|       |    return true;
 1446|   317k|}
pb_decode_fixed64:
 1450|   262k|{
 1451|   262k|    union {
 1452|   262k|        uint64_t fixed64;
 1453|   262k|        pb_byte_t bytes[8];
 1454|   262k|    } u;
 1455|       |
 1456|   262k|    if (!pb_read(stream, u.bytes, 8))
  ------------------
  |  Branch (1456:9): [True: 16, False: 262k]
  ------------------
 1457|     16|        return false;
 1458|       |
 1459|   262k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1460|       |    /* fast path - if we know that we're on little endian, assign directly */
 1461|   262k|    *(uint64_t*)dest = u.fixed64;
 1462|       |#else
 1463|       |    *(uint64_t*)dest = ((uint64_t)u.bytes[0] << 0) |
 1464|       |                       ((uint64_t)u.bytes[1] << 8) |
 1465|       |                       ((uint64_t)u.bytes[2] << 16) |
 1466|       |                       ((uint64_t)u.bytes[3] << 24) |
 1467|       |                       ((uint64_t)u.bytes[4] << 32) |
 1468|       |                       ((uint64_t)u.bytes[5] << 40) |
 1469|       |                       ((uint64_t)u.bytes[6] << 48) |
 1470|       |                       ((uint64_t)u.bytes[7] << 56);
 1471|       |#endif
 1472|       |    return true;
 1473|   262k|}
pb_decode.c:buf_read:
   69|  16.0M|{
   70|  16.0M|    const pb_byte_t *source = (const pb_byte_t*)stream->state;
   71|  16.0M|    stream->state = (pb_byte_t*)stream->state + count;
   72|       |    
   73|  16.0M|    if (buf != NULL)
  ------------------
  |  Branch (73:9): [True: 15.8M, False: 266k]
  ------------------
   74|  15.8M|    {
   75|  15.8M|        memcpy(buf, source, count * sizeof(pb_byte_t));
   76|  15.8M|    }
   77|       |    
   78|       |    return true;
   79|  16.0M|}
pb_decode.c:pb_readbyte:
  125|  18.4M|{
  126|  18.4M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (126:9): [True: 247, False: 18.4M]
  ------------------
  127|    247|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  923|    247|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|    247|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 247]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  128|       |
  129|  18.4M|#ifndef PB_BUFFER_ONLY
  130|  18.4M|    if (!stream->callback(stream, buf, 1))
  ------------------
  |  Branch (130:9): [True: 1.32k, False: 18.4M]
  ------------------
  131|  1.32k|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  923|  1.32k|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|  1.32k|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 1.32k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  132|       |#else
  133|       |    *buf = *(const pb_byte_t*)stream->state;
  134|       |    stream->state = (pb_byte_t*)stream->state + 1;
  135|       |#endif
  136|       |
  137|  18.4M|    stream->bytes_left--;
  138|       |    
  139|       |    return true;    
  140|  18.4M|}
pb_decode.c:pb_skip_varint:
  257|   797k|{
  258|   797k|    pb_byte_t byte;
  259|   797k|    do
  260|  1.00M|    {
  261|  1.00M|        if (!pb_read(stream, &byte, 1))
  ------------------
  |  Branch (261:13): [True: 68, False: 1.00M]
  ------------------
  262|     68|            return false;
  263|  1.00M|    } while (byte & 0x80);
  ------------------
  |  Branch (263:14): [True: 209k, False: 797k]
  ------------------
  264|   797k|    return true;
  265|   797k|}
pb_decode.c:pb_skip_string:
  268|   185k|{
  269|   185k|    uint32_t length;
  270|   185k|    if (!pb_decode_varint32(stream, &length))
  ------------------
  |  Branch (270:9): [True: 54, False: 185k]
  ------------------
  271|     54|        return false;
  272|       |    
  273|   185k|    if ((size_t)length != length)
  ------------------
  |  Branch (273:9): [True: 0, False: 185k]
  ------------------
  274|      0|    {
  275|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  276|      0|    }
  277|       |
  278|   185k|    return pb_read(stream, NULL, (size_t)length);
  279|   185k|}
pb_decode.c:pb_decode_inner:
 1049|   301k|{
 1050|       |    /* If the message contains extension fields, the extension handlers
 1051|       |     * are called when tag number is >= extension_range_start. This precheck
 1052|       |     * is just for speed, and the handlers will check for precise match.
 1053|       |     */
 1054|   301k|    uint32_t extension_range_start = 0;
 1055|   301k|    pb_extension_t *extensions = NULL;
 1056|       |
 1057|       |    /* 'fixed_count_field' and 'fixed_count_size' track position of a repeated fixed
 1058|       |     * count field. This can only handle _one_ repeated fixed count field that
 1059|       |     * is unpacked and unordered among other (non repeated fixed count) fields.
 1060|       |     */
 1061|   301k|    pb_size_t fixed_count_field = PB_SIZE_MAX;
  ------------------
  |  |  342|   301k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
 1062|   301k|    pb_size_t fixed_count_size = 0;
 1063|   301k|    pb_size_t fixed_count_total_size = 0;
 1064|       |
 1065|       |    /* Tag and wire type of next field from the input stream */
 1066|   301k|    uint32_t tag;
 1067|   301k|    pb_wire_type_t wire_type;
 1068|   301k|    bool eof;
 1069|       |
 1070|       |    /* Track presence of required fields */
 1071|   301k|    pb_fields_seen_t fields_seen = {{0, 0}};
 1072|   301k|    const uint32_t allbits = ~(uint32_t)0;
 1073|       |
 1074|       |    /* Descriptor for the structure field matching the tag decoded from stream */
 1075|   301k|    pb_field_iter_t iter;
 1076|       |
 1077|   301k|    if (pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1077:9): [True: 164k, False: 136k]
  ------------------
 1078|   164k|    {
 1079|   164k|        if ((flags & PB_DECODE_NOINIT) == 0)
  ------------------
  |  |  122|   164k|#define PB_DECODE_NOINIT          0x01U
  ------------------
  |  Branch (1079:13): [True: 12.6k, False: 151k]
  ------------------
 1080|  12.6k|        {
 1081|  12.6k|            if (!pb_message_set_to_defaults(&iter))
  ------------------
  |  Branch (1081:17): [True: 0, False: 12.6k]
  ------------------
 1082|      0|                PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1083|  12.6k|        }
 1084|   164k|    }
 1085|       |
 1086|  8.26M|    while (pb_decode_tag(stream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1086:12): [True: 7.96M, False: 299k]
  ------------------
 1087|  7.96M|    {
 1088|  7.96M|        if (tag == 0)
  ------------------
  |  Branch (1088:13): [True: 69, False: 7.96M]
  ------------------
 1089|     69|        {
 1090|     69|          if (flags & PB_DECODE_NULLTERMINATED)
  ------------------
  |  |  124|     69|#define PB_DECODE_NULLTERMINATED  0x04U
  ------------------
  |  Branch (1090:15): [True: 0, False: 69]
  ------------------
 1091|      0|          {
 1092|      0|            eof = true;
 1093|      0|            break;
 1094|      0|          }
 1095|     69|          else
 1096|     69|          {
 1097|     69|            PB_RETURN_ERROR(stream, "zero tag");
  ------------------
  |  |  923|     69|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     69|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 69]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1098|     69|          }
 1099|     69|        }
 1100|       |
 1101|  7.96M|        if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  6.75M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  6.75M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  6.75M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1101:13): [True: 1.20M, False: 6.75M]
  |  Branch (1101:48): [True: 458, False: 6.75M]
  ------------------
 1102|  1.20M|        {
 1103|       |            /* No match found, check if it matches an extension. */
 1104|  1.20M|            if (extension_range_start == 0)
  ------------------
  |  Branch (1104:17): [True: 27.5k, False: 1.18M]
  ------------------
 1105|  27.5k|            {
 1106|  27.5k|                if (pb_field_iter_find_extension(&iter))
  ------------------
  |  Branch (1106:21): [True: 3.66k, False: 23.8k]
  ------------------
 1107|  3.66k|                {
 1108|  3.66k|                    extensions = *(pb_extension_t* const *)iter.pData;
 1109|  3.66k|                    extension_range_start = iter.tag;
 1110|  3.66k|                }
 1111|       |
 1112|  27.5k|                if (!extensions)
  ------------------
  |  Branch (1112:21): [True: 24.7k, False: 2.74k]
  ------------------
 1113|  24.7k|                {
 1114|  24.7k|                    extension_range_start = (uint32_t)-1;
 1115|  24.7k|                }
 1116|  27.5k|            }
 1117|       |
 1118|  1.20M|            if (tag >= extension_range_start)
  ------------------
  |  Branch (1118:17): [True: 137k, False: 1.07M]
  ------------------
 1119|   137k|            {
 1120|   137k|                size_t pos = stream->bytes_left;
 1121|       |
 1122|   137k|                if (!decode_extension(stream, tag, wire_type, extensions))
  ------------------
  |  Branch (1122:21): [True: 33, False: 137k]
  ------------------
 1123|     33|                    return false;
 1124|       |
 1125|   137k|                if (pos != stream->bytes_left)
  ------------------
  |  Branch (1125:21): [True: 6.12k, False: 131k]
  ------------------
 1126|  6.12k|                {
 1127|       |                    /* The field was handled */
 1128|  6.12k|                    continue;
 1129|  6.12k|                }
 1130|   137k|            }
 1131|       |
 1132|       |            /* No match found, skip data */
 1133|  1.20M|            if (!pb_skip_field(stream, wire_type))
  ------------------
  |  Branch (1133:17): [True: 326, False: 1.20M]
  ------------------
 1134|    326|                return false;
 1135|  1.20M|            continue;
 1136|  1.20M|        }
 1137|       |
 1138|       |        /* If a repeated fixed count field was found, get size from
 1139|       |         * 'fixed_count_field' as there is no counter contained in the struct.
 1140|       |         */
 1141|  6.75M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  327|  6.75M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  6.75M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  314|  13.5M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1141:13): [True: 39.9k, False: 6.71M]
  |  Branch (1141:57): [True: 3.59k, False: 36.3k]
  ------------------
 1142|  3.59k|        {
 1143|  3.59k|            if (fixed_count_field != iter.index) {
  ------------------
  |  Branch (1143:17): [True: 3.30k, False: 292]
  ------------------
 1144|       |                /* If the new fixed count field does not match the previous one,
 1145|       |                 * check that the previous one is NULL or that it finished
 1146|       |                 * receiving all the expected data.
 1147|       |                 */
 1148|  3.30k|                if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  342|  6.61k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1148:21): [True: 1.67k, False: 1.62k]
  ------------------
 1149|  1.67k|                    fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1149:21): [True: 3, False: 1.67k]
  ------------------
 1150|      3|                {
 1151|      3|                    PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  923|      3|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      3|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1152|      3|                }
 1153|       |
 1154|  3.30k|                fixed_count_field = iter.index;
 1155|  3.30k|                fixed_count_size = 0;
 1156|  3.30k|                fixed_count_total_size = iter.array_size;
 1157|  3.30k|            }
 1158|       |
 1159|  3.59k|            iter.pSize = &fixed_count_size;
 1160|  3.59k|        }
 1161|       |
 1162|  6.75M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  327|  6.75M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  6.75M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  311|  13.5M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (1162:13): [True: 6.20M, False: 551k]
  ------------------
 1163|  6.20M|            && iter.required_field_index < PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  233|  6.20M|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1163:16): [True: 6.20M, False: 0]
  ------------------
 1164|  6.20M|        {
 1165|  6.20M|            uint32_t tmp = ((uint32_t)1 << (iter.required_field_index & 31));
 1166|  6.20M|            fields_seen.bitfield[iter.required_field_index >> 5] |= tmp;
 1167|  6.20M|        }
 1168|       |
 1169|  6.75M|        if (!decode_field(stream, wire_type, &iter))
  ------------------
  |  Branch (1169:13): [True: 1.26k, False: 6.75M]
  ------------------
 1170|  1.26k|            return false;
 1171|  6.75M|    }
 1172|       |
 1173|   299k|    if (!eof)
  ------------------
  |  Branch (1173:9): [True: 114, False: 299k]
  ------------------
 1174|    114|    {
 1175|       |        /* pb_decode_tag() returned error before end of stream */
 1176|    114|        return false;
 1177|    114|    }
 1178|       |
 1179|       |    /* Check that all elements of the last decoded fixed count field were present. */
 1180|   299k|    if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  342|   598k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1180:9): [True: 1.57k, False: 297k]
  ------------------
 1181|  1.57k|        fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1181:9): [True: 9, False: 1.56k]
  ------------------
 1182|      9|    {
 1183|      9|        PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  923|      9|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      9|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1184|      9|    }
 1185|       |
 1186|       |    /* Check that all required fields were present. */
 1187|   299k|    {
 1188|   299k|        pb_size_t req_field_count = iter.descriptor->required_field_count;
 1189|       |
 1190|   299k|        if (req_field_count > 0)
  ------------------
  |  Branch (1190:13): [True: 156k, False: 143k]
  ------------------
 1191|   156k|        {
 1192|   156k|            pb_size_t i;
 1193|       |
 1194|   156k|            if (req_field_count > PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  233|   156k|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1194:17): [True: 0, False: 156k]
  ------------------
 1195|      0|                req_field_count = PB_MAX_REQUIRED_FIELDS;
  ------------------
  |  |  233|      0|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
 1196|       |
 1197|       |            /* Check the whole words */
 1198|   156k|            for (i = 0; i < (req_field_count >> 5); i++)
  ------------------
  |  Branch (1198:25): [True: 0, False: 156k]
  ------------------
 1199|      0|            {
 1200|      0|                if (fields_seen.bitfield[i] != allbits)
  ------------------
  |  Branch (1200:21): [True: 0, False: 0]
  ------------------
 1201|      0|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1202|      0|            }
 1203|       |
 1204|       |            /* Check the remaining bits (if any) */
 1205|   156k|            if ((req_field_count & 31) != 0)
  ------------------
  |  Branch (1205:17): [True: 156k, False: 0]
  ------------------
 1206|   156k|            {
 1207|   156k|                if (fields_seen.bitfield[req_field_count >> 5] !=
  ------------------
  |  Branch (1207:21): [True: 350, False: 155k]
  ------------------
 1208|   156k|                    (allbits >> (uint_least8_t)(32 - (req_field_count & 31))))
 1209|    350|                {
 1210|    350|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  923|    350|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|    350|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 350]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1211|    350|                }
 1212|   156k|            }
 1213|   156k|        }
 1214|   299k|    }
 1215|       |
 1216|   299k|    return true;
 1217|   299k|}
pb_decode.c:pb_message_set_to_defaults:
 1010|   112k|{
 1011|   112k|    pb_istream_t defstream = PB_ISTREAM_EMPTY;
  ------------------
  |  |   71|   112k|#  define PB_ISTREAM_EMPTY {0,0,0,0}
  ------------------
 1012|   112k|    uint32_t tag = 0;
 1013|   112k|    pb_wire_type_t wire_type = PB_WT_VARINT;
 1014|   112k|    bool eof;
 1015|       |
 1016|   112k|    if (iter->descriptor->default_value)
  ------------------
  |  Branch (1016:9): [True: 106k, False: 5.89k]
  ------------------
 1017|   106k|    {
 1018|   106k|        defstream = pb_istream_from_buffer(iter->descriptor->default_value, (size_t)-1);
 1019|   106k|        if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1019:13): [True: 0, False: 106k]
  ------------------
 1020|      0|            return false;
 1021|   106k|    }
 1022|       |
 1023|   112k|    do
 1024|   985k|    {
 1025|   985k|        if (!pb_field_set_to_default(iter))
  ------------------
  |  Branch (1025:13): [True: 0, False: 985k]
  ------------------
 1026|      0|            return false;
 1027|       |
 1028|   985k|        if (tag != 0 && iter->tag == tag)
  ------------------
  |  Branch (1028:13): [True: 885k, False: 99.9k]
  |  Branch (1028:25): [True: 493k, False: 391k]
  ------------------
 1029|   493k|        {
 1030|       |            /* We have a default value for this field in the defstream */
 1031|   493k|            if (!decode_field(&defstream, wire_type, iter))
  ------------------
  |  Branch (1031:17): [True: 0, False: 493k]
  ------------------
 1032|      0|                return false;
 1033|   493k|            if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1033:17): [True: 0, False: 493k]
  ------------------
 1034|      0|                return false;
 1035|       |
 1036|   493k|            if (iter->pSize)
  ------------------
  |  Branch (1036:17): [True: 239k, False: 253k]
  ------------------
 1037|   239k|                *(bool*)iter->pSize = false;
 1038|   493k|        }
 1039|   985k|    } while (pb_field_iter_next(iter));
  ------------------
  |  Branch (1039:14): [True: 872k, False: 112k]
  ------------------
 1040|       |
 1041|   112k|    return true;
 1042|   112k|}
pb_decode.c:pb_field_set_to_default:
  928|   985k|{
  929|   985k|    pb_type_t type;
  930|   985k|    type = field->type;
  931|       |
  932|   985k|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|   985k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   985k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|   985k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (932:9): [True: 8.54k, False: 976k]
  ------------------
  933|  8.54k|    {
  934|  8.54k|        pb_extension_t *ext = *(pb_extension_t* const *)field->pData;
  935|  14.4k|        while (ext != NULL)
  ------------------
  |  Branch (935:16): [True: 5.89k, False: 8.54k]
  ------------------
  936|  5.89k|        {
  937|  5.89k|            pb_field_iter_t ext_iter;
  938|  5.89k|            if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (938:17): [True: 5.89k, False: 0]
  ------------------
  939|  5.89k|            {
  940|  5.89k|                ext->found = false;
  941|  5.89k|                if (!pb_message_set_to_defaults(&ext_iter))
  ------------------
  |  Branch (941:21): [True: 0, False: 5.89k]
  ------------------
  942|      0|                    return false;
  943|  5.89k|            }
  944|  5.89k|            ext = ext->next;
  945|  5.89k|        }
  946|  8.54k|    }
  947|   976k|    else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  326|   976k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   976k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  321|   976k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (947:14): [True: 903k, False: 73.1k]
  ------------------
  948|   903k|    {
  949|   903k|        bool init_data = true;
  950|   903k|        if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  327|   903k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   903k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  312|  1.80M|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (950:13): [True: 256k, False: 646k]
  |  Branch (950:52): [True: 256k, False: 0]
  ------------------
  951|   256k|        {
  952|       |            /* Set has_field to false. Still initialize the optional field
  953|       |             * itself also. */
  954|   256k|            *(bool*)field->pSize = false;
  955|   256k|        }
  956|   646k|        else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  327|   646k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   646k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  314|  1.29M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (956:18): [True: 151k, False: 494k]
  ------------------
  957|   494k|                 PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|   494k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   494k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                               PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|   494k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (957:18): [True: 42.7k, False: 452k]
  ------------------
  958|   194k|        {
  959|       |            /* REPEATED: Set array count to 0, no need to initialize contents.
  960|       |               ONEOF: Set which_field to 0. */
  961|   194k|            *(pb_size_t*)field->pSize = 0;
  962|   194k|            init_data = false;
  963|   194k|        }
  964|       |
  965|   903k|        if (init_data)
  ------------------
  |  Branch (965:13): [True: 709k, False: 194k]
  ------------------
  966|   709k|        {
  967|   709k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  329|  1.41M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|   709k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|   709k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  1.41M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 65.7k, False: 643k]
  |  |  ------------------
  |  |  330|  1.41M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|   643k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|   643k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|   643k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 643k]
  |  |  ------------------
  ------------------
  968|  65.7k|                (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (968:18): [True: 25.6k, False: 40.0k]
  ------------------
  969|  40.0k|                 field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (969:18): [True: 0, False: 40.0k]
  ------------------
  970|  40.0k|                 field->submsg_desc->submsg_info[0] != NULL))
  ------------------
  |  Branch (970:18): [True: 0, False: 40.0k]
  ------------------
  971|  25.6k|            {
  972|       |                /* Initialize submessage to defaults.
  973|       |                 * Only needed if it has default values
  974|       |                 * or callback/submessage fields. */
  975|  25.6k|                pb_field_iter_t submsg_iter;
  976|  25.6k|                if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (976:21): [True: 25.6k, False: 0]
  ------------------
  977|  25.6k|                {
  978|  25.6k|                    if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (978:25): [True: 0, False: 25.6k]
  ------------------
  979|      0|                        return false;
  980|  25.6k|                }
  981|  25.6k|            }
  982|   683k|            else
  983|   683k|            {
  984|       |                /* Initialize to zeros */
  985|   683k|                memset(field->pData, 0, (size_t)field->data_size);
  986|   683k|            }
  987|   709k|        }
  988|   903k|    }
  989|  73.1k|    else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  73.1k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  73.1k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  73.1k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (989:14): [True: 0, False: 73.1k]
  ------------------
  990|      0|    {
  991|       |        /* Initialize the pointer to NULL. */
  992|      0|        *(void**)field->pField = NULL;
  993|       |
  994|       |        /* Initialize array count to 0. */
  995|      0|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  327|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  314|      0|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (995:13): [True: 0, False: 0]
  ------------------
  996|      0|            PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|      0|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (996:13): [True: 0, False: 0]
  ------------------
  997|      0|        {
  998|      0|            *(pb_size_t*)field->pSize = 0;
  999|      0|        }
 1000|      0|    }
 1001|  73.1k|    else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  326|  73.1k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  73.1k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|  73.1k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (1001:14): [True: 73.1k, False: 0]
  ------------------
 1002|  73.1k|    {
 1003|       |        /* Don't overwrite callback */
 1004|  73.1k|    }
 1005|       |
 1006|   985k|    return true;
 1007|   985k|}
pb_decode.c:decode_extension:
  906|   137k|{
  907|   137k|    size_t pos = stream->bytes_left;
  908|       |    
  909|   274k|    while (extension != NULL && pos == stream->bytes_left)
  ------------------
  |  Branch (909:12): [True: 137k, False: 137k]
  |  Branch (909:33): [True: 137k, False: 0]
  ------------------
  910|   137k|    {
  911|   137k|        bool status;
  912|   137k|        if (extension->type->decode)
  ------------------
  |  Branch (912:13): [True: 0, False: 137k]
  ------------------
  913|      0|            status = extension->type->decode(stream, extension, tag, wire_type);
  914|   137k|        else
  915|   137k|            status = default_extension_decoder(stream, extension, tag, wire_type);
  916|       |
  917|   137k|        if (!status)
  ------------------
  |  Branch (917:13): [True: 33, False: 137k]
  ------------------
  918|     33|            return false;
  919|       |        
  920|   137k|        extension = extension->next;
  921|   137k|    }
  922|       |    
  923|   137k|    return true;
  924|   137k|}
pb_decode.c:default_extension_decoder:
  889|   137k|{
  890|   137k|    pb_field_iter_t iter;
  891|       |
  892|   137k|    if (!pb_field_iter_begin_extension(&iter, extension))
  ------------------
  |  Branch (892:9): [True: 0, False: 137k]
  ------------------
  893|      0|        PB_RETURN_ERROR(stream, "invalid extension");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  894|       |
  895|   137k|    if (iter.tag != tag || !iter.message)
  ------------------
  |  Branch (895:9): [True: 131k, False: 6.15k]
  |  Branch (895:28): [True: 0, False: 6.15k]
  ------------------
  896|   131k|        return true;
  897|       |
  898|  6.15k|    extension->found = true;
  899|  6.15k|    return decode_field(stream, wire_type, &iter);
  900|   137k|}
pb_decode.c:decode_field:
  857|  7.25M|{
  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|  7.25M|    switch (PB_ATYPE(field->type))
  ------------------
  |  |  326|  7.25M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  7.25M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
  869|  7.25M|    {
  870|  7.16M|        case PB_ATYPE_STATIC:
  ------------------
  |  |  321|  7.16M|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (870:9): [True: 7.16M, False: 83.0k]
  ------------------
  871|  7.16M|            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: 7.25M]
  ------------------
  874|      0|            return decode_pointer_field(stream, wire_type, field);
  875|       |        
  876|  83.0k|        case PB_ATYPE_CALLBACK:
  ------------------
  |  |  323|  83.0k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (876:9): [True: 83.0k, False: 7.16M]
  ------------------
  877|  83.0k|            return decode_callback_field(stream, wire_type, field);
  878|       |        
  879|      0|        default:
  ------------------
  |  Branch (879:9): [True: 0, False: 7.25M]
  ------------------
  880|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  881|  7.25M|    }
  882|  7.25M|}
pb_decode.c:decode_static_field:
  498|  7.16M|{
  499|  7.16M|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  327|  7.16M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  7.16M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  500|  7.16M|    {
  501|  6.41M|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  311|  6.41M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (501:9): [True: 6.41M, False: 758k]
  ------------------
  502|  6.41M|            return decode_basic_field(stream, wire_type, field);
  503|       |            
  504|   520k|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  312|   520k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (504:9): [True: 520k, False: 6.64M]
  ------------------
  505|   520k|            if (field->pSize != NULL)
  ------------------
  |  Branch (505:17): [True: 520k, False: 0]
  ------------------
  506|   520k|                *(bool*)field->pSize = true;
  507|   520k|            return decode_basic_field(stream, wire_type, field);
  508|       |    
  509|  32.1k|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  314|  32.1k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (509:9): [True: 32.1k, False: 7.13M]
  ------------------
  510|  32.1k|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (510:17): [True: 22.8k, False: 9.26k]
  ------------------
  511|  22.8k|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  328|  22.8k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  22.8k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  276|  22.8k|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (511:20): [True: 10.6k, False: 12.2k]
  ------------------
  512|  10.6k|            {
  513|       |                /* Packed array */
  514|  10.6k|                bool status = true;
  515|  10.6k|                pb_istream_t substream;
  516|  10.6k|                pb_size_t *size = (pb_size_t*)field->pSize;
  517|  10.6k|                field->pData = (char*)field->pField + field->data_size * (*size);
  518|       |
  519|  10.6k|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (519:21): [True: 68, False: 10.5k]
  ------------------
  520|     68|                    return false;
  521|       |
  522|  46.1k|                while (substream.bytes_left > 0 && *size < field->array_size)
  ------------------
  |  Branch (522:24): [True: 35.6k, False: 10.5k]
  |  Branch (522:52): [True: 35.6k, False: 24]
  ------------------
  523|  35.6k|                {
  524|  35.6k|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (524:25): [True: 30, False: 35.6k]
  ------------------
  525|     30|                    {
  526|     30|                        status = false;
  527|     30|                        break;
  528|     30|                    }
  529|  35.6k|                    (*size)++;
  530|  35.6k|                    field->pData = (char*)field->pData + field->data_size;
  531|  35.6k|                }
  532|       |
  533|  10.5k|                if (substream.bytes_left != 0)
  ------------------
  |  Branch (533:21): [True: 46, False: 10.5k]
  ------------------
  534|     46|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  923|     46|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     46|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 46]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  535|  10.5k|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (535:21): [True: 0, False: 10.5k]
  ------------------
  536|      0|                    return false;
  537|       |
  538|  10.5k|                return status;
  539|  10.5k|            }
  540|  21.5k|            else
  541|  21.5k|            {
  542|       |                /* Repeated field */
  543|  21.5k|                pb_size_t *size = (pb_size_t*)field->pSize;
  544|  21.5k|                field->pData = (char*)field->pField + field->data_size * (*size);
  545|       |
  546|  21.5k|                if ((*size)++ >= field->array_size)
  ------------------
  |  Branch (546:21): [True: 2, False: 21.5k]
  ------------------
  547|      2|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  923|      2|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      2|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  548|       |
  549|  21.5k|                return decode_basic_field(stream, wire_type, field);
  550|  21.5k|            }
  551|       |
  552|   205k|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  316|   205k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (552:9): [True: 205k, False: 6.96M]
  ------------------
  553|   205k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  329|   410k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|   205k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|   205k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|   410k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 158k, False: 47.1k]
  |  |  ------------------
  |  |  330|   410k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  47.1k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  47.1k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  47.1k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 46.9k, False: 290]
  |  |  ------------------
  ------------------
  554|   205k|                *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (554:17): [True: 118k, False: 86.8k]
  ------------------
  555|   118k|            {
  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|   118k|                memset(field->pData, 0, (size_t)field->data_size);
  564|       |
  565|       |                /* Set default values for the submessage fields. */
  566|   118k|                if (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (566:21): [True: 68.7k, False: 49.5k]
  ------------------
  567|  49.5k|                    field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (567:21): [True: 0, False: 49.5k]
  ------------------
  568|  49.5k|                    field->submsg_desc->submsg_info[0] != NULL)
  ------------------
  |  Branch (568:21): [True: 0, False: 49.5k]
  ------------------
  569|  68.7k|                {
  570|  68.7k|                    pb_field_iter_t submsg_iter;
  571|  68.7k|                    if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (571:25): [True: 68.7k, False: 0]
  ------------------
  572|  68.7k|                    {
  573|  68.7k|                        if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (573:29): [True: 0, False: 68.7k]
  ------------------
  574|      0|                            PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  575|  68.7k|                    }
  576|  68.7k|                }
  577|   118k|            }
  578|   205k|            *(pb_size_t*)field->pSize = field->tag;
  579|       |
  580|   205k|            return decode_basic_field(stream, wire_type, field);
  581|       |
  582|      0|        default:
  ------------------
  |  Branch (582:9): [True: 0, False: 7.16M]
  ------------------
  583|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  584|  7.16M|    }
  585|  7.16M|}
pb_decode.c:decode_basic_field:
  427|  7.19M|{
  428|  7.19M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  328|  7.19M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  7.19M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  429|  7.19M|    {
  430|   342k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  268|   342k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (430:9): [True: 342k, False: 6.85M]
  ------------------
  431|   342k|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (431:17): [True: 1.41k, False: 340k]
  |  Branch (431:46): [True: 7, False: 1.40k]
  ------------------
  432|      7|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|      7|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      7|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  433|       |
  434|   342k|            return pb_dec_bool(stream, field);
  435|       |
  436|  5.08M|        case PB_LTYPE_VARINT:
  ------------------
  |  |  269|  5.08M|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (436:9): [True: 5.08M, False: 2.10M]
  ------------------
  437|  5.47M|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  270|  5.47M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (437:9): [True: 388k, False: 6.80M]
  ------------------
  438|  5.65M|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  271|  5.65M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (438:9): [True: 178k, False: 7.01M]
  ------------------
  439|  5.65M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (439:17): [True: 23.6k, False: 5.63M]
  |  Branch (439:46): [True: 53, False: 23.5k]
  ------------------
  440|     53|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     53|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     53|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 53]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  441|       |
  442|  5.65M|            return pb_dec_varint(stream, field);
  443|       |
  444|   317k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  272|   317k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (444:9): [True: 317k, False: 6.87M]
  ------------------
  445|   317k|            if (wire_type != PB_WT_32BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (445:17): [True: 5.72k, False: 311k]
  |  Branch (445:45): [True: 15, False: 5.71k]
  ------------------
  446|     15|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     15|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     15|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  447|       |
  448|   317k|            return pb_decode_fixed32(stream, field->pData);
  449|       |
  450|   262k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  273|   262k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (450:9): [True: 262k, False: 6.93M]
  ------------------
  451|   262k|            if (wire_type != PB_WT_64BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (451:17): [True: 4.96k, False: 257k]
  |  Branch (451:45): [True: 12, False: 4.95k]
  ------------------
  452|     12|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     12|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     12|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|   262k|            return pb_decode_fixed64(stream, field->pData);
  465|      0|#endif
  466|       |
  467|  50.0k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  280|  50.0k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (467:9): [True: 50.0k, False: 7.14M]
  ------------------
  468|  50.0k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (468:17): [True: 14, False: 49.9k]
  ------------------
  469|     14|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     14|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     14|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  470|       |
  471|  49.9k|            return pb_dec_bytes(stream, field);
  472|       |
  473|   218k|        case PB_LTYPE_STRING:
  ------------------
  |  |  284|   218k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (473:9): [True: 218k, False: 6.97M]
  ------------------
  474|   218k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (474:17): [True: 8, False: 218k]
  ------------------
  475|      8|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|      8|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      8|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  476|       |
  477|   218k|            return pb_dec_string(stream, field);
  478|       |
  479|   273k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  288|   273k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (479:9): [True: 273k, False: 6.92M]
  ------------------
  480|   320k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  293|   320k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (480:9): [True: 46.9k, False: 7.14M]
  ------------------
  481|   320k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (481:17): [True: 15, False: 319k]
  ------------------
  482|     15|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|     15|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     15|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  483|       |
  484|   319k|            return pb_dec_submessage(stream, field);
  485|       |
  486|  28.9k|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  303|  28.9k|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (486:9): [True: 28.9k, False: 7.16M]
  ------------------
  487|  28.9k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (487:17): [True: 3, False: 28.9k]
  ------------------
  488|      3|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  923|      3|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      3|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  489|       |
  490|  28.9k|            return pb_dec_fixed_length_bytes(stream, field);
  491|       |
  492|      0|        default:
  ------------------
  |  Branch (492:9): [True: 0, False: 7.19M]
  ------------------
  493|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  494|  7.19M|    }
  495|  7.19M|}
pb_decode.c:pb_dec_bool:
 1477|   342k|{
 1478|   342k|    return pb_decode_bool(stream, (bool*)field->pData);
 1479|   342k|}
pb_decode.c:pb_dec_varint:
 1482|  5.65M|{
 1483|  5.65M|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  328|  5.65M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  5.65M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  270|  5.65M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (1483:9): [True: 388k, False: 5.26M]
  ------------------
 1484|   388k|    {
 1485|   388k|        pb_uint64_t value, clamped;
  ------------------
  |  |   57|   388k|#define pb_uint64_t uint64_t
  ------------------
 1486|   388k|        if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1486:13): [True: 18, False: 388k]
  ------------------
 1487|     18|            return false;
 1488|       |
 1489|       |        /* Cast to the proper field size, while checking for overflows */
 1490|   388k|        if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (1490:13): [True: 174k, False: 214k]
  ------------------
 1491|   174k|            clamped = *(pb_uint64_t*)field->pData = value;
 1492|   214k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (1492:18): [True: 188k, False: 26.1k]
  ------------------
 1493|   188k|            clamped = *(uint32_t*)field->pData = (uint32_t)value;
 1494|  26.1k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (1494:18): [True: 13.0k, False: 13.1k]
  ------------------
 1495|  13.0k|            clamped = *(uint_least16_t*)field->pData = (uint_least16_t)value;
 1496|  13.1k|        else if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (1496:18): [True: 13.1k, False: 0]
  ------------------
 1497|  13.1k|            clamped = *(uint_least8_t*)field->pData = (uint_least8_t)value;
 1498|      0|        else
 1499|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1500|       |
 1501|   388k|        if (clamped != value)
  ------------------
  |  Branch (1501:13): [True: 114, False: 388k]
  ------------------
 1502|    114|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  923|    114|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|    114|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 114]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1503|       |
 1504|   388k|        return true;
 1505|   388k|    }
 1506|  5.26M|    else
 1507|  5.26M|    {
 1508|  5.26M|        pb_uint64_t value;
  ------------------
  |  |   57|  5.26M|#define pb_uint64_t uint64_t
  ------------------
 1509|  5.26M|        pb_int64_t svalue;
  ------------------
  |  |   56|  5.26M|#define pb_int64_t int64_t
  ------------------
 1510|  5.26M|        pb_int64_t clamped;
  ------------------
  |  |   56|  5.26M|#define pb_int64_t int64_t
  ------------------
 1511|       |
 1512|  5.26M|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  328|  5.26M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  5.26M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  271|  5.26M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (1512:13): [True: 178k, False: 5.08M]
  ------------------
 1513|   178k|        {
 1514|   178k|            if (!pb_decode_svarint(stream, &svalue))
  ------------------
  |  Branch (1514:17): [True: 23, False: 178k]
  ------------------
 1515|     23|                return false;
 1516|   178k|        }
 1517|  5.08M|        else
 1518|  5.08M|        {
 1519|  5.08M|            if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1519:17): [True: 46, False: 5.08M]
  ------------------
 1520|     46|                return false;
 1521|       |
 1522|       |            /* See issue 97: Google's C++ protobuf allows negative varint values to
 1523|       |            * be cast as int32_t, instead of the int64_t that should be used when
 1524|       |            * encoding. Nanopb versions before 0.2.5 had a bug in encoding. In order to
 1525|       |            * not break decoding of such messages, we cast <=32 bit fields to
 1526|       |            * int32_t first to get the sign correct.
 1527|       |            */
 1528|  5.08M|            if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1528:17): [True: 163k, False: 4.92M]
  ------------------
 1529|   163k|                svalue = (pb_int64_t)value;
 1530|  4.92M|            else
 1531|  4.92M|                svalue = (int32_t)value;
 1532|  5.08M|        }
 1533|       |
 1534|       |        /* Cast to the proper field size, while checking for overflows */
 1535|  5.26M|        if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1535:13): [True: 243k, False: 5.02M]
  ------------------
 1536|   243k|            clamped = *(pb_int64_t*)field->pData = svalue;
 1537|  5.02M|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (1537:18): [True: 4.96M, False: 51.9k]
  ------------------
 1538|  4.96M|            clamped = *(int32_t*)field->pData = (int32_t)svalue;
 1539|  51.9k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (1539:18): [True: 25.9k, False: 25.9k]
  ------------------
 1540|  25.9k|            clamped = *(int_least16_t*)field->pData = (int_least16_t)svalue;
 1541|  25.9k|        else if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (1541:18): [True: 25.9k, False: 0]
  ------------------
 1542|  25.9k|            clamped = *(int_least8_t*)field->pData = (int_least8_t)svalue;
 1543|      0|        else
 1544|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1545|       |
 1546|  5.26M|        if (clamped != svalue)
  ------------------
  |  Branch (1546:13): [True: 96, False: 5.26M]
  ------------------
 1547|     96|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  923|     96|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     96|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 96]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1548|       |
 1549|  5.26M|        return true;
 1550|  5.26M|    }
 1551|  5.65M|}
pb_decode.c:pb_dec_bytes:
 1554|  49.9k|{
 1555|  49.9k|    uint32_t size;
 1556|  49.9k|    size_t alloc_size;
 1557|  49.9k|    pb_bytes_array_t *dest;
 1558|       |    
 1559|  49.9k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1559:9): [True: 6, False: 49.9k]
  ------------------
 1560|      6|        return false;
 1561|       |    
 1562|  49.9k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  342|  49.9k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1562:9): [True: 32, False: 49.9k]
  ------------------
 1563|     32|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  923|     32|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     32|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1564|       |    
 1565|  49.9k|    alloc_size = PB_BYTES_ARRAY_T_ALLOCSIZE(size);
  ------------------
  |  |  406|  49.9k|#define PB_BYTES_ARRAY_T_ALLOCSIZE(n) ((size_t)n + offsetof(pb_bytes_array_t, bytes))
  ------------------
 1566|  49.9k|    if (size > alloc_size)
  ------------------
  |  Branch (1566:9): [True: 0, False: 49.9k]
  ------------------
 1567|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1568|       |    
 1569|  49.9k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  49.9k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  49.9k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  49.9k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1569:9): [True: 0, False: 49.9k]
  ------------------
 1570|      0|    {
 1571|      0|#ifndef PB_ENABLE_MALLOC
 1572|      0|        PB_RETURN_ERROR(stream, "no malloc support");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1573|       |#else
 1574|       |        if (stream->bytes_left < size)
 1575|       |            PB_RETURN_ERROR(stream, "end-of-stream");
 1576|       |
 1577|       |        if (!allocate_field(stream, field->pData, alloc_size, 1))
 1578|       |            return false;
 1579|       |        dest = *(pb_bytes_array_t**)field->pData;
 1580|       |#endif
 1581|      0|    }
 1582|  49.9k|    else
 1583|  49.9k|    {
 1584|  49.9k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1584:13): [True: 46, False: 49.9k]
  ------------------
 1585|     46|            PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  923|     46|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     46|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 46]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1586|  49.9k|        dest = (pb_bytes_array_t*)field->pData;
 1587|  49.9k|    }
 1588|       |
 1589|  49.9k|    dest->size = (pb_size_t)size;
 1590|  49.9k|    return pb_read(stream, dest->bytes, (size_t)size);
 1591|  49.9k|}
pb_decode.c:pb_dec_string:
 1594|   218k|{
 1595|   218k|    uint32_t size;
 1596|   218k|    size_t alloc_size;
 1597|   218k|    pb_byte_t *dest = (pb_byte_t*)field->pData;
 1598|       |
 1599|   218k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1599:9): [True: 4, False: 218k]
  ------------------
 1600|      4|        return false;
 1601|       |
 1602|   218k|    if (size == (uint32_t)-1)
  ------------------
  |  Branch (1602:9): [True: 2, False: 218k]
  ------------------
 1603|      2|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  923|      2|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      2|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1604|       |
 1605|       |    /* Space for null terminator */
 1606|   218k|    alloc_size = (size_t)(size + 1);
 1607|       |
 1608|   218k|    if (alloc_size < size)
  ------------------
  |  Branch (1608:9): [True: 0, False: 218k]
  ------------------
 1609|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1610|       |
 1611|   218k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   218k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   218k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   218k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1611:9): [True: 0, False: 218k]
  ------------------
 1612|      0|    {
 1613|      0|#ifndef PB_ENABLE_MALLOC
 1614|      0|        PB_RETURN_ERROR(stream, "no malloc support");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1615|       |#else
 1616|       |        if (stream->bytes_left < size)
 1617|       |            PB_RETURN_ERROR(stream, "end-of-stream");
 1618|       |
 1619|       |        if (!allocate_field(stream, field->pData, alloc_size, 1))
 1620|       |            return false;
 1621|       |        dest = *(pb_byte_t**)field->pData;
 1622|       |#endif
 1623|      0|    }
 1624|   218k|    else
 1625|   218k|    {
 1626|   218k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1626:13): [True: 96, False: 218k]
  ------------------
 1627|     96|            PB_RETURN_ERROR(stream, "string overflow");
  ------------------
  |  |  923|     96|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     96|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 96]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1628|   218k|    }
 1629|       |    
 1630|   218k|    dest[size] = 0;
 1631|       |
 1632|   218k|    if (!pb_read(stream, dest, (size_t)size))
  ------------------
  |  Branch (1632:9): [True: 8, False: 218k]
  ------------------
 1633|      8|        return false;
 1634|       |
 1635|       |#ifdef PB_VALIDATE_UTF8
 1636|       |    if (!pb_validate_utf8((const char*)dest))
 1637|       |        PB_RETURN_ERROR(stream, "invalid utf8");
 1638|       |#endif
 1639|       |
 1640|   218k|    return true;
 1641|   218k|}
pb_decode.c:pb_dec_submessage:
 1644|   319k|{
 1645|   319k|    bool status = true;
 1646|   319k|    bool submsg_consumed = false;
 1647|   319k|    pb_istream_t substream;
 1648|       |
 1649|   319k|    if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1649:9): [True: 97, False: 319k]
  ------------------
 1650|     97|        return false;
 1651|       |    
 1652|   319k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (1652:9): [True: 0, False: 319k]
  ------------------
 1653|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1654|       |    
 1655|       |    /* Submessages can have a separate message-level callback that is called
 1656|       |     * before decoding the message. Typically it is used to set callback fields
 1657|       |     * inside oneofs. */
 1658|   319k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  328|   319k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   319k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  293|   639k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (1658:9): [True: 46.9k, False: 272k]
  |  Branch (1658:58): [True: 46.9k, False: 0]
  ------------------
 1659|  46.9k|    {
 1660|       |        /* Message callback is stored right before pSize. */
 1661|  46.9k|        pb_callback_t *callback = (pb_callback_t*)field->pSize - 1;
 1662|  46.9k|        if (callback->funcs.decode)
  ------------------
  |  Branch (1662:13): [True: 46.9k, False: 0]
  ------------------
 1663|  46.9k|        {
 1664|  46.9k|            status = callback->funcs.decode(&substream, field, &callback->arg);
 1665|       |
 1666|  46.9k|            if (substream.bytes_left == 0)
  ------------------
  |  Branch (1666:17): [True: 27.2k, False: 19.6k]
  ------------------
 1667|  27.2k|            {
 1668|  27.2k|                submsg_consumed = true;
 1669|  27.2k|            }
 1670|  46.9k|        }
 1671|  46.9k|    }
 1672|       |
 1673|       |    /* Now decode the submessage contents */
 1674|   319k|    if (status && !submsg_consumed)
  ------------------
  |  Branch (1674:9): [True: 319k, False: 0]
  |  Branch (1674:19): [True: 292k, False: 27.2k]
  ------------------
 1675|   292k|    {
 1676|   292k|        unsigned int flags = 0;
 1677|       |
 1678|       |        /* Static required/optional fields are already initialized by top-level
 1679|       |         * pb_decode(), no need to initialize them again. */
 1680|   292k|        if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  326|   292k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   292k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  321|   585k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1680:13): [True: 292k, False: 0]
  ------------------
 1681|   292k|            PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  327|   292k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   292k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  314|   292k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1681:13): [True: 287k, False: 5.21k]
  ------------------
 1682|   287k|        {
 1683|   287k|            flags = PB_DECODE_NOINIT;
  ------------------
  |  |  122|   287k|#define PB_DECODE_NOINIT          0x01U
  ------------------
 1684|   287k|        }
 1685|       |
 1686|   292k|        status = pb_decode_inner(&substream, field->submsg_desc, field->pData, flags);
 1687|   292k|    }
 1688|       |    
 1689|   319k|    if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1689:9): [True: 0, False: 319k]
  ------------------
 1690|      0|        return false;
 1691|       |
 1692|   319k|    return status;
 1693|   319k|}
pb_decode.c:pb_dec_fixed_length_bytes:
 1696|  28.9k|{
 1697|  28.9k|    uint32_t size;
 1698|       |
 1699|  28.9k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1699:9): [True: 6, False: 28.9k]
  ------------------
 1700|      6|        return false;
 1701|       |
 1702|  28.9k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  342|  28.9k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1702:9): [True: 31, False: 28.9k]
  ------------------
 1703|     31|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  923|     31|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     31|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 31]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1704|       |
 1705|  28.9k|    if (size == 0)
  ------------------
  |  Branch (1705:9): [True: 16.4k, False: 12.4k]
  ------------------
 1706|  16.4k|    {
 1707|       |        /* As a special case, treat empty bytes string as all zeros for fixed_length_bytes. */
 1708|  16.4k|        memset(field->pData, 0, (size_t)field->data_size);
 1709|  16.4k|        return true;
 1710|  16.4k|    }
 1711|       |
 1712|  12.4k|    if (size != field->data_size)
  ------------------
  |  Branch (1712:9): [True: 46, False: 12.4k]
  ------------------
 1713|     46|        PB_RETURN_ERROR(stream, "incorrect fixed length bytes size");
  ------------------
  |  |  923|     46|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|     46|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 46]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1714|       |
 1715|  12.4k|    return pb_read(stream, (pb_byte_t*)field->pData, (size_t)field->data_size);
 1716|  12.4k|}
pb_decode.c:decode_callback_field:
  783|  83.0k|{
  784|       |    /* Clear any data that may have been decoded for another oneof field
  785|       |     * that has come before this callback field.
  786|       |     */
  787|  83.0k|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  83.0k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  83.0k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  83.0k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (787:9): [True: 11.9k, False: 71.0k]
  ------------------
  788|  11.9k|    {
  789|  11.9k|        if (*(pb_size_t*)field->pSize != 0 && *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (789:13): [True: 11.4k, False: 501]
  |  Branch (789:47): [True: 1.58k, False: 9.91k]
  ------------------
  790|  1.58k|        {
  791|  1.58k|            memset(field->pData, 0, (size_t)field->data_size);
  792|  1.58k|        }
  793|  11.9k|        *(pb_size_t*)field->pSize = field->tag;
  794|  11.9k|    }
  795|       |
  796|  83.0k|    if (!field->descriptor->field_callback)
  ------------------
  |  Branch (796:9): [True: 0, False: 83.0k]
  ------------------
  797|      0|        return pb_skip_field(stream, wire_type);
  798|       |
  799|  83.0k|    if (wire_type == PB_WT_STRING)
  ------------------
  |  Branch (799:9): [True: 64.7k, False: 18.3k]
  ------------------
  800|  64.7k|    {
  801|  64.7k|        pb_istream_t substream;
  802|  64.7k|        size_t prev_bytes_left;
  803|       |        
  804|  64.7k|        if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (804:13): [True: 39, False: 64.6k]
  ------------------
  805|     39|            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|  64.6k|        if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  328|  64.6k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  64.6k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  293|   129k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (809:13): [True: 0, False: 64.6k]
  |  Branch (809:62): [True: 0, False: 0]
  ------------------
  810|      0|            pb_callback_t* callback;
  811|      0|            *(pb_size_t*)field->pSize = field->tag;
  812|      0|            callback = (pb_callback_t*)field->pSize - 1;
  813|       |
  814|      0|            if (callback->funcs.decode)
  ------------------
  |  Branch (814:17): [True: 0, False: 0]
  ------------------
  815|      0|            {
  816|      0|                if (!callback->funcs.decode(&substream, field, &callback->arg)) {
  ------------------
  |  Branch (816:21): [True: 0, False: 0]
  ------------------
  817|      0|                    PB_SET_ERROR(stream, substream.errmsg ? substream.errmsg : "submsg callback failed");
  ------------------
  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  ------------------
  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  Branch (919:92): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  818|      0|                    return false;
  819|      0|                }
  820|      0|            }
  821|      0|        }
  822|       |        
  823|  64.6k|        do
  824|  64.6k|        {
  825|  64.6k|            prev_bytes_left = substream.bytes_left;
  826|  64.6k|            if (!field->descriptor->field_callback(&substream, NULL, field))
  ------------------
  |  Branch (826:17): [True: 0, False: 64.6k]
  ------------------
  827|      0|            {
  828|      0|                PB_SET_ERROR(stream, substream.errmsg ? substream.errmsg : "callback failed");
  ------------------
  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  ------------------
  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  Branch (919:92): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  829|      0|                return false;
  830|      0|            }
  831|  64.6k|        } while (substream.bytes_left > 0 && substream.bytes_left < prev_bytes_left);
  ------------------
  |  Branch (831:18): [True: 24.8k, False: 39.8k]
  |  Branch (831:46): [True: 0, False: 24.8k]
  ------------------
  832|       |        
  833|  64.6k|        if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (833:13): [True: 0, False: 64.6k]
  ------------------
  834|      0|            return false;
  835|       |
  836|  64.6k|        return true;
  837|  64.6k|    }
  838|  18.3k|    else
  839|  18.3k|    {
  840|       |        /* Copy the single scalar value to stack.
  841|       |         * This is required so that we can limit the stream length,
  842|       |         * which in turn allows to use same callback for packed and
  843|       |         * not-packed fields. */
  844|  18.3k|        pb_istream_t substream;
  845|  18.3k|        pb_byte_t buffer[10];
  846|  18.3k|        size_t size = sizeof(buffer);
  847|       |        
  848|  18.3k|        if (!read_raw_value(stream, wire_type, buffer, &size))
  ------------------
  |  Branch (848:13): [True: 45, False: 18.2k]
  ------------------
  849|     45|            return false;
  850|  18.2k|        substream = pb_istream_from_buffer(buffer, size);
  851|       |        
  852|       |        return field->descriptor->field_callback(&substream, NULL, field);
  853|  18.3k|    }
  854|  83.0k|}
pb_decode.c:read_raw_value:
  342|  18.3k|{
  343|  18.3k|    size_t max_size = *size;
  344|  18.3k|    switch (wire_type)
  345|  18.3k|    {
  346|  12.5k|        case PB_WT_VARINT:
  ------------------
  |  Branch (346:9): [True: 12.5k, False: 5.73k]
  ------------------
  347|  12.5k|            *size = 0;
  348|  12.5k|            do
  349|  29.8k|            {
  350|  29.8k|                (*size)++;
  351|  29.8k|                if (*size > max_size)
  ------------------
  |  Branch (351:21): [True: 3, False: 29.8k]
  ------------------
  352|      3|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  923|      3|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      3|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  353|       |
  354|  29.8k|                if (!pb_read(stream, buf, 1))
  ------------------
  |  Branch (354:21): [True: 24, False: 29.8k]
  ------------------
  355|     24|                    return false;
  356|  29.8k|            } while (*buf++ & 0x80);
  ------------------
  |  Branch (356:22): [True: 17.3k, False: 12.5k]
  ------------------
  357|  12.5k|            return true;
  358|       |            
  359|  4.79k|        case PB_WT_64BIT:
  ------------------
  |  Branch (359:9): [True: 4.79k, False: 13.5k]
  ------------------
  360|  4.79k|            *size = 8;
  361|  4.79k|            return pb_read(stream, buf, 8);
  362|       |        
  363|    942|        case PB_WT_32BIT:
  ------------------
  |  Branch (363:9): [True: 942, False: 17.3k]
  ------------------
  364|    942|            *size = 4;
  365|    942|            return pb_read(stream, buf, 4);
  366|       |        
  367|      0|        case PB_WT_STRING:
  ------------------
  |  Branch (367:9): [True: 0, False: 18.3k]
  ------------------
  368|       |            /* Calling read_raw_value with a PB_WT_STRING is an error.
  369|       |             * Explicitly handle this case and fallthrough to default to avoid
  370|       |             * compiler warnings.
  371|       |             */
  372|       |
  373|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (373:2): [True: 0, False: 18.3k]
  ------------------
  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|      3|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  923|      3|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      3|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (379:9): [True: 3, False: 18.3k]
  ------------------
  380|  18.3k|    }
  381|  18.3k|}

pb_ostream_from_buffer:
   73|  2.65k|{
   74|  2.65k|    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.65k|    stream.callback = &buf_write;
   83|  2.65k|#endif
   84|  2.65k|    stream.state = buf;
   85|  2.65k|    stream.max_size = bufsize;
   86|  2.65k|    stream.bytes_written = 0;
   87|  2.65k|#ifndef PB_NO_ERRMSG
   88|       |    stream.errmsg = NULL;
   89|  2.65k|#endif
   90|  2.65k|    return stream;
   91|  2.65k|}
pb_write:
   94|   502k|{
   95|   502k|    if (count > 0 && stream->callback != NULL)
  ------------------
  |  Branch (95:9): [True: 488k, False: 13.4k]
  |  Branch (95:22): [True: 338k, False: 150k]
  ------------------
   96|   338k|    {
   97|   338k|        if (stream->bytes_written + count < stream->bytes_written ||
  ------------------
  |  Branch (97:13): [True: 0, False: 338k]
  ------------------
   98|   338k|            stream->bytes_written + count > stream->max_size)
  ------------------
  |  Branch (98:13): [True: 0, False: 338k]
  ------------------
   99|      0|        {
  100|      0|            PB_RETURN_ERROR(stream, "stream full");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  101|      0|        }
  102|       |
  103|       |#ifdef PB_BUFFER_ONLY
  104|       |        if (!buf_write(stream, buf, count))
  105|       |            PB_RETURN_ERROR(stream, "io error");
  106|       |#else        
  107|   338k|        if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (107:13): [True: 0, False: 338k]
  ------------------
  108|      0|            PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  109|   338k|#endif
  110|   338k|    }
  111|       |    
  112|   502k|    stream->bytes_written += count;
  113|       |    return true;
  114|   502k|}
pb_encode:
  522|  42.2k|{
  523|  42.2k|    pb_field_iter_t iter;
  524|  42.2k|    if (!pb_field_iter_begin_const(&iter, fields, src_struct))
  ------------------
  |  Branch (524:9): [True: 8.00k, False: 34.2k]
  ------------------
  525|  8.00k|        return true; /* Empty message type */
  526|       |    
  527|   328k|    do {
  528|   328k|        if (PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|   328k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   328k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|   328k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (528:13): [True: 2.65k, False: 325k]
  ------------------
  529|  2.65k|        {
  530|       |            /* Special case for the extension field placeholder */
  531|  2.65k|            if (!encode_extension_field(stream, &iter))
  ------------------
  |  Branch (531:17): [True: 0, False: 2.65k]
  ------------------
  532|      0|                return false;
  533|  2.65k|        }
  534|   325k|        else
  535|   325k|        {
  536|       |            /* Regular field */
  537|   325k|            if (!encode_field(stream, &iter))
  ------------------
  |  Branch (537:17): [True: 0, False: 325k]
  ------------------
  538|      0|                return false;
  539|   325k|        }
  540|   328k|    } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (540:14): [True: 294k, False: 34.2k]
  ------------------
  541|       |    
  542|  34.2k|    return true;
  543|  34.2k|}
pb_encode_varint:
  617|   446k|{
  618|   446k|    if (value <= 0x7F)
  ------------------
  |  Branch (618:9): [True: 367k, False: 78.3k]
  ------------------
  619|   367k|    {
  620|       |        /* Fast path: single byte */
  621|   367k|        pb_byte_t byte = (pb_byte_t)value;
  622|   367k|        return pb_write(stream, &byte, 1);
  623|   367k|    }
  624|  78.3k|    else
  625|  78.3k|    {
  626|       |#ifdef PB_WITHOUT_64BIT
  627|       |        return pb_encode_varint_32(stream, value, 0);
  628|       |#else
  629|  78.3k|        return pb_encode_varint_32(stream, (uint32_t)value, (uint32_t)(value >> 32));
  630|  78.3k|#endif
  631|  78.3k|    }
  632|   446k|}
pb_encode_svarint:
  635|  22.7k|{
  636|  22.7k|    pb_uint64_t zigzagged;
  ------------------
  |  |   46|  22.7k|#define pb_uint64_t uint64_t
  ------------------
  637|  22.7k|    pb_uint64_t mask = ((pb_uint64_t)-1) >> 1; /* Satisfy clang -fsanitize=integer */
  ------------------
  |  |   46|  22.7k|#define pb_uint64_t uint64_t
  ------------------
  638|  22.7k|    if (value < 0)
  ------------------
  |  Branch (638:9): [True: 9.67k, False: 13.1k]
  ------------------
  639|  9.67k|        zigzagged = ~(((pb_uint64_t)value & mask) << 1);
  640|  13.1k|    else
  641|  13.1k|        zigzagged = (pb_uint64_t)value << 1;
  642|       |    
  643|  22.7k|    return pb_encode_varint(stream, zigzagged);
  644|  22.7k|}
pb_encode_fixed32:
  647|  20.6k|{
  648|  20.6k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
  649|       |    /* Fast path if we know that we're on little endian */
  650|  20.6k|    return pb_write(stream, (const pb_byte_t*)value, 4);
  651|       |#else
  652|       |    uint32_t val = *(const uint32_t*)value;
  653|       |    pb_byte_t bytes[4];
  654|       |    bytes[0] = (pb_byte_t)(val & 0xFF);
  655|       |    bytes[1] = (pb_byte_t)((val >> 8) & 0xFF);
  656|       |    bytes[2] = (pb_byte_t)((val >> 16) & 0xFF);
  657|       |    bytes[3] = (pb_byte_t)((val >> 24) & 0xFF);
  658|       |    return pb_write(stream, bytes, 4);
  659|       |#endif
  660|  20.6k|}
pb_encode_fixed64:
  664|  11.9k|{
  665|  11.9k|#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.9k|    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.9k|}
pb_encode_tag:
  685|   209k|{
  686|   209k|    pb_uint64_t tag = ((pb_uint64_t)field_number << 3) | wiretype;
  ------------------
  |  |   46|   209k|#define pb_uint64_t uint64_t
  ------------------
  687|   209k|    return pb_encode_varint(stream, tag);
  688|   209k|}
pb_encode_tag_for_field:
  691|   200k|{
  692|   200k|    pb_wire_type_t wiretype;
  693|   200k|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  328|   200k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   200k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  694|   200k|    {
  695|  2.80k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  268|  2.80k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (695:9): [True: 2.80k, False: 197k]
  ------------------
  696|  79.8k|        case PB_LTYPE_VARINT:
  ------------------
  |  |  269|  79.8k|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (696:9): [True: 77.0k, False: 123k]
  ------------------
  697|   120k|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  270|   120k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (697:9): [True: 40.7k, False: 159k]
  ------------------
  698|   136k|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  271|   136k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (698:9): [True: 16.2k, False: 183k]
  ------------------
  699|   136k|            wiretype = PB_WT_VARINT;
  700|   136k|            break;
  701|       |        
  702|  11.3k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  272|  11.3k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (702:9): [True: 11.3k, False: 188k]
  ------------------
  703|  11.3k|            wiretype = PB_WT_32BIT;
  704|  11.3k|            break;
  705|       |        
  706|  8.98k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  273|  8.98k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (706:9): [True: 8.98k, False: 191k]
  ------------------
  707|  8.98k|            wiretype = PB_WT_64BIT;
  708|  8.98k|            break;
  709|       |        
  710|  3.88k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  280|  3.88k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (710:9): [True: 3.88k, False: 196k]
  ------------------
  711|  19.0k|        case PB_LTYPE_STRING:
  ------------------
  |  |  284|  19.0k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (711:9): [True: 15.1k, False: 184k]
  ------------------
  712|  38.8k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  288|  38.8k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (712:9): [True: 19.7k, False: 180k]
  ------------------
  713|  38.8k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  293|  38.8k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (713:9): [True: 0, False: 200k]
  ------------------
  714|  43.0k|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  303|  43.0k|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (714:9): [True: 4.16k, False: 195k]
  ------------------
  715|  43.0k|            wiretype = PB_WT_STRING;
  716|  43.0k|            break;
  717|       |        
  718|      0|        default:
  ------------------
  |  Branch (718:9): [True: 0, False: 200k]
  ------------------
  719|      0|            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  720|   200k|    }
  721|       |    
  722|   200k|    return pb_encode_tag(stream, wiretype, field->tag);
  723|   200k|}
pb_encode_string:
  726|  23.2k|{
  727|  23.2k|    if (!pb_encode_varint(stream, (pb_uint64_t)size))
  ------------------
  |  Branch (727:9): [True: 0, False: 23.2k]
  ------------------
  728|      0|        return false;
  729|       |    
  730|  23.2k|    return pb_write(stream, buffer, size);
  731|  23.2k|}
pb_encode_submessage:
  734|  19.7k|{
  735|       |    /* First calculate the message size using a non-writing substream. */
  736|  19.7k|    pb_ostream_t substream = PB_OSTREAM_SIZING;
  ------------------
  |  |  126|  19.7k|#define PB_OSTREAM_SIZING {0,0,0,0,0}
  ------------------
  737|  19.7k|#if !defined(PB_NO_ENCODE_SIZE_CHECK) || PB_NO_ENCODE_SIZE_CHECK == 0
  738|  19.7k|    bool status;
  739|  19.7k|    size_t size;
  740|  19.7k|#endif
  741|       |    
  742|  19.7k|    if (!pb_encode(&substream, fields, src_struct))
  ------------------
  |  Branch (742:9): [True: 0, False: 19.7k]
  ------------------
  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.7k|    if (!pb_encode_varint(stream, (pb_uint64_t)substream.bytes_written))
  ------------------
  |  Branch (750:9): [True: 0, False: 19.7k]
  ------------------
  751|      0|        return false;
  752|       |    
  753|  19.7k|    if (stream->callback == NULL)
  ------------------
  |  Branch (753:9): [True: 0, False: 19.7k]
  ------------------
  754|      0|        return pb_write(stream, NULL, substream.bytes_written); /* Just sizing */
  755|       |    
  756|  19.7k|    if (stream->bytes_written + substream.bytes_written > stream->max_size)
  ------------------
  |  Branch (756:9): [True: 0, False: 19.7k]
  ------------------
  757|      0|        PB_RETURN_ERROR(stream, "stream full");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  758|       |        
  759|       |#if defined(PB_NO_ENCODE_SIZE_CHECK) && PB_NO_ENCODE_SIZE_CHECK == 1
  760|       |    return pb_encode(stream, fields, src_struct);
  761|       |#else
  762|  19.7k|    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.7k|    substream.callback = stream->callback;
  766|  19.7k|    substream.state = stream->state;
  767|  19.7k|    substream.max_size = size;
  768|  19.7k|    substream.bytes_written = 0;
  769|  19.7k|#ifndef PB_NO_ERRMSG
  770|  19.7k|    substream.errmsg = NULL;
  771|  19.7k|#endif
  772|       |    
  773|  19.7k|    status = pb_encode(&substream, fields, src_struct);
  774|       |    
  775|  19.7k|    stream->bytes_written += substream.bytes_written;
  776|  19.7k|    stream->state = substream.state;
  777|  19.7k|#ifndef PB_NO_ERRMSG
  778|  19.7k|    stream->errmsg = substream.errmsg;
  779|  19.7k|#endif
  780|       |    
  781|  19.7k|    if (substream.bytes_written != size)
  ------------------
  |  Branch (781:9): [True: 0, False: 19.7k]
  ------------------
  782|      0|        PB_RETURN_ERROR(stream, "submsg size changed");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  783|       |
  784|  19.7k|    return status;
  785|  19.7k|#endif
  786|  19.7k|}
pb_encode.c:buf_write:
   54|   338k|{
   55|   338k|    pb_byte_t *dest = (pb_byte_t*)stream->state;
   56|   338k|    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|   338k|    if (buf != NULL)
  ------------------
  |  Branch (64:9): [True: 338k, False: 0]
  ------------------
   65|   338k|    {
   66|   338k|        memcpy(dest, buf, count * sizeof(pb_byte_t));
   67|   338k|    }
   68|       |
   69|       |    return true;
   70|   338k|}
pb_encode.c:encode_extension_field:
  497|  2.65k|{
  498|  2.65k|    const pb_extension_t *extension = *(const pb_extension_t* const *)field->pData;
  499|       |
  500|  5.31k|    while (extension)
  ------------------
  |  Branch (500:12): [True: 2.65k, False: 2.65k]
  ------------------
  501|  2.65k|    {
  502|  2.65k|        bool status;
  503|  2.65k|        if (extension->type->encode)
  ------------------
  |  Branch (503:13): [True: 0, False: 2.65k]
  ------------------
  504|      0|            status = extension->type->encode(stream, extension);
  505|  2.65k|        else
  506|  2.65k|            status = default_extension_encoder(stream, extension);
  507|       |
  508|  2.65k|        if (!status)
  ------------------
  |  Branch (508:13): [True: 0, False: 2.65k]
  ------------------
  509|      0|            return false;
  510|       |        
  511|  2.65k|        extension = extension->next;
  512|  2.65k|    }
  513|       |    
  514|  2.65k|    return true;
  515|  2.65k|}
pb_encode.c:default_extension_encoder:
  484|  2.65k|{
  485|  2.65k|    pb_field_iter_t iter;
  486|       |
  487|  2.65k|    if (!pb_field_iter_begin_extension_const(&iter, extension))
  ------------------
  |  Branch (487:9): [True: 0, False: 2.65k]
  ------------------
  488|      0|        PB_RETURN_ERROR(stream, "invalid extension");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  489|       |
  490|  2.65k|    return encode_field(stream, &iter);
  491|  2.65k|}
pb_encode.c:encode_field:
  428|   328k|{
  429|       |    /* Check field presence */
  430|   328k|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|   328k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   328k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|   328k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (430:9): [True: 18.6k, False: 310k]
  ------------------
  431|  18.6k|    {
  432|  18.6k|        if (*(const pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (432:13): [True: 17.7k, False: 888]
  ------------------
  433|  17.7k|        {
  434|       |            /* Different type oneof field */
  435|  17.7k|            return true;
  436|  17.7k|        }
  437|  18.6k|    }
  438|   310k|    else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL)
  ------------------
  |  |  327|   310k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   310k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL)
  ------------------
  |  |  312|   310k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (438:14): [True: 68.7k, False: 241k]
  ------------------
  439|  68.7k|    {
  440|  68.7k|        if (field->pSize)
  ------------------
  |  Branch (440:13): [True: 68.7k, False: 0]
  ------------------
  441|  68.7k|        {
  442|  68.7k|            if (safe_read_bool(field->pSize) == false)
  ------------------
  |  Branch (442:17): [True: 60.8k, False: 7.97k]
  ------------------
  443|  60.8k|            {
  444|       |                /* Missing optional field */
  445|  60.8k|                return true;
  446|  60.8k|            }
  447|  68.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|  68.7k|    }
  455|       |
  456|   250k|    if (!field->pData)
  ------------------
  |  Branch (456:9): [True: 0, False: 250k]
  ------------------
  457|      0|    {
  458|      0|        if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED)
  ------------------
  |  |  327|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED)
  ------------------
  |  |  311|      0|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (458:13): [True: 0, False: 0]
  ------------------
  459|      0|            PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  460|       |
  461|       |        /* Pointer field set to NULL */
  462|      0|        return true;
  463|      0|    }
  464|       |
  465|       |    /* Then encode field contents */
  466|   250k|    if (PB_ATYPE(field->type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  326|   250k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   250k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|   250k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (466:9): [True: 106, False: 249k]
  ------------------
  467|    106|    {
  468|    106|        return encode_callback_field(stream, field);
  469|    106|    }
  470|   249k|    else if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|   249k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   249k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|   249k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (470:14): [True: 55.8k, False: 194k]
  ------------------
  471|  55.8k|    {
  472|  55.8k|        return encode_array(stream, field);
  473|  55.8k|    }
  474|   194k|    else
  475|   194k|    {
  476|   194k|        return encode_basic_field(stream, field);
  477|   194k|    }
  478|   250k|}
pb_encode.c:safe_read_bool:
  125|  71.5k|{
  126|  71.5k|    const char *p = (const char *)pSize;
  127|  71.5k|    size_t i;
  128|   133k|    for (i = 0; i < sizeof(bool); i++)
  ------------------
  |  Branch (128:17): [True: 71.5k, False: 61.5k]
  ------------------
  129|  71.5k|    {
  130|  71.5k|        if (p[i] != 0)
  ------------------
  |  Branch (130:13): [True: 10.0k, False: 61.5k]
  ------------------
  131|  10.0k|            return true;
  132|  71.5k|    }
  133|  61.5k|    return false;
  134|  71.5k|}
pb_encode.c:encode_callback_field:
  417|    106|{
  418|    106|    if (field->descriptor->field_callback != NULL)
  ------------------
  |  Branch (418:9): [True: 106, False: 0]
  ------------------
  419|    106|    {
  420|    106|        if (!field->descriptor->field_callback(NULL, stream, field))
  ------------------
  |  Branch (420:13): [True: 0, False: 106]
  ------------------
  421|      0|            PB_RETURN_ERROR(stream, "callback error");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  422|    106|    }
  423|    106|    return true;
  424|    106|}
pb_encode.c:encode_array:
  138|  55.8k|{
  139|  55.8k|    pb_size_t i;
  140|  55.8k|    pb_size_t count;
  141|  55.8k|#ifndef PB_ENCODE_ARRAYS_UNPACKED
  142|  55.8k|    size_t size;
  143|  55.8k|#endif
  144|       |
  145|  55.8k|    count = *(pb_size_t*)field->pSize;
  146|       |
  147|  55.8k|    if (count == 0)
  ------------------
  |  Branch (147:9): [True: 45.1k, False: 10.7k]
  ------------------
  148|  45.1k|        return true;
  149|       |
  150|  10.7k|    if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size)
  ------------------
  |  |  326|  10.7k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  10.7k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size)
  ------------------
  |  |  322|  21.4k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (150:9): [True: 10.7k, False: 0]
  |  Branch (150:54): [True: 0, False: 10.7k]
  ------------------
  151|      0|        PB_RETURN_ERROR(stream, "array max size exceeded");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  152|       |    
  153|  10.7k|#ifndef PB_ENCODE_ARRAYS_UNPACKED
  154|       |    /* We always pack arrays if the datatype allows it. */
  155|  10.7k|    if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  328|  10.7k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  10.7k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  276|  10.7k|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (155:9): [True: 9.06k, False: 1.63k]
  ------------------
  156|  9.06k|    {
  157|  9.06k|        if (!pb_encode_tag(stream, PB_WT_STRING, field->tag))
  ------------------
  |  Branch (157:13): [True: 0, False: 9.06k]
  ------------------
  158|      0|            return false;
  159|       |        
  160|       |        /* Determine the total size of packed array. */
  161|  9.06k|        if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32)
  ------------------
  |  |  328|  9.06k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  9.06k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32)
  ------------------
  |  |  272|  9.06k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (161:13): [True: 3.17k, False: 5.89k]
  ------------------
  162|  3.17k|        {
  163|  3.17k|            size = 4 * (size_t)count;
  164|  3.17k|        }
  165|  5.89k|        else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  328|  5.89k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  5.89k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  273|  5.89k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (165:18): [True: 720, False: 5.17k]
  ------------------
  166|    720|        {
  167|    720|            size = 8 * (size_t)count;
  168|    720|        }
  169|  5.17k|        else
  170|  5.17k|        { 
  171|  5.17k|            pb_ostream_t sizestream = PB_OSTREAM_SIZING;
  ------------------
  |  |  126|  5.17k|#define PB_OSTREAM_SIZING {0,0,0,0,0}
  ------------------
  172|  5.17k|            void *pData_orig = field->pData;
  173|  29.3k|            for (i = 0; i < count; i++)
  ------------------
  |  Branch (173:25): [True: 24.1k, False: 5.17k]
  ------------------
  174|  24.1k|            {
  175|  24.1k|                if (!pb_enc_varint(&sizestream, field))
  ------------------
  |  Branch (175:21): [True: 0, False: 24.1k]
  ------------------
  176|      0|                    PB_RETURN_ERROR(stream, PB_GET_ERROR(&sizestream));
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  |  Branch (919:92): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  177|  24.1k|                field->pData = (char*)field->pData + field->data_size;
  178|  24.1k|            }
  179|  5.17k|            field->pData = pData_orig;
  180|  5.17k|            size = sizestream.bytes_written;
  181|  5.17k|        }
  182|       |        
  183|  9.06k|        if (!pb_encode_varint(stream, (pb_uint64_t)size))
  ------------------
  |  Branch (183:13): [True: 0, False: 9.06k]
  ------------------
  184|      0|            return false;
  185|       |        
  186|  9.06k|        if (stream->callback == NULL)
  ------------------
  |  Branch (186:13): [True: 0, False: 9.06k]
  ------------------
  187|      0|            return pb_write(stream, NULL, size); /* Just sizing.. */
  188|       |        
  189|       |        /* Write the data */
  190|  45.5k|        for (i = 0; i < count; i++)
  ------------------
  |  Branch (190:21): [True: 36.4k, False: 9.06k]
  ------------------
  191|  36.4k|        {
  192|  36.4k|            if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  328|  36.4k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  36.4k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  272|  72.9k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  328|  27.1k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  27.1k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  273|  27.1k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (192:17): [True: 9.30k, False: 27.1k]
  |  Branch (192:62): [True: 3.00k, False: 24.1k]
  ------------------
  193|  12.3k|            {
  194|  12.3k|                if (!pb_enc_fixed(stream, field))
  ------------------
  |  Branch (194:21): [True: 0, False: 12.3k]
  ------------------
  195|      0|                    return false;
  196|  12.3k|            }
  197|  24.1k|            else
  198|  24.1k|            {
  199|  24.1k|                if (!pb_enc_varint(stream, field))
  ------------------
  |  Branch (199:21): [True: 0, False: 24.1k]
  ------------------
  200|      0|                    return false;
  201|  24.1k|            }
  202|       |
  203|  36.4k|            field->pData = (char*)field->pData + field->data_size;
  204|  36.4k|        }
  205|  9.06k|    }
  206|  1.63k|    else /* Unpacked fields */
  207|  1.63k|#endif
  208|  1.63k|    {
  209|  7.61k|        for (i = 0; i < count; i++)
  ------------------
  |  Branch (209:21): [True: 5.98k, False: 1.63k]
  ------------------
  210|  5.98k|        {
  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.98k|            if (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  326|  5.98k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  5.98k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  322|  11.9k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (215:17): [True: 0, False: 5.98k]
  ------------------
  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.98k|            else
  240|  5.98k|            {
  241|  5.98k|                if (!encode_basic_field(stream, field))
  ------------------
  |  Branch (241:21): [True: 0, False: 5.98k]
  ------------------
  242|      0|                    return false;
  243|  5.98k|            }
  244|  5.98k|            field->pData = (char*)field->pData + field->data_size;
  245|  5.98k|        }
  246|  1.63k|    }
  247|       |    
  248|  10.7k|    return true;
  249|  10.7k|}
pb_encode.c:pb_enc_varint:
  798|   182k|{
  799|   182k|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  328|   182k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   182k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  270|   182k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (799:9): [True: 47.2k, False: 135k]
  ------------------
  800|  47.2k|    {
  801|       |        /* Perform unsigned integer extension */
  802|  47.2k|        pb_uint64_t value = 0;
  ------------------
  |  |   46|  47.2k|#define pb_uint64_t uint64_t
  ------------------
  803|       |
  804|  47.2k|        if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (804:13): [True: 5.31k, False: 41.9k]
  ------------------
  805|  5.31k|            value = *(const uint_least8_t*)field->pData;
  806|  41.9k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (806:18): [True: 5.31k, False: 36.6k]
  ------------------
  807|  5.31k|            value = *(const uint_least16_t*)field->pData;
  808|  36.6k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (808:18): [True: 20.3k, False: 16.2k]
  ------------------
  809|  20.3k|            value = *(const uint32_t*)field->pData;
  810|  16.2k|        else if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (810:18): [True: 16.2k, False: 0]
  ------------------
  811|  16.2k|            value = *(const pb_uint64_t*)field->pData;
  812|      0|        else
  813|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  814|       |
  815|  47.2k|        return pb_encode_varint(stream, value);
  816|  47.2k|    }
  817|   135k|    else
  818|   135k|    {
  819|       |        /* Perform signed integer extension */
  820|   135k|        pb_int64_t value = 0;
  ------------------
  |  |   45|   135k|#define pb_int64_t int64_t
  ------------------
  821|       |
  822|   135k|        if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (822:13): [True: 12.0k, False: 122k]
  ------------------
  823|  12.0k|            value = *(const int_least8_t*)field->pData;
  824|   122k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (824:18): [True: 10.6k, False: 112k]
  ------------------
  825|  10.6k|            value = *(const int_least16_t*)field->pData;
  826|   112k|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (826:18): [True: 89.4k, False: 22.8k]
  ------------------
  827|  89.4k|            value = *(const int32_t*)field->pData;
  828|  22.8k|        else if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (828:18): [True: 22.8k, False: 0]
  ------------------
  829|  22.8k|            value = *(const pb_int64_t*)field->pData;
  830|      0|        else
  831|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  832|       |
  833|   135k|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  328|   135k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   135k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  271|   135k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (833:13): [True: 22.7k, False: 112k]
  ------------------
  834|  22.7k|            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|   112k|        else
  840|   112k|            return pb_encode_varint(stream, (pb_uint64_t)value);
  841|       |
  842|   135k|    }
  843|   182k|}
pb_encode.c:pb_enc_fixed:
  846|  32.6k|{
  847|       |#ifdef PB_CONVERT_DOUBLE_FLOAT
  848|       |    if (field->data_size == sizeof(float) && PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  849|       |    {
  850|       |        return pb_encode_float_as_double(stream, *(float*)field->pData);
  851|       |    }
  852|       |#endif
  853|       |
  854|  32.6k|    if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (854:9): [True: 20.6k, False: 11.9k]
  ------------------
  855|  20.6k|    {
  856|  20.6k|        return pb_encode_fixed32(stream, field->pData);
  857|  20.6k|    }
  858|  11.9k|#ifndef PB_WITHOUT_64BIT
  859|  11.9k|    else if (field->data_size == sizeof(uint64_t))
  ------------------
  |  Branch (859:14): [True: 11.9k, False: 0]
  ------------------
  860|  11.9k|    {
  861|  11.9k|        return pb_encode_fixed64(stream, field->pData);
  862|  11.9k|    }
  863|      0|#endif
  864|      0|    else
  865|      0|    {
  866|       |        PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  867|      0|    }
  868|  32.6k|}
pb_encode.c:encode_basic_field:
  372|   200k|{
  373|   200k|    if (!field->pData)
  ------------------
  |  Branch (373:9): [True: 0, False: 200k]
  ------------------
  374|      0|    {
  375|       |        /* Missing pointer field */
  376|      0|        return true;
  377|      0|    }
  378|       |
  379|   200k|    if (!pb_encode_tag_for_field(stream, field))
  ------------------
  |  Branch (379:9): [True: 0, False: 200k]
  ------------------
  380|      0|        return false;
  381|       |
  382|   200k|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  328|   200k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   200k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  383|   200k|    {
  384|  2.80k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  268|  2.80k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (384:9): [True: 2.80k, False: 197k]
  ------------------
  385|  2.80k|            return pb_enc_bool(stream, field);
  386|       |
  387|  77.0k|        case PB_LTYPE_VARINT:
  ------------------
  |  |  269|  77.0k|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (387:9): [True: 77.0k, False: 123k]
  ------------------
  388|   117k|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  270|   117k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (388:9): [True: 40.7k, False: 159k]
  ------------------
  389|   133k|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  271|   133k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (389:9): [True: 16.2k, False: 183k]
  ------------------
  390|   133k|            return pb_enc_varint(stream, field);
  391|       |
  392|  11.3k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  272|  11.3k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (392:9): [True: 11.3k, False: 188k]
  ------------------
  393|  20.3k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  273|  20.3k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (393:9): [True: 8.98k, False: 191k]
  ------------------
  394|  20.3k|            return pb_enc_fixed(stream, field);
  395|       |
  396|  3.88k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  280|  3.88k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (396:9): [True: 3.88k, False: 196k]
  ------------------
  397|  3.88k|            return pb_enc_bytes(stream, field);
  398|       |
  399|  15.1k|        case PB_LTYPE_STRING:
  ------------------
  |  |  284|  15.1k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (399:9): [True: 15.1k, False: 184k]
  ------------------
  400|  15.1k|            return pb_enc_string(stream, field);
  401|       |
  402|  19.7k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  288|  19.7k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (402:9): [True: 19.7k, False: 180k]
  ------------------
  403|  19.7k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  293|  19.7k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (403:9): [True: 0, False: 200k]
  ------------------
  404|  19.7k|            return pb_enc_submessage(stream, field);
  405|       |
  406|  4.16k|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  303|  4.16k|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (406:9): [True: 4.16k, False: 195k]
  ------------------
  407|  4.16k|            return pb_enc_fixed_length_bytes(stream, field);
  408|       |
  409|      0|        default:
  ------------------
  |  Branch (409:9): [True: 0, False: 200k]
  ------------------
  410|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  411|   200k|    }
  412|   200k|}
pb_encode.c:pb_enc_bool:
  791|  2.80k|{
  792|  2.80k|    uint32_t value = safe_read_bool(field->pData) ? 1 : 0;
  ------------------
  |  Branch (792:22): [True: 2.10k, False: 698]
  ------------------
  793|  2.80k|    PB_UNUSED(field);
  ------------------
  |  |  172|  2.80k|#define PB_UNUSED(x) (void)(x)
  ------------------
  794|  2.80k|    return pb_encode_varint(stream, value);
  795|  2.80k|}
pb_encode.c:pb_enc_bytes:
  871|  3.88k|{
  872|  3.88k|    const pb_bytes_array_t *bytes = NULL;
  873|       |
  874|  3.88k|    bytes = (const pb_bytes_array_t*)field->pData;
  875|       |    
  876|  3.88k|    if (bytes == NULL)
  ------------------
  |  Branch (876:9): [True: 0, False: 3.88k]
  ------------------
  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.88k|    if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  326|  3.88k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  3.88k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  321|  7.76k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (882:9): [True: 3.88k, False: 0]
  ------------------
  883|  3.88k|        bytes->size > field->data_size - offsetof(pb_bytes_array_t, bytes))
  ------------------
  |  Branch (883:9): [True: 0, False: 3.88k]
  ------------------
  884|      0|    {
  885|      0|        PB_RETURN_ERROR(stream, "bytes size exceeded");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  886|      0|    }
  887|       |    
  888|  3.88k|    return pb_encode_string(stream, bytes->bytes, (size_t)bytes->size);
  889|  3.88k|}
pb_encode.c:pb_enc_string:
  892|  15.1k|{
  893|  15.1k|    size_t size = 0;
  894|  15.1k|    size_t max_size = (size_t)field->data_size;
  895|  15.1k|    const char *str = (const char*)field->pData;
  896|       |    
  897|  15.1k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  15.1k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  15.1k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  15.1k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (897:9): [True: 0, False: 15.1k]
  ------------------
  898|      0|    {
  899|      0|        max_size = (size_t)-1;
  900|      0|    }
  901|  15.1k|    else
  902|  15.1k|    {
  903|       |        /* pb_dec_string() assumes string fields end with a null
  904|       |         * terminator when the type isn't PB_ATYPE_POINTER, so we
  905|       |         * shouldn't allow more than max-1 bytes to be written to
  906|       |         * allow space for the null terminator.
  907|       |         */
  908|  15.1k|        if (max_size == 0)
  ------------------
  |  Branch (908:13): [True: 0, False: 15.1k]
  ------------------
  909|      0|            PB_RETURN_ERROR(stream, "zero-length string");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  910|       |
  911|  15.1k|        max_size -= 1;
  912|  15.1k|    }
  913|       |
  914|       |
  915|  15.1k|    if (str == NULL)
  ------------------
  |  Branch (915:9): [True: 0, False: 15.1k]
  ------------------
  916|      0|    {
  917|      0|        size = 0; /* Treat null pointer as an empty string */
  918|      0|    }
  919|  15.1k|    else
  920|  15.1k|    {
  921|  15.1k|        const char *p = str;
  922|       |
  923|       |        /* strnlen() is not always available, so just use a loop */
  924|  72.4k|        while (size < max_size && *p != '\0')
  ------------------
  |  Branch (924:16): [True: 72.1k, False: 312]
  |  Branch (924:35): [True: 57.3k, False: 14.8k]
  ------------------
  925|  57.3k|        {
  926|  57.3k|            size++;
  927|  57.3k|            p++;
  928|  57.3k|        }
  929|       |
  930|  15.1k|        if (*p != '\0')
  ------------------
  |  Branch (930:13): [True: 0, False: 15.1k]
  ------------------
  931|      0|        {
  932|      0|            PB_RETURN_ERROR(stream, "unterminated string");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  933|      0|        }
  934|  15.1k|    }
  935|       |
  936|       |#ifdef PB_VALIDATE_UTF8
  937|       |    if (!pb_validate_utf8(str))
  938|       |        PB_RETURN_ERROR(stream, "invalid utf8");
  939|       |#endif
  940|       |
  941|  15.1k|    return pb_encode_string(stream, (const pb_byte_t*)str, size);
  942|  15.1k|}
pb_encode.c:pb_enc_submessage:
  945|  19.7k|{
  946|  19.7k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (946:9): [True: 0, False: 19.7k]
  ------------------
  947|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  923|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  919|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (919:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  948|       |
  949|  19.7k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  328|  19.7k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  19.7k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  293|  39.5k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (949:9): [True: 0, False: 19.7k]
  |  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.7k|    return pb_encode_submessage(stream, field->submsg_desc, field->pData);
  961|  19.7k|}
pb_encode.c:pb_enc_fixed_length_bytes:
  964|  4.16k|{
  965|  4.16k|    return pb_encode_string(stream, (const pb_byte_t*)field->pData, (size_t)field->data_size);
  966|  4.16k|}
pb_encode.c:pb_encode_varint_32:
  583|  78.3k|{
  584|  78.3k|    size_t i = 0;
  585|  78.3k|    pb_byte_t buffer[10];
  586|  78.3k|    pb_byte_t byte = (pb_byte_t)(low & 0x7F);
  587|  78.3k|    low >>= 7;
  588|       |
  589|   213k|    while (i < 4 && (low != 0 || high != 0))
  ------------------
  |  Branch (589:12): [True: 200k, False: 13.3k]
  |  Branch (589:22): [True: 134k, False: 65.3k]
  |  Branch (589:34): [True: 306, False: 65.0k]
  ------------------
  590|   135k|    {
  591|   135k|        byte |= 0x80;
  592|   135k|        buffer[i++] = byte;
  593|   135k|        byte = (pb_byte_t)(low & 0x7F);
  594|   135k|        low >>= 7;
  595|   135k|    }
  596|       |
  597|  78.3k|    if (high)
  ------------------
  |  Branch (597:9): [True: 11.5k, False: 66.7k]
  ------------------
  598|  11.5k|    {
  599|  11.5k|        byte = (pb_byte_t)(byte | ((high & 0x07) << 4));
  600|  11.5k|        high >>= 3;
  601|       |
  602|  58.2k|        while (high)
  ------------------
  |  Branch (602:16): [True: 46.6k, False: 11.5k]
  ------------------
  603|  46.6k|        {
  604|  46.6k|            byte |= 0x80;
  605|  46.6k|            buffer[i++] = byte;
  606|  46.6k|            byte = (pb_byte_t)(high & 0x7F);
  607|  46.6k|            high >>= 7;
  608|  46.6k|        }
  609|  11.5k|    }
  610|       |
  611|  78.3k|    buffer[i++] = byte;
  612|       |
  613|  78.3k|    return pb_write(stream, buffer, i);
  614|  78.3k|}

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

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

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

validate_static:
    7|   513k|{
    8|   513k|    pb_size_t count = 1;
    9|   513k|    pb_size_t i;
   10|   513k|    bool truebool = true;
   11|   513k|    bool falsebool = false;
   12|       |
   13|   513k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  327|   513k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   513k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  314|  1.02M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (13:9): [True: 111k, False: 401k]
  |  Branch (13:54): [True: 111k, False: 0]
  ------------------
   14|   111k|    {
   15|       |        /* Array count must be between 0 and statically allocated size */
   16|   111k|        count = *(pb_size_t*)iter->pSize;
   17|   111k|        assert(count <= iter->array_size);
  ------------------
  |  Branch (17:9): [True: 0, False: 111k]
  |  Branch (17:9): [True: 111k, False: 0]
  ------------------
   18|   111k|    }
   19|   401k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  327|   401k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   401k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  312|   803k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (19:14): [True: 121k, False: 280k]
  |  Branch (19:59): [True: 121k, False: 0]
  ------------------
   20|   121k|    {
   21|       |        /* Boolean has_ field must have a valid value */
   22|   121k|        assert(memcmp(iter->pSize, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (22:9): [True: 121k, False: 0]
  |  Branch (22:9): [True: 0, False: 0]
  |  Branch (22:9): [True: 12.0k, False: 109k]
  |  Branch (22:9): [True: 109k, False: 0]
  ------------------
   23|   121k|               memcmp(iter->pSize, &falsebool, sizeof(bool)) == 0);
   24|   121k|    }
   25|   280k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|   280k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   280k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|   280k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (25:14): [True: 26.5k, False: 253k]
  ------------------
   26|  26.5k|    {
   27|  26.5k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (27:13): [True: 25.0k, False: 1.56k]
  ------------------
   28|  25.0k|        {
   29|       |            /* Some different field in oneof */
   30|  25.0k|            return;
   31|  25.0k|        }
   32|  26.5k|    }
   33|       |
   34|   949k|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (34:17): [True: 461k, False: 488k]
  ------------------
   35|   461k|    {
   36|   461k|        void *pData = (char*)iter->pData + iter->data_size * i;
   37|       |
   38|   461k|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  328|   461k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   461k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  284|   461k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (38:13): [True: 28.3k, False: 433k]
  ------------------
   39|  28.3k|        {
   40|       |            /* String length must be at most statically allocated size */
   41|  28.3k|            assert(strlen(pData) + 1 <= iter->data_size);
  ------------------
  |  Branch (41:13): [True: 0, False: 28.3k]
  |  Branch (41:13): [True: 28.3k, False: 0]
  ------------------
   42|  28.3k|        }
   43|   433k|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  328|   433k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   433k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  280|   433k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (43:18): [True: 12.5k, False: 420k]
  ------------------
   44|  12.5k|        {
   45|       |            /* Bytes length must be at most statically allocated size */
   46|  12.5k|            pb_bytes_array_t *bytes = pData;
   47|  12.5k|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= iter->data_size);
  ------------------
  |  Branch (47:13): [True: 0, False: 12.5k]
  |  Branch (47:13): [True: 12.5k, False: 0]
  ------------------
   48|  12.5k|        }
   49|   420k|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  328|   420k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   420k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  268|   420k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (49:18): [True: 12.0k, False: 408k]
  ------------------
   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.27k, False: 6.81k]
  |  Branch (52:13): [True: 6.81k, False: 0]
  ------------------
   53|  12.0k|                   memcmp(pData, &falsebool, sizeof(bool)) == 0);
   54|  12.0k|        }
   55|   408k|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  329|   408k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|   408k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|   408k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|   817k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 43.8k, False: 364k]
  |  |  ------------------
  |  |  330|   408k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|   364k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|   364k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|   364k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 364k]
  |  |  ------------------
  ------------------
   56|  43.8k|        {
   57|  43.8k|            validate_message(pData, 0, iter->submsg_desc);
   58|  43.8k|        }
   59|   461k|    }
   60|   488k|}
validate_message:
  145|  49.1k|{
  146|  49.1k|    pb_field_iter_t iter;
  147|       |
  148|  49.1k|    if (pb_field_iter_begin_const(&iter, msgtype, msg))
  ------------------
  |  Branch (148:9): [True: 36.4k, False: 12.7k]
  ------------------
  149|  36.4k|    {
  150|  36.4k|        do
  151|   529k|        {
  152|   529k|            if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  326|   529k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   529k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  321|   529k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (152:17): [True: 513k, False: 15.9k]
  ------------------
  153|   513k|            {
  154|   513k|                validate_static(&iter);
  155|   513k|            }
  156|  15.9k|            else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  15.9k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  15.9k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  15.9k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (156:22): [True: 0, False: 15.9k]
  ------------------
  157|      0|            {
  158|      0|                validate_pointer(&iter);
  159|      0|            }
  160|   529k|        } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (160:18): [True: 492k, False: 36.4k]
  ------------------
  161|  36.4k|    }
  162|  49.1k|}

